list.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view class="admin-kaoshi-page">
  3. <view class="icon-title-navBar-box">
  4. <view @click="goUpPage" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">课程管理</text>
  6. </view>
  7. <!-- 课程列表 -->
  8. <view class="kaoshi-content-box">
  9. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
  10. :refresher-threshold="50" refresher-background="transparent" @refresherrefresh="onRefresh"
  11. class="kaoshi-scroll-view">
  12. <uni-list class="admin-list-box">
  13. <uni-list-item v-for="item in data.list" class="admin-list-item-box">
  14. <template v-slot:body>
  15. <view class="item-kaoshi-row">
  16. <!-- 数量 -->
  17. <view class="ks-item-top">
  18. <view>{{item.name}}</view>
  19. <view class="ks-zyLevelName">{{item.zyLevelName}}</view>
  20. </view>
  21. <view class="ks-totalTm">
  22. <icon class="phone-time-icon" />时间:{{formatDuration(item.period)}}分钟
  23. </view>
  24. <button @click="checkKecheng(item)" type="primary" size="mini" class="kaoshi-btn">查看内容</button>
  25. </view>
  26. </template>
  27. </uni-list-item>
  28. <uni-load-more :status="data.state" @click="getMore(0)"
  29. :contentText="data.contentText"></uni-load-more>
  30. </uni-list>
  31. </scroll-view>
  32. </view>
  33. <!-- 页面底端 -->
  34. <customTabbarAdminVue></customTabbarAdminVue>
  35. </view>
  36. </template>
  37. <script setup>
  38. import customTabbarAdminVue from "@/components/custom-tabbar/custom-tabbar-admin.vue";
  39. import {
  40. ref,
  41. reactive
  42. } from "vue";
  43. import {
  44. onLoad
  45. } from "@dcloudio/uni-app";
  46. import * as kechengApi from "@/api/kecheng.js"
  47. import {formatDuration} from "@/utils/common.js"
  48. const data = reactive({
  49. zyName: '', // 职业名称
  50. list: [], // 考试列表
  51. loading: false,
  52. page: 0,
  53. size: 10,
  54. state: 'more',
  55. contentText: {
  56. contentdown: '查看更多',
  57. contentrefresh: '加载中',
  58. contentnomore: '没有更多'
  59. }
  60. })
  61. function goUpPage() {
  62. uni.redirectTo({
  63. url: '/pages/client/ShouYe/shouye'
  64. })
  65. }
  66. function handleSearch() {
  67. data.page = 0;
  68. refreshData();
  69. }
  70. function checkKecheng(item) {
  71. uni.navigateTo({
  72. url: `/pages/client/Kecheng/study?kcId=${item.kcId}`
  73. })
  74. }
  75. function onRefresh() {
  76. data.page = 0;
  77. data.list = [];
  78. data.loading = true;
  79. refreshData();
  80. }
  81. function refreshData() {
  82. const opt = {
  83. page: 1,
  84. size: 10, // 固定查询10条
  85. zyName: data.zyName
  86. }
  87. data.list = [];
  88. // 数学
  89. data.state = 'loading';
  90. data.page++;
  91. opt.page = data.page;
  92. kechengApi.getClientKechengList(opt).then(res => {
  93. data.list = data.list.concat(res.data.data);
  94. data.loading = false;
  95. if (res.data.total > data.list.length) {
  96. data.state = 'more';
  97. data.loading = false;
  98. } else {
  99. data.state = 'no-more';
  100. data.loading = false;
  101. }
  102. }).catch(err => {
  103. data.state = 'more';
  104. data.loading = false;
  105. })
  106. }
  107. function getMore() {
  108. const opt = {
  109. page: 1,
  110. size: 10, // 固定查询10条
  111. zyName: data.zyName
  112. }
  113. if (data.state == 'no-more') return;
  114. data.state = 'loading';
  115. data.page++;
  116. opt.page = data.page;
  117. kechengApi.getClientKechengList(opt).then(res => {
  118. data.list = data.list.concat(res.data.data);
  119. data.loading = false;
  120. if (res.data.total > data.list.length) {
  121. data.state = 'more';
  122. data.loading = false;
  123. } else {
  124. data.state = 'no-more';
  125. data.loading = false;
  126. }
  127. }).catch(err => {
  128. data.state = 'more';
  129. data.loading = false;
  130. })
  131. }
  132. onLoad(() => {
  133. getMore()
  134. })
  135. </script>
  136. <style lang="scss" scoped>
  137. .phone-kecheng-page {
  138. background-color: #ccc;
  139. box-sizing: border-box;
  140. }
  141. .phone-search-content {
  142. position: relative;
  143. background-color: #fff;
  144. height: 42px;
  145. .search-input {
  146. height: 42px;
  147. line-height: 40px;
  148. border-radius: 20px;
  149. border: 1px solid #ccc;
  150. padding: 0 70px 0 20px;
  151. }
  152. .search-icon {
  153. position: absolute;
  154. right: 5px;
  155. top: 4px;
  156. padding: 6px;
  157. background-color: #ccc;
  158. border-radius: 20px;
  159. width: 50px;
  160. text-align: center;
  161. }
  162. }
  163. </style>