list.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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"
  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 goUpPage() {
  62. const pages = getCurrentPages();
  63. if (pages.length > 1) {
  64. uni.navigateBack()
  65. } else {
  66. /* uni.redirectTo({
  67. url: '/pages/client/ShouYe/shouye'
  68. }) */
  69. history.back();
  70. }
  71. }
  72. function handleSearch() {
  73. data.page = 0;
  74. refreshData();
  75. }
  76. function checkKecheng(item) {
  77. uni.navigateTo({
  78. url: `/pages/client/Kecheng/study?kcId=${item.kcId}&jzId=${item.jzId}&from=kechengList`
  79. })
  80. }
  81. function onRefresh() {
  82. data.page = 0;
  83. data.list = [];
  84. data.loading = true;
  85. refreshData();
  86. }
  87. function refreshData() {
  88. const opt = {
  89. page: 1,
  90. size: 10, // 固定查询10条
  91. }
  92. data.list = [];
  93. // 数学
  94. data.state = 'loading';
  95. data.page++;
  96. opt.page = data.page;
  97. kechengApi.getClientKechengList(opt).then(res => {
  98. data.list = data.list.concat(res.data.data);
  99. data.loading = false;
  100. if (res.data.total > data.list.length) {
  101. data.state = 'more';
  102. data.loading = false;
  103. } else {
  104. data.state = 'no-more';
  105. data.loading = false;
  106. }
  107. }).catch(err => {
  108. data.state = 'more';
  109. data.loading = false;
  110. })
  111. }
  112. function getMore() {
  113. const opt = {
  114. page: 1,
  115. size: 10, // 固定查询10条
  116. }
  117. if (data.state == 'no-more') return;
  118. data.state = 'loading';
  119. data.page++;
  120. opt.page = data.page;
  121. kechengApi.getClientKechengList(opt).then(res => {
  122. data.list = data.list.concat(res.data.data);
  123. data.loading = false;
  124. if (res.data.total > data.list.length) {
  125. data.state = 'more';
  126. data.loading = false;
  127. } else {
  128. data.state = 'no-more';
  129. data.loading = false;
  130. }
  131. }).catch(err => {
  132. data.state = 'more';
  133. data.loading = false;
  134. })
  135. }
  136. onLoad((options) => {
  137. data.from = options.from;
  138. })
  139. onShow(() => {
  140. getMore()
  141. })
  142. </script>