list.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <view class="phone-list-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. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
  16. :refresher-threshold="50" refresher-background="transparent" @refresherrefresh="onRefresh"
  17. class="phone-scroll-view">
  18. <uni-list class="admin-list-box">
  19. <uni-list-item v-for="item in data.list" class="admin-list-item-box">
  20. <template v-slot:body>
  21. <view class="item-card-row">
  22. <!-- 数量 -->
  23. <view class="ks-item-top">
  24. <view>{{item.zyName}}</view>
  25. <view class="ks-zyLevelName">{{item.zyLevelName}}</view>
  26. </view>
  27. <view class="ks-totalTm">
  28. <icon class="phone-time-icon" />时间:{{formatDuration(item.period)}}分钟
  29. </view>
  30. <button @click="checkKecheng(item)" type="primary" size="mini" class="item-view-btn">查看内容</button>
  31. </view>
  32. </template>
  33. </uni-list-item>
  34. <uni-load-more :status="data.state" @click="getMore(0)"
  35. :contentText="data.contentText"></uni-load-more>
  36. </uni-list>
  37. </scroll-view>
  38. <!-- 页面底端 -->
  39. <customTabbarAdminVue></customTabbarAdminVue>
  40. </view>
  41. </template>
  42. <script setup>
  43. import customTabbarAdminVue from "@/components/custom-tabbar/custom-tabbar-admin.vue";
  44. import {
  45. ref,
  46. reactive
  47. } from "vue";
  48. import {
  49. onLoad
  50. } from "@dcloudio/uni-app";
  51. import * as kechengApi from "@/api/kecheng.js"
  52. import {formatDuration} from "@/utils/common.js"
  53. const data = reactive({
  54. zyName: '', // 职业名称
  55. list: [], // 考试列表
  56. loading: false,
  57. page: 0,
  58. size: 10,
  59. state: 'more',
  60. contentText: {
  61. contentdown: '查看更多',
  62. contentrefresh: '加载中',
  63. contentnomore: '没有更多'
  64. }
  65. })
  66. function goUpPage() {
  67. uni.redirectTo({
  68. url: '/pages/admin/ShouYe/shouye'
  69. })
  70. }
  71. function handleSearch() {
  72. data.page = 0;
  73. refreshData();
  74. }
  75. function checkKecheng(item) {
  76. uni.navigateTo({
  77. url: `/pages/admin/Kecheng/study?kcId=${item.kcId}`
  78. })
  79. }
  80. function onRefresh() {
  81. data.page = 0;
  82. data.list = [];
  83. data.loading = true;
  84. refreshData();
  85. }
  86. function refreshData() {
  87. const opt = {
  88. page: 1,
  89. size: 10, // 固定查询10条
  90. zyName: data.zyName
  91. }
  92. data.list = [];
  93. // 数学
  94. data.state = 'loading';
  95. data.page++;
  96. opt.page = data.page;
  97. kechengApi.getKechengGlList(opt).then(res => {
  98. data.list = data.list.concat(res.data.data);
  99. data.loading = false;
  100. if (res.data.total > data.list.length) {
  101. data.state = 'more';
  102. data.loading = false;
  103. } else {
  104. data.state = 'no-more';
  105. data.loading = false;
  106. }
  107. }).catch(err => {
  108. data.state = 'more';
  109. data.loading = false;
  110. })
  111. }
  112. function getMore() {
  113. const opt = {
  114. page: 1,
  115. size: 10, // 固定查询10条
  116. zyName: data.zyName
  117. }
  118. if (data.state == 'no-more') return;
  119. data.state = 'loading';
  120. data.page++;
  121. opt.page = data.page;
  122. kechengApi.getKechengGlList(opt).then(res => {
  123. data.list = data.list.concat(res.data.data);
  124. data.loading = false;
  125. if (res.data.total > data.list.length) {
  126. data.state = 'more';
  127. data.loading = false;
  128. } else {
  129. data.state = 'no-more';
  130. data.loading = false;
  131. }
  132. }).catch(err => {
  133. data.state = 'more';
  134. data.loading = false;
  135. })
  136. }
  137. onLoad(() => {
  138. getMore()
  139. })
  140. </script>
  141. <style lang="scss" scoped>
  142. .phone-kecheng-page {
  143. background-color: #ccc;
  144. box-sizing: border-box;
  145. }
  146. .phone-search-content {
  147. position: relative;
  148. background-color: #fff;
  149. height: 42px;
  150. .search-input {
  151. height: 42px;
  152. line-height: 40px;
  153. border-radius: 20px;
  154. border: 1px solid #ccc;
  155. padding: 0 70px 0 20px;
  156. }
  157. .search-icon {
  158. position: absolute;
  159. right: 5px;
  160. top: 4px;
  161. padding: 6px;
  162. background-color: #ccc;
  163. border-radius: 20px;
  164. width: 50px;
  165. text-align: center;
  166. }
  167. }
  168. </style>