announcementAll.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view class="container">
  3. <view class="message_list" v-if="list.length">
  4. <view class="mim-view" v-for="(item) in list" :key="item.id">
  5. <view class="storm mim-flex-wrap-space-between">
  6. <view class="mim-flex-vertical" style="max-width: 60%;">
  7. <text class="mim-multi-line msg_p">{{item.title}}</text>
  8. <text class="msg_time">{{item.created_at}}</text>
  9. </view>
  10. <view class="mim-button details" @click="goDetails(item.id)">查看详情</view>
  11. </view>
  12. </view>
  13. <u-divider bg-color='#f7f7f7' fontSize='24' class="divider">{{divider}}</u-divider>
  14. </view>
  15. <view v-else style="margin-top: 350rpx;">
  16. <u-empty></u-empty>
  17. </view>
  18. <view class="mim-view-list"></view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. data() {
  24. return {
  25. title: '',
  26. list: [],
  27. form: {
  28. type_id: '',
  29. page: 1,
  30. per_page: 10,
  31. },
  32. page: '',
  33. divider: '没有更多数据啦~'
  34. };
  35. },
  36. onLoad(option) {
  37. this.form.type_id = option.type
  38. switch (option.type) {
  39. case '2': //罗山新闻
  40. this.title = "罗山新闻"
  41. break;
  42. case '3': //罗山县情
  43. this.title = "罗山县情"
  44. break;
  45. case '4': //发展动态
  46. this.title = "发展动态"
  47. break;
  48. case '5': //营商环境
  49. this.title = "营商环境"
  50. break;
  51. case '6': //全域旅游
  52. this.title = "全域旅游"
  53. break;
  54. default: //公告版
  55. this.title = "公告板"
  56. break;
  57. }
  58. this.infoListFn()
  59. },
  60. onPullDownRefresh() {
  61. //下拉刷新
  62. this.form.page = 1
  63. this.infoListFn()
  64. },
  65. onReachBottom() {
  66. //触底加载
  67. console.log('触底加载')
  68. this.divider = '加载中。。。'
  69. let page = this.form.page
  70. if (this.page > page) {
  71. page++
  72. this.form.page = page
  73. this.infoListFn()
  74. } else {
  75. this.divider = '没有更多数据啦~'
  76. uni.showToast({
  77. title: '没有更多数据啦~',
  78. icon: 'none'
  79. })
  80. }
  81. },
  82. methods: {
  83. //初始化页面
  84. async infoListFn() {
  85. uni.showNavigationBarLoading()
  86. const res = await this.$u.api.infoList(this.form)
  87. console.log(res)
  88. if (res.status === "success") {
  89. const {
  90. data: {
  91. data,
  92. meta
  93. }
  94. } = res
  95. this.meta = meta
  96. this.page = this.meta.pagination.total_pages
  97. if (this.page > 1) {
  98. this.list = this.list.concat(data)
  99. } else {
  100. this.list = data
  101. }
  102. this.divider = '没有更多数据啦~'
  103. }
  104. uni.hideNavigationBarLoading()
  105. uni.stopPullDownRefresh();
  106. },
  107. //查看详情
  108. goDetails(e) {
  109. this.$u.route('/pages/detailPage/detailPage', {
  110. id: e,
  111. type: this.form.type_id
  112. });
  113. }
  114. }
  115. }
  116. </script>
  117. <style lang="scss">
  118. page {
  119. background-color: #f7f7f7;
  120. .container {
  121. .message_list {
  122. .storm {
  123. .msg_p {
  124. font-size: 30rpx;
  125. font-weight: normal;
  126. line-height: 36rpx;
  127. letter-spacing: 0em;
  128. color: #333333;
  129. }
  130. .msg_time {
  131. font-size: 24rpx;
  132. font-weight: normal;
  133. line-height: 24rpx;
  134. letter-spacing: 0em;
  135. color: #999999;
  136. margin-top: 32rpx;
  137. }
  138. }
  139. .details {
  140. width: 176rpx;
  141. height: 64rpx;
  142. margin-left: 30rpx;
  143. }
  144. }
  145. }
  146. }
  147. </style>