information.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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 tabBar from '@/pages/component/tabBar.vue'
  31. export default {
  32. components: {
  33. tabBar
  34. },
  35. data() {
  36. return {
  37. queryParams: {
  38. page: 1,
  39. pageSize: 10,
  40. },
  41. total: 0,
  42. dataList: [],
  43. getDataType: false,
  44. typeList: [],
  45. }
  46. },
  47. onLoad() {
  48. },
  49. onShow() {
  50. },
  51. mounted() {
  52. this.systemNoticeGetNoticeType();
  53. },
  54. methods: {
  55. //详情页
  56. goInfoPage(item) {
  57. console.log('item',item)
  58. uni.navigateTo({
  59. url: '/pages/views/information/informationInfo?item=' + encodeURIComponent(JSON.stringify(item))
  60. });
  61. },
  62. //滚动事件
  63. scrollGet() {
  64. let self = this;
  65. if (self.total / self.queryParams.pageSize <= self.queryParams.page) {
  66. this.$set(this, 'getDataType', true);
  67. } else {
  68. this.queryParams.page += 1;
  69. this.$nextTick(() => {
  70. this.getList();
  71. })
  72. }
  73. },
  74. //获取列表数据
  75. async getList() {
  76. let self = this;
  77. const {
  78. data
  79. } = await systemNoticeGetNoticeList(this.queryParams);
  80. if (data.code == 200) {
  81. data.data.records.forEach((item) => {
  82. this.typeList.forEach((typeItem) => {
  83. if (typeItem.code == item.noticeType) {
  84. item.sendTime = parseTime(item.sendTime, "{y}-{m}-{d} {h}:{i}");
  85. item.className = typeItem.name;
  86. }
  87. })
  88. })
  89. if (self.queryParams.page == 1) {
  90. this.dataList = data.data.records;
  91. this.total = data.data.total;
  92. if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
  93. this.$set(this, 'getDataType', true);
  94. }
  95. } else {
  96. this.dataList = [...this.dataList, ...data.data.records]
  97. this.total = data.data.total;
  98. if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
  99. this.$set(this, 'getDataType', true);
  100. }
  101. }
  102. }
  103. },
  104. //获取系统消息类型
  105. async systemNoticeGetNoticeType() {
  106. let self = this;
  107. const {
  108. data
  109. } = await systemNoticeGetNoticeType();
  110. if (data.code == 200) {
  111. this.$set(this, 'typeList', data.data);
  112. this.getList();
  113. }
  114. },
  115. }
  116. }
  117. </script>
  118. <style lang="stylus" scoped>
  119. #information {
  120. height: 100%;
  121. display flex;
  122. flex-direction: column;
  123. background #fff;
  124. .info-max-box {
  125. flex: 1;
  126. overflow: scroll;
  127. background #fff;
  128. .for-info-box:nth-child(1) {
  129. border: none;
  130. }
  131. .for-info-box {
  132. height: 150rpx;
  133. border-top: 1rpx solid #F5F5F5;
  134. position: relative;
  135. display flex;
  136. img {
  137. border-radius: 50%;
  138. margin: 25rpx 28rpx 25rpx 20rpx;
  139. width: 100rpx;
  140. height: 100rpx;
  141. }
  142. .right-box {
  143. flex: 1;
  144. overflow: hidden;
  145. .top-box {
  146. display flex;
  147. line-height: 67rpx;
  148. margin-top: 7rpx;
  149. margin-right: 20rpx;
  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. .tips-box{
  182. position: absolute;
  183. top:0;
  184. left:0;
  185. background-color: #fa5151;
  186. }
  187. }
  188. .get-null-box {
  189. height: 100rpx;
  190. line-height: 100rpx;
  191. color: #999;
  192. text-align center
  193. padding-bottom:200rpx;
  194. }
  195. }
  196. }
  197. </style>