list.vue 4.3 KB

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