list.vue 5.4 KB

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