index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <div class="CustomerList" :style="viewColor">
  3. <view>
  4. <block v-if="type == 0 && list.length>0" v-for="(item,index) in list" :key="index">
  5. <div v-if="item.merchant" class="item acea-row" @click="goPage(item)">
  6. <view class="logo">
  7. <image :src="item.merchant && item.merchant.mer_avatar" mode=""></image>
  8. </view>
  9. <view class="info">
  10. <view class="name">{{item.merchant ? item.merchant.mer_name : ''}}</view>
  11. <view class="con line1" v-if="item.last && item.last.msn_type == 1">{{item.last.msn}}</view>
  12. <view class="con line1" v-if="item.last && item.last.msn_type == 2">[表情]</view>
  13. <view class="con line1" v-if="item.last && item.last.msn_type == 3">[图片]</view>
  14. <view class="con line1" v-if="item.last && item.last.msn_type == 4">[商品]</view>
  15. <view class="con line1" v-if="item.last && (item.last.msn_type == 5 || item.last.msn_type == 6)">[订单]</view>
  16. </view>
  17. <view class="right-box">
  18. <view class="time">{{item.last && item.last.create_time.split(' ')[1] || ''}}</view>
  19. <view class="num" v-if="item.num>0">{{item.num}}</view>
  20. </view>
  21. </div>
  22. </block>
  23. <block v-if="type == 1 && list.length>0" v-for="(item,index) in list" :key="index">
  24. <div class="item acea-row" @click="goPage(item)">
  25. <view class="logo">
  26. <image :src="(item.user && item.user.avatar) ? item.user.avatar : '/static/images/f.png'" mode=""></image>
  27. </view>
  28. <view class="info">
  29. <view class="name">{{item.user && item.user.nickname}}</view>
  30. <view class="con line1" v-if="item.last && item.last.msn_type == 1">{{item.last.msn}}</view>
  31. <view class="con line1" v-if="item.last && item.last.msn_type == 2">[表情]</view>
  32. <view class="con line1" v-if="item.last && item.last.msn_type == 3">[图片]</view>
  33. <view class="con line1" v-if="item.last && (item.last.msn_type == 4 || item.last.msn_type == 7)">[商品]</view>
  34. <view class="con line1" v-if="item.last && (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.split(' ')[1]}}</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. </view>
  46. </div>
  47. </template>
  48. <script>
  49. // +----------------------------------------------------------------------
  50. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  51. // +----------------------------------------------------------------------
  52. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  53. // +----------------------------------------------------------------------
  54. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  55. // +----------------------------------------------------------------------
  56. // | Author: CRMEB Team <admin@crmeb.com>
  57. // +----------------------------------------------------------------------
  58. import emptyPage from '@/components/emptyPage.vue'
  59. import { serviceList, serviceUserList } from "@/api/user";
  60. import { toLogin } from '@/libs/login.js';
  61. import { mapGetters } from "vuex";
  62. export default {
  63. name: "CustomerList",
  64. components:{
  65. emptyPage,
  66. },
  67. data() {
  68. return {
  69. list: [],
  70. productId: 0,
  71. orderId: "",
  72. type: 0 ,// 0 用户 1客服
  73. timer: null,
  74. page:1,
  75. limit:9999,
  76. mer_id: '',
  77. loading: false,
  78. clear: false,
  79. };
  80. },
  81. computed: mapGetters(['isLogin','viewColor']),
  82. onLoad(optios) {
  83. this.type = optios.type;
  84. this.mer_id = optios.mer_id;
  85. if(this.isLogin){
  86. this.getList(this.mer_id)
  87. } else {
  88. toLogin()
  89. }
  90. },
  91. onShow(option) {
  92. if(this.isLogin){
  93. this.liveUpdate();
  94. } else {
  95. toLogin()
  96. }
  97. },
  98. onHide(){
  99. if(this.timer) {
  100. clearInterval(this.timer);
  101. this.timer = null;
  102. }
  103. this.clear = true;
  104. },
  105. onUnload() {
  106. if(this.timer) {
  107. clearInterval(this.timer);
  108. this.timer = null;
  109. }
  110. this.clear = true;
  111. },
  112. methods: {
  113. getList(mer_id) {
  114. this.loading = true;
  115. if(this.type == 0){
  116. serviceList({
  117. page:this.page,
  118. limit:this.limit
  119. }).then(res => {
  120. this.list = res.data.list;
  121. if(res.status == 400){
  122. clearInterval(this.timer);
  123. this.timer = null;
  124. return this.$util.Tips({
  125. title: res.message
  126. })
  127. }
  128. }).finally(v=>{
  129. this.loading = false;
  130. return this.$util.Tips({
  131. title: v
  132. })
  133. }).catch(err => {
  134. return this.$util.Tips({
  135. title: err
  136. })
  137. });
  138. }else{
  139. serviceUserList(mer_id,{
  140. page:this.page,
  141. limit:this.limit
  142. }).then(res =>{
  143. this.list = res.data.list;
  144. if(res.status == 400){
  145. clearInterval(this.timer);
  146. this.timer = null;
  147. return this.$util.Tips({
  148. title: res.message
  149. })
  150. }
  151. }).finally(v=>{
  152. this.loading = false;
  153. clearInterval(this.timer);
  154. this.timer = null;
  155. return this.$util.Tips({
  156. title: v
  157. })
  158. }).catch(err => {
  159. clearInterval(this.timer);
  160. this.timer = null;
  161. return this.$util.Tips({
  162. title: err
  163. })
  164. });
  165. }
  166. },
  167. //实时刷新列表
  168. liveUpdate(){
  169. let that = this;
  170. this.clear = false;
  171. if(that.timer) {
  172. clearInterval(that.timer);
  173. that.timer = null;
  174. }
  175. that.timer = setInterval(function(){
  176. if(that.clear){
  177. clearInterval(that.timer);
  178. return ;
  179. }
  180. // 用户
  181. (!that.loading) && that.getList(that.mer_id);
  182. },5000);
  183. },
  184. goPage(item) {
  185. item.num = 0;
  186. if(this.type == 0){
  187. uni.navigateTo({
  188. url: `/pages/chat/customer_list/chat?mer_id=${item.mer_id}`
  189. })
  190. }else{
  191. uni.navigateTo({
  192. url: `/pages/chat/customer_list/chat?userId=${item.user.uid}&mer_id=${item.mer_id}`
  193. })
  194. }
  195. }
  196. },
  197. };
  198. </script>
  199. <style lang="scss">
  200. .CustomerList {
  201. .spin {
  202. display: block;
  203. transform: rotate(180deg);
  204. font-size: 36rpx;
  205. }
  206. .popupn{
  207. position: fixed;
  208. width: 100%;
  209. text-align: center;
  210. top: 0;
  211. left: 0;
  212. background: #ffffff;
  213. height: 90rpx;
  214. line-height: 90rpx;
  215. z-index: 100;
  216. .title{
  217. max-width: 560rpx;
  218. margin: 0 auto;
  219. position: relative;
  220. }
  221. .iconfont{
  222. display: inline-block;
  223. position: relative;
  224. top: 4rpx;
  225. right: 0;
  226. }
  227. .mer_logo{
  228. width: 34rpx;
  229. height: 34rpx;
  230. position: relative;
  231. top: 6rpx;
  232. right: 10px;
  233. }
  234. .mer_name{
  235. display: inline-block;
  236. max-width: 650rpx;
  237. }
  238. .invoice-content{
  239. background-color: #ffffff;
  240. }
  241. }
  242. .list_count{
  243. margin-top: 104rpx;
  244. }
  245. .item {
  246. align-items: center;
  247. border-bottom: 1px solid #eee;
  248. padding: 20rpx 30rpx;
  249. background-color: #fff;
  250. .logo image{
  251. width: 88rpx;
  252. height: 88rpx;
  253. border-radius: 50%;
  254. }
  255. .info{
  256. width: 334rpx;
  257. margin-left: 20rpx;
  258. .con{
  259. margin-top: 10rpx;
  260. color: #999999;
  261. font-size: 24rpx;
  262. }
  263. }
  264. .right-box{
  265. flex: 1;
  266. display: flex;
  267. flex-direction: column;
  268. align-items: flex-end;
  269. font-size: 20rpx;
  270. color: #BBBBBB;
  271. .time{
  272. margin-bottom: 10rpx;
  273. }
  274. .num{
  275. min-width: 6px;
  276. background-color: var(--view-theme);
  277. border-radius: 15px;
  278. font-size: 10px;
  279. padding: 0 4px;
  280. font-size: 20rpx;
  281. color: #fff;
  282. }
  283. }
  284. }
  285. }
  286. </style>