index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <custom-scroll-list :refreshFn="getExamList" :tabList="tabData" :defaultTab="1" ref="scrollRef">
  3. <template #default="{list}">
  4. <scroll-list-card v-for="(item,index) in list" :key="item.ksId" :data="item"
  5. @btnClick="handleClick"></scroll-list-card>
  6. </template>
  7. </custom-scroll-list>
  8. <!-- 考试须知 -->
  9. <kaoshixuzhi ref="ksxzRef" @confirm="handleConfirm"></kaoshixuzhi>
  10. </template>
  11. <script setup>
  12. import {
  13. getExamList,
  14. kaoShiApply,
  15. getClientKaoshiInfo
  16. } from "@/api/exam.js";
  17. import {
  18. onReady,
  19. } from "@dcloudio/uni-app"
  20. import {
  21. reactive,
  22. ref
  23. } from "vue";
  24. import kaoshixuzhi from "@/components/kaoshixuzhi/kaoshixuzhi.vue"
  25. const activeKs = ref(null);
  26. const scrollRef = ref(null);
  27. const examNoticeInfo = ref(null);
  28. const textareaHtml = ref(null);
  29. const examNoticeShowFlag = ref(false);
  30. const ksxzRef = ref(null);
  31. const tabData = [{
  32. label: "可以考试",
  33. value: 1,
  34. },
  35. {
  36. label: "已结束",
  37. value: 4,
  38. }
  39. ]
  40. function goKaoshiPage(data) {
  41. uni.redirectTo({
  42. url: `/pages/exam/exam?ksId=${data.ksId}&zhuapai=${data.zhuapai}`
  43. })
  44. }
  45. function handleConfirm() {
  46. goKaoshiPage(activeKs.value)
  47. }
  48. function showKaoshiXuzhi() {
  49. const option = {
  50. ksId: activeKs.value.ksId
  51. }
  52. getClientKaoshiInfo(option).then(res => {
  53. examNoticeInfo.value = res.data;
  54. // 校验抓拍
  55. doCheckZhuapai()
  56. })
  57. }
  58. function doCheckZhuapai() {
  59. if (examNoticeInfo.value.zhuapai) {
  60. // 存在抓拍
  61. } else {
  62. // 不存在抓拍
  63. ksxzRef.value.showDialog(examNoticeInfo.value)
  64. }
  65. }
  66. function handleClick(data) {
  67. activeKs.value = data;
  68. if (data.status == 0) {
  69. // 未开始
  70. // goKaoshiPage(data);
  71. showKaoshiXuzhi()
  72. }
  73. if (data.status == 1) {
  74. // 可以考试
  75. // goKaoshiPage(data);
  76. showKaoshiXuzhi()
  77. }
  78. if (data.status == 2) {
  79. // 再次考试
  80. // goKaoshiPage(data);
  81. showKaoshiXuzhi()
  82. }
  83. if (data.status == 3) {
  84. // 考试中
  85. // goKaoshiPage(data);
  86. showKaoshiXuzhi()
  87. }
  88. if (data.status == 4) {
  89. // 已结束
  90. uni.showToast({
  91. title: '考试已结束',
  92. icon: 'none'
  93. })
  94. }
  95. if (data.status == 5) {
  96. // 未报名
  97. kaoShiApply({
  98. ksId: data.ksId
  99. }).then(res => {
  100. uni.showToast({
  101. title: '报名成功',
  102. icon: 'none'
  103. })
  104. scrollRef.value.onRefresh()
  105. })
  106. }
  107. }
  108. </script>
  109. <style lang="scss">
  110. </style>