list.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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" @scrolltolower="onScrolltolower"
  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 onScrolltolower() {
  94. getMore()
  95. }
  96. function goUpPage() {
  97. const pages = getCurrentPages();
  98. if (pages.length > 1) {
  99. uni.navigateBack()
  100. } else {
  101. // uni.redirectTo({
  102. // url: '/pages/client/ShouYe/shouye'
  103. // })
  104. history.back();
  105. }
  106. }
  107. // 修改身份
  108. function handleChangeIdentification() {
  109. uni.navigateTo({
  110. url: '/pages/client/my/myInfo?from=kaoshiList'
  111. })
  112. }
  113. function handleConfirmIdent(data) {
  114. saveIdentCache(activeks.value.ksId, true);
  115. ksxzRef.value.showDialog(activeks.value)
  116. }
  117. function handleConfirmKs(data) {
  118. checkKaoshi(data)
  119. }
  120. function checkKsXz(data) {
  121. activeks.value = data;
  122. if (data.status == 3) {
  123. // 考试中 直接进入考试
  124. checkKaoshi(data)
  125. return;
  126. }
  127. const result = getIdentCache(data.ksId);
  128. if (result) {
  129. ksxzRef.value.showDialog(data)
  130. } else {
  131. kaoshiApi.getClientUserInfo({
  132. ksId: data.ksId
  133. }).then(res => {
  134. shenfenRef.value.showDialog(res.data);
  135. })
  136. }
  137. }
  138. function handleSearch() {
  139. data.page = 0;
  140. refreshData();
  141. }
  142. function checkKaoshi(item) {
  143. // #ifdef H5
  144. history.replaceState({
  145. ...history.state,
  146. newKey: 'newValue'
  147. }, '', window.location.href);
  148. // #endif
  149. uni.navigateTo({
  150. url: `/pages/client/Kaoshi/exam?ksId=${item.ksId}&zhuapai=${activeks.value.zhuapai}&userKaozhengId=${activeks.value.userKaozhengId}&from=kaoshiList`
  151. })
  152. }
  153. function onRefresh() {
  154. data.page = 0;
  155. data.list = [];
  156. data.loading = true;
  157. refreshData();
  158. }
  159. function refreshData() {
  160. const opt = {
  161. page: 1,
  162. size: data.size, // 固定查询10条
  163. zyName: data.zyName
  164. }
  165. data.list = [];
  166. // 数学
  167. data.state = 'loading';
  168. data.page++;
  169. opt.page = data.page;
  170. kaoshiApi.getClientKaoshiList(opt).then(res => {
  171. data.list = data.list.concat(res.data.data);
  172. data.loading = false;
  173. if (res.data.total > data.list.length) {
  174. data.state = 'more';
  175. data.loading = false;
  176. } else {
  177. data.state = 'no-more';
  178. data.loading = false;
  179. }
  180. }).catch(err => {
  181. data.state = 'more';
  182. data.loading = false;
  183. })
  184. }
  185. function getMore() {
  186. const opt = {
  187. page: 1,
  188. size: data.size, // 固定查询10条
  189. zyName: data.zyName
  190. }
  191. if (data.state == 'no-more') return;
  192. data.state = 'loading';
  193. data.page++;
  194. opt.page = data.page;
  195. kaoshiApi.getClientKaoshiList(opt).then(res => {
  196. data.list = data.list.concat(res.data.data);
  197. data.loading = false;
  198. if (res.data.total > data.list.length) {
  199. data.state = 'more';
  200. data.loading = false;
  201. } else {
  202. data.state = 'no-more';
  203. data.loading = false;
  204. }
  205. }).catch(err => {
  206. data.state = 'more';
  207. data.loading = false;
  208. })
  209. }
  210. onLoad((options) => {
  211. data.from = options.from
  212. })
  213. onShow(() => {
  214. getMore()
  215. })
  216. </script>