list.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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"
  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 searchBtn() {
  88. searchRef.value.handleShow()
  89. }
  90. function handleSearchFromBtn(textD) {
  91. data.name = textD;
  92. handleSearch()
  93. }
  94. function handleSelectLeixing(item) {
  95. data.leixing = item.lable;
  96. selectClassify.value = item;
  97. handleSearch();
  98. }
  99. function handleResetLeixing() {
  100. selectClassify.value = null;
  101. data.leixing = '全部类型';
  102. handleSearch();
  103. }
  104. function clickAlltype() {
  105. kclxRef.value.showPopup({
  106. data: data.leixingList
  107. })
  108. }
  109. function goUpPage() {
  110. uni.redirectTo({
  111. url: '/pages/admin/ShouYe/shouye'
  112. })
  113. }
  114. function handleSearch() {
  115. data.page = 0;
  116. refreshData();
  117. }
  118. function checkKecheng(item) {
  119. uni.navigateTo({
  120. url: `/pages/admin/Kecheng/study?kcId=${item.kcId}`
  121. })
  122. }
  123. function onRefresh() {
  124. data.page = 0;
  125. data.list = [];
  126. data.loading = true;
  127. refreshData();
  128. }
  129. function refreshData() {
  130. const opt = {
  131. page: 1,
  132. size: 10, // 固定查询10条
  133. name: data.name,
  134. kcClassifyId: selectClassify.value && selectClassify.value.id || null,
  135. }
  136. data.list = [];
  137. // 数学
  138. data.state = 'loading';
  139. data.page++;
  140. opt.page = data.page;
  141. kechengApi.getKechengGlList(opt).then(res => {
  142. data.list = data.list.concat(res.data.data);
  143. data.loading = false;
  144. if (res.data.total > data.list.length) {
  145. data.state = 'more';
  146. data.loading = false;
  147. } else {
  148. data.state = 'no-more';
  149. data.loading = false;
  150. }
  151. }).catch(err => {
  152. data.state = 'more';
  153. data.loading = false;
  154. })
  155. }
  156. function getMore() {
  157. const opt = {
  158. page: 1,
  159. size: 10, // 固定查询10条
  160. name: data.name,
  161. kcClassifyId: selectClassify.value && selectClassify.value.id || null,
  162. }
  163. if (data.state == 'no-more') return;
  164. data.state = 'loading';
  165. data.page++;
  166. opt.page = data.page;
  167. kechengApi.getKechengGlList(opt).then(res => {
  168. data.list = data.list.concat(res.data.data);
  169. data.loading = false;
  170. if (res.data.total > data.list.length) {
  171. data.state = 'more';
  172. data.loading = false;
  173. } else {
  174. data.state = 'no-more';
  175. data.loading = false;
  176. }
  177. }).catch(err => {
  178. data.state = 'more';
  179. data.loading = false;
  180. })
  181. }
  182. function getKechengClassify() {
  183. kechengApi.getAdminClassify().then(res => {
  184. res.data.children.forEach(item => {
  185. item.checked = false;
  186. })
  187. data.leixingList = res.data.children || [];
  188. })
  189. }
  190. onLoad(() => {
  191. getMore()
  192. getKechengClassify();
  193. })
  194. </script>
  195. <style lang="scss" scoped>
  196. .phone-kecheng-page {
  197. background-color: #ccc;
  198. box-sizing: border-box;
  199. }
  200. .phone-search-content {
  201. position: relative;
  202. background-color: #fff;
  203. height: 42px;
  204. .search-input {
  205. height: 42px;
  206. line-height: 40px;
  207. border-radius: 20px;
  208. border: 1px solid #ccc;
  209. padding: 0 70px 0 20px;
  210. }
  211. .search-icon {
  212. position: absolute;
  213. right: 5px;
  214. top: 4px;
  215. padding: 6px;
  216. background-color: #ccc;
  217. border-radius: 20px;
  218. width: 50px;
  219. text-align: center;
  220. }
  221. }
  222. </style>