list.vue 5.8 KB

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