list.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
  9. :refresher-threshold="50" refresher-background="transparent" @refresherrefresh="onRefresh"
  10. class="admin-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="kecheng-list-card">
  15. <img :src="item.pic">
  16. <view class="item-card-row">
  17. <!-- 数量 -->
  18. <view class="ks-item-top">
  19. <view class="kc-name">{{item.name}}</view>
  20. </view>
  21. <view class="ks-totalTm kc-totalTm">
  22. <icon class="phone-time-icon" />时间:{{formatDuration(item.period)}}分钟
  23. </view>
  24. <button @click="checkKecheng(item)" type="primary" size="mini" class="item-view-btn">查看内容</button>
  25. </view>
  26. </view>
  27. </template>
  28. </uni-list-item>
  29. <uni-load-more :status="data.state" @click="getMore(0)"
  30. :contentText="data.contentText"></uni-load-more>
  31. </uni-list>
  32. </scroll-view>
  33. <!-- 页面底端 -->
  34. <customTabbarAdminVue :current-tab="2"></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. list: [], // 考试列表
  50. loading: false,
  51. page: 0,
  52. size: 10,
  53. state: 'more',
  54. contentText: {
  55. contentdown: '查看更多',
  56. contentrefresh: '加载中',
  57. contentnomore: '没有更多'
  58. }
  59. })
  60. function goUpPage() {
  61. uni.redirectTo({
  62. url: '/pages/admin/ShouYe/shouye'
  63. })
  64. }
  65. function handleSearch() {
  66. data.page = 0;
  67. refreshData();
  68. }
  69. function checkKecheng(item) {
  70. uni.navigateTo({
  71. url: `/pages/admin/Kecheng/study?kcId=${item.kcId}`
  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. }
  85. data.list = [];
  86. // 数学
  87. data.state = 'loading';
  88. data.page++;
  89. opt.page = data.page;
  90. kechengApi.getKechengGlList(opt).then(res => {
  91. data.list = data.list.concat(res.data.data);
  92. data.loading = false;
  93. if (res.data.total > data.list.length) {
  94. data.state = 'more';
  95. data.loading = false;
  96. } else {
  97. data.state = 'no-more';
  98. data.loading = false;
  99. }
  100. }).catch(err => {
  101. data.state = 'more';
  102. data.loading = false;
  103. })
  104. }
  105. function getMore() {
  106. const opt = {
  107. page: 1,
  108. size: 10, // 固定查询10条
  109. }
  110. if (data.state == 'no-more') return;
  111. data.state = 'loading';
  112. data.page++;
  113. opt.page = data.page;
  114. kechengApi.getKechengGlList(opt).then(res => {
  115. data.list = data.list.concat(res.data.data);
  116. data.loading = false;
  117. if (res.data.total > data.list.length) {
  118. data.state = 'more';
  119. data.loading = false;
  120. } else {
  121. data.state = 'no-more';
  122. data.loading = false;
  123. }
  124. }).catch(err => {
  125. data.state = 'more';
  126. data.loading = false;
  127. })
  128. }
  129. onLoad(() => {
  130. getMore()
  131. })
  132. </script>
  133. <style lang="scss" scoped>
  134. .phone-kecheng-page {
  135. background-color: #ccc;
  136. box-sizing: border-box;
  137. }
  138. .phone-search-content {
  139. position: relative;
  140. background-color: #fff;
  141. height: 42px;
  142. .search-input {
  143. height: 42px;
  144. line-height: 40px;
  145. border-radius: 20px;
  146. border: 1px solid #ccc;
  147. padding: 0 70px 0 20px;
  148. }
  149. .search-icon {
  150. position: absolute;
  151. right: 5px;
  152. top: 4px;
  153. padding: 6px;
  154. background-color: #ccc;
  155. border-radius: 20px;
  156. width: 50px;
  157. text-align: center;
  158. }
  159. }
  160. </style>