list.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <view class="admin-kaoshi-page">
  3. <view class="icon-title-navBar-box">
  4. <view @click="goUpPage" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">课程管理</text>
  6. </view>
  7. <!-- 查询职业 -->
  8. <view class="phone-search-box">
  9. <input class="search-input" placeholder="请输入职业名称" v-model="data.zyName" />
  10. <view class="search-icon" @click="handleSearch">
  11. <uni-icons type="search" size="24" color="#fff"></uni-icons>
  12. </view>
  13. </view>
  14. <!-- 课程列表 -->
  15. <view class="kaoshi-content-box">
  16. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
  17. :refresher-threshold="50" refresher-background="transparent" @refresherrefresh="onRefresh"
  18. class="kaoshi-scroll-view">
  19. <uni-list class="admin-list-box">
  20. <uni-list-item v-for="item in data.list" class="admin-list-item-box">
  21. <template v-slot:body>
  22. <view class="item-kaoshi-row">
  23. <!-- 数量 -->
  24. <view class="ks-item-top">
  25. <view>{{item.name}}</view>
  26. <view class="ks-zyLevelName">{{item.zyLevelName}}</view>
  27. </view>
  28. <view class="ks-totalTm">
  29. <icon class="phone-time-icon" />时间:{{formatDuration(item.period)}}分钟
  30. </view>
  31. <button @click="checkKecheng(item)" type="primary" size="mini" class="kaoshi-btn">查看内容</button>
  32. </view>
  33. </template>
  34. </uni-list-item>
  35. <uni-load-more :status="data.state" @click="getMore(0)"
  36. :contentText="data.contentText"></uni-load-more>
  37. </uni-list>
  38. </scroll-view>
  39. </view>
  40. <!-- 页面底端 -->
  41. <customTabbarAdminVue></customTabbarAdminVue>
  42. </view>
  43. </template>
  44. <script setup>
  45. import customTabbarAdminVue from "@/components/custom-tabbar/custom-tabbar-admin.vue";
  46. import {
  47. ref,
  48. reactive
  49. } from "vue";
  50. import {
  51. onLoad
  52. } from "@dcloudio/uni-app";
  53. import * as kechengApi from "@/api/kecheng.js"
  54. import {formatDuration} from "@/utils/common.js"
  55. const data = reactive({
  56. zyName: '', // 职业名称
  57. list: [], // 考试列表
  58. loading: false,
  59. page: 0,
  60. size: 10,
  61. state: 'more',
  62. contentText: {
  63. contentdown: '查看更多',
  64. contentrefresh: '加载中',
  65. contentnomore: '没有更多'
  66. }
  67. })
  68. function goUpPage() {
  69. uni.redirectTo({
  70. url: '/pages/admin/ShouYe/shouye'
  71. })
  72. }
  73. function handleSearch() {
  74. data.page = 0;
  75. refreshData();
  76. }
  77. function checkKecheng(item) {
  78. uni.navigateTo({
  79. url: `/pages/admin/Kecheng/study?kcId=${item.kcId}`
  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: 10, // 固定查询10条
  92. zyName: data.zyName
  93. }
  94. data.list = [];
  95. // 数学
  96. data.state = 'loading';
  97. data.page++;
  98. opt.page = data.page;
  99. kechengApi.getKechengGlList(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: 10, // 固定查询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. kechengApi.getKechengGlList(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-kecheng-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. </style>