优化刷新token

master
chen 2022-08-17 09:32:58 +08:00
parent 5fb3964ed4
commit ac04a11951
3 changed files with 16 additions and 17 deletions

View File

@ -411,17 +411,18 @@ const tools = {
success: (res)=> { success: (res)=> {
var params = {code:res.code} var params = {code:res.code}
uni.request({ uni.request({
url: `${uni.getStorageSync('hostapi')}/api/user/login`, url: `${getApp().globalData.hostapi}/api/user/login`,
method: 'post', method: 'post',
data: params, data: params,
success: res => { success: result => {
if(res.data.data.token!=''){ if(result.data.data.token!=''){
uni.setStorageSync('token',res.data.data.token); // 缓存token console.log('刷新了token');
uni.setStorageSync('openid',res.data.data.openid)//缓存openid uni.setStorageSync('token',result.data.data.token); // 缓存token
uni.setStorageSync('expire',res.data.data.expire); // 缓存失效时间(时间戳格式) uni.setStorageSync('openid',result.data.data.openid)//缓存openid
uni.setStorageSync('phone_active',res.data.data.phone_active); // 是否绑定手机号 uni.setStorageSync('expire',result.data.data.expire); // 缓存失效时间(时间戳格式)
uni.setStorageSync('is_active',res.data.data.is_active)//是否第一次授权 uni.setStorageSync('phone_active',result.data.data.phone_active); // 是否绑定手机号
uni.setStorageSync('invite_code',res.data.data.invite_code)//缓存用户邀请码 uni.setStorageSync('is_active',result.data.data.is_active)//是否第一次授权
uni.setStorageSync('invite_code',result.data.data.invite_code)//缓存用户邀请码
} }
} }
}) })

View File

@ -35,12 +35,7 @@
}, },
data() { data() {
return { return {
dataList:[ dataList:[],
{imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg',title:'思通造化随通而行为术基础动作教学思通造化随通而行为术基础动作教学',time:'2022.07.20 12:12:12',price:'199.00'},
{imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg',title:'思通造化随通而行为术基础动作教学思通造化随通而行为术基础动作教学',time:'2022.07.20 12:12:12',price:'199.00'},
{imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg',title:'思通造化随通而行为术基础动作教学思通造化随通而行为术基础动作教学',time:'2022.07.20 12:12:12',price:'199.00'},
{imgsrc:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg',title:'思通造化随通而行为术基础动作教学思通造化随通而行为术基础动作教学',time:'2022.07.20 12:12:12',price:'199.00'},
],
page:1, page:1,
size:20, size:20,
total:0, total:0,
@ -62,7 +57,11 @@
// //
getCouresList(){ getCouresList(){
this.loading = false; this.loading = false;
this.$requst.get('/api/user/course').then(res=>{ let params = {
page:this.page,
size:this.size
}
this.$requst.get('/api/user/course',params).then(res=>{
this.total = res.data.total; this.total = res.data.total;
if(this.page==1){this.dataList=[];} if(this.page==1){this.dataList=[];}
this.dataList = [...this.dataList,...res.data.list]; this.dataList = [...this.dataList,...res.data.list];

View File

@ -61,7 +61,6 @@
}, },
onLoad(op) { onLoad(op) {
this.levelIndex = op.level*1; this.levelIndex = op.level*1;
console.log(this.levelIndex);
this.getExtend(); this.getExtend();
}, },
onReachBottom() { onReachBottom() {