4 回复
//页面跳转 _get Go () { wx.redirect To ({ url: '../evaluate/evaluate' }) }, _login() {//授权登录 wx.login({ success: res => { console.log(res) // 获取code const code = res.code; console.log(code) wx.request({ url: 'https://www.samewarm.com/Sandy/v2.0/userOpenIdHuiYiShi/fo' , data: { code }, method: 'get' , success: res => { console.log(res.data. Value ) const str = res.data. Status ; const names = res.data. Value . WeChat ; //判断用户是否认证 if (str == true) { if (names == "Initialize" ) { //新用户没有登录过 const open Id = res.data. Value . OpenId ; //获取的openid const SessionKey = res.data. Value . SessionKey ; //获取的 SessionKey const UnionId = res.data. Value . UnionId ; //获取的 UnionId this.set Data ({ //更新状态 open Id , SessionKey , UnionId }) wx.set StorageSync ( 'key' , { //缓存数据 SessionKey1 : this.data. SessionKey , open Id1 : this.data.open Id , UnionId1 : this.data. UnionId }) const sfz = this.data.is Hide //如果是新用户就显示授权页面 this.set Data ({ is Hide : true }) } else { //老用户 //把这些缓存上 UserId Token console.log( "123" ) this._get Go () /*缓存token和user Id **/ wx.set StorageSync ( 'UTR' , { /*缓存token和user Id **/ UserId : res.data. Value . UserId , Token : res.data. Value . Token , RefreshToken : res.data. Value . RefreshToken }) this.set Data ({ is Hide : false }) } } |