赞
踩
app.js
//换取新token var tokentime = wx.getStorageSync('tokentime');//过期时间 let newTime = Date.parse(new Date());// 当前时间 var token = wx.getStorageSync('token'); if (!token) { return; } if (newTime > tokentime) { var newTokenTime = 24 * 3600 * 10;//过期时间10天 wx.request({ url: this.globalData.userUrl + 'api/auth/refresh?token='+token+'', method: "GET", success: function (res) { if (!res.data.message) { wx.setStorageSync('token', res.data.data.token); wx.setStorageSync('tokentime', Date.parse(new Date() + newTokenTime)); } var token2 = wx.getStorageSync('token'); console.log('新token', token2); } }); }
有什么问题欢迎评论留言,我会及时回复你的
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。