message.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <view class="container">
  3. <!-- 每一个消息区域 -->
  4. <view class="box" v-for="item in msgList" :key="item.id" @click="handleRead(item)">
  5. <view class="box_time">{{ item.updateTime }}</view>
  6. <view class="box_info">
  7. <view class="info_circle" :class="{ while: item.isRead === 1 }"></view>
  8. <view class="info_icon">
  9. <img src="../../static/images/repairsImg/msg.png" />
  10. </view>
  11. <view class="info_msg">
  12. <view class="msg_title">{{ item.content }}</view>
  13. <view class="msg_order">订单号:{{ item.recordNo }}</view>
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. export default {
  21. data() {
  22. return {
  23. // 信息列表
  24. msgList: [],
  25. // 用户id
  26. userId: '',
  27. // 当前页
  28. currentPage: 1,
  29. // 每页多少条
  30. pageCount: 8,
  31. // 总条数
  32. total: null
  33. }
  34. },
  35. onLoad(options) {
  36. const repairsUserInfo = uni.getStorageSync('repairsUserInfo')
  37. this.userId = repairsUserInfo.userId
  38. if (options.list) {
  39. this.msgList = JSON.parse(options.list)
  40. this.total = options.total
  41. } else {
  42. this.getMsgList()
  43. }
  44. },
  45. // 页面上拉触底回调
  46. onReachBottom() {
  47. if (this.total > this.msgList.length) {
  48. this.currentPage++
  49. this.getMsgList()
  50. } else {
  51. uni.showToast({
  52. title: '没有更多数据了',
  53. icon: 'none'
  54. })
  55. }
  56. },
  57. methods: {
  58. // 点击信息回调
  59. async handleRead(item) {
  60. // 未读信息
  61. if (item.isRead === 0) {
  62. const res = await this.$myRequest_repairs({
  63. url: '/repairSystemMessages/readSystemMessage',
  64. data: {
  65. id: item.id
  66. }
  67. })
  68. // console.log(res)
  69. if (res.code === '200') {
  70. uni.navigateTo({
  71. url: `/pagesRepairs/repairDetails/repairDetails?id=${item.recordId}`
  72. })
  73. }
  74. } else {
  75. uni.navigateTo({
  76. url: `/pagesRepairs/repairDetails/repairDetails?id=${item.recordId}`
  77. })
  78. }
  79. },
  80. // 获取列表信息
  81. async getMsgList() {
  82. const res = await this.$myRequest_repairs({
  83. url: '/repairSystemMessages/querySystemMessagePage',
  84. data: {
  85. currentPage: this.currentPage,
  86. pageCount: this.pageCount,
  87. userId: this.userId
  88. }
  89. })
  90. // console.log(res)
  91. if (res.code === '200') {
  92. this.total = res.data.totalCount
  93. this.msgList = [...this.msgList, ...res.data.list]
  94. }
  95. }
  96. }
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. .container {
  101. width: 100vw;
  102. min-height: 100vh;
  103. background-color: #f2f2f2;
  104. overflow-y: auto;
  105. .box {
  106. margin-top: 10rpx;
  107. height: 194rpx;
  108. background-color: #fff;
  109. .box_time {
  110. height: 76rpx;
  111. line-height: 76rpx;
  112. text-align: center;
  113. color: #999999;
  114. font-size: 24rpx;
  115. }
  116. .box_info {
  117. display: flex;
  118. align-items: center;
  119. margin-left: 30rpx;
  120. .info_circle {
  121. width: 16rpx;
  122. height: 16rpx;
  123. border-radius: 50%;
  124. background-color: #d43030;
  125. }
  126. .while {
  127. background-color: #fff;
  128. }
  129. .info_icon {
  130. margin: 0 8rpx;
  131. width: 90rpx;
  132. height: 90rpx;
  133. img {
  134. width: 100%;
  135. height: 100%;
  136. }
  137. }
  138. .info_msg {
  139. flex: 1;
  140. overflow: hidden;
  141. .msg_title {
  142. font-size: 32rpx;
  143. font-weight: bold;
  144. overflow: hidden;
  145. text-overflow: ellipsis;
  146. white-space: nowrap;
  147. }
  148. .msg_order {
  149. margin-top: 10rpx;
  150. color: #808080;
  151. font-size: 24rpx;
  152. }
  153. }
  154. }
  155. }
  156. }
  157. </style>