微信API 需要查看图片缺失问题

This commit is contained in:
limqhz
2023-02-06 18:51:37 +08:00
parent 23a10593c8
commit 40ca4223dd
8 changed files with 98 additions and 93 deletions

View File

@@ -17,24 +17,33 @@ Page({
}
},
loginAcc () {
let that = this;
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);
let param = {
appid:'wxb1f499f0a173865b',
secret:'833eefaf9206337d6c2d643f94baef7b',
js_code: res.code,
grant_type: 'authorization_code'
};
//发起网络请求
wx.request({
url: 'https://api.weixin.qq.com/sns/jscode2session',
data: param,
success: function(x) {
app.$api.loginAccount({"openId":x.data.openid}).then(t=>{
wx.setStorageSync("userId",t.data)
that.setData({
noLogin : false
})
})
}
})
} else {
console.log('登录失败!' + res.errMsg)
}
}
})
app.$api.loginAccount(wx.getStorageSync('openid')).then(res => {
wx.setStorageSync('userId',res.data)
});
}
});