tishiDl.vue 1.0 KB

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