list.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <view class="phone-kaoshi-page">
  3. <!-- 查询职业 -->
  4. <view style="padding: 10px">
  5. <view class="phone-search-content">
  6. <input class="search-input" placeholder="请输入职业" v-model="data.zyName" />
  7. <view class="search-icon" @click="handleSearch">
  8. <uni-icons type="search" size="20"></uni-icons>
  9. </view>
  10. </view>
  11. </view>
  12. <!-- 考试列表 -->
  13. <view class="kaoshi-content-box">
  14. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
  15. :refresher-threshold="50" refresher-background="transparent" @refresherrefresh="onRefresh"
  16. class="kaoshi-scroll-view">
  17. <uni-list>
  18. <uni-list-item v-for="item in data.list" class="list-item-box">
  19. <template v-slot:body>
  20. <!-- 考试项 -->
  21. <view class="item-kaoshi-row">
  22. <!-- 考试名 + 等级 -->
  23. <view class="ks-item-top row-item">
  24. <view class="ks-name">{{item.ksName}}</view>
  25. <view class="ks-zyLevelName">{{item.zyLevelName}}</view>
  26. </view>
  27. <!-- 时间 -->
  28. <view class="ks-totalTm row-item">时间:{{item.totalTm}} 分钟</view>
  29. <view class="ks-totalTm row-item">次数:{{item.maxTimes}}次</view>
  30. <!-- 分数 -->
  31. <view class="ks-score-content row-item">
  32. <text class="ks-score">总分: {{item.ksScore}}</text>
  33. <text class="ks-okScore">及格分: {{item.okScore}}</text>
  34. </view>
  35. <button type="primary" size="mini" @click="checkKaoshi(item)" class="kaoshi-btn">查看内容</button>
  36. </view>
  37. </template>
  38. </uni-list-item>
  39. <uni-load-more :status="data.state" @click="getMore(0)"
  40. :contentText="data.contentText"></uni-load-more>
  41. </uni-list>
  42. </scroll-view>
  43. </view>
  44. <!-- 页面底端 -->
  45. <customTabbarAdminVue></customTabbarAdminVue>
  46. </view>
  47. </template>
  48. <script setup>
  49. import customTabbarAdminVue from "@/components/custom-tabbar/custom-tabbar-admin.vue";
  50. import {
  51. ref,
  52. reactive
  53. } from "vue";
  54. import {
  55. onLoad
  56. } from "@dcloudio/uni-app";
  57. import {
  58. getKaoshiList
  59. } from "@/api/kaoshi.js"
  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. })
  73. function handleSearch() {
  74. data.page = 0;
  75. refreshData();
  76. }
  77. function checkKaoshi(item) {
  78. uni.navigateTo({
  79. url: `/pages/admin/Kaoshi/exam?ksId=${item.ksId}`
  80. })
  81. }
  82. function onRefresh() {
  83. data.page = 0;
  84. data.list = [];
  85. data.loading = true;
  86. refreshData();
  87. }
  88. function refreshData() {
  89. const opt = {
  90. page: 1,
  91. size: data.size, // 固定查询10条
  92. zyName: data.zyName
  93. }
  94. data.list = [];
  95. // 数学
  96. data.state = 'loading';
  97. data.page++;
  98. opt.page = data.page;
  99. getKaoshiList(opt).then(res => {
  100. data.list = data.list.concat(res.data.data);
  101. data.loading = false;
  102. if (res.data.total > data.list.length) {
  103. data.state = 'more';
  104. data.loading = false;
  105. } else {
  106. data.state = 'no-more';
  107. data.loading = false;
  108. }
  109. }).catch(err => {
  110. data.state = 'more';
  111. data.loading = false;
  112. })
  113. }
  114. function getMore() {
  115. const opt = {
  116. page: 1,
  117. size: data.size, // 固定查询10条
  118. zyName: data.zyName
  119. }
  120. if (data.state == 'no-more') return;
  121. data.state = 'loading';
  122. data.page++;
  123. opt.page = data.page;
  124. getKaoshiList(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. })
  135. }
  136. onLoad(() => {
  137. getMore()
  138. })
  139. </script>
  140. <style lang="scss" scoped>
  141. .phone-kaoshi-page {
  142. background-color: #ccc;
  143. box-sizing: border-box;
  144. // 查询区域
  145. .phone-search-content {
  146. position: relative;
  147. background-color: #fff;
  148. height: 42px;
  149. .search-input {
  150. height: 42px;
  151. line-height: 40px;
  152. border-radius: 20px;
  153. border: 1px solid #ccc;
  154. padding: 0 70px 0 20px;
  155. }
  156. .search-icon {
  157. position: absolute;
  158. right: 5px;
  159. top: 4px;
  160. padding: 6px;
  161. background-color: #ccc;
  162. border-radius: 20px;
  163. width: 50px;
  164. text-align: center;
  165. }
  166. }
  167. // 列表区域
  168. .item-kaoshi-row {
  169. width: 100%;
  170. .ks-item-top {
  171. display: flex;
  172. justify-content: space-between;
  173. .ks-name {
  174. font-weight: bold;
  175. font-size: 18px;
  176. }
  177. .ks-zyLevelName {
  178. padding: 2px 20px;
  179. background-color: #ccc;
  180. border-radius: 4px;
  181. }
  182. }
  183. .ks-totalTm {}
  184. .ks-score-content {
  185. background-color: #ccc;
  186. width: calc(100vw - 140px);
  187. .ks-score {
  188. padding-right: 10px
  189. }
  190. .ks-okScore {}
  191. }
  192. .row-item {
  193. margin-bottom: 10px;
  194. }
  195. .kaoshi-btn {
  196. width: 120px;
  197. font-size: 16px;
  198. margin-left: 0;
  199. }
  200. }
  201. }
  202. .kaoshi-scroll-view {
  203. height: calc(100vh - 166px);
  204. }
  205. </style>