tishiDl.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <!-- 弹窗 -->
  3. <view>
  4. <uni-popup ref="popupRef" :animation="false" :is-mask-click="false" 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. </view>
  13. </template>
  14. <script setup>
  15. import {
  16. nextTick,
  17. ref
  18. } from "vue"
  19. const times = ref(null)
  20. const count = ref(5);
  21. const popupRef = ref(null);
  22. function initTime() {
  23. times.value = setTimeout(() => {
  24. if (count.value == 0) {
  25. handleClose();
  26. return;
  27. }
  28. count.value--;
  29. initTime()
  30. }, 1000)
  31. }
  32. function clearTime() {
  33. clearTimeout(times.value);
  34. times.value = null;
  35. count.value = 5;
  36. }
  37. function handleClose() {
  38. clearTime();
  39. popupRef.value.close();
  40. }
  41. function open() {
  42. popupRef.value.open();
  43. nextTick(() => initTime())
  44. }
  45. defineExpose({
  46. open
  47. })
  48. </script>
  49. <style>
  50. </style>