list.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <view class="phone-list-page">
  3. <customNavbarVue title="练习管理" :show-back-btn="true" @back="goUpPage"></customNavbarVue>
  4. <!-- 考试列表 -->
  5. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
  6. :refresher-threshold="50" refresher-background="transparent" @refresherrefresh="onRefresh" @scrolltolower="onScrolltolower"
  7. class="phone-scroll-view">
  8. <uni-list class="admin-list-box">
  9. <uni-list-item v-for="item in data.list" class="admin-list-item-box">
  10. <template v-slot:body style="width: 100%;">
  11. <!-- 考试项 -->
  12. <view class="item-card-row">
  13. <!-- 考试名 + 等级 -->
  14. <view class="ks-item-top">
  15. <view class="ks-name">{{item.zyName}}</view>
  16. <view class="ks-zyLevelName">{{item.zyLevelName}}</view>
  17. </view>
  18. <!-- 时间 -->
  19. <!-- <view class="ks-totalTm">
  20. <icon class="phone-time-icon" />时间:{{item.totalTm}}分钟
  21. </view> -->
  22. <!-- 分数 -->
  23. <view class="ks-score-content">
  24. <view class="ks-score">
  25. <icon class="phone-zongfen-icon" />总分:<text>{{item.ksScore}}</text>
  26. </view>
  27. <view class="ks-okScore">
  28. <icon class="phone-jigefen-icon" />及格分:<text>{{item.okScore}}</text>
  29. </view>
  30. </view>
  31. <button type="primary" size="mini" @click="checkKsXz(item)"
  32. class="item-view-btn">进行练习</button>
  33. </view>
  34. </template>
  35. </uni-list-item>
  36. <uni-load-more :status="data.state" @click="getMore(0)" :contentText="data.contentText"></uni-load-more>
  37. </uni-list>
  38. </scroll-view>
  39. <!-- 页面底端 -->
  40. <customTabbarClientVue></customTabbarClientVue>
  41. <!-- 考试须知 -->
  42. <lianxixuzhi ref="lxxzRef" @confirm="handleConfirmKs"></lianxixuzhi>
  43. </view>
  44. </template>
  45. <script setup>
  46. import customNavbarVue from "@/components/custom-navbar/custom-navbar.vue";
  47. import * as lianxiApi from "@/api/lianxi.js";
  48. import customTabbarClientVue from "@/components/custom-tabbar/custom-tabbar-client.vue";
  49. import lianxixuzhi from "@/components/kaoshixuzhi/lianxixuzhi.vue";
  50. import {
  51. ref,
  52. reactive
  53. } from "vue";
  54. import {
  55. onLoad,
  56. onShow
  57. } from "@dcloudio/uni-app";
  58. const lxxzRef = ref(null);
  59. const data = reactive({
  60. zyName: '', // 职业名称
  61. list: [], // 考试列表
  62. loading: false,
  63. page: 0,
  64. size: 8,
  65. state: 'more',
  66. contentText: {
  67. contentdown: '查看更多',
  68. contentrefresh: '加载中',
  69. contentnomore: '没有更多'
  70. },
  71. from: ''
  72. })
  73. function onScrolltolower() {
  74. getMore()
  75. }
  76. function checkKsXz(data) {
  77. lxxzRef.value.showDialog(data)
  78. }
  79. function handleConfirmKs(data) {
  80. checkKaoshi(data)
  81. }
  82. function goUpPage() {
  83. const pages = getCurrentPages();
  84. if (pages.length > 1) {
  85. uni.navigateBack()
  86. } else {
  87. /* uni.redirectTo({
  88. url: '/pages/client/ShouYe/shouye'
  89. }) */
  90. history.back();
  91. }
  92. }
  93. function handleSearch() {
  94. data.page = 0;
  95. refreshData();
  96. }
  97. function checkKaoshi(item) {
  98. uni.navigateTo({
  99. url: `/pages/client/Lianxi/exam?lxId=${item.lxId}&from=lianxiList`
  100. })
  101. }
  102. function onRefresh() {
  103. data.page = 0;
  104. data.list = [];
  105. data.loading = true;
  106. refreshData();
  107. }
  108. function refreshData() {
  109. const opt = {
  110. page: 1,
  111. size: data.size, // 固定查询10条
  112. zyName: data.zyName
  113. }
  114. data.list = [];
  115. // 数学
  116. data.state = 'loading';
  117. data.page++;
  118. opt.page = data.page;
  119. lianxiApi.getClientLianxiList(opt).then(res => {
  120. data.list = data.list.concat(res.data.data);
  121. data.loading = false;
  122. if (res.data.total > data.list.length) {
  123. data.state = 'more';
  124. data.loading = false;
  125. } else {
  126. data.state = 'no-more';
  127. data.loading = false;
  128. }
  129. }).catch(err => {
  130. data.state = 'more';
  131. data.loading = false;
  132. })
  133. }
  134. function getMore() {
  135. const opt = {
  136. page: 1,
  137. size: data.size, // 固定查询10条
  138. zyName: data.zyName
  139. }
  140. if (data.state == 'no-more') return;
  141. data.state = 'loading';
  142. data.page++;
  143. opt.page = data.page;
  144. lianxiApi.getClientLianxiList(opt).then(res => {
  145. data.list = data.list.concat(res.data.data);
  146. data.loading = false;
  147. if (res.data.total > data.list.length) {
  148. data.state = 'more';
  149. data.loading = false;
  150. } else {
  151. data.state = 'no-more';
  152. data.loading = false;
  153. }
  154. }).catch(err => {
  155. data.state = 'more';
  156. data.loading = false;
  157. })
  158. }
  159. onLoad((options) => {
  160. data.from = options.from;
  161. })
  162. onShow(() => {
  163. getMore()
  164. })
  165. </script>
  166. <style>
  167. </style>