list.vue 4.8 KB

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