有偿求获取微信小程序的code,signature,求怎么能够获取微信小程序的code,signature
获取code参考
http://t.csdn.cn/o61Dt
获取signature参考
http://www.ionic.wang/weixin/api/signature.html
现在要获取登录 需要2步骤
wx.getUserProfile({
desc: '微信登录',
success: res => {
wx.login({
success(res) {
console.log('login code',res);
wx.request({
url: , // 目标服务器url
header:{'content-type':'application/x-www-form-urlencoded'},
method:'POST',
data: {
ac: 'wx_login',
nickName: app.globalData.userInfo.nickName,
logo: app.globalData.userInfo.avatarUrl,
city: app.globalData.userInfo.city,
province: app.globalData.userInfo.province,
encryptedData: res.encryptedData,
iv: res.iv,
sign: res.signature,
code: res.code,
},
success: (res) => {console.log(res.data)
//登录成功后操作
}
});
},
fail(res) {
console.log(`login调用失败`);
}
});
}
})
后台用appid和密匙进行获取即可