|
@@ -1,12 +1,6 @@
|
|
|
//app.js
|
|
|
App({
|
|
|
onLaunch: function () {
|
|
|
- wx.showLoading({
|
|
|
- title:'加载中'
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
// 登录
|
|
|
wx.login({
|
|
|
success: res => {
|
|
@@ -27,76 +21,41 @@ App({
|
|
|
success: res => {
|
|
|
let self = this;
|
|
|
if (res.authSetting['scope.userInfo']) {
|
|
|
- // // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
|
|
|
- // wx.getUserInfo({
|
|
|
- // success: res => {
|
|
|
- // // 可以将 res 发送给后台解码出 unionId
|
|
|
- // self.globalData.userInfo = res.userInfo
|
|
|
- // wx.request({
|
|
|
- // url: 'https://passport.lrlz.com/mobile/index.php?act=login&op=wxauthor&client_type=ios',
|
|
|
- // method: 'GET',
|
|
|
- // data: {
|
|
|
- // user_info: userInfo
|
|
|
- // },
|
|
|
- // success: function (res) {
|
|
|
- // wx.setStorageSync('session_id', res.data.datas.HPHPSESSID);
|
|
|
- // if (res.statusCode == 200) {
|
|
|
- // wx.switchTab({
|
|
|
- // url: '/pages/index/index'
|
|
|
- // })
|
|
|
- // }
|
|
|
- // else {
|
|
|
-
|
|
|
- // }
|
|
|
- // }
|
|
|
- // })
|
|
|
- // // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
|
|
|
- // // 所以此处加入 callback 以防止这种情况
|
|
|
- // if (this.userInfoReadyCallback) {
|
|
|
- // this.userInfoReadyCallback(res)
|
|
|
- // }
|
|
|
- // }
|
|
|
- // })
|
|
|
- // wx.authorize({
|
|
|
- // scope: 'scope.userInfo',
|
|
|
- // success: function (res) {
|
|
|
- // wx.getUserInfo({
|
|
|
- // success: res => {
|
|
|
-
|
|
|
- // // 可以将 res 发送给后台解码出 unionId
|
|
|
- // self.globalData.userInfo = res.userInfo;
|
|
|
- // self.globalData.userInfo.nickname = res.userInfo.nickName;
|
|
|
- // let userInfo = Object.assign({}, self.globalData.userId, self.globalData.userInfo);
|
|
|
- // wx.request({
|
|
|
- // url: 'https://passport.lrlz.com/mobile/index.php?act=login&op=wxauthor&client_type=ios',
|
|
|
- // method: 'GET',
|
|
|
- // data: {
|
|
|
- // user_info: userInfo
|
|
|
- // },
|
|
|
- // success: function (res) {
|
|
|
- // wx.setStorageSync('session_id', res.data.datas.HPHPSESSID);
|
|
|
- // if (res.statusCode == 200) {
|
|
|
- // wx.switchTab({
|
|
|
- // url: '/pages/index/index'
|
|
|
- // })
|
|
|
- // }
|
|
|
- // else {
|
|
|
+ let local_session_id = wx.getStorageSync('session_id');
|
|
|
+ if (local_session_id == '') {
|
|
|
+ wx.getUserInfo({
|
|
|
+ success: res => {
|
|
|
+ // 可以将 res 发送给后台解码出 unionId
|
|
|
+ self.globalData.userInfo = res.userInfo;
|
|
|
+ self.globalData.userInfo.nickname = res.userInfo.nickName;
|
|
|
+ let userInfo = Object.assign({}, self.globalData.userId, self.globalData.userInfo);
|
|
|
+ wx.request({
|
|
|
+ url: 'https://passport.lrlz.com/mobile/index.php?act=login&op=wxauthor&client_type=ios',
|
|
|
+ method: 'GET',
|
|
|
+ data: {
|
|
|
+ user_info: userInfo
|
|
|
+ },
|
|
|
+ success: function (res) {
|
|
|
+ wx.setStorageSync('session_id', res.data.datas.HPHPSESSID);
|
|
|
+ if (res.statusCode == 200) {
|
|
|
+ let current_url = "/" + getCurrentPages()[0].route;
|
|
|
+ wx.reLaunch({
|
|
|
+ url: current_url
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else {
|
|
|
|
|
|
- // }
|
|
|
- // }
|
|
|
- // })
|
|
|
- // // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
|
|
|
- // // 所以此处加入 callback 以防止这种情况
|
|
|
- // if (this.userInfoReadyCallback) {
|
|
|
- // this.userInfoReadyCallback(res)
|
|
|
- // }
|
|
|
- // }
|
|
|
- // })
|
|
|
- // }
|
|
|
- // });
|
|
|
- // wx.switchTab({
|
|
|
- // url: '/pages/index/index'
|
|
|
- // })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
|
|
|
+ // 所以此处加入 callback 以防止这种情况
|
|
|
+ if (this.userInfoReadyCallback) {
|
|
|
+ this.userInfoReadyCallback(res)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
wx.authorize({
|
|
@@ -104,7 +63,6 @@ App({
|
|
|
success:function(res){
|
|
|
wx.getUserInfo({
|
|
|
success: res => {
|
|
|
-
|
|
|
// 可以将 res 发送给后台解码出 unionId
|
|
|
self.globalData.userInfo = res.userInfo;
|
|
|
self.globalData.userInfo.nickname = res.userInfo.nickName;
|
|
@@ -118,9 +76,10 @@ App({
|
|
|
success:function(res){
|
|
|
wx.setStorageSync('session_id', res.data.datas.HPHPSESSID);
|
|
|
if (res.statusCode == 200) {
|
|
|
- wx.switchTab({
|
|
|
- url: '/pages/index/index'
|
|
|
- })
|
|
|
+ let current_url = "/" + getCurrentPages()[0].route;
|
|
|
+ wx.reLaunch({
|
|
|
+ url: current_url
|
|
|
+ });
|
|
|
}
|
|
|
else {
|
|
|
|