list.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <view class="phone-kecheng-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="cuoti-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="cuoti-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-cuoti-row">
  22. <view>{{item.ksName}}</view>
  23. <view>时间:{{item.totalTm}} 分钟</view>
  24. <view>次数: {{item.maxTimes}}</view>
  25. <view>总分: {{item.ksScore}}</view>
  26. <view>及格分: {{item.okScore}}</view>
  27. </view>
  28. <view @click="checkKaoshi(item)" class="cuoti-btn">查看考试</view>
  29. </template>
  30. </uni-list-item>
  31. <uni-load-more :status="data.state" @click="getMore(0)"
  32. :contentText="data.contentText"></uni-load-more>
  33. </uni-list>
  34. </scroll-view>
  35. </view>
  36. </view>
  37. </template>
  38. <script setup>
  39. import {
  40. ref,reactive
  41. } from "vue";
  42. import {
  43. onLoad
  44. } from "@dcloudio/uni-app";
  45. import * as kechengApi from "@/api/kecheng.js"
  46. const data = reactive({
  47. zyName: '', // 职业名称
  48. list: [], // 考试列表
  49. loading: false,
  50. page: 0,
  51. size: 10,
  52. state: 'more',
  53. contentText: {
  54. contentdown: '查看更多',
  55. contentrefresh: '加载中',
  56. contentnomore: '没有更多'
  57. }
  58. })
  59. function handleSearch() {
  60. data.page = 0;
  61. refreshData();
  62. }
  63. function checkKaoshi(item) {
  64. uni.navigateTo({
  65. url: `/pages/admin/Kaoshi/exam?ksId=${item.ksId}`
  66. })
  67. }
  68. function onRefresh() {
  69. data.page = 0;
  70. data.list = [];
  71. data.loading = true;
  72. refreshData();
  73. }
  74. function refreshData() {
  75. const opt = {
  76. page: 1,
  77. size: 10, // 固定查询10条
  78. zyName: data.zyName
  79. }
  80. data.list = [];
  81. // 数学
  82. data.state = 'loading';
  83. data.page++;
  84. opt.page = data.page;
  85. kechengApi.getKechengGlList(opt).then(res =>{
  86. data.list = data.list.concat(res.data.data);
  87. data.loading = false;
  88. if (res.data.total >= data.list.length) {
  89. data.state = 'no-more';
  90. data.loading = false;
  91. } else {
  92. data.state = 'more';
  93. data.loading = false;
  94. }
  95. }).catch(err => {
  96. data.state = 'more';
  97. data.loading = false;
  98. })
  99. }
  100. function getMore() {
  101. const opt = {
  102. page: 1,
  103. size: 10, // 固定查询10条
  104. zyName: data.zyName
  105. }
  106. if (data.state == 'no-more') return;
  107. data.state = 'loading';
  108. data.page++;
  109. opt.page = data.page;
  110. kechengApi.getKechengGlList(opt).then(res =>{
  111. data.list = data.list.concat(res.data.data);
  112. data.loading = false;
  113. if (res.data.total >= data.list.length) {
  114. // 数学
  115. data.state = 'no-more';
  116. data.loading = false;
  117. } else {
  118. // 数学
  119. data.state = 'more';
  120. data.loading = false;
  121. }
  122. })
  123. }
  124. onLoad(() => {
  125. getMore()
  126. })
  127. </script>
  128. <style lang="scss" scoped>
  129. .phone-kecheng-page {
  130. background-color: #ccc;
  131. box-sizing: border-box;
  132. }
  133. .phone-search-content {
  134. position: relative;
  135. background-color: #fff;
  136. height: 42px;
  137. .search-input {
  138. height: 42px;
  139. line-height: 40px;
  140. border-radius: 20px;
  141. border: 1px solid #ccc;
  142. padding: 0 70px 0 20px;
  143. }
  144. .search-icon {
  145. position: absolute;
  146. right: 5px;
  147. top: 4px;
  148. padding: 6px;
  149. background-color: #ccc;
  150. border-radius: 20px;
  151. width: 50px;
  152. text-align: center;
  153. }
  154. }
  155. </style>