tishiDl.vue 1002 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <!-- 弹窗 -->
  3. <uni-popup ref="popupRef" :animation="false" :is-mask-click="false"
  4. mask-background-color="rgba(51, 137, 217, 0.95);">
  5. <view @click="handleClose">close</view>
  6. <view>
  7. <view class="text-score">完成了本节基础课程的学习</view>
  8. <view class="course-btn-box">
  9. <text v-if="times">({{count}}S)</text>
  10. </view>
  11. </view>
  12. </uni-popup>
  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>