Loading.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <!-- 初始化判断页面 -->
  2. <template>
  3. <view>
  4. <view class="loading-container-bg">
  5. <!-- <image mode="aspectFill" src="../../../static/loading.jpg"></image> -->
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. import config from '../../../common/config.js';
  11. import reqUtil from "@/util/util-js/requstUtil.js";
  12. import {
  13. mapState,
  14. mapMutations
  15. } from 'vuex'
  16. export default {
  17. data() {
  18. return {}
  19. },
  20. computed: mapState(['bNewUser']),
  21. onLoad() {},
  22. onShow() {
  23. let bCanLoading = false;
  24. //验证登录存储
  25. //如果登录过,直接跳转登录页面
  26. const value = uni.getStorageSync('token');
  27. var _self = this;
  28. if (value) {
  29. console.log("验证登录Token值:",value,config.URL.VERIFICATION);
  30. reqUtil.requestData(config.URL.VERIFICATION, {
  31. token: value
  32. }).then(res => {
  33. console.log('requestData VERIFICATION =====', res);
  34. if (res.code == 0) {
  35. // TODO token时效性问题
  36. _self.$store.state.token = value;
  37. _self.$store.state.bNewUser = res.data.newUser;
  38. _self.accountLogin(function() {
  39. // console.log("======");
  40. if (_self.bNewUser) {
  41. _self.onNavTo("userInfo");
  42. } else {
  43. _self.onNavTo("personal");
  44. }
  45. });
  46. } else {
  47. //如果token 不合法,不存在,跳转登录页面
  48. _self.onNavTo("login");
  49. }
  50. },
  51. e => {
  52. console.log(e)
  53. });
  54. } else {
  55. //如果没有token,进入登录界面
  56. _self.onNavTo("login");
  57. }
  58. },
  59. methods: {
  60. ...mapMutations(['accountLogin']),
  61. onNavTo(navType) {
  62. // uni.hideToast();
  63. console.log('navType:',navType);
  64. if (navType == "userInfo") {
  65. uni.redirectTo({
  66. url: "../../my-page/userInfo/userInfo"
  67. })
  68. } else if (navType == "personal") {
  69. // uni.redirectTo({
  70. uni.redirectTo({
  71. url: "../../personal-page/personal/personal"
  72. })
  73. } else {
  74. uni.redirectTo({
  75. url: "../../login-page/login/login"
  76. })
  77. }
  78. }
  79. }
  80. }
  81. </script>
  82. <style>
  83. .loading-container-bg {
  84. position: absolute;
  85. left: 0;
  86. top: 0;
  87. bottom: 0;
  88. right: 0;
  89. width: 750rpx;
  90. height: 100%;
  91. }
  92. .loading-container-bg image {
  93. width: 100%;
  94. height: 100%;
  95. }
  96. </style>