|
|
@@ -8,6 +8,7 @@ function $get (url, params, success, fail) {
|
|
|
wx.showNavigationBarLoading()
|
|
|
var session = wx.getStorageSync('lbt_session_key')
|
|
|
var token = wx.getStorageSync('lbt_token_key')
|
|
|
+ // console.log('nowtoken',token);
|
|
|
wx.request({
|
|
|
url: apiHost + url,
|
|
|
data: params,
|
|
|
@@ -140,16 +141,24 @@ function callBack (res, success, fail) {
|
|
|
|
|
|
if (getApp().globalData.try_login) {
|
|
|
getApp().globalData.try_login = false
|
|
|
- wx.showToast({
|
|
|
- title: '尝试登陆失败,请到个人中心进行授权登陆',
|
|
|
- icon: 'none',
|
|
|
- duration: 2000
|
|
|
- })
|
|
|
- setTimeout(function(){
|
|
|
- wx.switchTab({
|
|
|
- url: '/pages/user/all/all'
|
|
|
- })
|
|
|
- },1000)
|
|
|
+ // wx.showToast({
|
|
|
+ // title: '尝试登陆失败,请到个人中心进行授权登陆',
|
|
|
+ // icon: 'none',
|
|
|
+ // duration: 2000
|
|
|
+ // })
|
|
|
+ // setTimeout(function(){
|
|
|
+ // wx.switchTab({
|
|
|
+ // url: '/pages/user/all/all'
|
|
|
+ // })
|
|
|
+ // },1000)
|
|
|
+
|
|
|
+ //新token
|
|
|
+ wx.login({
|
|
|
+ success: res => {
|
|
|
+ getApp().globalData.try_login = true;
|
|
|
+ pageLogin(res, url)
|
|
|
+ }
|
|
|
+ })
|
|
|
} else {
|
|
|
wx.login({
|
|
|
success: res => {
|
|
|
@@ -171,14 +180,18 @@ function callBack (res, success, fail) {
|
|
|
// 登陆接口
|
|
|
function login (res) {
|
|
|
var url = 'xcx/login'
|
|
|
+ var invite = wx.getStorageSync('invite');
|
|
|
var params = {
|
|
|
- code: res.code
|
|
|
+ code: res.code,
|
|
|
+ invite_id: invite//新token模式
|
|
|
}
|
|
|
var success = function (res) {
|
|
|
wx.setStorageSync('lbt_session_key', res.data.session_key)
|
|
|
wx.setStorageSync('lbt_session_time', Date.now())
|
|
|
wx.setStorageSync('lbt_token_key', res.data.token)
|
|
|
// check()
|
|
|
+ console.log('login:id=' + res.data.wx_user.id)
|
|
|
+ getApp().globalData.wx_id = res.data.wx_user.id;
|
|
|
}
|
|
|
$get(url, params, success)
|
|
|
}
|
|
|
@@ -274,9 +287,11 @@ function pageLogin (res, str) {
|
|
|
}
|
|
|
var success = function (res) {
|
|
|
console.log('pageLogin',res);
|
|
|
+ res = res.data;
|
|
|
if(res.wx_user){
|
|
|
- wx.setStorageSync('lbt_session_key', res.data.session_key)
|
|
|
- wx.setStorageSync('lbt_token_key', res.data.token)
|
|
|
+ // console.log('newtoken---',res.token);
|
|
|
+ wx.setStorageSync('lbt_session_key', res.session_key)
|
|
|
+ wx.setStorageSync('lbt_token_key', res.token)
|
|
|
wx.setStorageSync('lbt_session_time', Date.now())
|
|
|
wx.redirectTo({
|
|
|
url: str
|