list.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. :style="{ height: `calc(100vh - ${statusBarHeight}px - 212rpx);`}" class="phone-scroll-overflow">
  8. <uni-list class="admin-list-box">
  9. <uni-list-item v-for="item in data.list" class="admin-list-item-box" :key="item.lxId">
  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" :style="{ backgroundImage: 'url(' + data.imgsArr.phoneZongfenIcon + ')' }"/>
  26. 总分:<text>{{item.ksScore}}</text>
  27. </view>
  28. <view class="ks-okScore">
  29. <icon class="phone-jigefen-icon" :style="{ backgroundImage: 'url(' + data.imgsArr.phoneJigefenIcon + ')' }"/>
  30. 及格分:<text>{{item.okScore}}</text>
  31. </view>
  32. </view>
  33. <button type="primary" size="mini" @click="checkKsXz(item)"
  34. class="item-view-btn">进行练习</button>
  35. </view>
  36. </template>
  37. </uni-list-item>
  38. <uni-load-more :status="data.state" @click="getMore(0)" :contentText="data.contentText"></uni-load-more>
  39. </uni-list>
  40. </scroll-view>
  41. <!-- 页面底端 -->
  42. <customTabbarClientVue></customTabbarClientVue>
  43. <!-- 考试须知 -->
  44. <lianxixuzhi ref="lxxzRef" @confirm="handleConfirmKs"></lianxixuzhi>
  45. </view>
  46. </template>
  47. <script setup>
  48. import cacheManager from '@/utils/cacheManager.js';
  49. import customNavbarVue from "@/components/custom-navbar/custom-navbar.vue";
  50. import * as lianxiApi from "@/api/lianxi.js";
  51. import customTabbarClientVue from "@/components/custom-tabbar/custom-tabbar-client.vue";
  52. import lianxixuzhi from "@/components/kaoshixuzhi/lianxixuzhi.vue";
  53. import {ref,onMounted,reactive} from "vue";
  54. import {
  55. onLoad,
  56. onShow
  57. } from "@dcloudio/uni-app";
  58. const lxxzRef = ref(null);
  59. const statusBarHeight = ref(0);
  60. const data = reactive({
  61. zyName: '', // 职业名称
  62. list: [], // 考试列表
  63. loading: false,
  64. page: 0,
  65. size: 8,
  66. state: 'more',
  67. contentText: {
  68. contentdown: '查看更多',
  69. contentrefresh: '加载中',
  70. contentnomore: '没有更多'
  71. },
  72. from: '',
  73. imgsArr: {
  74. phoneZongfenIcon: '',
  75. phoneJigefenIcon: '',
  76. },
  77. })
  78. function onScrolltolower() {
  79. getMore()
  80. }
  81. function checkKsXz(data) {
  82. lxxzRef.value.showDialog(data)
  83. }
  84. function handleConfirmKs(data) {
  85. checkKaoshi(data)
  86. }
  87. function goUpPage() {
  88. const pages = getCurrentPages();
  89. if (pages.length > 1) {
  90. uni.navigateBack()
  91. } else {
  92. /* uni.redirectTo({
  93. url: '/pages/client/ShouYe/shouye'
  94. }) */
  95. history.back();
  96. }
  97. }
  98. function handleSearch() {
  99. data.page = 0;
  100. refreshData();
  101. }
  102. function checkKaoshi(item) {
  103. uni.navigateTo({
  104. url: `/pages/client/Lianxi/exam?lxId=${item.lxId}&from=lianxiList`
  105. })
  106. }
  107. function onRefresh() {
  108. data.page = 0;
  109. data.list = [];
  110. data.loading = true;
  111. refreshData();
  112. }
  113. function refreshData() {
  114. const opt = {
  115. page: 1,
  116. size: data.size, // 固定查询10条
  117. zyName: data.zyName
  118. }
  119. data.list = [];
  120. // 数学
  121. data.state = 'loading';
  122. data.page++;
  123. opt.page = data.page;
  124. lianxiApi.getClientLianxiList(opt).then(res => {
  125. data.list = data.list.concat(res.data.data);
  126. data.loading = false;
  127. if (res.data.total > data.list.length) {
  128. data.state = 'more';
  129. data.loading = false;
  130. } else {
  131. data.state = 'no-more';
  132. data.loading = false;
  133. }
  134. }).catch(err => {
  135. data.state = 'more';
  136. data.loading = false;
  137. })
  138. }
  139. function getMore() {
  140. const opt = {
  141. page: 1,
  142. size: data.size, // 固定查询10条
  143. zyName: data.zyName
  144. }
  145. if (data.state == 'no-more') return;
  146. data.state = 'loading';
  147. data.page++;
  148. opt.page = data.page;
  149. lianxiApi.getClientLianxiList(opt).then(res => {
  150. data.list = data.list.concat(res.data.data);
  151. data.loading = false;
  152. if (res.data.total > data.list.length) {
  153. data.state = 'more';
  154. data.loading = false;
  155. } else {
  156. data.state = 'no-more';
  157. data.loading = false;
  158. }
  159. }).catch(err => {
  160. data.state = 'more';
  161. data.loading = false;
  162. })
  163. }
  164. onLoad((options) => {
  165. data.from = options.from;
  166. data.imgsArr.phoneZongfenIcon = cacheManager.get('projectImg').zongfen_icon;
  167. data.imgsArr.phoneJigefenIcon = cacheManager.get('projectImg').jigefen_icon;
  168. console.log(data,'data');
  169. })
  170. onMounted(() => {
  171. uni.getSystemInfo({
  172. success: (res) => {
  173. statusBarHeight.value = res.statusBarHeight;
  174. }
  175. });
  176. });
  177. onShow(() => {
  178. getMore()
  179. })
  180. </script>
  181. <style>
  182. </style>