37 lines
914 B
JavaScript
37 lines
914 B
JavaScript
const app = getApp()
|
|
Page({
|
|
data: {
|
|
noLogin: true,
|
|
},
|
|
onLoad: function (options) {
|
|
let openId = wx.getStorageSync("userId");
|
|
if (openId) {
|
|
this.setData({
|
|
noLogin : false
|
|
})
|
|
}
|
|
},
|
|
onShow: function () {
|
|
if (wx.canIUse('hideHomeButton')) {
|
|
wx.hideHomeButton()
|
|
}
|
|
},
|
|
loginAcc () {
|
|
let that = this;
|
|
wx.login({
|
|
success (res) {
|
|
if (res.code) {
|
|
app.$api.loginAccount({"wxCode":res.code}).then(t=>{
|
|
wx.setStorageSync("userId",t.data)
|
|
that.setData({
|
|
noLogin : false
|
|
})
|
|
})
|
|
} else {
|
|
console.log('登录失败!' + res.errMsg)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
});
|