微信小程序实现登录功能(云函数的创建和调用)
Page({
data: {
userInfo: {},
},
getUserProfile (e) {
wx.getUserProfile({
desc: '用于完善会员资料',
success: result => {
wx.cloud.callFunction({
name: 'login',
success: res => {
this.setData({
userInfo: result.userInfo,
'userInfo.openid': res.result.openid
})
wx.setStorageSync('userInfo', this.data.userInfo)
}
})
}
})
},
onLoad (options) {
const ui = wx.getStorageSync('userInfo')
this.setData({
userInfo: ui
})
}
})