|
|
|
@ -49,13 +49,22 @@ Page({
|
|
|
|
|
},
|
|
|
|
|
// 微信用户初始化
|
|
|
|
|
initData() {
|
|
|
|
|
let that = this;
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
this.getUserCode().then(() => {
|
|
|
|
|
this.getOpenidByCode().then(() => {
|
|
|
|
|
wx.login({
|
|
|
|
|
success(res) {
|
|
|
|
|
that.setData({
|
|
|
|
|
code: res.code
|
|
|
|
|
})
|
|
|
|
|
that.getOpenidByCode().then(() => {
|
|
|
|
|
resolve(true)
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
console.log(err)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
fail() {
|
|
|
|
|
reject(false)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
@ -145,11 +154,13 @@ Page({
|
|
|
|
|
const userInfo = Object.assign({}, res, {
|
|
|
|
|
nickName: this.data.nickName,
|
|
|
|
|
avatarUrl: this.data.avatarUrl,
|
|
|
|
|
userName: this.data.userName
|
|
|
|
|
userName: this.data.userName,
|
|
|
|
|
headImg: res.headImg
|
|
|
|
|
})
|
|
|
|
|
wx.setStorageSync('token', res.toKen);
|
|
|
|
|
wx.setStorageSync('userInfo', userInfo);
|
|
|
|
|
wx.setStorageSync('openid', this.data.openid);
|
|
|
|
|
wx.setStorageSync('unionID', this.data.unionID);
|
|
|
|
|
wx.navigateBack({
|
|
|
|
|
delta: 1
|
|
|
|
|
});
|
|
|
|
@ -158,11 +169,13 @@ Page({
|
|
|
|
|
let data = err.Data;
|
|
|
|
|
const userInfo = Object.assign({}, data, {
|
|
|
|
|
nickName: this.data.nickName,
|
|
|
|
|
avatarUrl: this.data.avatarUrl
|
|
|
|
|
avatarUrl: this.data.avatarUrl,
|
|
|
|
|
userName: this.data.userName,
|
|
|
|
|
})
|
|
|
|
|
wx.setStorageSync('token', data.toKen);
|
|
|
|
|
wx.setStorageSync('userInfo', userInfo);
|
|
|
|
|
wx.setStorageSync('openid', this.data.openid);
|
|
|
|
|
wx.setStorageSync('unionID', this.data.unionID);
|
|
|
|
|
wx.showModal({
|
|
|
|
|
title: '提示',
|
|
|
|
|
content: '登录成功,但未关注公众号。',
|
|
|
|
|