kaoshixuzhi.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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-dialog">
  5. <view class="ksxz-title-row">
  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 class="ksxz-content-box">
  12. <view v-if="data.name">考试名称:{{data.name}}</view>
  13. <view v-if="data.userName">用户名:{{data.userName}}</view>
  14. <view v-if="data.credit">学分:{{data.credit}}</view>
  15. <view v-if="data.okScore">及格分:{{data.okScore}}</view>
  16. <view v-if="data.ksScore">总分:{{data.ksScore}}</view>
  17. <view v-if="data.startTime">开始:{{data.startTime}}</view>
  18. <view v-if="data.endTime">结束:{{data.endTime}}</view>
  19. <view>
  20. <view v-if="data.textareaHtml" class="ksms-row">考试描述:</view>
  21. <rich-text v-if="data.textareaHtml" :nodes="data.textareaHtml" class="ksms-intro"></rich-text>
  22. </view>
  23. </view>
  24. <view class="ksxz-btn-box">
  25. <view class="ksxz-btn" @click="handleClose">取消</view>
  26. <view class="ksxz-btn" v-if="isCanJoinExam" @click="handleConfirm">确定</view>
  27. </view>
  28. </view>
  29. </uni-popup>
  30. </view>
  31. </template>
  32. <script setup>
  33. import { getAuth } from "@/utils/auth";
  34. import examCountDownVue from "./examCountDown.vue";
  35. import {
  36. ref,
  37. reactive,
  38. nextTick,
  39. } from "vue";
  40. const popupRef = ref(null)
  41. const countDownRef = ref(null)
  42. const data = reactive({
  43. intro: '',
  44. name: '',
  45. ksScore: '',
  46. okScore: '',
  47. textareaHtml: '',
  48. credit: '',
  49. startTime: '',
  50. endTime: '',
  51. ksId: '',
  52. startSecond: 0
  53. })
  54. const isCanJoinExam = ref(false)
  55. const emits = defineEmits(['confirm', 'cancel'])
  56. function showDialog(options) {
  57. data.intro = options.intro;
  58. data.ksName = options.name;
  59. data.ksScore = options.ksScore;
  60. data.okScore = options.okScore;
  61. data.credit = options.credit;
  62. data.startTime = options.startTime;
  63. data.endTime = options.endTime;
  64. data.startSecond = options.startSecond;
  65. data.ksId = options.ksId;
  66. data.userName = getAuth() && getAuth().userName
  67. if (typeof options.intro == 'undefined' || options.intro == null || options.intro == '') {
  68. data.textareaHtml = '暂无描述信息';
  69. } else {
  70. data.textareaHtml = options.intro;
  71. }
  72. if (data.startSecond <= 0) {
  73. isCanJoinExam.value = true;
  74. } else {
  75. setTimeout(() => {
  76. countDownRef.value.init()
  77. }, 0)
  78. }
  79. popupRef.value.open('center')
  80. }
  81. function handleClose() {
  82. emits('cancel');
  83. popupRef.value.close()
  84. isCanJoinExam.value = false;
  85. }
  86. function handleConfirm() {
  87. emits('confirm', data);
  88. popupRef.value.close()
  89. }
  90. function onTimeEnd() {
  91. isCanJoinExam.value = true;
  92. }
  93. defineExpose({
  94. showDialog
  95. })
  96. </script>
  97. <style lang="scss">
  98. </style>