|
@@ -17,41 +17,47 @@ Page({
|
|
|
wx.getUserInfo({
|
|
|
success: res => {
|
|
|
app.globalData.userInfo = res.userInfo
|
|
|
- wx.reLaunch({
|
|
|
- url: '/pages/index/index',
|
|
|
- })
|
|
|
+
|
|
|
}
|
|
|
})
|
|
|
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
- // 登录
|
|
|
- wx.login({
|
|
|
- success: res => {
|
|
|
- console.log(res)
|
|
|
- // 发送 res.code 到后台换取 openId, sessionKey, unionId
|
|
|
- if (res.code) {
|
|
|
- //发起网络请求
|
|
|
- wx.request({
|
|
|
- url: Api.postgetOpenId(),
|
|
|
- data: {
|
|
|
- codeId: res.code
|
|
|
- },
|
|
|
- success (res) {
|
|
|
- console.log(res)
|
|
|
- if(res.statusCode==200){
|
|
|
- // app.globalData.openid=res.data.data.openid
|
|
|
- wx.setStorageSync('openid', res.data.data.openid)
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- console.log('登录失败!' + res.errMsg)
|
|
|
+ //登录
|
|
|
+ wx.login({
|
|
|
+ success: res => {
|
|
|
+ // console.log(res)
|
|
|
+ // 发送 res.code 到后台换取 openId, sessionKey, unionId
|
|
|
+ if (res.code) {
|
|
|
+ //发起网络请求
|
|
|
+ wx.request({
|
|
|
+ url: Api.postgetOpenId(),
|
|
|
+ data: {
|
|
|
+ codeId: res.code
|
|
|
+ },
|
|
|
+ success (res) {
|
|
|
+ // console.log(res)
|
|
|
+ if(res.statusCode==200){
|
|
|
+ // app.globalData.openid=res.data.data.openid
|
|
|
+ wx.setStorageSync('openid', res.data.data.openid)
|
|
|
+ var pages = getCurrentPages(); // 当前页面
|
|
|
+ var beforePage = pages[pages.length - 2]
|
|
|
+ wx.navigateBack({
|
|
|
+ success: function() {
|
|
|
+ beforePage.onLoad(); // 执行前一个页面的onLoad方法
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ console.log('登录失败!' + res.errMsg)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
/**
|