You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
1.8 KiB
83 lines
1.8 KiB
<script> |
|
import { calcDate } from '@/utils/date.js' |
|
import { tokenTime } from '@/common/setting.js' |
|
export default { |
|
data() { |
|
return { refreshLock: false } |
|
}, |
|
onLaunch: function() { |
|
this.refreshToken() |
|
console.log('App Launch') |
|
}, |
|
onShow: function() { |
|
console.log('App Show') |
|
}, |
|
onHide: function() { |
|
console.log('App Hide') |
|
}, |
|
methods: { |
|
// 定时检测token |
|
refreshToken() { |
|
this.refreshTime = setInterval(() => { |
|
const token = uni.getStorageSync('token') |
|
const date = calcDate(token.datetime, new Date().getTime()) |
|
if (!date) return |
|
if (date.seconds >= tokenTime && !this.refreshLock) { |
|
this.refreshLock = true |
|
this.$u.api |
|
.refreshToken(token.content, '000000') |
|
.then(res => { |
|
this.$u.func |
|
.refreshToken(res) |
|
.then(() => { |
|
this.refreshLock = false |
|
}) |
|
.catch(() => { |
|
this.refreshLock = false |
|
}) |
|
}) |
|
.catch(() => { |
|
this.refreshLock = false |
|
}) |
|
} |
|
}, 30000) |
|
} |
|
} |
|
} |
|
</script> |
|
<style> |
|
@import url('./common/uni.css'); |
|
@import url('./static/iconfont/iconfont.css'); |
|
|
|
/* 解决头条小程序组件内引入字体不生效的问题 */ |
|
/* #ifdef MP-TOUTIAO */ |
|
@font-face { |
|
font-family: uniicons; |
|
src: url('/static/uni.ttf'); |
|
} |
|
|
|
/* #endif */ |
|
.uni-input-border { |
|
border:1px solid #E2E8F0;; |
|
border-radius: 20rpx; |
|
height: 90rpx; |
|
line-height: 90rpx; |
|
padding: 0 20rpx; |
|
text-align: center; |
|
/* background-color: #fff; */ |
|
background: #F8FAFC; |
|
} |
|
</style> |
|
<style lang="scss"> |
|
// @import '@/uni_modules/uview-ui/index.scss'; |
|
.buttonBox { |
|
display: flex; |
|
margin-top: 40rpx; |
|
.button { |
|
width: 200rpx; |
|
} |
|
} |
|
.t-td { |
|
padding: 6rpx !important; |
|
} |
|
</style> |