list.vue 4.4 KB

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