list.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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.name}}</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
  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. if ( data.from == 'shouye') {
  62. uni.redirectTo({
  63. url: '/pages/client/ShouYe/shouye'
  64. })
  65. } else if (data.from == 'my'){
  66. uni.redirectTo({
  67. url: '/pages/client/my/index'
  68. })
  69. } else {
  70. uni.redirectTo({
  71. url: '/pages/client/ShouYe/shouye'
  72. })
  73. }
  74. }
  75. function handleSearch() {
  76. data.page = 0;
  77. refreshData();
  78. }
  79. function checkKecheng(item) {
  80. uni.redirectTo({
  81. url: `/pages/client/Kecheng/study?kcId=${item.kcId}&from=kechengList`
  82. })
  83. }
  84. function onRefresh() {
  85. data.page = 0;
  86. data.list = [];
  87. data.loading = true;
  88. refreshData();
  89. }
  90. function refreshData() {
  91. const opt = {
  92. page: 1,
  93. size: 10, // 固定查询10条
  94. zyName: data.zyName
  95. }
  96. data.list = [];
  97. // 数学
  98. data.state = 'loading';
  99. data.page++;
  100. opt.page = data.page;
  101. kechengApi.getClientKechengList(opt).then(res => {
  102. data.list = data.list.concat(res.data.data);
  103. data.loading = false;
  104. if (res.data.total > data.list.length) {
  105. data.state = 'more';
  106. data.loading = false;
  107. } else {
  108. data.state = 'no-more';
  109. data.loading = false;
  110. }
  111. }).catch(err => {
  112. data.state = 'more';
  113. data.loading = false;
  114. })
  115. }
  116. function getMore() {
  117. const opt = {
  118. page: 1,
  119. size: 10, // 固定查询10条
  120. zyName: data.zyName
  121. }
  122. if (data.state == 'no-more') return;
  123. data.state = 'loading';
  124. data.page++;
  125. opt.page = data.page;
  126. kechengApi.getClientKechengList(opt).then(res => {
  127. data.list = data.list.concat(res.data.data);
  128. data.loading = false;
  129. if (res.data.total > data.list.length) {
  130. data.state = 'more';
  131. data.loading = false;
  132. } else {
  133. data.state = 'no-more';
  134. data.loading = false;
  135. }
  136. }).catch(err => {
  137. data.state = 'more';
  138. data.loading = false;
  139. })
  140. }
  141. onLoad((options) => {
  142. data.from = options.from;
  143. getMore()
  144. })
  145. </script>
  146. <style lang="scss" scoped>
  147. .phone-kecheng-page {
  148. background-color: #ccc;
  149. box-sizing: border-box;
  150. }
  151. .phone-search-content {
  152. position: relative;
  153. background-color: #fff;
  154. height: 42px;
  155. .search-input {
  156. height: 42px;
  157. line-height: 40px;
  158. border-radius: 20px;
  159. border: 1px solid #ccc;
  160. padding: 0 70px 0 20px;
  161. }
  162. .search-icon {
  163. position: absolute;
  164. right: 5px;
  165. top: 4px;
  166. padding: 6px;
  167. background-color: #ccc;
  168. border-radius: 20px;
  169. width: 50px;
  170. text-align: center;
  171. }
  172. }
  173. </style>