App.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <script>
  2. export default {
  3. // 此处globalData为了演示其作用,不是uView框架的一部分
  4. globalData: {
  5. username: '白居易'
  6. },
  7. onLaunch() {
  8. // 1.1.0版本之前关于http拦截器代码,已平滑移动到/common/http.interceptor.js中
  9. // 注意,需要在/main.js中实例化Vue之后引入如下(详见文档说明):
  10. // import httpInterceptor from '@/common/http.interceptor.js'
  11. // Vue.use(httpInterceptor, app)
  12. // process.env.VUE_APP_PLATFORM 为通过js判断平台名称的方法,结果分别如下:
  13. /**
  14. * h5,app-plus(nvue下也为app-plus),mp-weixin,mp-alipay......
  15. */
  16. },
  17. created() {
  18. let time = new Date().getTime()
  19. if (uni.getStorageSync('effective_time')) {
  20. if (uni.getStorageSync('effective_time') <= time) {
  21. //console.log("token过期了")
  22. uni.redirectTo({
  23. url: 'pages/login/index'
  24. });
  25. }else{
  26. //console.log("直接进入首页")
  27. uni.redirectTo({
  28. url: 'pages/home/index'
  29. });
  30. }
  31. }else{
  32. //console.log('第一次登录')
  33. uni.redirectTo({
  34. url: 'pages/login/index'
  35. });
  36. }
  37. }
  38. }
  39. </script>
  40. <style lang="scss">
  41. @import "uview-ui/index.scss";
  42. @import "common/demo.scss";
  43. </style>