list.vue 3.9 KB

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