tishiDl.vue 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <!-- 弹窗 -->
  3. <uni-popup ref="popupRef" :animation="false" :is-mask-click="false" mask-background-color="rgba(0,0,0, 0.76);">
  4. <view class="ezy-tip-dialog tip-e-dialog ">
  5. <view class="close-btn" @click="handleClose"></view>
  6. <view class="e-img bs-e-img"></view>
  7. <view class="text-score">暂无在学课程</view>
  8. <view class="time-tip-box" v-if="times">({{count}}S)</view>
  9. </view>
  10. </uni-popup>
  11. </template>
  12. <script setup>
  13. import {
  14. nextTick,
  15. ref
  16. } from "vue"
  17. const times = ref(null)
  18. const count = ref(2);
  19. const popupRef = ref(null);
  20. function initTime() {
  21. times.value = setTimeout(() => {
  22. if (count.value == 0) {
  23. handleClose();
  24. return;
  25. }
  26. count.value--;
  27. initTime()
  28. }, 1000)
  29. }
  30. function clearTime() {
  31. clearTimeout(times.value);
  32. times.value = null;
  33. count.value = 2;
  34. }
  35. function handleClose() {
  36. clearTime();
  37. popupRef.value.close();
  38. }
  39. function open() {
  40. popupRef.value.open();
  41. nextTick(() => initTime())
  42. }
  43. defineExpose({
  44. open
  45. })
  46. </script>
  47. <style>
  48. </style>