list.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <view class="phone-list-page">
  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="item-card-row">
  15. <!-- 数量 -->
  16. <view class="ks-item-top">
  17. <view>{{item.zyName}}</view>
  18. <view class="ks-zyLevelName">{{item.zyLevelName}}</view>
  19. </view>
  20. <view class="ks-totalTm">
  21. <icon class="phone-time-icon" />时间:{{formatSecondsToCnhms(item.period, true)}}
  22. </view>
  23. <button @click="checkKecheng(item)" type="primary" size="mini" class="item-view-btn">查看内容</button>
  24. </view>
  25. </template>
  26. </uni-list-item>
  27. <uni-load-more :status="data.state" @click="getMore(0)"
  28. :contentText="data.contentText"></uni-load-more>
  29. </uni-list>
  30. </scroll-view>
  31. <!-- 页面底端 -->
  32. <customTabbarClientVue></customTabbarClientVue>
  33. </view>
  34. </template>
  35. <script setup>
  36. import customTabbarClientVue from "@/components/custom-tabbar/custom-tabbar-client.vue";
  37. import {
  38. ref,
  39. reactive
  40. } from "vue";
  41. import {
  42. onLoad, onShow
  43. } from "@dcloudio/uni-app";
  44. import * as kechengApi from "@/api/kecheng.js"
  45. import {formatSecondsToCnhms} 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. uni.redirectTo({
  62. url: '/pages/client/ShouYe/shouye'
  63. })
  64. }
  65. function handleSearch() {
  66. data.page = 0;
  67. refreshData();
  68. }
  69. function checkKecheng(item) {
  70. uni.navigateTo({
  71. url: `/pages/client/Kecheng/study?kcId=${item.kcId}&from=kechengList`
  72. })
  73. }
  74. function onRefresh() {
  75. data.page = 0;
  76. data.list = [];
  77. data.loading = true;
  78. refreshData();
  79. }
  80. function refreshData() {
  81. const opt = {
  82. page: 1,
  83. size: 10, // 固定查询10条
  84. zyName: data.zyName
  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. zyName: data.zyName
  111. }
  112. if (data.state == 'no-more') return;
  113. data.state = 'loading';
  114. data.page++;
  115. opt.page = data.page;
  116. kechengApi.getClientKechengList(opt).then(res => {
  117. data.list = data.list.concat(res.data.data);
  118. data.loading = false;
  119. if (res.data.total > data.list.length) {
  120. data.state = 'more';
  121. data.loading = false;
  122. } else {
  123. data.state = 'no-more';
  124. data.loading = false;
  125. }
  126. }).catch(err => {
  127. data.state = 'more';
  128. data.loading = false;
  129. })
  130. }
  131. onLoad((options) => {
  132. data.from = options.from;
  133. })
  134. onShow(() => {
  135. getMore()
  136. })
  137. </script>
  138. <style lang="scss" scoped>
  139. .phone-kecheng-page {
  140. background-color: #ccc;
  141. box-sizing: border-box;
  142. }
  143. .phone-search-content {
  144. position: relative;
  145. background-color: #fff;
  146. height: 42px;
  147. .search-input {
  148. height: 42px;
  149. line-height: 40px;
  150. border-radius: 20px;
  151. border: 1px solid #ccc;
  152. padding: 0 70px 0 20px;
  153. }
  154. .search-icon {
  155. position: absolute;
  156. right: 5px;
  157. top: 4px;
  158. padding: 6px;
  159. background-color: #ccc;
  160. border-radius: 20px;
  161. width: 50px;
  162. text-align: center;
  163. }
  164. }
  165. </style>