init.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <view>
  3. <loading></loading>
  4. </view>
  5. </template>
  6. <script>
  7. import {
  8. mapState
  9. } from 'vuex'
  10. export default {
  11. computed: {
  12. ...mapState('m_children', ['examData', 'workData', 'swapData'])
  13. },
  14. onLoad() {
  15. //缓存中同步token
  16. if (!uni.getStorageSync('token')) {
  17. console.log('无Token跳转登录');
  18. setTimeout(function() {
  19. uni.redirectTo({
  20. url: '/subpkg/startup/login'
  21. })
  22. }, 1500);
  23. } else {
  24. if (!uni.getStorageSync('phoneNumber')) {
  25. uni.redirectTo({
  26. url: '/subpkg/startup/guide'
  27. })
  28. return console.log('有Token无手机号跳转引导页');
  29. }
  30. if (!uni.getStorageSync('childInfo')) {
  31. uni.redirectTo({
  32. url: '/subpkg/startup/options'
  33. })
  34. return console.log('有Token有手机号无孩子信息跳转选择页');
  35. }
  36. console.log('有Token跳转首页');
  37. this.allTasks()
  38. }
  39. },
  40. methods: {
  41. //获得异步请求返回值
  42. async allTasks() {
  43. try {
  44. await this.$initTab()
  45. uni.switchTab({
  46. url: '/pages/tab_home/tab_home'
  47. })
  48. } catch (e) {
  49. this.$logOut()
  50. }
  51. },
  52. }
  53. }
  54. </script>
  55. <style lang="scss">
  56. </style>