shop-applet/pages/chat/customer_list/index.vue

351 lines
8.6 KiB
Vue
Raw Normal View History

2023-09-20 18:16:59 +08:00
<template>
<div class="CustomerList" :style="viewColor">
<view>
<block v-if="type == 0 && list.length>0" v-for="(item,index) in list" :key="index">
<div v-if="item.merchant" class="item acea-row" @click="goPage(item)">
<view class="logo">
<image :src="item.merchant && item.merchant.mer_avatar" mode=""></image>
</view>
<view class="info">
<view class="name">{{item.merchant ? item.merchant.mer_name : ''}}</view>
<view class="con line1" v-if="item.last && item.last.msn_type == 1">{{item.last.msn}}</view>
<view class="con line1" v-if="item.last && item.last.msn_type == 2">[表情]</view>
<view class="con line1" v-if="item.last && item.last.msn_type == 3">[图片]</view>
<view class="con line1" v-if="item.last && item.last.msn_type == 4">[商品]</view>
2024-04-29 23:05:49 +08:00
<view class="con line1"
v-if="item.last && (item.last.msn_type == 5 || item.last.msn_type == 6)">[订单]</view>
2023-09-20 18:16:59 +08:00
</view>
<view class="right-box">
<view class="time">{{item.last && item.last.create_time.split(' ')[1] || ''}}</view>
<view class="num" v-if="item.num>0">{{item.num}}</view>
</view>
</div>
</block>
<block v-if="type == 1 && list.length>0" v-for="(item,index) in list" :key="index">
<div class="item acea-row" @click="goPage(item)">
<view class="logo">
2024-04-29 23:05:49 +08:00
<image :src="(item.user && item.user.avatar) ? item.user.avatar : '/static/images/f.png'"
mode=""></image>
2023-09-20 18:16:59 +08:00
</view>
<view class="info">
<view class="name">{{item.user && item.user.nickname}}</view>
<view class="con line1" v-if="item.last && item.last.msn_type == 1">{{item.last.msn}}</view>
<view class="con line1" v-if="item.last && item.last.msn_type == 2">[表情]</view>
<view class="con line1" v-if="item.last && item.last.msn_type == 3">[图片]</view>
2024-04-29 23:05:49 +08:00
<view class="con line1"
v-if="item.last && (item.last.msn_type == 4 || item.last.msn_type == 7)">[商品]</view>
<view class="con line1"
v-if="item.last && (item.last.msn_type == 5 || item.last.msn_type == 6)">[订单]</view>
2023-09-20 18:16:59 +08:00
</view>
<view class="right-box">
<view class="time">{{item.last && item.last.create_time.split(' ')[1]}}</view>
<view class="num" v-if="item.num>0">{{item.num}}</view>
</view>
</div>
</block>
<block v-if="list.length == 0">
<emptyPage title="暂无数据~"></emptyPage>
</block>
</view>
<authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize>
</div>
</template>
<script>
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import emptyPage from '@/components/emptyPage.vue'
import authorize from '@/components/Authorize';
import {
serviceList,
serviceUserList
} from "@/api/user";
2023-09-25 09:27:16 +08:00
import {
getUserInfo
} from '@/api/user.js';
2024-04-29 23:05:49 +08:00
import {
mapGetters
} from "vuex";
2023-09-20 18:16:59 +08:00
export default {
name: "CustomerList",
2024-04-29 23:05:49 +08:00
components: {
2023-09-20 18:16:59 +08:00
emptyPage,
authorize
},
data() {
return {
list: [],
productId: 0,
orderId: "",
2024-04-29 23:05:49 +08:00
type: 0, // 0 用户 1客服
2023-09-20 18:16:59 +08:00
timer: null,
2024-04-29 23:05:49 +08:00
page: 1,
limit: 9999,
2023-09-20 18:16:59 +08:00
mer_id: '',
loading: false,
clear: false,
isAuto: false, //没有授权的不会自动授权
isShowAuth: false, //是否隐藏授权
};
},
2024-04-29 23:05:49 +08:00
computed: mapGetters(['isLogin', 'viewColor']),
2023-09-20 18:16:59 +08:00
onLoad(optios) {
2024-04-29 23:05:49 +08:00
this.type = optios.type || 1;
2023-09-20 18:16:59 +08:00
},
onShow(option) {
2024-04-29 23:05:49 +08:00
if (this.isLogin) {
2023-09-20 18:16:59 +08:00
this.liveUpdate();
} else {
this.isAuto = true;
this.isShowAuth = true
}
2024-04-29 23:05:49 +08:00
this.getindex()
2023-09-20 18:16:59 +08:00
},
2024-04-29 23:05:49 +08:00
onHide() {
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
}
2023-09-20 18:16:59 +08:00
this.clear = true;
},
onUnload() {
2024-04-29 23:05:49 +08:00
if (this.timer) {
clearInterval(this.timer);
this.timer = null;
}
2023-09-20 18:16:59 +08:00
this.clear = true;
},
methods: {
2023-09-25 09:27:16 +08:00
//获取商户信息
2024-04-29 23:05:49 +08:00
getindex() {
2023-09-25 09:27:16 +08:00
getUserInfo().then(res => {
2024-04-29 23:05:49 +08:00
if (res.data.mer_info.length == 0) {
return uni.showModal({
title: '暂未开通商户',
complete(res) {
// #ifdef APP-PLUS
uni.sendHostEvent('closeApp', (ret) => {
//发送消息成功回调
console.log('关闭应用' + JSON.stringify(ret));
});
// #endif
}
})
}
2023-09-25 09:27:16 +08:00
this.mer_id = res.data.service.mer_id;
2024-04-29 23:05:49 +08:00
if (this.isLogin) {
2023-09-25 09:27:16 +08:00
this.getList(this.mer_id)
} else {
this.isAuto = true;
this.isShowAuth = true
}
2024-04-29 23:05:49 +08:00
// this.getList(this.mer_id)
2023-09-25 09:27:16 +08:00
// this.getList(res.data.service.mer_id, true);
});
},
2023-09-20 18:16:59 +08:00
onLoadFun() {
this.isShowAuth = false;
this.getList(this.mer_id);
this.liveUpdate();
},
// 授权关闭
authColse: function(e) {
this.isShowAuth = e
},
2024-04-29 23:05:49 +08:00
getList(mer_id) {
2023-09-20 18:16:59 +08:00
this.loading = true;
2024-04-29 23:05:49 +08:00
if (this.type == 0) {
2023-09-20 18:16:59 +08:00
serviceList({
2024-04-29 23:05:49 +08:00
page: this.page,
limit: this.limit
2023-09-20 18:16:59 +08:00
}).then(res => {
this.list = res.data.list;
2024-04-29 23:05:49 +08:00
if (res.status == 400) {
2023-09-20 18:16:59 +08:00
clearInterval(this.timer);
2024-04-29 23:05:49 +08:00
this.timer = null;
2023-09-20 18:16:59 +08:00
return this.$util.Tips({
title: res.message
})
2024-04-29 23:05:49 +08:00
}
}).finally(v => {
2023-09-20 18:16:59 +08:00
this.loading = false;
return this.$util.Tips({
title: v
})
}).catch(err => {
return this.$util.Tips({
title: err
})
});
2024-04-29 23:05:49 +08:00
} else {
serviceUserList(mer_id, {
page: this.page,
limit: this.limit
}).then(res => {
2023-09-20 18:16:59 +08:00
this.list = res.data.list;
2024-04-29 23:05:49 +08:00
if (res.status == 400) {
2023-09-20 18:16:59 +08:00
clearInterval(this.timer);
2024-04-29 23:05:49 +08:00
this.timer = null;
2023-09-20 18:16:59 +08:00
return this.$util.Tips({
title: res.message
})
}
2024-04-29 23:05:49 +08:00
}).finally(v => {
2023-09-20 18:16:59 +08:00
this.loading = false;
clearInterval(this.timer);
2024-04-29 23:05:49 +08:00
this.timer = null;
2023-09-20 18:16:59 +08:00
return this.$util.Tips({
title: v
})
}).catch(err => {
clearInterval(this.timer);
2024-04-29 23:05:49 +08:00
this.timer = null;
2023-09-20 18:16:59 +08:00
return this.$util.Tips({
title: err
})
});
2024-04-29 23:05:49 +08:00
}
2023-09-20 18:16:59 +08:00
},
//实时刷新列表
2024-04-29 23:05:49 +08:00
liveUpdate() {
2023-09-20 18:16:59 +08:00
let that = this;
this.clear = false;
2024-04-29 23:05:49 +08:00
if (that.timer) {
2023-09-20 18:16:59 +08:00
clearInterval(that.timer);
2024-04-29 23:05:49 +08:00
that.timer = null;
}
that.timer = setInterval(function() {
if (that.clear) {
2023-09-20 18:16:59 +08:00
clearInterval(that.timer);
2024-04-29 23:05:49 +08:00
return;
2023-09-20 18:16:59 +08:00
}
// 用户
(!that.loading) && that.getList(that.mer_id);
2024-04-29 23:05:49 +08:00
}, 5000);
2023-09-20 18:16:59 +08:00
},
goPage(item) {
item.num = 0;
2024-04-29 23:05:49 +08:00
if (this.type == 0) {
2023-09-20 18:16:59 +08:00
uni.navigateTo({
url: `/pages/chat/customer_list/chat?mer_id=${item.mer_id}`
})
2024-04-29 23:05:49 +08:00
} else {
2023-09-20 18:16:59 +08:00
uni.navigateTo({
url: `/pages/chat/customer_list/chat?userId=${item.user.uid}&mer_id=${item.mer_id}`
})
}
}
},
changeTitle(e) {
this.mer_id = e.detail.value.toString();
},
};
</script>
2023-09-25 09:27:16 +08:00
<style lang="scss" scoped>
2023-09-20 18:16:59 +08:00
.CustomerList {
.spin {
display: block;
transform: rotate(180deg);
font-size: 36rpx;
}
2024-04-29 23:05:49 +08:00
.popupn {
2023-09-20 18:16:59 +08:00
position: fixed;
width: 100%;
text-align: center;
top: 0;
left: 0;
background: #ffffff;
height: 90rpx;
line-height: 90rpx;
z-index: 100;
2024-04-29 23:05:49 +08:00
.title {
2023-09-20 18:16:59 +08:00
max-width: 560rpx;
margin: 0 auto;
position: relative;
}
2024-04-29 23:05:49 +08:00
.iconfont {
2023-09-20 18:16:59 +08:00
display: inline-block;
position: relative;
top: 4rpx;
right: 0;
}
2024-04-29 23:05:49 +08:00
.mer_logo {
2023-09-20 18:16:59 +08:00
width: 34rpx;
height: 34rpx;
position: relative;
top: 6rpx;
2024-04-29 23:05:49 +08:00
right: 10px;
2023-09-20 18:16:59 +08:00
}
2024-04-29 23:05:49 +08:00
.mer_name {
2023-09-20 18:16:59 +08:00
display: inline-block;
max-width: 650rpx;
}
2024-04-29 23:05:49 +08:00
.invoice-content {
2023-09-20 18:16:59 +08:00
background-color: #ffffff;
}
}
2024-04-29 23:05:49 +08:00
.list_count {
2023-09-20 18:16:59 +08:00
margin-top: 104rpx;
}
2024-04-29 23:05:49 +08:00
2023-09-20 18:16:59 +08:00
.item {
align-items: center;
border-bottom: 1px solid #eee;
padding: 20rpx 30rpx;
background-color: #fff;
2024-04-29 23:05:49 +08:00
.logo image {
2023-09-20 18:16:59 +08:00
width: 88rpx;
height: 88rpx;
border-radius: 50%;
}
2024-04-29 23:05:49 +08:00
.info {
2023-09-20 18:16:59 +08:00
width: 334rpx;
margin-left: 20rpx;
2024-04-29 23:05:49 +08:00
.con {
2023-09-20 18:16:59 +08:00
margin-top: 10rpx;
color: #999999;
font-size: 24rpx;
}
}
2024-04-29 23:05:49 +08:00
.right-box {
2023-09-20 18:16:59 +08:00
flex: 1;
display: flex;
flex-direction: column;
align-items: flex-end;
font-size: 20rpx;
color: #BBBBBB;
2024-04-29 23:05:49 +08:00
.time {
2023-09-20 18:16:59 +08:00
margin-bottom: 10rpx;
}
2024-04-29 23:05:49 +08:00
.num {
2023-09-20 18:16:59 +08:00
min-width: 6px;
background-color: var(--view-theme);
border-radius: 15px;
font-size: 10px;
padding: 0 4px;
font-size: 20rpx;
color: #fff;
}
}
}
}
2024-04-29 23:05:49 +08:00
</style>