list.vue 5.2 KB

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