list.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <view class="phone-list-page kecheng-list">
  3. <view class="icon-title-bjcolor-navBar-box">
  4. <view @click="goUpPage" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">课程管理</text>
  6. </view>
  7. <!-- 课程列表 -->
  8. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
  9. :refresher-threshold="50" refresher-background="transparent" @refresherrefresh="onRefresh" @scrolltolower="onScrolltolower"
  10. class="phone-scroll-view">
  11. <uni-list class="admin-list-box">
  12. <uni-list-item v-for="item in data.list" class="admin-list-item-box">
  13. <template v-slot:body>
  14. <view class="kecheng-list-card-box" @click="checkKecheng(item)">
  15. <img :src="item.pic">
  16. <view class="card-right-box">
  17. <view class="card-name">{{item.name}}</view>
  18. <view class="ks-totalTm kc-fenlei">
  19. <icon class="phone-fenlei-icon" />分类:{{item.kcClassifyName}}
  20. </view>
  21. <view>课时:{{formatSecondsToCnhms(item.period, true)}}</view>
  22. <view>{{item.createTime}}</view>
  23. </view>
  24. </view>
  25. </template>
  26. </uni-list-item>
  27. <uni-load-more :status="data.state" @click="getMore(0)" :contentText="data.contentText"></uni-load-more>
  28. </uni-list>
  29. </scroll-view>
  30. <!-- 页面底端 -->
  31. <customTabbarClientVue></customTabbarClientVue>
  32. </view>
  33. </template>
  34. <script setup>
  35. import customTabbarClientVue from "@/components/custom-tabbar/custom-tabbar-client.vue";
  36. import {
  37. ref,
  38. reactive
  39. } from "vue";
  40. import {
  41. onLoad,
  42. onShow
  43. } from "@dcloudio/uni-app";
  44. import * as kechengApi from "@/api/kecheng.js"
  45. import {
  46. formatSecondsToCnhms
  47. } from "@/utils/common.js"
  48. const data = reactive({
  49. list: [], // 考试列表
  50. loading: false,
  51. page: 0,
  52. size: 10,
  53. state: 'more',
  54. contentText: {
  55. contentdown: '查看更多',
  56. contentrefresh: '加载中',
  57. contentnomore: '没有更多'
  58. },
  59. from: ''
  60. })
  61. function onScrolltolower() {
  62. getMore()
  63. }
  64. function goUpPage() {
  65. const pages = getCurrentPages();
  66. if (pages.length > 1) {
  67. uni.navigateBack()
  68. } else {
  69. /* uni.redirectTo({
  70. url: '/pages/client/ShouYe/shouye'
  71. }) */
  72. history.back();
  73. }
  74. }
  75. function handleSearch() {
  76. data.page = 0;
  77. refreshData();
  78. }
  79. function checkKecheng(item) {
  80. uni.navigateTo({
  81. url: `/pages/client/Kecheng/study?kcId=${item.kcId}&jzId=${item.jzId}&from=kechengList`
  82. })
  83. }
  84. function onRefresh() {
  85. data.page = 0;
  86. data.list = [];
  87. data.loading = true;
  88. refreshData();
  89. }
  90. function refreshData() {
  91. const opt = {
  92. page: 1,
  93. size: 10, // 固定查询10条
  94. }
  95. data.list = [];
  96. // 数学
  97. data.state = 'loading';
  98. data.page++;
  99. opt.page = data.page;
  100. kechengApi.getClientKechengList(opt).then(res => {
  101. data.list = data.list.concat(res.data.data);
  102. data.loading = false;
  103. if (res.data.total > data.list.length) {
  104. data.state = 'more';
  105. data.loading = false;
  106. } else {
  107. data.state = 'no-more';
  108. data.loading = false;
  109. }
  110. }).catch(err => {
  111. data.state = 'more';
  112. data.loading = false;
  113. })
  114. }
  115. function getMore() {
  116. const opt = {
  117. page: 1,
  118. size: 10, // 固定查询10条
  119. }
  120. if (data.state == 'no-more') return;
  121. data.state = 'loading';
  122. data.page++;
  123. opt.page = data.page;
  124. kechengApi.getClientKechengList(opt).then(res => {
  125. data.list = data.list.concat(res.data.data);
  126. data.loading = false;
  127. if (res.data.total > data.list.length) {
  128. data.state = 'more';
  129. data.loading = false;
  130. } else {
  131. data.state = 'no-more';
  132. data.loading = false;
  133. }
  134. }).catch(err => {
  135. data.state = 'more';
  136. data.loading = false;
  137. })
  138. }
  139. onLoad((options) => {
  140. data.from = options.from;
  141. })
  142. onShow(() => {
  143. getMore()
  144. })
  145. </script>