微信API
This commit is contained in:
@@ -1,11 +1,40 @@
|
||||
const app = getApp()
|
||||
Page({
|
||||
data: {},
|
||||
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 () {
|
||||
wx.login({
|
||||
success (res) {
|
||||
if (res.code) {
|
||||
app.$api.getOpenId(res.code).then(res => {
|
||||
wx.setStorageSync("openid",res.data.openid)
|
||||
this.setData({
|
||||
noLogin : false
|
||||
})
|
||||
}, err => {
|
||||
console.log(err);
|
||||
})
|
||||
} else {
|
||||
console.log('登录失败!' + res.errMsg)
|
||||
}
|
||||
}
|
||||
})
|
||||
app.$api.loginAccount(wx.getStorageSync('openid')).then(res => {
|
||||
wx.setStorageSync('userId',res.data)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user