|
|
|
@@ -23,9 +23,43 @@ App({ |
|
|
|
// // 发送 res.code 到后台换取 openId, sessionKey, unionId |
|
|
|
// } |
|
|
|
// }) |
|
|
|
this.loginGettoken() |
|
|
|
}, |
|
|
|
globalData: { |
|
|
|
userInfo: null, |
|
|
|
token: '1212121212' |
|
|
|
} |
|
|
|
token: '2222' |
|
|
|
}, |
|
|
|
//登录-获取token |
|
|
|
loginGettoken(){ |
|
|
|
let that = this |
|
|
|
wx.login({ |
|
|
|
success (res) { |
|
|
|
if (res.code) { |
|
|
|
//发起网络请求 |
|
|
|
wx.request({ |
|
|
|
url:'https://cktest.2weisou.com/meta/auth/mobile/token/social?grant_type=mobil&mobile=MINI_C@'+res.code+'@'+'', |
|
|
|
method: "POST", |
|
|
|
data: { |
|
|
|
}, |
|
|
|
header: { |
|
|
|
Authorization: "Basic YXBwbGV0OmFwcGxldA==", |
|
|
|
}, |
|
|
|
success(res1) { |
|
|
|
if (res1.statusCode == 200) { |
|
|
|
let userInfo = res1.data.user_info |
|
|
|
that.globalData.token = res1.data.access_token |
|
|
|
that.globalData.userInfo = res1.data.user_info |
|
|
|
// console.log(that.globalData.token) |
|
|
|
// console.log(that.globalData.userInfo) |
|
|
|
wx.setStorageSync('token', res1.data.access_token) |
|
|
|
wx.setStorageSync('userInfo', res1.data.user_info) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
console.log('登录失败!' + res.errMsg) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
}) |