list.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. const pages = getCurrentPages();
  65. if (pages.length > 1) {
  66. uni.navigateBack()
  67. } else {
  68. /* uni.redirectTo({
  69. url: '/pages/client/ShouYe/shouye'
  70. }) */
  71. history.back();
  72. }
  73. }
  74. function handleSearch() {
  75. data.page = 0;
  76. refreshData();
  77. }
  78. function checkKecheng(item) {
  79. uni.navigateTo({
  80. url: `/pages/admin/tongzhi/details?noticeId=${item.noticeId}`
  81. })
  82. }
  83. function onRefresh() {
  84. data.page = 0;
  85. data.list = [];
  86. data.loading = true;
  87. refreshData();
  88. }
  89. function refreshData() {
  90. const opt = {
  91. page: 1,
  92. size: 10, // 固定查询10条
  93. }
  94. data.list = [];
  95. // 数学
  96. data.state = 'loading';
  97. data.page++;
  98. opt.page = data.page;
  99. getAppNoticeList(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. }
  119. if (data.state == 'no-more') return;
  120. data.state = 'loading';
  121. data.page++;
  122. opt.page = data.page;
  123. getAppNoticeList(opt).then(res => {
  124. data.list = data.list.concat(res.data.data);
  125. data.loading = false;
  126. if (res.data.total > data.list.length) {
  127. data.state = 'more';
  128. data.loading = false;
  129. } else {
  130. data.state = 'no-more';
  131. data.loading = false;
  132. }
  133. }).catch(err => {
  134. data.state = 'more';
  135. data.loading = false;
  136. })
  137. }
  138. onLoad((options) => {
  139. data.from = options.from;
  140. })
  141. onShow(() => {
  142. getMore()
  143. })
  144. </script>