var that = this
wx.login({
success: function (res) {
var appId = ' ';//微信公眾號(hào)平臺(tái)申請(qǐng)的appid
var appSecret = ' ';//微信公眾號(hào)平臺(tái)申請(qǐng)的app secret
var js_code = res.code;//調(diào)用登錄接口獲得的用戶的登錄憑證code
wx.request({
url: 'https://api.weixin.qq.com/sns/jscode2session?appid=' + appId + '&secret=' + appSecret + '&js_code=' + js_code + '&grant_type=authorization_code',
data: {},
method: 'GET',
success: function (res) {
var openid = res.data.openid //返回的用戶唯一標(biāo)識(shí)符openid
console.log(openid)
console.log("試試吧上面就是獲得的openid")
}
})
}
})
//試驗(yàn)自己的服務(wù)器獲取openId
//調(diào)用登錄接口
wx.login({
success: function (res) {
//console.log(res);
that.globalData.loginCode = res.code
wx.getUserInfo({
success: function (res) {
that.globalData.userInfo = res.userInfo
that.globalData.iv = res.iv
that.globalData.encryptedData = res.encryptedData
typeof cb == "function" && cb(that.globalData.userInfo)
that.req(
'https://lifar網(wǎng)址.aspx?Action=ActionLogin',
{
encryptedData: that.globalData.encryptedData,
iv: that.globalData.iv,
code: that.globalData.loginCode
},
'GET',
function (res) {
console.log(res)
if (
|