information.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. item.isRead = true;
  61. uni.navigateTo({
  62. url: '/pages/views/information/informationInfo?item=' + encodeURIComponent(JSON.stringify(item))
  63. });
  64. },
  65. //滚动事件
  66. scrollGet() {
  67. let self = this;
  68. if (self.total / self.queryParams.pageSize <= self.queryParams.page) {
  69. this.$set(this, 'getDataType', true);
  70. } else {
  71. this.queryParams.page += 1;
  72. this.$nextTick(() => {
  73. this.getList();
  74. })
  75. }
  76. },
  77. //获取列表数据
  78. async getList() {
  79. let self = this;
  80. const {
  81. data
  82. } = await systemNoticeGetNoticeList(this.queryParams);
  83. if (data.code == 200) {
  84. data.data.records.forEach((item) => {
  85. this.typeList.forEach((typeItem) => {
  86. if (typeItem.code == item.noticeType) {
  87. item.sendTime = parseTime(item.sendTime, "{y}-{m}-{d} {h}:{i}");
  88. item.className = typeItem.name;
  89. }
  90. })
  91. })
  92. if (self.queryParams.page == 1) {
  93. this.dataList = data.data.records;
  94. this.total = data.data.total;
  95. if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
  96. this.$set(this, 'getDataType', true);
  97. }
  98. } else {
  99. this.dataList = [...this.dataList, ...data.data.records]
  100. this.total = data.data.total;
  101. if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
  102. this.$set(this, 'getDataType', true);
  103. }
  104. }
  105. }
  106. },
  107. //获取系统消息类型
  108. async systemNoticeGetNoticeType() {
  109. let self = this;
  110. const {
  111. data
  112. } = await systemNoticeGetNoticeType();
  113. if (data.code == 200) {
  114. this.$set(this, 'typeList', data.data);
  115. this.getList();
  116. }
  117. },
  118. }
  119. }
  120. </script>
  121. <style lang="stylus" scoped>
  122. #information {
  123. height: 100%;
  124. display flex;
  125. flex-direction: column;
  126. background #fff;
  127. .info-max-box {
  128. flex: 1;
  129. overflow: scroll;
  130. background #fff;
  131. .for-info-box:nth-child(1) {
  132. border: none;
  133. }
  134. .for-info-box {
  135. height: 150rpx;
  136. border-top: 1rpx solid #F5F5F5;
  137. position: relative;
  138. display flex;
  139. img {
  140. border-radius: 50%;
  141. margin: 25rpx 28rpx 25rpx 20rpx;
  142. width: 100rpx;
  143. height: 100rpx;
  144. }
  145. .right-box {
  146. flex: 1;
  147. overflow: hidden;
  148. .top-box {
  149. display flex;
  150. line-height: 67rpx;
  151. margin-top: 7rpx;
  152. margin-right: 20rpx;
  153. view:nth-child(1) {
  154. font-size: 30rpx;
  155. color: #333333;
  156. margin-right: 28rpx;
  157. }
  158. view:nth-child(2) {
  159. font-size: 24rpx;
  160. color: #999;
  161. flex: 1;
  162. display: block;
  163. overflow: hidden;
  164. text-overflow: ellipsis;
  165. white-space: nowrap;
  166. }
  167. view:nth-child(3) {
  168. font-size: 20rpx;
  169. color: #999;
  170. text-align right;
  171. }
  172. }
  173. .bottom {
  174. width: 530rpx;
  175. line-height: 62rpx;
  176. font-size: 25rpx;
  177. color: #666666;
  178. display block;
  179. overflow: hidden;
  180. text-overflow: ellipsis;
  181. white-space: nowrap;
  182. }
  183. }
  184. .tips-box{
  185. position: absolute;
  186. top: 55px;
  187. left: 50px;
  188. background-color: #fa5151;
  189. width: 15rpx;
  190. height: 15rpx;
  191. border-radius: 50%;
  192. }
  193. }
  194. .get-null-box {
  195. height: 100rpx;
  196. line-height: 100rpx;
  197. color: #999;
  198. text-align center
  199. padding-bottom:200rpx;
  200. }
  201. }
  202. }
  203. </style>