list.vue 3.7 KB

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