欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

如何在vue中通過cookie獲取用戶的登錄信息

這期內(nèi)容當(dāng)中小編將會(huì)給大家?guī)碛嘘P(guān)如何在vue中通過cookie獲取用戶的登錄信息,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

成都創(chuàng)新互聯(lián)公司是一家專業(yè)提供新興企業(yè)網(wǎng)站建設(shè),專注與成都網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)、H5場(chǎng)景定制、小程序制作等業(yè)務(wù)。10年已為新興眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站制作公司優(yōu)惠進(jìn)行中。

思路

  • 進(jìn)入頁面

  • 若未登錄,跳轉(zhuǎn)至登陸頁面

  • 若已登錄,從cookie中獲取用戶信息,并執(zhí)行后續(xù)操作

2. 登錄頁面,存入cookie(setCookie)

import {setCookie,getCookie}from 'src/js/cookieUtil'
 methods: {
  async cheack_n_p () {
   if( this.checkCode === this.pwd) {
    this.loginData = await getUserInfo(this.uname, this.pwd, this.adminPhone);
    if (this.loginData.res !== 0) {
     setCookie('userName',this.uname);
     setCookie('userPwd',this.pwd,);
     setCookie('phone',this.uname);
     setCookie('userId',this.loginData.obj.id);
     setCookie('userType',this.loginData.obj.userType);
     setCookie('adminPhone',this.adminPhone);
//    this.$router.go(-1);
     this.$router.replace('/');
    } else {
     alert("驗(yàn)證碼錯(cuò)誤!")
    }
   }
  },
  //驗(yàn)證手機(jī)號(hào)碼部分
  async sendcode(){
   var pattern = /^0{0,1}(1[0-9][0-9]|15[7-9]|153|156|18[7-9])[0-9]{8}$/,
    str =this.uname;
   if (!pattern.test(str)) {
    alert('請(qǐng)正確輸入手機(jī)號(hào)!');
    return ;
   }
   this.time=60;
   this.disabled=true;
   this.timer();
   this.checkCode = (await getUserPhoneCode(this.uname)).resMsg;
   // this.checkCode = '123456';
   console.log( this.checkCode)
  },
  timer:function () {
   if (this.time > 0) {
    this.time--;
//         console.log(this.time);
    this.btntxt=this.time+"s后重新獲取";
    setTimeout(this.timer, 1000);
   } else{
    this.time=0;
    this.btntxt="獲取驗(yàn)證碼";
    this.disabled=false;
   }
  }
 },

2. 頁面判斷

import {setCookie,getCookie}from 'src/js/cookieUtil'
 mounted () {
  if (this.isLogin==undefined||this.isLogin=="") {
   this.$router.replace('/login');
  } else {
   // 執(zhí)行后續(xù)操作
   this.phone = getCookie("phone");
   }
 },
 computed: {
  isLogin () {
   // return this.$store.getters.getLogin;
   this.userId = getCookie("userId");
   // console.log(this.userId);
   return this.userId;
  }
 },

3. cookieUtil(setCookie,getCookie)

/**
 * Created by Schon on 2018/9/13 0013.
 */
//設(shè)置cookie
export function setCookie(key,value) {
 var exdate = new Date(); //獲取時(shí)間
 exdate.setTime(exdate.getTime() + 24 * 60 * 60 * 1000 * 36500); //保存的天數(shù),我這里寫的是100年
 //字符串拼接cookie
 window.document.cookie = key + "=" + value + ";path=/;expires=" + exdate.toGMTString();
};
//讀取cookie
export function getCookie(param) {
 var c_param = '';
 if (document.cookie.length > 0) {
  var arr = document.cookie.split('; '); //這里顯示的格式需要切割一下自己可輸出看下
  for (var i = 0; i < arr.length; i++) {
   var arr2 = arr[i].split('='); //再次切割
   //判斷查找相對(duì)應(yīng)的值
   if (arr2[0] == param) {
    c_param = arr2[1];
    //保存到保存數(shù)據(jù)的地方
   }
  }
  return c_param;
 }
};
function padLeftZero (str) {
 return ('00' + str).substr(str.length);
};

上述就是小編為大家分享的如何在vue中通過cookie獲取用戶的登錄信息了,如果剛好有類似的疑惑,不妨參照上述分析進(jìn)行理解。如果想知道更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

分享標(biāo)題:如何在vue中通過cookie獲取用戶的登錄信息
網(wǎng)頁地址:http://aaarwkj.com/article26/ipdjcg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、小程序開發(fā)App設(shè)計(jì)、ChatGPT定制網(wǎng)站、網(wǎng)站營(yíng)銷

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

小程序開發(fā)
欧美精品在,欧美一区二区| 欧美精品亚洲精品日韩经典| 两性色午夜视频免费网站| 女同三人按摩高潮喷出| 日韩欧美亚洲自拍另类| 最新日韩av一区二区| 国产精品一区二区三区四区久久| 久久se精品一区精品二区国产| 91国产精品视频在线| 国产一区二区精品不卡| 日本高清免费观看一区| 亚洲国产综合六月深深爱| 91精品超碰人人在线公开| 日韩在线一区中文字幕| 久久夜色精品亚洲国产| 免费在线观看欧美色妇| 日本免费一区二区三区手机在线| 亚洲精品女同专区视频| 国产91香蕉在线精品| 国产在线精品不卡一区| 久久成人av一区二区三区| 亚洲成人av网址大全| 日本久久91跳蛋视频| 视频久久这里只有精品| 免费国产中文字幕黄网站| 色综合婷婷九月中文字幕| 亚洲欧美av中文日韩二区| 国产成人亚洲精品在线看| 国产女人和拘做受视频| 欧美v日韩v亚洲综合国产高清| 99热国产这里只有精品| 中文日韩av在线免费播放| 日本精品av免费观看| 十八禁在线观看网址免费| 国产婷婷色三区一区二区| 视频一二区免费在线观看| 91在线视频欧美国产| 日韩蜜桃av一二三四区| 日本不卡高清视频在线播放| 下一篇亚洲一区二区三区| 国产精品久久久久久久久|