liaotian.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <view class="">
  3. <view v-if="chatList.length" class="content ">
  4. <view class="radius padding-lr-sm bg" style="margin-top: 4rpx;" @click="goIM(item)"
  5. v-for="(item,index) in chatList" :key='index'>
  6. <view class="flex padding-tb " v-if="userId == item.userId">
  7. <view>
  8. <u-image shape="circle" width='80rpx' height="80rpx" :src="item.shopCover"></u-image>
  9. </view>
  10. <view class="flex-sub margin-left-sm">
  11. <view class="flex justify-between">
  12. <view style="width: 55%;">{{item.shopName}}</view>
  13. <view class="text-grey">{{item.createTime}}</view>
  14. </view>
  15. <view class="flex justify-between">
  16. <view class="text-grey">{{ item.messageType == 1? item.content : '[图片]'}}</view>
  17. <view v-if="item.riderUnread"
  18. style="height: 32rpx;width: 32rpx;border-radius: 100rpx;background-color: red;color: #FFF;text-align: center;">
  19. {{item.riderUnread}}
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="flex padding-tb" v-else>
  25. <view>
  26. <u-image shape="circle" width='80rpx' height="80rpx" :src="item.shopCover"></u-image>
  27. </view>
  28. <view class="flex-sub margin-left-sm">
  29. <view class="flex justify-between">
  30. <view style="width: 55%;">{{item.shopName}}</view>
  31. <view class="text-grey">{{item.createTime}}</view>
  32. </view>
  33. <view class="flex justify-between">
  34. <view class="text-grey">{{ item.messageType == 1? item.content : '[图片]'}}</view>
  35. <view v-if="item.riderUnread"
  36. style="height: 32rpx;width: 32rpx;border-radius: 100rpx;background-color: red;color: #FFF;text-align: center;">
  37. {{item.riderUnread}}
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <empty v-if="!chatList.length && !msgList.length" content='暂无消息'></empty>
  45. </view>
  46. </template>
  47. <script>
  48. import empty from '../../../components/empty.vue'
  49. export default {
  50. components: {
  51. empty
  52. },
  53. data() {
  54. return {
  55. page: 1,
  56. limit: 20,
  57. chatList: [],
  58. userId: '',
  59. msgList: [],
  60. count: 0,
  61. time: '',
  62. messageCount: 0,
  63. scrollTop: false,
  64. }
  65. },
  66. onPullDownRefresh: function() {
  67. this.page = 1;
  68. this.getChatList();
  69. },
  70. onLoad() {
  71. this.$queue.showLoading("加载中...")
  72. that.userId = uni.getStorageSync('userId')
  73. if (that.userId) {
  74. that.time = setInterval(function() {
  75. that.getChatList()
  76. // that.getMsgList()
  77. that.$nextTick(function() {
  78. that.messageCount = uni.getStorageSync('messageCount')
  79. })
  80. }, 10000)
  81. } else {
  82. that.chatList = []
  83. that.msgList = []
  84. }
  85. },
  86. onShow() {
  87. let that = this
  88. this.page = 1;
  89. this.getChatList();
  90. },
  91. onHide() {
  92. clearInterval(this.time)
  93. },
  94. methods: {
  95. getChatList() {
  96. this.$Request.getT("/app/ordersChat/selectOrdersChatPageRider", {
  97. page: this.page,
  98. limit: this.limit,
  99. // shopId: uni.getStorageSync('shopId')
  100. }).then(res => {
  101. if (res.code === 0) {
  102. this.totalCount = res.data.totalCount
  103. if (this.page == 1) {
  104. this.chatList = res.data.list
  105. } else {
  106. res.data.list.forEach(d => {
  107. this.chatList.push(d);
  108. });
  109. }
  110. this.count = res.data.totalCount;
  111. }
  112. uni.hideLoading();
  113. uni.stopPullDownRefresh();
  114. // if (res.code == 0) {
  115. // this.chatList = res.data.list
  116. // }
  117. });
  118. },
  119. goIM(e) {
  120. let userId = this.$queue.getData('userId');
  121. if (e.userId == userId) {
  122. userId = e.byUserId
  123. } else {
  124. userId = e.userId
  125. }
  126. uni.navigateTo({
  127. url: '/pages/riderMy/kefu/liaotianshi?orderId=' + e.ordersId
  128. })
  129. },
  130. goMsg() {
  131. uni.navigateTo({
  132. url: '/pages/msg/message'
  133. })
  134. }
  135. },
  136. onPageScroll: function(e) {
  137. this.scrollTop = e.scrollTop > 200;
  138. },
  139. onReachBottom: function() {
  140. if (this.chatList.length == this.count) {
  141. uni.showToast({
  142. title: '已经到底了',
  143. icon: 'none'
  144. })
  145. } else {
  146. this.page = this.page + 1;
  147. this.getChatList();
  148. }
  149. },
  150. }
  151. </script>
  152. <style>
  153. page {
  154. background-color: #F7F7F7;
  155. }
  156. .bg {
  157. background: #FFFFFF;
  158. }
  159. </style>