list.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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 client-kaoshi-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.maxTimes:'不限'}}次
  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)"
  38. class="item-view-btn">查看内容</button>
  39. </view>
  40. </template>
  41. </uni-list-item>
  42. <uni-load-more :status="data.state" @click="getMore(0)" :contentText="data.contentText"></uni-load-more>
  43. </uni-list>
  44. </scroll-view>
  45. <!-- 页面底端 -->
  46. <customTabbarClientVue></customTabbarClientVue>
  47. <!-- 考试须知 -->
  48. <kaoshixuzhiVue ref="ksxzRef" @confirm="handleConfirmKs" key="1"></kaoshixuzhiVue>
  49. <!-- 身份确认 -->
  50. <identificationVue ref="shenfenRef" @confirm="handleConfirmIdent" @changeData="handleChangeIdentification"
  51. key="2"></identificationVue>
  52. </view>
  53. </template>
  54. <script setup>
  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 {
  59. useIdentificationTools
  60. } from "./examTools.js"
  61. import {
  62. ref,
  63. reactive
  64. } from "vue";
  65. import {
  66. onLoad,
  67. onShow
  68. } from "@dcloudio/uni-app";
  69. import * as kaoshiApi from "@/api/kaoshi.js";
  70. const {
  71. saveIdentCache,
  72. getIdentCache,
  73. removeIdentCache
  74. } = useIdentificationTools();
  75. const ksxzRef = ref(null);
  76. const shenfenRef = ref(null);
  77. const activeks = ref(null);
  78. const data = reactive({
  79. zyName: '', // 职业名称
  80. list: [], // 考试列表
  81. loading: false,
  82. page: 0,
  83. size: 8,
  84. state: 'more',
  85. contentText: {
  86. contentdown: '查看更多',
  87. contentrefresh: '加载中',
  88. contentnomore: '没有更多'
  89. },
  90. from: ''
  91. })
  92. function goUpPage() {
  93. const pages = getCurrentPages();
  94. if (pages.length > 1) {
  95. uni.navigateBack()
  96. } else {
  97. // uni.redirectTo({
  98. // url: '/pages/client/ShouYe/shouye'
  99. // })
  100. history.back();
  101. }
  102. }
  103. // 修改身份
  104. function handleChangeIdentification() {
  105. uni.navigateTo({
  106. url: '/pages/client/my/myInfo?from=kaoshiList'
  107. })
  108. }
  109. function handleConfirmIdent(data) {
  110. saveIdentCache(activeks.value.ksId, true);
  111. ksxzRef.value.showDialog(activeks.value)
  112. }
  113. function handleConfirmKs(data) {
  114. checkKaoshi(data)
  115. }
  116. function checkKsXz(data) {
  117. activeks.value = data;
  118. if (data.status == 3) {
  119. // 考试中 直接进入考试
  120. checkKaoshi(data)
  121. return;
  122. }
  123. const result = getIdentCache(data.ksId);
  124. if (result) {
  125. ksxzRef.value.showDialog(data)
  126. } else {
  127. kaoshiApi.getClientUserInfo({
  128. ksId: data.ksId
  129. }).then(res => {
  130. shenfenRef.value.showDialog(res.data);
  131. })
  132. }
  133. }
  134. function handleSearch() {
  135. data.page = 0;
  136. refreshData();
  137. }
  138. function checkKaoshi(item) {
  139. // #ifdef H5
  140. history.replaceState({
  141. ...history.state,
  142. newKey: 'newValue'
  143. }, '', window.location.href);
  144. // #endif
  145. uni.navigateTo({
  146. url: `/pages/client/Kaoshi/exam?ksId=${item.ksId}&zhuapai=${activeks.value.zhuapai}&from=kaoshiList`
  147. })
  148. }
  149. function onRefresh() {
  150. data.page = 0;
  151. data.list = [];
  152. data.loading = true;
  153. refreshData();
  154. }
  155. function refreshData() {
  156. const opt = {
  157. page: 1,
  158. size: data.size, // 固定查询10条
  159. zyName: data.zyName
  160. }
  161. data.list = [];
  162. // 数学
  163. data.state = 'loading';
  164. data.page++;
  165. opt.page = data.page;
  166. kaoshiApi.getClientKaoshiList(opt).then(res => {
  167. data.list = data.list.concat(res.data.data);
  168. data.loading = false;
  169. if (res.data.total > data.list.length) {
  170. data.state = 'more';
  171. data.loading = false;
  172. } else {
  173. data.state = 'no-more';
  174. data.loading = false;
  175. }
  176. }).catch(err => {
  177. data.state = 'more';
  178. data.loading = false;
  179. })
  180. }
  181. function getMore() {
  182. const opt = {
  183. page: 1,
  184. size: data.size, // 固定查询10条
  185. zyName: data.zyName
  186. }
  187. if (data.state == 'no-more') return;
  188. data.state = 'loading';
  189. data.page++;
  190. opt.page = data.page;
  191. kaoshiApi.getClientKaoshiList(opt).then(res => {
  192. data.list = data.list.concat(res.data.data);
  193. data.loading = false;
  194. if (res.data.total > data.list.length) {
  195. data.state = 'more';
  196. data.loading = false;
  197. } else {
  198. data.state = 'no-more';
  199. data.loading = false;
  200. }
  201. }).catch(err => {
  202. data.state = 'more';
  203. data.loading = false;
  204. })
  205. }
  206. onLoad((options) => {
  207. data.from = options.from
  208. })
  209. onShow(() => {
  210. getMore()
  211. })
  212. </script>