StartUpPage.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <view class="img-view" :class="['qn-page-' + theme]">
  3. <block v-if="startUpPage.isEnable && startUpPage.img">
  4. <view @click="goPageS('/pages/index/index', 'switchTab')" class="go-index-btn">跳过 {{ time }} s</view>
  5. <view class="startUpPage-view">
  6. <image @click="goPageS(startUpPage.url, startUpPage.switchTab)" class="start-img" :src="startUpPage.img" mode="aspectFill"></image>
  7. </view>
  8. </block>
  9. </view>
  10. </template>
  11. <script>
  12. import amap from '@/access/amap-wx.js';
  13. export default {
  14. data() {
  15. return {
  16. startUpPage: {
  17. img: '',
  18. isEnable: false,
  19. time: 5
  20. },
  21. time: 5,
  22. timesInterval: null
  23. };
  24. },
  25. watch: {
  26. // 监听倒计时,当时间为0时跳转页面,在这里监听的原因是为了跳出setInterval,防止setInterval不会终止,而不停的跳转首页
  27. time(val) {
  28. if (val === 0) {
  29. uni.switchTab({
  30. url: '/pages/index/index'
  31. });
  32. }
  33. }
  34. },
  35. async onLoad() {
  36. // #ifdef MP-TOUTIAO
  37. uni.switchTab({
  38. url: '/pages/index/index'
  39. });
  40. return;
  41. // #endif
  42. // #ifdef MP-WEIXIN || APP-PLUS || H5
  43. await this.getBasicField();
  44. // #endif
  45. },
  46. methods: {
  47. goPageS(url, type) {
  48. if (!url) {
  49. return;
  50. }
  51. clearInterval(this.timesInterval);
  52. this.goPage(url, type);
  53. },
  54. // 获取商城基本设置
  55. async getBasicField() {
  56. // startUpPage,启动页设置
  57. await this.$u.api
  58. .getBasicField({
  59. field: ['startUpPage']
  60. })
  61. .then(({ data }) => {
  62. if (!data.startUpPage || !data.startUpPage.isEnable || !data.startUpPage.img) {
  63. uni.switchTab({
  64. url: '/pages/index/index'
  65. });
  66. return;
  67. }
  68. if (data.startUpPage && data.startUpPage.isEnable && data.startUpPage.img) {
  69. this.startUpPage = data.startUpPage;
  70. this.time = this.startUpPage.time;
  71. this.timesInterval = setInterval(() => {
  72. if (this.time === 0) {
  73. clearInterval(this.timesInterval);
  74. } else {
  75. this.time = this.time - 1;
  76. }
  77. }, 1000);
  78. }
  79. });
  80. }
  81. }
  82. };
  83. </script>
  84. <style scoped lang="scss">
  85. .img-view {
  86. position: relative;
  87. width: 750upx;
  88. height: 100vh;
  89. .logo-view {
  90. height: 300rpx;
  91. text-align: center;
  92. background-color: #ffffff;
  93. .logo-view-in {
  94. transform: translateY(60rpx);
  95. .en-logo {
  96. height: 120rpx;
  97. width: 120rpx;
  98. display: block;
  99. margin: 0 auto;
  100. }
  101. .en-name {
  102. font-size: 36rpx;
  103. padding-top: 20rpx;
  104. }
  105. }
  106. }
  107. .go-index-btn {
  108. position: absolute;
  109. bottom: 350upx;
  110. right: 20upx;
  111. font-size: 26upx;
  112. color: #fff;
  113. background-color: rgba($color: #000000, $alpha: 0.4);
  114. width: 150upx;
  115. height: 55upx;
  116. line-height: 55upx;
  117. text-align: center;
  118. border-radius: 66upx;
  119. z-index: 9;
  120. }
  121. .startUpPage-view {
  122. width: 750upx;
  123. height: 100vh;
  124. overflow: hidden;
  125. background-color: #ffffff;
  126. .start-img {
  127. width: 100%;
  128. height: 100%;
  129. display: block;
  130. }
  131. }
  132. }
  133. </style>