···
This commit is contained in:
@@ -1,84 +0,0 @@
|
|||||||
const wxSilentLogin = () => {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
wx.login({
|
|
||||||
success: function(res) {
|
|
||||||
if (res.code) {
|
|
||||||
console.log('Http网络请求信息', {
|
|
||||||
"wxCode": res.code
|
|
||||||
})
|
|
||||||
uni.request({
|
|
||||||
// 组装请求地址
|
|
||||||
url: getApp().globalData.wxSilentLoginURL + "?wxCode=" + res
|
|
||||||
.code,
|
|
||||||
// 请求方式 GET POST
|
|
||||||
method: "GET",
|
|
||||||
header: {
|
|
||||||
// 传参方式
|
|
||||||
'content-type': "application/x-www-form-urlencoded"
|
|
||||||
},
|
|
||||||
// 具体参数
|
|
||||||
data: {
|
|
||||||
"wxCode": res.code
|
|
||||||
},
|
|
||||||
success: res => {
|
|
||||||
console.log("请求openid", res)
|
|
||||||
// if (getApp().globalData.isDebug) {
|
|
||||||
// console.log('Http网络路径', getApp().globalData
|
|
||||||
// .wxSilentLoginURL)
|
|
||||||
// }
|
|
||||||
if (res.statusCode == 200) {
|
|
||||||
if (!res.data.success) {
|
|
||||||
|
|
||||||
if (res.data.code == "110") {
|
|
||||||
console.log(res.data.data);
|
|
||||||
// 未绑定用户
|
|
||||||
// uni.navigateTo({
|
|
||||||
// url: '/pages/index/BindPhone?openid=' +
|
|
||||||
// res.data.data.wxMpOpenid
|
|
||||||
// })
|
|
||||||
|
|
||||||
uni.navigateTo({
|
|
||||||
url: '/pages/index/BindPhone?openid=' +
|
|
||||||
res.data.data.wxMpOpenid
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
console.log("Http网络请求res", res)
|
|
||||||
console.log("Global-Auth-Token", res.data.data
|
|
||||||
.token)
|
|
||||||
|
|
||||||
|
|
||||||
getApp().globalData.sid = res.data.data
|
|
||||||
.sid
|
|
||||||
|
|
||||||
uni.switchTab({
|
|
||||||
url: '/pages/card/card'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
getApp().globalData.isLogin = false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: (err) => {
|
|
||||||
if (getApp().globalData.isDebug) {
|
|
||||||
console.log("Http网络请求fail", err)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
complete: () => {}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: function(res) {
|
|
||||||
uni.showToast({
|
|
||||||
title: "静默登录失败:" + res.errMsg,
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
|
|
||||||
reject(res.errMsg)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
}
|
|
||||||
export default wxSilentLogin
|
|
||||||
Reference in New Issue
Block a user