tishiDl.vue 974 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. setTimeout(() => {
  24. if (count.value == 0) {
  25. handleClose();
  26. return;
  27. }
  28. count.value--;
  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>