...
|
...
|
@@ -7,9 +7,9 @@ Page({ |
|
|
*/
|
|
|
data: {
|
|
|
imgUrls: [
|
|
|
'../../imgs/lunbo1@3x.png',
|
|
|
'../../imgs/lunbo2@3x.png',
|
|
|
'../../imgs/lunbo3@3x.png'
|
|
|
app.globalData.imgUrl + 'lunbo1@3x.png',
|
|
|
app.globalData.imgUrl + 'lunbo2@3x.png',
|
|
|
app.globalData.imgUrl + 'lunbo3@3x.png'
|
|
|
],
|
|
|
indexs: 0,
|
|
|
color: '#cccccc',
|
...
|
...
|
@@ -17,7 +17,8 @@ Page({ |
|
|
autoplay: true,
|
|
|
activecolor: '#ffffff',
|
|
|
interval: 5000,
|
|
|
duration: 1000
|
|
|
duration: 1000,
|
|
|
imgUrl: app.globalData.imgUrl
|
|
|
},
|
|
|
|
|
|
start(e) {
|
...
|
...
|
@@ -32,9 +33,9 @@ Page({ |
|
|
code: s.code
|
|
|
}
|
|
|
app.post(url, param).then((res) => {
|
|
|
console.log(res);
|
|
|
console.log(e);
|
|
|
that.login(res.data.openid, res.data.session_key, e.detail.encryptedData, e.detail.iv, e.detail.rawData, e.detail.signature);
|
|
|
// console.log(res);
|
|
|
// console.log(e);
|
|
|
that.login(res.data.openid, res.data.session_key, e.detail.encryptedData, e.detail.iv);
|
|
|
}).catch((errMsg) => {
|
|
|
console.log(errMsg);
|
|
|
})
|
...
|
...
|
@@ -42,25 +43,22 @@ Page({ |
|
|
}
|
|
|
});
|
|
|
},
|
|
|
login(openid, session_key, encrypted_data, iv,r,s) {
|
|
|
login(openid, session_key, encrypted_data, iv) {
|
|
|
let that = this;
|
|
|
wx.checkSession({
|
|
|
success: function () {
|
|
|
console.log('未过期');
|
|
|
//session_key 未过期,并且在本生命周期一直有效
|
|
|
let param = {
|
|
|
openid: openid,
|
|
|
session_key: session_key,
|
|
|
encrypted_data: encrypted_data,
|
|
|
iv: iv,
|
|
|
rawData: r,
|
|
|
signature: s
|
|
|
}
|
|
|
let url = 'wxapp/public/login';
|
|
|
// wx.navigateTo({
|
|
|
// url: '/pages/login/login',
|
|
|
// success: function (res) { },
|
|
|
// fail: function (res) { },
|
|
|
// complete: function (res) { },
|
|
|
// })
|
|
|
|
|
|
app.post(url, param).then((res) => {
|
|
|
console.log(res)
|
|
|
// console.log(res)
|
|
|
wx.setStorageSync('token', res.data.token);
|
|
|
let u = "wxapp/public/isMobile";
|
|
|
let header = {
|
...
|
...
|
@@ -70,7 +68,22 @@ Page({ |
|
|
type: 1
|
|
|
}
|
|
|
app.post(u, data, header).then((r) => {
|
|
|
console.log(r)
|
|
|
console.log(r);
|
|
|
if (r.data.is_mobile == 2) {
|
|
|
wx.redirectTo({
|
|
|
url: '/pages/login/login',
|
|
|
success: function (res) { },
|
|
|
fail: function (res) { },
|
|
|
complete: function (res) { },
|
|
|
})
|
|
|
} else if (r.data.is_mobile == 1) {
|
|
|
wx.redirectTo({
|
|
|
url: '/pages/index/index',
|
|
|
success: function (res) { },
|
|
|
fail: function (res) { },
|
|
|
complete: function (res) { },
|
|
|
})
|
|
|
}
|
|
|
}).catch((err) => {
|
|
|
|
|
|
})
|
...
|
...
|
@@ -84,6 +97,14 @@ Page({ |
|
|
console.log(errMsg);
|
|
|
})
|
|
|
},
|
|
|
fail: function () {
|
|
|
console.log('session_key 已经失效');
|
|
|
// session_key 已经失效,需要重新执行登录流程
|
|
|
that.start() //重新登录
|
|
|
}
|
|
|
})
|
|
|
|
|
|
},
|
|
|
changeindexs(e) {
|
|
|
this.setData({
|
|
|
indexs: e.detail.current
|
...
|
...
|
|