mn_yindaoye.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <view class="box" :style="{ height: screenHeight + 'px' }">
  3. <view class="tiaoguo" @click="skipGuide">
  4. <view>{{ countdown }}跳过</view>
  5. </view>
  6. </view>
  7. </template>
  8. <script>
  9. export default {
  10. data() {
  11. return {
  12. screenHeight: 0,
  13. interval: null, // 用于存储倒计时的定时器ID
  14. countdown: 3 // 倒计时初始值
  15. };
  16. },
  17. onLoad() {
  18. // 获取窗口高度
  19. const systemInfo = uni.getSystemInfoSync();
  20. this.screenHeight = systemInfo.screenHeight;
  21. },
  22. mounted() {
  23. this.startCountdown();
  24. },
  25. methods: {
  26. // 开始倒计时
  27. startCountdown() {
  28. this.interval = setInterval(() => {
  29. if (this.countdown > 0) {
  30. this.countdown--;
  31. } else {
  32. clearInterval(this.interval);
  33. this.closeGuide();
  34. }
  35. }, 1000); // 每秒减少1
  36. },
  37. // 跳过引导
  38. skipGuide() {
  39. // 清除延时器不然会跳 两次
  40. clearInterval(this.interval);
  41. this.closeGuide();
  42. },
  43. closeGuide() {
  44. uni.switchTab({
  45. url: '/pages/index/index'
  46. });
  47. }
  48. }
  49. };
  50. </script>
  51. <style>
  52. .box {
  53. width: 100%;
  54. height: 100%;
  55. background-image: url('https://huli-app.wenlvti.net/app_static/minnanhun/image/mn_yindaoye.jpg');
  56. background-size: cover;
  57. }
  58. .img {
  59. width: 100%;
  60. height: 100%;
  61. }
  62. .tiaoguo {
  63. width: 100rpx;
  64. border-radius: 20rpx;
  65. position: absolute;
  66. top: 180rpx;
  67. right: 38rpx;
  68. text-align: center;
  69. background-color: rgba(0, 0, 0, 0.3);
  70. }
  71. </style>