init.vue 1.2 KB

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