list.vue 3.8 KB

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