- 新增客服电话、服务时间、企业微信客服配置项 - 新增客服弹窗组件支持微信在线客服和电话拨打 - 调整核销码为6位数字,修复相关提示文本 - 优化订单服务项目展示逻辑 - 完善抢单大厅加载动画和列表样式
325 行
7.5 KiB
Vue
325 行
7.5 KiB
Vue
<template>
|
||
<view class="svc-mask" v-if="visible" @tap="close" @touchmove.stop.prevent>
|
||
<view class="svc-sheet" @tap.stop>
|
||
<!-- 标题栏 -->
|
||
<view class="svc-head">
|
||
<view class="svc-head-left">
|
||
<text class="svc-title">联系客服</text>
|
||
<text class="svc-worktime" v-if="config.service_work_time">服务时间:{{ config.service_work_time }}</text>
|
||
</view>
|
||
<view class="svc-close clickable-hover" @tap="close">
|
||
<image class="svc-close-ico" src="/static/icons/close.svg" mode="aspectFit" />
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 客服方式列表 -->
|
||
<view class="svc-body">
|
||
<!-- 1. 在线客服(微信客服) -->
|
||
<!-- #ifdef MP-WEIXIN -->
|
||
<view
|
||
v-if="hasEnterpriseKf"
|
||
class="svc-card clickable-hover"
|
||
@tap="openEnterpriseKf"
|
||
>
|
||
<view class="svc-card-l">
|
||
<image class="svc-ico" src="/static/icons/service-online-chat.svg" mode="aspectFit" />
|
||
<view class="svc-info">
|
||
<text class="svc-name">在线客服</text>
|
||
<text class="svc-desc">微信在线实时沟通,快速解答</text>
|
||
</view>
|
||
</view>
|
||
<image class="svc-arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" />
|
||
</view>
|
||
<button
|
||
v-else
|
||
class="svc-card svc-btn clickable-hover"
|
||
open-type="contact"
|
||
@contact="close"
|
||
@error="onContactError"
|
||
>
|
||
<view class="svc-card-l">
|
||
<image class="svc-ico" src="/static/icons/service-online-chat.svg" mode="aspectFit" />
|
||
<view class="svc-info">
|
||
<text class="svc-name">在线客服</text>
|
||
<text class="svc-desc">微信在线实时沟通,快速解答</text>
|
||
</view>
|
||
</view>
|
||
<image class="svc-arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" />
|
||
</button>
|
||
<!-- #endif -->
|
||
|
||
<!-- #ifndef MP-WEIXIN -->
|
||
<view class="svc-card clickable-hover" @tap="openNonWxKf">
|
||
<view class="svc-card-l">
|
||
<image class="svc-ico" src="/static/icons/service-online-chat.svg" mode="aspectFit" />
|
||
<view class="svc-info">
|
||
<text class="svc-name">在线客服</text>
|
||
<text class="svc-desc">微信在线实时沟通,快速解答</text>
|
||
</view>
|
||
</view>
|
||
<image class="svc-arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" />
|
||
</view>
|
||
<!-- #endif -->
|
||
|
||
<!-- 2. 客服电话(后台配置) -->
|
||
<view
|
||
class="svc-card clickable-hover"
|
||
:class="{ 'svc-card-disabled': !config.service_phone }"
|
||
@tap="callServicePhone"
|
||
>
|
||
<view class="svc-card-l">
|
||
<image class="svc-ico" src="/static/icons/service-hotline.svg" mode="aspectFit" />
|
||
<view class="svc-info">
|
||
<text class="svc-name">客服电话</text>
|
||
<text class="svc-desc" v-if="config.service_phone">{{ config.service_phone }}</text>
|
||
<text class="svc-desc muted" v-else>暂未配置客服电话</text>
|
||
</view>
|
||
</view>
|
||
<image v-if="config.service_phone" class="svc-arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" />
|
||
</view>
|
||
</view>
|
||
|
||
<!-- 底部取消按钮 -->
|
||
<view class="svc-cancel clickable-hover" @tap="close">取消</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script setup>
|
||
import { ref, computed, watch } from 'vue';
|
||
import api from '@/utils/api.js';
|
||
|
||
const props = defineProps({
|
||
visible: { type: Boolean, default: false }
|
||
});
|
||
|
||
const emit = defineEmits(['update:visible']);
|
||
|
||
const config = ref(api.getCachedServiceConfig());
|
||
|
||
const hasEnterpriseKf = computed(() => {
|
||
return Boolean(config.value.service_corp_id && config.value.service_kf_url);
|
||
});
|
||
|
||
watch(() => props.visible, (val) => {
|
||
if (val) {
|
||
config.value = api.getCachedServiceConfig();
|
||
syncLatestConfig();
|
||
}
|
||
});
|
||
|
||
async function syncLatestConfig() {
|
||
const latest = await api.getServiceConfig(true);
|
||
if (latest) {
|
||
config.value = latest;
|
||
}
|
||
}
|
||
|
||
function close() {
|
||
emit('update:visible', false);
|
||
}
|
||
|
||
function onContactError(e) {
|
||
console.warn('小程序原生客服打开失败', e);
|
||
uni.showToast({ title: '暂无法拉起在线客服,请拨打客服电话', icon: 'none' });
|
||
}
|
||
|
||
function openEnterpriseKf() {
|
||
// #ifdef MP-WEIXIN
|
||
if (typeof wx !== 'undefined' && typeof wx.openCustomerServiceChat === 'function') {
|
||
wx.openCustomerServiceChat({
|
||
extInfo: { url: config.value.service_kf_url },
|
||
corpId: config.value.service_corp_id,
|
||
success: () => {
|
||
close();
|
||
},
|
||
fail: (err) => {
|
||
console.warn('拉起微信客服失败', err);
|
||
uni.showToast({ title: '拉起微信客服失败,请尝试拨打客服电话', icon: 'none' });
|
||
}
|
||
});
|
||
} else {
|
||
uni.showToast({ title: '当前微信版本暂不支持,请升级微信', icon: 'none' });
|
||
}
|
||
// #endif
|
||
}
|
||
|
||
function openNonWxKf() {
|
||
if (config.value.service_kf_url) {
|
||
// #ifdef H5
|
||
window.open(config.value.service_kf_url, '_blank');
|
||
close();
|
||
return;
|
||
// #endif
|
||
}
|
||
uni.showToast({ title: '请在微信小程序内使用在线客服', icon: 'none' });
|
||
}
|
||
|
||
function callServicePhone() {
|
||
const phone = (config.value.service_phone || '').trim();
|
||
if (!phone) {
|
||
uni.showToast({ title: '平台暂未配置客服电话', icon: 'none' });
|
||
return;
|
||
}
|
||
close();
|
||
uni.makePhoneCall({
|
||
phoneNumber: phone,
|
||
fail: () => {}
|
||
});
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.svc-mask {
|
||
position: fixed;
|
||
inset: 0;
|
||
background: rgba(0, 0, 0, 0.52);
|
||
z-index: 9999;
|
||
display: flex;
|
||
flex-direction: column;
|
||
justify-content: flex-end;
|
||
}
|
||
|
||
.svc-sheet {
|
||
background: $yjyf-bg-card;
|
||
border-top-left-radius: 28rpx;
|
||
border-top-right-radius: 28rpx;
|
||
padding: 32rpx 32rpx calc(32rpx + env(safe-area-inset-bottom));
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.svc-head {
|
||
display: flex;
|
||
align-items: flex-start;
|
||
justify-content: space-between;
|
||
padding-bottom: 24rpx;
|
||
}
|
||
|
||
.svc-head-left {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 6rpx;
|
||
}
|
||
|
||
.svc-title {
|
||
font-size: $yjyf-font-title;
|
||
font-weight: 700;
|
||
color: $yjyf-text-main;
|
||
line-height: 1.3;
|
||
}
|
||
|
||
.svc-worktime {
|
||
font-size: $yjyf-font-sub;
|
||
color: $yjyf-text-secondary;
|
||
}
|
||
|
||
.svc-close {
|
||
width: 56rpx;
|
||
height: 56rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: flex-end;
|
||
}
|
||
|
||
.svc-close-ico {
|
||
width: 30rpx;
|
||
height: 30rpx;
|
||
opacity: 0.6;
|
||
}
|
||
|
||
.svc-body {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 20rpx;
|
||
}
|
||
|
||
.svc-card {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
padding: 26rpx 24rpx;
|
||
background: $yjyf-bg-page;
|
||
border-radius: $yjyf-radius-md;
|
||
box-sizing: border-box;
|
||
width: 100%;
|
||
}
|
||
|
||
.svc-btn {
|
||
margin: 0;
|
||
border: none;
|
||
text-align: left;
|
||
line-height: normal;
|
||
font-family: inherit;
|
||
&::after {
|
||
border: none;
|
||
}
|
||
}
|
||
|
||
.svc-card-disabled {
|
||
opacity: 0.72;
|
||
}
|
||
|
||
.svc-card-l {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 22rpx;
|
||
flex: 1;
|
||
min-width: 0;
|
||
}
|
||
|
||
.svc-ico {
|
||
width: 80rpx;
|
||
height: 80rpx;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.svc-info {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 6rpx;
|
||
min-width: 0;
|
||
flex: 1;
|
||
}
|
||
|
||
.svc-name {
|
||
font-size: 30rpx;
|
||
font-weight: 600;
|
||
color: $yjyf-text-main;
|
||
line-height: 1.3;
|
||
}
|
||
|
||
.svc-desc {
|
||
font-size: $yjyf-font-sub;
|
||
color: $yjyf-text-secondary;
|
||
line-height: 1.4;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.svc-desc.muted {
|
||
color: $yjyf-text-muted;
|
||
}
|
||
|
||
.svc-arrow {
|
||
width: 28rpx;
|
||
height: 28rpx;
|
||
flex-shrink: 0;
|
||
opacity: 0.55;
|
||
margin-left: 16rpx;
|
||
}
|
||
|
||
.svc-cancel {
|
||
margin-top: 24rpx;
|
||
height: 88rpx;
|
||
border-radius: $yjyf-radius-pill;
|
||
background: $yjyf-bg-page;
|
||
color: $yjyf-text-regular;
|
||
font-size: 30rpx;
|
||
font-weight: 500;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
</style>
|