list.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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. :style="{ height: `calc(100vh - ${statusBarHeight}px - 212rpx);`}" class="phone-scroll-overflow">
  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 {ref,reactive,onMounted} from "vue";
  60. import {
  61. onLoad,
  62. onShow
  63. } from "@dcloudio/uni-app";
  64. import * as kaoshiApi from "@/api/kaoshi.js";
  65. const statusBarHeight = ref(0);
  66. const {
  67. saveIdentCache,
  68. getIdentCache,
  69. removeIdentCache
  70. } = useIdentificationTools();
  71. const ksxzRef = ref(null);
  72. const shenfenRef = ref(null);
  73. const activeks = ref(null);
  74. const data = reactive({
  75. zyName: '', // 职业名称
  76. list: [], // 考试列表
  77. loading: false,
  78. page: 0,
  79. size: 8,
  80. state: 'more',
  81. contentText: {
  82. contentdown: '查看更多',
  83. contentrefresh: '加载中',
  84. contentnomore: '没有更多'
  85. },
  86. from: '',
  87. imgsArr: {
  88. phoneZongfenIcon: '',
  89. phoneJigefenIcon: '',
  90. phoneCiShuIicon: '',
  91. phoneTimeIcon: '',
  92. },
  93. })
  94. function onScrolltolower() {
  95. getMore()
  96. }
  97. function goUpPage() {
  98. const pages = getCurrentPages();
  99. if (pages.length > 1) {
  100. uni.navigateBack()
  101. } else {
  102. // uni.redirectTo({
  103. // url: '/pages/client/ShouYe/shouye'
  104. // })
  105. history.back();
  106. }
  107. }
  108. // 修改身份
  109. function handleChangeIdentification() {
  110. uni.navigateTo({
  111. url: '/pages/client/my/myInfo?from=kaoshiList'
  112. })
  113. }
  114. function handleConfirmIdent(data) {
  115. saveIdentCache(activeks.value.ksId, true);
  116. ksxzRef.value.showDialog(activeks.value)
  117. }
  118. function handleConfirmKs(data) {
  119. checkKaoshi(data)
  120. }
  121. function checkKsXz(data) {
  122. activeks.value = data;
  123. if (data.status == 3) {
  124. // 考试中 直接进入考试
  125. checkKaoshi(data)
  126. return;
  127. }
  128. const result = getIdentCache(data.ksId);
  129. if (result) {
  130. ksxzRef.value.showDialog(data)
  131. } else {
  132. kaoshiApi.getClientUserInfo({
  133. ksId: data.ksId
  134. }).then(res => {
  135. shenfenRef.value.showDialog(res.data);
  136. })
  137. }
  138. }
  139. function handleSearch() {
  140. data.page = 0;
  141. refreshData();
  142. }
  143. function checkKaoshi(item) {
  144. // #ifdef H5
  145. /* history.replaceState({
  146. ...history.state,
  147. newKey: 'newValue'
  148. }, '', window.location.href); */
  149. // #endif
  150. // 判断是否有抓拍,有抓拍需要跳转到验证页面
  151. if (activeks.value.zhuapai) {
  152. uni.navigateTo({
  153. url: `/pages/client/Kaoshi/examCamera?ksId=${item.ksId}&zhuapai=${activeks.value.zhuapai}&userKaozhengId=${activeks.value.userKaozhengId}&from=kaoshiList`
  154. })
  155. } else {
  156. uni.navigateTo({
  157. url: `/pages/client/Kaoshi/exam?ksId=${item.ksId}&zhuapai=${activeks.value.zhuapai}&userKaozhengId=${activeks.value.userKaozhengId}&from=kaoshiList`
  158. })
  159. }
  160. }
  161. function onRefresh() {
  162. data.page = 0;
  163. data.list = [];
  164. data.loading = true;
  165. refreshData();
  166. }
  167. function refreshData() {
  168. const opt = {
  169. page: 1,
  170. size: data.size, // 固定查询10条
  171. zyName: data.zyName
  172. }
  173. data.list = [];
  174. // 数学
  175. data.state = 'loading';
  176. data.page++;
  177. opt.page = data.page;
  178. kaoshiApi.getClientKaoshiList(opt).then(res => {
  179. data.list = data.list.concat(res.data.data);
  180. data.loading = false;
  181. if (res.data.total > data.list.length) {
  182. data.state = 'more';
  183. data.loading = false;
  184. } else {
  185. data.state = 'no-more';
  186. data.loading = false;
  187. }
  188. }).catch(err => {
  189. data.state = 'more';
  190. data.loading = false;
  191. })
  192. }
  193. function getMore() {
  194. const opt = {
  195. page: 1,
  196. size: data.size, // 固定查询10条
  197. zyName: data.zyName
  198. }
  199. if (data.state == 'no-more') return;
  200. data.state = 'loading';
  201. data.page++;
  202. opt.page = data.page;
  203. kaoshiApi.getClientKaoshiList(opt).then(res => {
  204. data.list = data.list.concat(res.data.data);
  205. data.loading = false;
  206. if (res.data.total > data.list.length) {
  207. data.state = 'more';
  208. data.loading = false;
  209. } else {
  210. data.state = 'no-more';
  211. data.loading = false;
  212. }
  213. }).catch(err => {
  214. data.state = 'more';
  215. data.loading = false;
  216. })
  217. }
  218. onMounted(() => {
  219. uni.getSystemInfo({
  220. success: (res) => {
  221. statusBarHeight.value = res.statusBarHeight;
  222. }
  223. });
  224. });
  225. onLoad((options) => {
  226. data.from = options.from;
  227. data.imgsArr.phoneZongfenIcon = cacheManager.get('projectImg').zongfen_icon;
  228. data.imgsArr.phoneJigefenIcon = cacheManager.get('projectImg').jigefen_icon;
  229. data.imgsArr.phoneCiShuIicon = cacheManager.get('projectImg').cishu_icon;
  230. data.imgsArr.phoneTimeIcon = cacheManager.get('projectImg').time_icon;
  231. })
  232. onShow(() => {
  233. getMore()
  234. })
  235. </script>