kaoshixuzhi.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <view>
  3. <uni-popup ref="popupRef" :animation="false" :is-mask-click="false" mask-background-color="rgba(0, 0, 0, 0.4);">
  4. <view class="ksxz-content-box" style="background-color: #fff;padding: 20rpx;">
  5. <view>
  6. <text>考试须知</text>
  7. <!-- 倒计时 -->
  8. <examCountDownVue v-if="data.startSecond>0" :count="data.startSecond" ref="countDownRef"
  9. class="cur-exam-count-down" @time-end="onTimeEnd"></examCountDownVue>
  10. </view>
  11. <view v-if="data.name">考试名称:{{data.name}}</view>
  12. <view v-if="data.ksScore">用户名:{{data.ksScore}}</view>
  13. <view v-if="data.credit">学分:{{data.credit}}</view>
  14. <view v-if="data.okScore">及格分:{{data.okScore}}</view>
  15. <view v-if="data.ksScore">总分:{{data.ksScore}}</view>
  16. <view v-if="data.startTime">开始:{{data.startTime}}</view>
  17. <view v-if="data.endTime">结束:{{data.endTime}}</view>
  18. <view>
  19. <view v-if="data.textareaHtml" class="ksms-row">考试描述:</view>
  20. <rich-text v-if="data.textareaHtml" :nodes="data.textareaHtml" class="ksms-intro"></rich-text>
  21. </view>
  22. <view>
  23. <button class="cancel" @click="handleClose">取消</button>
  24. <button class="confirm" v-if="isCanJoinExam" @click="handleConfirm">确定</button>
  25. </view>
  26. </view>
  27. </uni-popup>
  28. </view>
  29. </template>
  30. <script setup>
  31. import examCountDownVue from "./examCountDown.vue";
  32. import {
  33. ref,
  34. reactive,
  35. nextTick
  36. } from "vue";
  37. const popupRef = ref(null)
  38. const countDownRef = ref(null)
  39. const data = reactive({
  40. intro: '',
  41. name: '',
  42. ksScore: '',
  43. okScore: '',
  44. textareaHtml: '',
  45. credit: '',
  46. startTime: '',
  47. endTime: '',
  48. ksId: '',
  49. startSecond: 0
  50. })
  51. const isCanJoinExam = ref(false)
  52. const emits = defineEmits(['confirm', 'cancel'])
  53. function showDialog(options) {
  54. data.intro = options.intro;
  55. data.ksName = options.name;
  56. data.ksScore = options.ksScore;
  57. data.okScore = options.okScore;
  58. data.credit = options.credit;
  59. data.startTime = options.startTime;
  60. data.endTime = options.endTime;
  61. data.startSecond = options.startSecond;
  62. data.ksId = options.ksId;
  63. if (typeof options.intro == 'undefined' || options.intro == null || options.intro == '') {
  64. data.textareaHtml = '暂无描述信息';
  65. } else {
  66. data.textareaHtml = options.intro;
  67. }
  68. if (options.startSecond < 0) {
  69. isCanJoinExam.value = true;
  70. }
  71. popupRef.value.open('center')
  72. setTimeout(() => {
  73. countDownRef.value.init()
  74. }, 0)
  75. }
  76. function handleClose() {
  77. emits('cancel');
  78. popupRef.value.close()
  79. isCanJoinExam.value = false;
  80. countDownRef.value.termination()
  81. }
  82. function handleConfirm() {
  83. emits('confirm', data);
  84. popupRef.value.close()
  85. }
  86. function onTimeEnd() {
  87. isCanJoinExam.value = true;
  88. }
  89. defineExpose({
  90. showDialog
  91. })
  92. </script>
  93. <style lang="scss">
  94. </style>