list.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <view class="phone-list-page">
  3. <customNavbarVue title="考试管理" :show-back-btn="true" @back="goUpPage"></customNavbarVue>
  4. <!-- 考试列表 -->
  5. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
  6. :refresher-threshold="50" refresher-background="transparent" @refresherrefresh="onRefresh" @scrolltolower="onScrolltolower"
  7. class="phone-scroll-view">
  8. <uni-list class="admin-list-box">
  9. <uni-list-item v-for="item in data.list" class="admin-list-item-box" :key="item.ksId">
  10. <template v-slot:body style="width: 100%;">
  11. <!-- 考试项 -->
  12. <view class="item-card-row">
  13. <!-- 考试名 + 等级 -->
  14. <view class="ks-item-top">
  15. <view class="ks-name">{{item.zyName}}</view>
  16. <view class="ks-zyLevelName">{{item.zyLevelName}}</view>
  17. </view>
  18. <!-- 时间 -->
  19. <view class="ks-totalTm">
  20. <icon class="phone-time-icon" :style="{ backgroundImage: 'url(' + data.imgsArr.phoneTimeIcon + ')' }"/>时间:{{item.totalTm}}分钟
  21. </view>
  22. <view class="ks-totalTm">
  23. <icon class="phone-cishu-icon" :style="{ backgroundImage: 'url(' + data.imgsArr.phoneCiShuIicon + ')' }"/>次数:{{item.maxTimes ? item.loseTimes:'不限'}}次
  24. </view>
  25. <!-- 分数 -->
  26. <view class="ks-score-content">
  27. <view class="ks-score">
  28. <icon class="phone-zongfen-icon" :style="{ backgroundImage: 'url(' + data.imgsArr.phoneZongfenIcon + ')' }"/>总分:<text>{{item.ksScore}}</text>
  29. </view>
  30. <view class="ks-okScore">
  31. <icon class="phone-jigefen-icon" :style="{ backgroundImage: 'url(' + data.imgsArr.phoneJigefenIcon + ')' }"/>及格分:<text>{{item.okScore}}</text>
  32. </view>
  33. </view>
  34. <button type="primary" size="mini" @click="checkKsXz(item)" v-if="item.status == 1" class="item-view-btn">进行考试</button>
  35. <button type="primary" size="mini" @click="checkKsXz(item)" v-if="item.status == 2" class="item-view-btn">进行考试</button>
  36. <button type="primary" size="mini" @click="checkKsXz(item)" v-if="item.status == 3" class="item-view-btn">考试中</button>
  37. </view>
  38. </template>
  39. </uni-list-item>
  40. <uni-load-more :status="data.state" @click="getMore(0)" :contentText="data.contentText"></uni-load-more>
  41. </uni-list>
  42. </scroll-view>
  43. <!-- 页面底端 -->
  44. <customTabbarClientVue></customTabbarClientVue>
  45. <!-- 考试须知 -->
  46. <kaoshixuzhiVue ref="ksxzRef" @confirm="handleConfirmKs" key="1"></kaoshixuzhiVue>
  47. <!-- 身份确认 -->
  48. <identificationVue ref="shenfenRef" @confirm="handleConfirmIdent" @changeData="handleChangeIdentification"
  49. key="2"></identificationVue>
  50. </view>
  51. </template>
  52. <script setup>
  53. import cacheManager from '@/utils/cacheManager.js';
  54. import customNavbarVue from "@/components/custom-navbar/custom-navbar.vue";
  55. import customTabbarClientVue from "@/components/custom-tabbar/custom-tabbar-client.vue";
  56. import kaoshixuzhiVue from "@/components/kaoshixuzhi/kaoshixuzhi.vue";
  57. import identificationVue from "@/components/identification/identification.vue";
  58. import {useIdentificationTools} from "@/utils/examTools.js"
  59. import {
  60. ref,
  61. reactive
  62. } from "vue";
  63. import {
  64. onLoad,
  65. onShow
  66. } from "@dcloudio/uni-app";
  67. import * as kaoshiApi from "@/api/kaoshi.js";
  68. const {
  69. saveIdentCache,
  70. getIdentCache,
  71. removeIdentCache
  72. } = useIdentificationTools();
  73. const ksxzRef = ref(null);
  74. const shenfenRef = ref(null);
  75. const activeks = ref(null);
  76. const data = reactive({
  77. zyName: '', // 职业名称
  78. list: [], // 考试列表
  79. loading: false,
  80. page: 0,
  81. size: 8,
  82. state: 'more',
  83. contentText: {
  84. contentdown: '查看更多',
  85. contentrefresh: '加载中',
  86. contentnomore: '没有更多'
  87. },
  88. from: '',
  89. imgsArr: {
  90. phoneZongfenIcon: '',
  91. phoneJigefenIcon: '',
  92. phoneCiShuIicon: '',
  93. phoneTimeIcon: '',
  94. },
  95. })
  96. function onScrolltolower() {
  97. getMore()
  98. }
  99. function goUpPage() {
  100. const pages = getCurrentPages();
  101. if (pages.length > 1) {
  102. uni.navigateBack()
  103. } else {
  104. // uni.redirectTo({
  105. // url: '/pages/client/ShouYe/shouye'
  106. // })
  107. history.back();
  108. }
  109. }
  110. // 修改身份
  111. function handleChangeIdentification() {
  112. uni.navigateTo({
  113. url: '/pages/client/my/myInfo?from=kaoshiList'
  114. })
  115. }
  116. function handleConfirmIdent(data) {
  117. saveIdentCache(activeks.value.ksId, true);
  118. ksxzRef.value.showDialog(activeks.value)
  119. }
  120. function handleConfirmKs(data) {
  121. checkKaoshi(data)
  122. }
  123. function checkKsXz(data) {
  124. activeks.value = data;
  125. if (data.status == 3) {
  126. // 考试中 直接进入考试
  127. checkKaoshi(data)
  128. return;
  129. }
  130. const result = getIdentCache(data.ksId);
  131. if (result) {
  132. ksxzRef.value.showDialog(data)
  133. } else {
  134. kaoshiApi.getClientUserInfo({
  135. ksId: data.ksId
  136. }).then(res => {
  137. shenfenRef.value.showDialog(res.data);
  138. })
  139. }
  140. }
  141. function handleSearch() {
  142. data.page = 0;
  143. refreshData();
  144. }
  145. function checkKaoshi(item) {
  146. // #ifdef H5
  147. /* history.replaceState({
  148. ...history.state,
  149. newKey: 'newValue'
  150. }, '', window.location.href); */
  151. // #endif
  152. // 判断是否有抓拍,有抓拍需要跳转到验证页面
  153. if (activeks.value.zhuapai) {
  154. uni.navigateTo({
  155. url: `/pages/client/Kaoshi/examCamera?ksId=${item.ksId}&zhuapai=${activeks.value.zhuapai}&userKaozhengId=${activeks.value.userKaozhengId}&from=kaoshiList`
  156. })
  157. } else {
  158. uni.navigateTo({
  159. url: `/pages/client/Kaoshi/exam?ksId=${item.ksId}&zhuapai=${activeks.value.zhuapai}&userKaozhengId=${activeks.value.userKaozhengId}&from=kaoshiList`
  160. })
  161. }
  162. }
  163. function onRefresh() {
  164. data.page = 0;
  165. data.list = [];
  166. data.loading = true;
  167. refreshData();
  168. }
  169. function refreshData() {
  170. const opt = {
  171. page: 1,
  172. size: data.size, // 固定查询10条
  173. zyName: data.zyName
  174. }
  175. data.list = [];
  176. // 数学
  177. data.state = 'loading';
  178. data.page++;
  179. opt.page = data.page;
  180. kaoshiApi.getClientKaoshiList(opt).then(res => {
  181. data.list = data.list.concat(res.data.data);
  182. data.loading = false;
  183. if (res.data.total > data.list.length) {
  184. data.state = 'more';
  185. data.loading = false;
  186. } else {
  187. data.state = 'no-more';
  188. data.loading = false;
  189. }
  190. }).catch(err => {
  191. data.state = 'more';
  192. data.loading = false;
  193. })
  194. }
  195. function getMore() {
  196. const opt = {
  197. page: 1,
  198. size: data.size, // 固定查询10条
  199. zyName: data.zyName
  200. }
  201. if (data.state == 'no-more') return;
  202. data.state = 'loading';
  203. data.page++;
  204. opt.page = data.page;
  205. kaoshiApi.getClientKaoshiList(opt).then(res => {
  206. data.list = data.list.concat(res.data.data);
  207. data.loading = false;
  208. if (res.data.total > data.list.length) {
  209. data.state = 'more';
  210. data.loading = false;
  211. } else {
  212. data.state = 'no-more';
  213. data.loading = false;
  214. }
  215. }).catch(err => {
  216. data.state = 'more';
  217. data.loading = false;
  218. })
  219. }
  220. onLoad((options) => {
  221. data.from = options.from;
  222. data.imgsArr.phoneZongfenIcon = cacheManager.get('projectImg').zongfen_icon;
  223. data.imgsArr.phoneJigefenIcon = cacheManager.get('projectImg').jigefen_icon;
  224. data.imgsArr.phoneCiShuIicon = cacheManager.get('projectImg').cishu_icon;
  225. data.imgsArr.phoneTimeIcon = cacheManager.get('projectImg').time_icon;
  226. })
  227. onShow(() => {
  228. getMore()
  229. })
  230. </script>