650完成,670完成部分
This commit is contained in:
@ -146,10 +146,31 @@
|
||||
}
|
||||
try {
|
||||
|
||||
|
||||
console.log('44444');
|
||||
if(uni.getStorageSync("token") && uni.getStorageSync("clientID")){//免登陆
|
||||
|
||||
let time=uni.getStorageSync("tokenTime");
|
||||
if(!time){
|
||||
time=0;
|
||||
}
|
||||
let currTime=new Date().getTime();
|
||||
if(currTime<time){
|
||||
uni.switchTab({
|
||||
url: '/pages/common/index/index'
|
||||
});
|
||||
return;
|
||||
}else{
|
||||
//token过期了
|
||||
uni.removeStorageSync("token")
|
||||
uni.removeStorageSync("clientID")
|
||||
uni.removeStorageSync("tokenTime")
|
||||
}
|
||||
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '登录中...'
|
||||
})
|
||||
console.log('44444');
|
||||
// 调用登录接口
|
||||
const res = await login({
|
||||
phonenumber: this.phone,
|
||||
@ -158,16 +179,21 @@
|
||||
})
|
||||
if (res.code == 200) {
|
||||
console.log(res, 'ressss');
|
||||
uni.hideLoading()
|
||||
uni.setStorageSync('token', res.data.access_token) // 缓存token
|
||||
uni.setStorageSync('clientID', res.data.client_id) // 缓存token
|
||||
uni.hideLoading();
|
||||
uni.setStorageSync('token', res.data.access_token); // 缓存token
|
||||
uni.setStorageSync('clientID', res.data.client_id); // 缓存token
|
||||
uni.setStorageSync('tokenTime',new Date().getTime()+86400000);//过期时间
|
||||
uni.showToast({
|
||||
title: '登录成功',
|
||||
icon: 'success'
|
||||
})
|
||||
uni.switchTab({
|
||||
url: '/pages/common/index/index'
|
||||
})
|
||||
});
|
||||
|
||||
// uni.navigateTo({
|
||||
// url:"/pages/BlueTooth/ModeSetting/index"
|
||||
// });
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
|
Reference in New Issue
Block a user