123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <script>
- export default {
- onLaunch: function() {
- console.log('App Launch')
- this.$u.func.checkLogin()
- //this.refreshToken()
- },
- onShow: function() {
- console.log('App Show')
- },
- onHide: function() {
- console.log('App Hide')
- },
- onShareAppMessage(res) { //发送给朋友
- return {
- title: '警地融合小程序',
- path:'/pages/index/index',
- imageUrl: '',
- }
- },
- onShareTimeline(res) { //分享到朋友圈
- return {
- title: '警地融合小程序',
- imageUrl: '',
- }
- },
- methods:{
- // 检测token
- refreshToken() {
- const tokenValidPeriod = 20000;
- // 如果token为空或者已经超过有效期,需要生成新的token
-
- if (this.token!=undefined && Number(Date.now() - this.userInfo.tokenGeneratedTime) > Number(tokenValidPeriod)) {
- console.log(this.token,Date.now() - this.userInfo.tokenGeneratedTime);
- this.$u.vuex('userInfo', {
- avatar: '',
- nick_name: '游客',
- tenant_id: '暂无'
- })
- this.$u.vuex('accessToken', '')
- this.$u.vuex('isLogin', false)
- }
- }
- }
- }
- </script>
- <style lang="scss">
- /*每个页面公共css */
- /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
- @import "@/uni_modules/uview-ui/index.scss";
-
- </style>
|