list.vue 3.6 KB

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