list.vue 6.7 KB

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