Loading.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. if (navType == "userInfo") {
  64. uni.redirectTo({
  65. url: "../../my-page/userInfo/userInfo"
  66. })
  67. } else if (navType == "personal") {
  68. uni.redirectTo({
  69. url: "../../personal-page/personal/personal"
  70. })
  71. } else {
  72. uni.redirectTo({
  73. url: "../../login-page/login/login"
  74. })
  75. }
  76. }
  77. }
  78. }
  79. </script>
  80. <style>
  81. .loading-container-bg {
  82. position: absolute;
  83. left: 0;
  84. top: 0;
  85. bottom: 0;
  86. right: 0;
  87. width: 750rpx;
  88. height: 100%;
  89. }
  90. .loading-container-bg image {
  91. width: 100%;
  92. height: 100%;
  93. }
  94. </style>