messageList.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view class="container">
  3. <scroll-view class="message-list-box" scroll-y="true" @scrolltolower="handleLoadMore()">
  4. <view style="padding-top: 20px;background-color: #FFFFFF;" v-if="messageList.length<=0">
  5. <u-divider color="#909399" border-color="#909399">没有更多了</u-divider>
  6. </view>
  7. <view class="message-row" v-for="(item, index1) in messageList" :key="index1">
  8. <image class="message-head" :src="item.headImg"></image>
  9. <view class="message-info-box">
  10. <view class="message-name">{{item.userName}}</view>
  11. <view class="message-date">{{item.leaMsgTime}}</view>
  12. <view class="message-text">{{item.leaMsgContent}}</view>
  13. <view class="message-img-box" v-for="(site, index2) in item.orderLeaImgResVOs" :key="index2">
  14. <!-- <image class="message-img -->" :src="site.imgUrl" mode="aspectFill"></image>
  15. </view>
  16. </view>
  17. </view>
  18. </scroll-view>
  19. <view class="message-handle">
  20. <u-button type="success" shape="circle" :ripple="true" @click="addMessage" class="handle-custom">发布留言</u-button>
  21. </view>
  22. <u-top-tips ref="uTips"></u-top-tips>
  23. </view>
  24. </template>
  25. <script>
  26. const NET = require('@/utils/request')
  27. const API = require('@/config/api')
  28. export default {
  29. data() {
  30. return {
  31. orderId: '',
  32. tenantCode: '',
  33. pageIndex: 1,
  34. isOver: false,
  35. messageList: [],
  36. }
  37. },
  38. onLoad(options) {
  39. this.orderId = options.orderId
  40. this.tenantCode = options.tenantCode
  41. },
  42. onShow() {
  43. this.pageIndex = 1
  44. this.messageList = []
  45. this.getMessageList()
  46. },
  47. onPullDownRefresh() {
  48. this.pageIndex = 1
  49. this.messageList = []
  50. this.getMessageList('refresh')
  51. },
  52. methods: {
  53. // 懒加载
  54. handleLoadMore() {
  55. if (!this.isOver) {
  56. this.pageIndex++
  57. this.getMessageList()
  58. }
  59. },
  60. // 获取全部留言
  61. getMessageList(type) {
  62. NET.request(API.getMessageList + this.pageIndex + '/10', {
  63. flag: 1,
  64. orderId: this.orderId
  65. }, 'GET').then(res => {
  66. if (type == 'refresh') {
  67. uni.stopPullDownRefresh();
  68. }
  69. this.isOver = res.data.list.length != 10
  70. this.messageList = this.messageList.concat(res.data.list)
  71. }).catch(error => {
  72. this.$refs.uTips.show({
  73. title: error.data.msg,
  74. type: 'warning',
  75. })
  76. })
  77. },
  78. // 新增留言
  79. addMessage() {
  80. uni.navigateTo({
  81. url: '/pagesMain/messageForm?orderId=' + this.orderId + '&tenantCode=' + this.tenantCode
  82. });
  83. },
  84. }
  85. }
  86. </script>
  87. <style lang="less" scoped>
  88. page {
  89. width: 100%;
  90. height: 100%;
  91. }
  92. .container {
  93. width: 100%;
  94. height: 100%;
  95. float: left;
  96. position: relative;
  97. .message-list-box {
  98. width: 100%;
  99. height: calc(100% - 70px);
  100. float: left;
  101. .message-row {
  102. width: calc(100% - 30px);
  103. float: left;
  104. padding-bottom: 15px;
  105. border-bottom: 1px solid #F6F6F6;
  106. margin: 0 15px 15px 15px;
  107. .message-head {
  108. width: 50px;
  109. height: 50px;
  110. object-fit: cover;
  111. float: left;
  112. border-radius: 50%;
  113. overflow: hidden;
  114. }
  115. .message-info-box {
  116. width: calc(100% - 75px);
  117. float: right;
  118. .message-name {
  119. width: 50%;
  120. height: 30px;
  121. float: left;
  122. font-size: 15px;
  123. font-family: PingFang SC;
  124. color: #333333;
  125. line-height: 30px;
  126. overflow: hidden;
  127. text-overflow: ellipsis;
  128. white-space: nowrap;
  129. }
  130. .message-date {
  131. width: 50%;
  132. height: 30px;
  133. float: left;
  134. font-size: 12px;
  135. font-family: PingFang SC;
  136. color: #666666;
  137. text-align: right;
  138. line-height: 30px;
  139. overflow: hidden;
  140. text-overflow: ellipsis;
  141. white-space: nowrap;
  142. }
  143. .message-text {
  144. width: 100%;
  145. height: 20px;
  146. float: left;
  147. font-size: 12px;
  148. font-family: PingFang SC;
  149. color: #666666;
  150. line-height: 20px;
  151. overflow: hidden;
  152. text-overflow: ellipsis;
  153. white-space: nowrap;
  154. }
  155. .message-img-box {
  156. width: 100%;
  157. float: left;
  158. .message-img {
  159. width: 76px;
  160. height: 76px;
  161. object-fit: cover;
  162. float: left;
  163. margin: 0 10px 10px 0;
  164. }
  165. }
  166. }
  167. }
  168. }
  169. .message-handle {
  170. width: calc(100% - 30px);
  171. height: 40px;
  172. position: fixed;
  173. bottom: 20px;
  174. left: 15px;
  175. .handle-custom {
  176. background-color: #51A539;
  177. /deep/button {
  178. background-color: #56a83a;
  179. }
  180. /deep/.u-btn--success--disabled {
  181. background-color: #74bd60 !important;
  182. }
  183. }
  184. }
  185. }
  186. </style>