list.vue 5.9 KB

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