welcome.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <view class="wrap">
  3. <u-navbar title="答题即将开始" bgColor="rgba(255,255,255,0.3)" leftText="返回" :autoBack="true" titleStyle="font-weight:bold;color:#7a5831"></u-navbar>
  4. <view style="position: relative" class="screen" v-if="screenImage" :style="{ height: screenHeight + 'px' }">
  5. <image :src="screenImage" mode="aspectFill" :style="{ height: screenHeight + 'px' }"></image>
  6. <view @click="skipBtn" style="position: absolute; top: 200rpx; right: 38rpx; display: flex; align-items: center; justify-content: space-between">
  7. <u-button customStyle="width:100rpx" shape="circle" size="mini" text="跳过" color="#3e3c41"></u-button>
  8. </view>
  9. <view class="b-countdown" @click="onJumHome">
  10. <view class="s-text">{{ screenCountdown }}</view>
  11. </view>
  12. </view>
  13. <!-- 加载中 -->
  14. <load-more :loadingType="loadingType" :loadingText="loadingText" :top="300"></load-more>
  15. </view>
  16. </template>
  17. <script>
  18. import { getConfig } from '@/service/api/common.js';
  19. import { silentReload, smartLogin } from '@/service/request/main.js';
  20. import Util from '../../common/util.js';
  21. // import mixinsCommon from '../../mixins/common.js';
  22. export default {
  23. // mixins: [mixinsCommon],
  24. data() {
  25. return {
  26. screenHeight: 0,
  27. screenImage: 'https://huli-app.wenlvti.net/app_static/WenWuGuanJia/image/dtydy.png',
  28. screenCountdown: 5,
  29. loadingType: 1,
  30. loadingText: '',
  31. interval: 0,
  32. aid: 0,
  33. user: {}
  34. };
  35. },
  36. onLoad(options) {
  37. console.log('web onLoad', options);
  38. let params = options;
  39. this.aid = options.aid;
  40. let from = params.from;
  41. if (params.scene) {
  42. params = Util.urlDecode(decodeURIComponent(params.scene));
  43. from = 'qrcode';
  44. }
  45. this.$store.commit('setActivityId', params.aid);
  46. getConfig().then(([err, res]) => {
  47. // console.log('getConfig', err, res);
  48. if (!err) {
  49. this.user = this.$common.userInfo();
  50. this.loadingType = -1;
  51. this.$store.commit('setGlobalConfig', res);
  52. // this.screenImage = res.welcome_img;
  53. this.screenCountdown = res.welcome_countdown || 5;
  54. if (this.screenImage) {
  55. // 验证码倒计时
  56. this.interval = setInterval(() => {
  57. this.screenCountdown--;
  58. }, 1000);
  59. setTimeout(() => {
  60. if (this.interval > 0) {
  61. this.onJumHome(from);
  62. }
  63. }, this.screenCountdown * 1000);
  64. } else {
  65. this.onJumHome(from);
  66. }
  67. } else {
  68. this.loadingType = 3;
  69. this.loadingText = err.data.msg || '加载失败';
  70. }
  71. });
  72. // 获取窗口高度
  73. const systemInfo = uni.getSystemInfoSync();
  74. this.screenHeight = systemInfo.screenHeight;
  75. },
  76. onShow() {},
  77. methods: {
  78. onJumHome(from) {
  79. if (this.interval > 0) {
  80. clearInterval(this.interval);
  81. this.interval = 0;
  82. }
  83. if (this.$store.getters.accessToken) {
  84. // console.log(this.user, '78787878');
  85. uni.redirectTo({
  86. url: '/answer_pages/home/index?SharerId=' + this.user.id // 跳到首页
  87. });
  88. } else {
  89. if (from === 'qrcode') {
  90. // console.info('needLogin qrcode', 'silentReload');
  91. silentReload(false, ''); // 扫描尝试自动登录
  92. } else {
  93. smartLogin('/answer_pages/home/dashboard');
  94. }
  95. }
  96. },
  97. /* 跳过事件 */
  98. skipBtn() {
  99. clearTimeout(this.interval);
  100. this.interval = null;
  101. uni.redirectTo({
  102. url: '/answer_pages/home/index?SharerId=' + this.user.id // 跳到首页
  103. });
  104. }
  105. }
  106. };
  107. </script>
  108. <style lang="scss">
  109. .wrap {
  110. }
  111. .screen {
  112. width: 750upx;
  113. image {
  114. width: 750upx;
  115. }
  116. .b-countdown {
  117. position: absolute;
  118. right: 80upx;
  119. bottom: 80upx;
  120. width: 80upx;
  121. height: 80upx;
  122. border-radius: 40upx;
  123. background: rgba(0, 0, 0, 0.5);
  124. display: flex;
  125. align-items: center;
  126. justify-content: center;
  127. .s-text {
  128. font-size: 32upx;
  129. font-weight: bold;
  130. color: #fff;
  131. }
  132. }
  133. }
  134. </style>