list.vue 6.0 KB

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