1.获取openid
appid和秘钥在小程序后台可获取
//获取openid
openid() {
let that = this
wx.login({
success(res) {
wx.request({
url: 'https://api.weixin.qq.com/sns/jscode2session',
method: 'GET',
data: {
appid: "",//appid
secret: "",//秘钥
js_code: res.code,
grant_type: "authorization_code"
},
success: (res) => {
that.setData({
openid: res.data.openid
})
}
})
}
})
},