index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 ksxzRef = ref(null);
  29. const tabData = [{
  30. label: "可以考试",
  31. value: 1,
  32. },
  33. {
  34. label: "已结束",
  35. value: 4,
  36. }
  37. ]
  38. function goKaoshiPage(data) {
  39. uni.redirectTo({
  40. url: `/pages/exam/exam?ksId=${data.ksId}&zhuapai=${data.zhuapai}`
  41. })
  42. }
  43. function handleConfirm() {
  44. goKaoshiPage(activeKs.value)
  45. }
  46. function showKaoshiXuzhi() {
  47. const option = {
  48. ksId: activeKs.value.ksId
  49. }
  50. getClientKaoshiInfo(option).then(res => {
  51. examNoticeInfo.value = res.data;
  52. // 校验抓拍
  53. doCheckZhuapai()
  54. })
  55. }
  56. function doCheckZhuapai() {
  57. if (examNoticeInfo.value.zhuapai) {
  58. // 存在抓拍
  59. } else {
  60. // 不存在抓拍
  61. ksxzRef.value.showDialog(examNoticeInfo.value)
  62. }
  63. }
  64. function handleClick(data) {
  65. activeKs.value = data;
  66. if (data.status == 0) {
  67. // 未开始
  68. // goKaoshiPage(data);
  69. showKaoshiXuzhi()
  70. }
  71. if (data.status == 1) {
  72. // 可以考试
  73. // goKaoshiPage(data);
  74. showKaoshiXuzhi()
  75. }
  76. if (data.status == 2) {
  77. // 再次考试
  78. // goKaoshiPage(data);
  79. showKaoshiXuzhi()
  80. }
  81. if (data.status == 3) {
  82. // 考试中
  83. // goKaoshiPage(data);
  84. showKaoshiXuzhi()
  85. }
  86. if (data.status == 4) {
  87. // 已结束
  88. uni.showToast({
  89. title: '考试已结束',
  90. icon: 'none'
  91. })
  92. }
  93. if (data.status == 5) {
  94. // 未报名
  95. kaoShiApply({
  96. ksId: data.ksId
  97. }).then(res => {
  98. uni.showToast({
  99. title: '报名成功',
  100. icon: 'none'
  101. })
  102. scrollRef.value.onRefresh()
  103. })
  104. }
  105. }
  106. </script>
  107. <style lang="scss">
  108. </style>