文件
yjyf/yjyf-master-app/components/YjyfServicePopup.vue
MiAn 14533eadb7 feat: 用户端与师傅端双小程序架构解耦,新增师傅独立认证及超时自动关单机制
1. 账号体系与数据库解耦:
   - 师傅表 fa_master 解除对 fa_user.id 的外键依赖,升级为独立认证账号主表;
   - 新增师傅端独立支撑表:fa_master_security、fa_master_token、fa_master_wechat、fa_master_agreement_read;
   - 新增工单超时未接单自动关闭与原路退款配置(order_unaccepted_close_days)。

2. 服务端(Server):
   - 新增师傅端独立 API 控制器与认证库(MasterAuth, MasterBase, MasterMessage, MasterSecurity, MasterToken);
   - WxLogin 支持双小程序端(user/master)独立换取 session_key、openid 与 access_token;
   - 新增控制台调度命令 php think order:autoclose,支持订单超时自动关闭与售后退款闭环;
   - 修复 PHP 8.5 兼容性问题(Request.php 的 (bool) 强制转换);
   - 系统业务配置全面收敛至数据库 fa_config 及 site.php。

3. 小程序端:
   - yjyf-app(用户端):彻底剥离师傅端路由、组件及静态资源,增加隐私授权弹窗与评价模块;
   - yjyf-master-app(师傅端):全新独立微信小程序工程(wx140d90ceda786107),实现工作台、接单大厅、资质认证、工单协同与钱包提现完整闭环。
2026-11-23 15:10:30 +08:00

325 行
7.5 KiB
Vue

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<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>