information.vue 4.5 KB

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