index.vue 2.3 KB

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