list.vue 3.5 KB

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