|
@@ -74,39 +74,45 @@ App({
|
|
|
console.log(msg)
|
|
|
},
|
|
|
getAuthKey: function () {
|
|
|
+ console.log("apppppppjsjsjsjsjjsjsj");
|
|
|
+
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
// 调用登录接口
|
|
|
wx.login({
|
|
|
success: function (res) {
|
|
|
if (res.code) {
|
|
|
- console.log("appppppppppppppppppppppppppp用户的code:" + res.code);
|
|
|
-
|
|
|
- const appid = "wx1c015df104db7030"
|
|
|
- const secret = "d1956c1b5d3601657c98b0dc80a006f7"
|
|
|
- let url = 'https://api.weixin.qq.com/sns/jscode2session?appid=' + appid + '&secret=' + secret + '&js_code=' + res.code + '&grant_type=authorization_code';
|
|
|
+ // const appid = "wx1c015df104db7030"
|
|
|
+ // const secret = "d1956c1b5d3601657c98b0dc80a006f7"
|
|
|
+ // let url = 'https://api.weixin.qq.com/sns/jscode2session?appid=' + appid + '&secret=' + secret + '&js_code=' + res.code + '&grant_type=authorization_code';
|
|
|
wx.request({
|
|
|
- // 自行补上自己的 APPID 和 SECRET
|
|
|
- url: url,
|
|
|
+ url: util.globalData.publicUrl + '/wx/getAppletOpenId',
|
|
|
+ method: "GET",
|
|
|
+ data: {
|
|
|
+ cid: 'applet',
|
|
|
+ code: res.code
|
|
|
+ },
|
|
|
success: res => {
|
|
|
// 获取到用户的 openid
|
|
|
- console.log("用户的openid:" + res.data.openid);
|
|
|
- wx.setStorageSync('openId', res.data.openid)
|
|
|
- wx.request({
|
|
|
- url: util.globalData.publicUrl + '/applet/isExist',
|
|
|
- method: "GET",
|
|
|
- data: {
|
|
|
- appletsId: wx.getStorageSync('openId')
|
|
|
- },
|
|
|
- success: (res) => {
|
|
|
- console.log('app登录是否绑定的',res);
|
|
|
- if (res.data.code == 0) {
|
|
|
- if (res.data.data) {
|
|
|
- wx.setStorageSync('user', 'user');
|
|
|
+ if (res.data.status == 200) {
|
|
|
+ wx.setStorageSync('openId', res.data.data.openid)
|
|
|
+ wx.request({
|
|
|
+ url: util.globalData.publicUrl + '/applet/isExist',
|
|
|
+ method: "GET",
|
|
|
+ data: {
|
|
|
+ appletsId: wx.getStorageSync('openId')
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ console.log('app登录是否绑定的', res.data.code);
|
|
|
+ if (res.data.code == 0) {
|
|
|
+ if (res.data.data) {
|
|
|
+ wx.setStorageSync('user', 'user');
|
|
|
+ }
|
|
|
+ resolve(res);
|
|
|
}
|
|
|
- resolve(res);
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
} else {
|