launchScreen.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <view class="container launch-container">
  3. <view class="lauch-min">
  4. <image src="@/static/logo2.png" class="logo"></image>
  5. </view>
  6. <template v-if="!isLogin">
  7. <button class="goLogin" @click="Login">去登录</button>
  8. <view class="warn_txt"> ●请登录后查看,仅限内部员工使用 </view>
  9. </template>
  10. </view>
  11. </template>
  12. <script>
  13. import { User } from "@/config/api.js";
  14. export default {
  15. data() {
  16. return {
  17. isLogin: false,
  18. };
  19. },
  20. methods: {
  21. Login() {
  22. setTimeout(function () {
  23. uni.redirectTo({
  24. url: "/pageMy/login/login",
  25. });
  26. }, 500);
  27. },
  28. },
  29. onLoad() {
  30. // 判断是否有token缓存
  31. let token = this.$db.get("token");
  32. if (!token) {
  33. this.isLogin = false;
  34. } else {
  35. // 校验token
  36. User.checkToken()
  37. .then((res) => {
  38. if (res.Ret === 200) {
  39. this.isLogin = true;
  40. setTimeout(function () {
  41. uni.redirectTo({
  42. url: "/pages/index/index",
  43. });
  44. }, 2000);
  45. } else {
  46. this.isLogin = false;
  47. this.$util.toast(res.Msg);
  48. this.$db.del("token");
  49. this.$db.del("account");
  50. }
  51. })
  52. .catch((err) => {
  53. this.$toast(err);
  54. });
  55. }
  56. },
  57. };
  58. </script>
  59. <style lang="scss">
  60. .launch-container {
  61. background-color: #376cbb;
  62. .lauch-min {
  63. width: 100%;
  64. position: absolute;
  65. top: 40%;
  66. left: 0;
  67. transform: translateY(-50%);
  68. .logo {
  69. display: block;
  70. width: 582rpx;
  71. height: 404rpx;
  72. margin: 0 auto 50rpx;
  73. }
  74. .logo-tit {
  75. text-align: center;
  76. font-size: 78rpx;
  77. color: #fff;
  78. text {
  79. display: inline-block;
  80. }
  81. .logo-tit-first {
  82. margin-right: 50rpx;
  83. }
  84. }
  85. }
  86. .goLogin {
  87. width: 400rpx;
  88. height: 90rpx;
  89. line-height: 90rpx;
  90. position: absolute;
  91. left: 50%;
  92. bottom: 15%;
  93. transform: translateX(-50%);
  94. color: #fff;
  95. font-size: 38rpx;
  96. background-color: #376cbb;
  97. border: 1rpx solid #fff;
  98. border-radius: 90rpx;
  99. }
  100. .warn_txt {
  101. width: 100%;
  102. font-size: 26rpx;
  103. color: #fff;
  104. position: absolute;
  105. left: 0;
  106. bottom: 8%;
  107. text-align: center;
  108. }
  109. }
  110. </style>