index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <div class="CustomerList">
  3. <block v-if="type == 0 && list.length>0" v-for="(item,index) in list" :key="index">
  4. <div class="item acea-row" @click="goPage(item)">
  5. <view class="logo">
  6. <image :src="item.merchant.mer_avatar" mode=""></image>
  7. </view>
  8. <view class="info">
  9. <view class="name">{{item.merchant.mer_name}}</view>
  10. <view class="con line1" v-if="item.last.msn_type == 1">{{item.last.msn}}</view>
  11. <view class="con line1" v-if="item.last.msn_type == 2">[表情]</view>
  12. <view class="con line1" v-if="item.last.msn_type == 3">[图片]</view>
  13. <view class="con line1" v-if="item.last.msn_type == 4">[商品]</view>
  14. <view class="con line1" v-if="item.last.msn_type == 5 || item.last.msn_type == 6">[订单]</view>
  15. </view>
  16. <view class="right-box">
  17. <view class="time">{{item.last && item.last.create_time}}</view>
  18. <view class="num" v-if="item.num>0">{{item.num}}</view>
  19. </view>
  20. </div>
  21. </block>
  22. <block v-if="type == 1 && list.length>0" v-for="(item,index) in list" :key="index">
  23. <div class="item acea-row" @click="goPage(item)">
  24. <view class="logo">
  25. <image v-if="item.user.avatar" :src="item.user.avatar" mode=""></image>
  26. <image v-else src="/static/images/f.png" mode=""></image>
  27. </view>
  28. <view class="info">
  29. <view class="name">{{item.user.nickname}}</view>
  30. <view class="con line1" v-if="item.last.msn_type == 1">{{item.last.msn}}</view>
  31. <view class="con line1" v-if="item.last.msn_type == 2">[表情]</view>
  32. <view class="con line1" v-if="item.last.msn_type == 3">[图片]</view>
  33. <view class="con line1" v-if="item.last.msn_type == 4 || item.last.msn_type == 7">[商品]</view>
  34. <view class="con line1" v-if="item.last.msn_type == 5 || item.last.msn_type == 6">[订单]</view>
  35. </view>
  36. <view class="right-box">
  37. <view class="time">{{item.last && item.last.create_time}}</view>
  38. <view class="num" v-if="item.num>0">{{item.num}}</view>
  39. </view>
  40. </div>
  41. </block>
  42. <block v-if="list.length == 0">
  43. <emptyPage title="暂无数据~"></emptyPage>
  44. </block>
  45. </div>
  46. </template>
  47. <script>
  48. import emptyPage from '@/components/emptyPage.vue'
  49. import {
  50. serviceList,
  51. serviceUserList
  52. } from "@/api/user";
  53. export default {
  54. name: "CustomerList",
  55. components:{
  56. emptyPage
  57. },
  58. data() {
  59. return {
  60. list: [],
  61. productId: 0,
  62. orderId: "",
  63. type: 0 ,// 0 用户 1客服
  64. timer: null,
  65. page:1,
  66. limit:9999
  67. };
  68. },
  69. onLoad(optios) {
  70. this.type = optios.type
  71. },
  72. onShow(option) {
  73. this.getList();
  74. this.liveUpdate()
  75. },
  76. onHide(){
  77. if(this.timer) {
  78. clearInterval(this.timer);
  79. this.timer = null;
  80. }
  81. },
  82. onUnload() {
  83. if(this.timer) {
  84. clearInterval(this.timer);
  85. this.timer = null;
  86. }
  87. },
  88. methods: {
  89. getList() {
  90. if(this.type == 0){
  91. serviceList({
  92. page:this.page,
  93. limit:this.limit
  94. }).then(res => {
  95. this.list = res.data.list;
  96. });
  97. }else{
  98. serviceUserList({
  99. page:this.page,
  100. limit:this.limit
  101. }).then(res =>{
  102. this.list = res.data.list;
  103. })
  104. }
  105. },
  106. //实时刷新列表
  107. liveUpdate(){
  108. if(this.timer) {
  109. clearInterval(this.timer);
  110. this.timer = null;
  111. }
  112. let that = this;
  113. this.timer = setInterval(function(){
  114. // 用户
  115. that.getList();
  116. },5000);
  117. },
  118. goPage(item) {
  119. if(this.type == 0){
  120. uni.navigateTo({
  121. url: `/pages/chat/customer_list/chat?mer_id=${item.mer_id}`
  122. })
  123. }else{
  124. uni.navigateTo({
  125. url: `/pages/chat/customer_list/chat?userId=${item.user.uid}&mer_id=${item.mer_id}`
  126. })
  127. }
  128. }
  129. },
  130. };
  131. </script>
  132. <style lang="scss">
  133. .CustomerList {
  134. .item {
  135. align-items: center;
  136. border-bottom: 1px solid #eee;
  137. padding: 20rpx 30rpx;
  138. background-color: #fff;
  139. .logo image{
  140. width: 88rpx;
  141. height: 88rpx;
  142. border-radius: 50%;
  143. }
  144. .info{
  145. width: 334rpx;
  146. margin-left: 20rpx;
  147. .con{
  148. margin-top: 10rpx;
  149. color: #999999;
  150. font-size: 24rpx;
  151. }
  152. }
  153. .right-box{
  154. flex: 1;
  155. display: flex;
  156. flex-direction: column;
  157. align-items: flex-end;
  158. font-size: 20rpx;
  159. color: #BBBBBB;
  160. .time{
  161. margin-bottom: 10rpx;
  162. }
  163. .num{
  164. min-width: 6px;
  165. background-color: $theme-color;
  166. border-radius: 15px;
  167. font-size: 10px;
  168. padding: 0 4px;
  169. font-size: 20rpx;
  170. color: #fff;
  171. }
  172. }
  173. }
  174. }
  175. </style>