list.vue 6.3 KB

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