list.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <view class="phone-list-page">
  3. <view class="phone-navBar-box">
  4. <view @click="goUpPage" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">课程管理</text>
  6. <uni-icons class="nav-bar-right-icon" type="search" size="22" color="#666" @click="searchBtn"></uni-icons>
  7. </view>
  8. <!-- 查询职业 -->
  9. <view class="jiazheng-search-box">
  10. <view @click.stop="clickAlltype" class="select-item-box">
  11. <text class="kc-select-text">{{data.leixing}}</text>
  12. <icon class="select-jt-default" />
  13. </view>
  14. <!-- <input class="search-input" placeholder="请输入课程名称" v-model="data.name" />
  15. <view class="search-icon" @click="handleSearch">
  16. <uni-icons type="search" size="24" color="#fff"></uni-icons>
  17. </view> -->
  18. </view>
  19. <!-- 课程列表 -->
  20. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
  21. :refresher-threshold="50" refresher-background="transparent" @refresherrefresh="onRefresh" @scrolltolower="onScrolltolower"
  22. class="phone-scroll-saixuan-view scroll-top-border">
  23. <uni-list class="admin-list-box">
  24. <uni-list-item v-for="item in data.list" class="admin-list-item-box">
  25. <template v-slot:body>
  26. <view class="kecheng-list-card">
  27. <img :src="item.pic">
  28. <view class="item-card-row">
  29. <!-- 数量 -->
  30. <view class="ks-item-top">
  31. <view class="kc-name">{{item.name}}</view>
  32. </view>
  33. <view class="ks-totalTm kc-fenlei">
  34. <icon class="phone-fenlei-icon" />分类:{{item.kcClassifyName}}
  35. </view>
  36. <view class="ks-totalTm kc-totalTm">
  37. <icon class="phone-time-icon" />时间:{{formatDuration(item.period)}}分钟
  38. </view>
  39. <button @click="checkKecheng(item)" type="primary" size="mini"
  40. class="item-view-btn">查看内容</button>
  41. </view>
  42. </view>
  43. </template>
  44. </uni-list-item>
  45. <uni-load-more :status="data.state" @click="getMore(0)" :contentText="data.contentText"></uni-load-more>
  46. </uni-list>
  47. </scroll-view>
  48. <!-- 页面底端 -->
  49. <customTabbarAdminVue :current-tab="2"></customTabbarAdminVue>
  50. <searchVue ref="searchRef" @search-btn="handleSearchFromBtn"></searchVue>
  51. <kechengLeixingVue ref="kclxRef" @select="handleSelectLeixing" @reset="handleResetLeixing"></kechengLeixingVue>
  52. </view>
  53. </template>
  54. <script setup>
  55. import customTabbarAdminVue from "@/components/custom-tabbar/custom-tabbar-admin.vue";
  56. import kechengLeixingVue from "@/pages/admin/Kecheng/components/kechengLeixing.vue";
  57. import searchVue from "./components/search.vue";
  58. import {
  59. ref,
  60. reactive
  61. } from "vue";
  62. import {
  63. onLoad
  64. } from "@dcloudio/uni-app";
  65. import * as kechengApi from "@/api/kecheng.js"
  66. import {
  67. formatDuration
  68. } from "@/utils/common.js"
  69. const kclxRef = ref(null)
  70. const selectClassify = ref(null)
  71. const searchRef = ref(null)
  72. const data = reactive({
  73. leixing: '全部类型',
  74. leixingList: [],
  75. name: '',
  76. list: [], // 考试列表
  77. loading: false,
  78. page: 0,
  79. size: 10,
  80. state: 'more',
  81. contentText: {
  82. contentdown: '查看更多',
  83. contentrefresh: '加载中',
  84. contentnomore: '没有更多'
  85. }
  86. })
  87. function onScrolltolower() {
  88. getMore()
  89. }
  90. function searchBtn() {
  91. searchRef.value.handleShow()
  92. }
  93. function handleSearchFromBtn(textD) {
  94. data.name = textD;
  95. handleSearch()
  96. }
  97. function handleSelectLeixing(item) {
  98. data.leixing = item.lable;
  99. selectClassify.value = item;
  100. handleSearch();
  101. }
  102. function handleResetLeixing() {
  103. selectClassify.value = null;
  104. data.leixing = '全部类型';
  105. handleSearch();
  106. }
  107. function clickAlltype() {
  108. kclxRef.value.showPopup({
  109. data: data.leixingList
  110. })
  111. }
  112. function goUpPage() {
  113. uni.redirectTo({
  114. url: '/pages/admin/ShouYe/shouye'
  115. })
  116. }
  117. function handleSearch() {
  118. data.page = 0;
  119. refreshData();
  120. }
  121. function checkKecheng(item) {
  122. uni.navigateTo({
  123. url: `/pages/admin/Kecheng/study?kcId=${item.kcId}`
  124. })
  125. }
  126. function onRefresh() {
  127. data.page = 0;
  128. data.list = [];
  129. data.loading = true;
  130. refreshData();
  131. }
  132. function refreshData() {
  133. const opt = {
  134. page: 1,
  135. size: 10, // 固定查询10条
  136. name: data.name,
  137. kcClassifyId: selectClassify.value && selectClassify.value.id || null,
  138. }
  139. data.list = [];
  140. // 数学
  141. data.state = 'loading';
  142. data.page++;
  143. opt.page = data.page;
  144. kechengApi.getKechengGlList(opt).then(res => {
  145. data.list = data.list.concat(res.data.data);
  146. data.loading = false;
  147. if (res.data.total > data.list.length) {
  148. data.state = 'more';
  149. data.loading = false;
  150. } else {
  151. data.state = 'no-more';
  152. data.loading = false;
  153. }
  154. }).catch(err => {
  155. data.state = 'more';
  156. data.loading = false;
  157. })
  158. }
  159. function getMore() {
  160. const opt = {
  161. page: 1,
  162. size: 10, // 固定查询10条
  163. name: data.name,
  164. kcClassifyId: selectClassify.value && selectClassify.value.id || null,
  165. }
  166. if (data.state == 'no-more') return;
  167. data.state = 'loading';
  168. data.page++;
  169. opt.page = data.page;
  170. kechengApi.getKechengGlList(opt).then(res => {
  171. data.list = data.list.concat(res.data.data);
  172. data.loading = false;
  173. if (res.data.total > data.list.length) {
  174. data.state = 'more';
  175. data.loading = false;
  176. } else {
  177. data.state = 'no-more';
  178. data.loading = false;
  179. }
  180. }).catch(err => {
  181. data.state = 'more';
  182. data.loading = false;
  183. })
  184. }
  185. function getKechengClassify() {
  186. kechengApi.getAdminClassify().then(res => {
  187. res.data.children.forEach(item => {
  188. item.checked = false;
  189. })
  190. data.leixingList = res.data.children || [];
  191. })
  192. }
  193. onLoad(() => {
  194. getMore()
  195. getKechengClassify();
  196. })
  197. </script>
  198. <style lang="scss" scoped>
  199. .phone-kecheng-page {
  200. background-color: #ccc;
  201. box-sizing: border-box;
  202. }
  203. .phone-search-content {
  204. position: relative;
  205. background-color: #fff;
  206. height: 42px;
  207. .search-input {
  208. height: 42px;
  209. line-height: 40px;
  210. border-radius: 20px;
  211. border: 1px solid #ccc;
  212. padding: 0 70px 0 20px;
  213. }
  214. .search-icon {
  215. position: absolute;
  216. right: 5px;
  217. top: 4px;
  218. padding: 6px;
  219. background-color: #ccc;
  220. border-radius: 20px;
  221. width: 50px;
  222. text-align: center;
  223. }
  224. }
  225. </style>