list.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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.ksName}}</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}}次</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
  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. if ( data.from == 'shouye') {
  78. uni.redirectTo({
  79. url: '/pages/client/ShouYe/shouye'
  80. })
  81. } else if (data.from = 'my'){
  82. uni.redirectTo({
  83. url: '/pages/client/my/index'
  84. })
  85. } else {
  86. uni.redirectTo({
  87. url: '/pages/client/ShouYe/shouye'
  88. })
  89. }
  90. }
  91. // 修改身份
  92. function handleChangeIdentification() {
  93. uni.redirectTo({
  94. url:'/pages/client/my/info?from=kaoshiList'
  95. })
  96. }
  97. function handleConfirmIdent(data) {
  98. saveIdentCache(activeks.value.ksId, true);
  99. ksxzRef.value.showDialog(activeks.value)
  100. }
  101. function handleConfirmKs(data) {
  102. checkKaoshi(data)
  103. }
  104. function checkKsXz(data) {
  105. activeks.value = data;
  106. if (data.status == 3) {
  107. // 考试中 直接进入考试
  108. checkKaoshi(data)
  109. return;
  110. }
  111. const result = getIdentCache(data.ksId);
  112. if (result) {
  113. ksxzRef.value.showDialog(data)
  114. } else {
  115. kaoshiApi.getClientUserInfo({ksId: data.ksId}).then(res => {
  116. shenfenRef.value.showDialog(res.data);
  117. })
  118. }
  119. }
  120. function handleSearch() {
  121. data.page = 0;
  122. refreshData();
  123. }
  124. function checkKaoshi(item) {
  125. uni.navigateTo({
  126. url: `/pages/client/Kaoshi/exam?ksId=${item.ksId}&zhuapai=${activeks.value.zhuapai}&from=kaoshiList`
  127. })
  128. }
  129. function onRefresh() {
  130. data.page = 0;
  131. data.list = [];
  132. data.loading = true;
  133. refreshData();
  134. }
  135. function refreshData() {
  136. const opt = {
  137. page: 1,
  138. size: data.size, // 固定查询10条
  139. zyName: data.zyName
  140. }
  141. data.list = [];
  142. // 数学
  143. data.state = 'loading';
  144. data.page++;
  145. opt.page = data.page;
  146. kaoshiApi.getClientKaoshiList(opt).then(res => {
  147. data.list = data.list.concat(res.data.data);
  148. data.loading = false;
  149. if (res.data.total > data.list.length) {
  150. data.state = 'more';
  151. data.loading = false;
  152. } else {
  153. data.state = 'no-more';
  154. data.loading = false;
  155. }
  156. }).catch(err => {
  157. data.state = 'more';
  158. data.loading = false;
  159. })
  160. }
  161. function getMore() {
  162. const opt = {
  163. page: 1,
  164. size: data.size, // 固定查询10条
  165. zyName: data.zyName
  166. }
  167. if (data.state == 'no-more') return;
  168. data.state = 'loading';
  169. data.page++;
  170. opt.page = data.page;
  171. kaoshiApi.getClientKaoshiList(opt).then(res => {
  172. data.list = data.list.concat(res.data.data);
  173. data.loading = false;
  174. if (res.data.total > data.list.length) {
  175. data.state = 'more';
  176. data.loading = false;
  177. } else {
  178. data.state = 'no-more';
  179. data.loading = false;
  180. }
  181. }).catch(err => {
  182. data.state = 'more';
  183. data.loading = false;
  184. })
  185. }
  186. onLoad((options) => {
  187. data.from = options.from
  188. getMore()
  189. })
  190. </script>