list.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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"
  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-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 handleSearch() {
  69. data.page = 0;
  70. refreshData();
  71. }
  72. function checkKecheng(item) {
  73. uni.navigateTo({
  74. url: `/pages/admin/tongzhi/details?noticeId=${item.noticeId}`
  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. }
  88. data.list = [];
  89. // 数学
  90. data.state = 'loading';
  91. data.page++;
  92. opt.page = data.page;
  93. getAppNoticeList(opt).then(res => {
  94. data.list = data.list.concat(res.data.data);
  95. data.loading = false;
  96. if (res.data.total > data.list.length) {
  97. data.state = 'more';
  98. data.loading = false;
  99. } else {
  100. data.state = 'no-more';
  101. data.loading = false;
  102. }
  103. }).catch(err => {
  104. data.state = 'more';
  105. data.loading = false;
  106. })
  107. }
  108. function getMore() {
  109. const opt = {
  110. page: 1,
  111. size: 10, // 固定查询10条
  112. }
  113. if (data.state == 'no-more') return;
  114. data.state = 'loading';
  115. data.page++;
  116. opt.page = data.page;
  117. getAppNoticeList(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((options) => {
  133. data.from = options.from;
  134. })
  135. onShow(() => {
  136. getMore()
  137. })
  138. </script>