kaoshixuzhi.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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.userName">用户名:{{data.userName}}</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 { getAuth } from "@/utils/auth";
  32. import examCountDownVue from "./examCountDown.vue";
  33. import {
  34. ref,
  35. reactive,
  36. nextTick,
  37. } from "vue";
  38. const popupRef = ref(null)
  39. const countDownRef = ref(null)
  40. const data = reactive({
  41. intro: '',
  42. name: '',
  43. ksScore: '',
  44. okScore: '',
  45. textareaHtml: '',
  46. credit: '',
  47. startTime: '',
  48. endTime: '',
  49. ksId: '',
  50. startSecond: 0
  51. })
  52. const isCanJoinExam = ref(false)
  53. const emits = defineEmits(['confirm', 'cancel'])
  54. function showDialog(options) {
  55. data.intro = options.intro;
  56. data.ksName = options.name;
  57. data.ksScore = options.ksScore;
  58. data.okScore = options.okScore;
  59. data.credit = options.credit;
  60. data.startTime = options.startTime;
  61. data.endTime = options.endTime;
  62. data.startSecond = options.startSecond;
  63. data.ksId = options.ksId;
  64. data.userName = getAuth() && getAuth().userName
  65. if (typeof options.intro == 'undefined' || options.intro == null || options.intro == '') {
  66. data.textareaHtml = '暂无描述信息';
  67. } else {
  68. data.textareaHtml = options.intro;
  69. }
  70. if (data.startSecond <= 0) {
  71. isCanJoinExam.value = true;
  72. } else {
  73. setTimeout(() => {
  74. countDownRef.value.init()
  75. }, 0)
  76. }
  77. popupRef.value.open('center')
  78. }
  79. function handleClose() {
  80. emits('cancel');
  81. popupRef.value.close()
  82. isCanJoinExam.value = false;
  83. }
  84. function handleConfirm() {
  85. emits('confirm', data);
  86. popupRef.value.close()
  87. }
  88. function onTimeEnd() {
  89. isCanJoinExam.value = true;
  90. }
  91. defineExpose({
  92. showDialog
  93. })
  94. </script>
  95. <style lang="scss">
  96. </style>