list.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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"
  24. class="item-view-btn">查看内容</button>
  25. </view>
  26. </template>
  27. </uni-list-item>
  28. <uni-load-more :status="data.state" @click="getMore(0)" :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,
  43. onShow
  44. } from "@dcloudio/uni-app";
  45. import * as kechengApi from "@/api/kecheng.js"
  46. import {
  47. formatSecondsToCnhms
  48. } from "@/utils/common.js"
  49. const data = reactive({
  50. zyName: '', // 职业名称
  51. list: [], // 考试列表
  52. loading: false,
  53. page: 0,
  54. size: 10,
  55. state: 'more',
  56. contentText: {
  57. contentdown: '查看更多',
  58. contentrefresh: '加载中',
  59. contentnomore: '没有更多'
  60. },
  61. from: ''
  62. })
  63. function goUpPage() {
  64. const pages = getCurrentPages();
  65. if (pages.length > 1) {
  66. uni.navigateBack()
  67. } else {
  68. /* uni.redirectTo({
  69. url: '/pages/client/ShouYe/shouye'
  70. }) */
  71. history.back();
  72. }
  73. }
  74. function handleSearch() {
  75. data.page = 0;
  76. refreshData();
  77. }
  78. function checkKecheng(item) {
  79. uni.navigateTo({
  80. url: `/pages/client/Kecheng/study?kcId=${item.kcId}&from=kechengList`
  81. })
  82. }
  83. function onRefresh() {
  84. data.page = 0;
  85. data.list = [];
  86. data.loading = true;
  87. refreshData();
  88. }
  89. function refreshData() {
  90. const opt = {
  91. page: 1,
  92. size: 10, // 固定查询10条
  93. zyName: data.zyName
  94. }
  95. data.list = [];
  96. // 数学
  97. data.state = 'loading';
  98. data.page++;
  99. opt.page = data.page;
  100. kechengApi.getClientKechengList(opt).then(res => {
  101. data.list = data.list.concat(res.data.data);
  102. data.loading = false;
  103. if (res.data.total > data.list.length) {
  104. data.state = 'more';
  105. data.loading = false;
  106. } else {
  107. data.state = 'no-more';
  108. data.loading = false;
  109. }
  110. }).catch(err => {
  111. data.state = 'more';
  112. data.loading = false;
  113. })
  114. }
  115. function getMore() {
  116. const opt = {
  117. page: 1,
  118. size: 10, // 固定查询10条
  119. zyName: data.zyName
  120. }
  121. if (data.state == 'no-more') return;
  122. data.state = 'loading';
  123. data.page++;
  124. opt.page = data.page;
  125. kechengApi.getClientKechengList(opt).then(res => {
  126. data.list = data.list.concat(res.data.data);
  127. data.loading = false;
  128. if (res.data.total > data.list.length) {
  129. data.state = 'more';
  130. data.loading = false;
  131. } else {
  132. data.state = 'no-more';
  133. data.loading = false;
  134. }
  135. }).catch(err => {
  136. data.state = 'more';
  137. data.loading = false;
  138. })
  139. }
  140. onLoad((options) => {
  141. data.from = options.from;
  142. })
  143. onShow(() => {
  144. getMore()
  145. })
  146. </script>
  147. <style lang="scss" scoped>
  148. .phone-kecheng-page {
  149. background-color: #ccc;
  150. box-sizing: border-box;
  151. }
  152. .phone-search-content {
  153. position: relative;
  154. background-color: #fff;
  155. height: 42px;
  156. .search-input {
  157. height: 42px;
  158. line-height: 40px;
  159. border-radius: 20px;
  160. border: 1px solid #ccc;
  161. padding: 0 70px 0 20px;
  162. }
  163. .search-icon {
  164. position: absolute;
  165. right: 5px;
  166. top: 4px;
  167. padding: 6px;
  168. background-color: #ccc;
  169. border-radius: 20px;
  170. width: 50px;
  171. text-align: center;
  172. }
  173. }
  174. </style>