information.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <!-- 消息 -->
  2. <template>
  3. <view id="information">
  4. <scroll-view scroll-y @scrolltolower="scrollGet" class="info-max-box">
  5. <view class="for-info-box" v-for="(item,index) in dataList" :key="index" @click="goInfoPage(item)">
  6. <img src="@/pages/images/icon_xx_tz.png">
  7. <view class="right-box">
  8. <view class="top-box">
  9. <view>{{item.className}}</view>
  10. <view>{{item.userName}}</view>
  11. <view>{{item.sendTime}}</view>
  12. </view>
  13. <view class="bottom">{{item.title}}</view>
  14. </view>
  15. </view>
  16. <view class="get-null-box" v-if="!dataList[0]">暂无更多数据</view>
  17. </scroll-view>
  18. <tab-bar ref='infoAll'></tab-bar>
  19. </view>
  20. </template>
  21. <script>
  22. import {
  23. parseTime
  24. } from '@/component/public.js'
  25. import {
  26. systemNoticeGetNoticeType,
  27. systemNoticeGetNoticeList
  28. } from '@/pages/api/index.js'
  29. import {
  30. tabBar
  31. } from '@/pages/component/tabBar.vue'
  32. export default {
  33. components: {
  34. tabBar
  35. },
  36. data() {
  37. return {
  38. queryParams: {
  39. page: 1,
  40. pageSize: 10,
  41. },
  42. total: 0,
  43. dataList: [],
  44. getDataType: false,
  45. typeList: [],
  46. }
  47. },
  48. onLoad() {
  49. },
  50. onShow() {
  51. },
  52. mounted() {
  53. this.systemNoticeGetNoticeType();
  54. },
  55. methods: {
  56. //详情页
  57. goInfoPage(item) {
  58. console.log('item',item)
  59. uni.navigateTo({
  60. url: '/pages/views/information/informationInfo?item=' + encodeURIComponent(JSON.stringify(item))
  61. });
  62. },
  63. //滚动事件
  64. scrollGet() {
  65. let self = this;
  66. if (self.total / self.queryParams.pageSize <= self.queryParams.page) {
  67. this.$set(this, 'getDataType', true);
  68. } else {
  69. this.queryParams.page += 1;
  70. this.$nextTick(() => {
  71. this.getList();
  72. })
  73. }
  74. },
  75. //获取列表数据
  76. async getList() {
  77. let self = this;
  78. const {
  79. data
  80. } = await systemNoticeGetNoticeList(this.queryParams);
  81. if (data.code == 200) {
  82. data.data.records.forEach((item) => {
  83. this.typeList.forEach((typeItem) => {
  84. if (typeItem.code == item.noticeType) {
  85. item.sendTime = parseTime(item.sendTime, "{y}-{m}-{d} {h}:{i}");
  86. item.className = typeItem.name;
  87. }
  88. })
  89. })
  90. if (self.queryParams.page == 1) {
  91. this.dataList = data.data.records;
  92. this.total = data.data.total;
  93. if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
  94. this.$set(this, 'getDataType', true);
  95. }
  96. } else {
  97. this.dataList = [...this.dataList, ...data.data.records]
  98. this.total = data.data.total;
  99. if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
  100. this.$set(this, 'getDataType', true);
  101. }
  102. }
  103. }
  104. },
  105. //获取系统消息类型
  106. async systemNoticeGetNoticeType() {
  107. let self = this;
  108. const {
  109. data
  110. } = await systemNoticeGetNoticeType();
  111. if (data.code == 200) {
  112. this.$set(this, 'typeList', data.data);
  113. this.getList();
  114. }
  115. },
  116. }
  117. }
  118. </script>
  119. <style lang="stylus" scoped>
  120. #information {
  121. height: 100%;
  122. display flex;
  123. background #fff;
  124. .info-max-box {
  125. flex: 1;
  126. overflow: scroll;
  127. padding-bottom: 100rpx;
  128. background #fff;
  129. margin: 0 20rpx;
  130. .for-info-box:nth-child(1) {
  131. border: none;
  132. }
  133. .for-info-box {
  134. height: 150rpx;
  135. border-top: 1rpx solid #F5F5F5;
  136. display flex;
  137. img {
  138. border-radius: 50%;
  139. margin: 25rpx 28rpx 25rpx 20rpx;
  140. width: 100rpx;
  141. height: 100rpx;
  142. }
  143. .right-box {
  144. flex: 1;
  145. overflow: hidden;
  146. .top-box {
  147. display flex;
  148. line-height: 67rpx;
  149. margin-top: 7rpx;
  150. view:nth-child(1) {
  151. font-size: 30rpx;
  152. color: #333333;
  153. margin-right: 28rpx;
  154. }
  155. view:nth-child(2) {
  156. font-size: 24rpx;
  157. color: #999;
  158. flex: 1;
  159. display: block;
  160. overflow: hidden;
  161. text-overflow: ellipsis;
  162. white-space: nowrap;
  163. }
  164. view:nth-child(3) {
  165. font-size: 20rpx;
  166. color: #999;
  167. text-align right;
  168. }
  169. }
  170. .bottom {
  171. width: 530rpx;
  172. line-height: 62rpx;
  173. font-size: 25rpx;
  174. color: #666666;
  175. display block;
  176. overflow: hidden;
  177. text-overflow: ellipsis;
  178. white-space: nowrap;
  179. }
  180. }
  181. }
  182. .get-null-box {
  183. height: 100rpx;
  184. line-height: 100rpx;
  185. color: #999;
  186. text-align center
  187. }
  188. }
  189. }
  190. </style>