index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view class="phone-list-page kecheng-list">
  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="xiaoxi-list-card-box" @click="checkKecheng(item)">
  15. <view class="card-name">{{item.zyName}}</view>
  16. <view>{{item.zyName}}{{item.zyLevelName}}</view>
  17. <view>课时:{{formatSecondsToCnhms(item.period, true)}}</view>
  18. <view>{{item.createTime}}</view>
  19. </view>
  20. </template>
  21. </uni-list-item>
  22. <uni-load-more :status="data.state" @click="getMore(0)" :contentText="data.contentText"></uni-load-more>
  23. </uni-list>
  24. </scroll-view>
  25. <!-- 页面底端 -->
  26. <customTabbarClientVue></customTabbarClientVue>
  27. </view>
  28. </template>
  29. <script setup>
  30. import customTabbarClientVue from "@/components/custom-tabbar/custom-tabbar-admin.vue";
  31. import {
  32. ref,
  33. reactive
  34. } from "vue";
  35. import {
  36. onLoad,
  37. onShow
  38. } from "@dcloudio/uni-app";
  39. import * as kechengApi from "@/api/kecheng.js"
  40. import {
  41. formatSecondsToCnhms
  42. } from "@/utils/common.js"
  43. const data = reactive({
  44. zyName: '', // 职业名称
  45. list: [], // 考试列表
  46. loading: false,
  47. page: 0,
  48. size: 10,
  49. state: 'more',
  50. contentText: {
  51. contentdown: '查看更多',
  52. contentrefresh: '加载中',
  53. contentnomore: '没有更多'
  54. },
  55. from: ''
  56. })
  57. function goUpPage() {
  58. const pages = getCurrentPages();
  59. if (pages.length > 1) {
  60. uni.navigateBack()
  61. } else {
  62. /* uni.redirectTo({
  63. url: '/pages/client/ShouYe/shouye'
  64. }) */
  65. history.back();
  66. }
  67. }
  68. function handleSearch() {
  69. data.page = 0;
  70. refreshData();
  71. }
  72. function checkKecheng(item) {
  73. uni.navigateTo({
  74. url: `/pages/client/Kecheng/study?kcId=${item.kcId}&from=kechengList`
  75. })
  76. }
  77. function onRefresh() {
  78. data.page = 0;
  79. data.list = [];
  80. data.loading = true;
  81. refreshData();
  82. }
  83. function refreshData() {
  84. const opt = {
  85. page: 1,
  86. size: 10, // 固定查询10条
  87. zyName: data.zyName
  88. }
  89. data.list = [];
  90. // 数学
  91. data.state = 'loading';
  92. data.page++;
  93. opt.page = data.page;
  94. kechengApi.getClientKechengList(opt).then(res => {
  95. data.list = data.list.concat(res.data.data);
  96. data.loading = false;
  97. if (res.data.total > data.list.length) {
  98. data.state = 'more';
  99. data.loading = false;
  100. } else {
  101. data.state = 'no-more';
  102. data.loading = false;
  103. }
  104. }).catch(err => {
  105. data.state = 'more';
  106. data.loading = false;
  107. })
  108. }
  109. function getMore() {
  110. const opt = {
  111. page: 1,
  112. size: 10, // 固定查询10条
  113. zyName: data.zyName
  114. }
  115. if (data.state == 'no-more') return;
  116. data.state = 'loading';
  117. data.page++;
  118. opt.page = data.page;
  119. kechengApi.getClientKechengList(opt).then(res => {
  120. data.list = data.list.concat(res.data.data);
  121. data.loading = false;
  122. if (res.data.total > data.list.length) {
  123. data.state = 'more';
  124. data.loading = false;
  125. } else {
  126. data.state = 'no-more';
  127. data.loading = false;
  128. }
  129. }).catch(err => {
  130. data.state = 'more';
  131. data.loading = false;
  132. })
  133. }
  134. onLoad((options) => {
  135. data.from = options.from;
  136. })
  137. onShow(() => {
  138. getMore()
  139. })
  140. </script>