msg.nvue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view class="page">
  3. <!-- 状态栏占位 -->
  4. <view class="status-bar" :style="{height: statusBarHeight + 'px'}"></view>
  5. <!-- 自定义导航栏 -->
  6. <view class="nav-bar">
  7. <image src="/static/public/backBlack.png" mode="aspectFill" class="back-img" @click="goBack"></image>
  8. <text class="nav-title">消息中心</text>
  9. <view class="nav-right"></view>
  10. </view>
  11. <!-- 消息列表 -->
  12. <list class="msg-list" v-if="list.length > 0">
  13. <cell v-for="(itm, index) in list" :key="index">
  14. <view class="msg-item" @click="toDetail(itm)">
  15. <image class="msg-avatar" :src="itm.avatar || '/static/144x144.png'" mode="aspectFill"></image>
  16. <view class="msg-info">
  17. <view class="msg-top-line">
  18. <view class="msg-name-wrap">
  19. <text class="msg-name">{{itm.name || itm.phone || '系统'}}</text>
  20. <view class="msg-unread" v-if="itm.readFlag == '0'"></view>
  21. </view>
  22. <text class="msg-time">{{itm.createTime || ''}}</text>
  23. </view>
  24. <text class="msg-content">{{itm.content || '向您推荐了方案'}}</text>
  25. </view>
  26. </view>
  27. </cell>
  28. </list>
  29. <!-- 空状态 -->
  30. <view class="empty-wrap" v-else>
  31. <text class="empty-text">暂无消息</text>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. data() {
  38. return {
  39. statusBarHeight: 44,
  40. list: []
  41. }
  42. },
  43. onShow() {
  44. const sysInfo = uni.getSystemInfoSync()
  45. this.statusBarHeight = sysInfo.statusBarHeight || 44
  46. this.init()
  47. },
  48. onPullDownRefresh() {
  49. this.list = []
  50. this.init()
  51. },
  52. methods: {
  53. goBack() {
  54. uni.navigateBack()
  55. },
  56. toDetail(row) {
  57. // TODO: 后续对接后台接口
  58. // uni.navigateTo({ url: '/pages/detail/detail?id=' + row.dataId })
  59. },
  60. init() {
  61. // TODO: 后续对接后台接口获取消息列表
  62. uni.stopPullDownRefresh()
  63. }
  64. }
  65. }
  66. </script>
  67. <style>
  68. .page {
  69. flex: 1;
  70. background-color: #FFFFFF;
  71. }
  72. .status-bar {
  73. background-color: #FFFFFF;
  74. }
  75. .nav-bar {
  76. flex-direction: row;
  77. align-items: center;
  78. justify-content: space-between;
  79. height: 88rpx;
  80. padding-left: 54rpx;
  81. padding-right: 54rpx;
  82. background-color: #FFFFFF;
  83. }
  84. .back-img {
  85. width: 50rpx;
  86. height: 50rpx;
  87. }
  88. .nav-title {
  89. font-weight: bold;
  90. font-size: 32rpx;
  91. color: #545F71;
  92. }
  93. .nav-right {
  94. width: 50rpx;
  95. height: 50rpx;
  96. }
  97. /* 消息列表 */
  98. .msg-list {
  99. flex: 1;
  100. }
  101. .msg-item {
  102. flex-direction: row;
  103. align-items: center;
  104. margin-left: 38rpx;
  105. margin-right: 38rpx;
  106. padding-top: 20rpx;
  107. padding-bottom: 20rpx;
  108. border-bottom-width: 1px;
  109. border-bottom-color: #EEF1F4;
  110. border-bottom-style: solid;
  111. }
  112. .msg-avatar {
  113. width: 100rpx;
  114. height: 100rpx;
  115. border-radius: 100rpx;
  116. margin-right: 16rpx;
  117. }
  118. .msg-info {
  119. flex: 1;
  120. }
  121. .msg-top-line {
  122. flex-direction: row;
  123. justify-content: space-between;
  124. align-items: center;
  125. margin-bottom: 6rpx;
  126. }
  127. .msg-name-wrap {
  128. flex-direction: row;
  129. align-items: center;
  130. }
  131. .msg-name {
  132. font-size: 32rpx;
  133. color: #545F71;
  134. line-height: 44rpx;
  135. margin-right: 10rpx;
  136. }
  137. .msg-unread {
  138. width: 10rpx;
  139. height: 10rpx;
  140. background-color: #F65252;
  141. border-radius: 10rpx;
  142. }
  143. .msg-time {
  144. font-size: 26rpx;
  145. color: #9BA5B7;
  146. line-height: 44rpx;
  147. }
  148. .msg-content {
  149. font-size: 26rpx;
  150. color: #9BA5B7;
  151. line-height: 44rpx;
  152. }
  153. /* 空状态 */
  154. .empty-wrap {
  155. flex: 1;
  156. align-items: center;
  157. padding-top: 200rpx;
  158. }
  159. .empty-text {
  160. font-size: 28rpx;
  161. color: #9BA5B7;
  162. }
  163. </style>