- 删除 pages/order/chat、聊天接口/仓储方法/order_messages 建表与客户端 API - 买家「联系大神」、大神「联系老板」、大神详情「在线客服」、组局「私聊」统一改为 openSupportSheet(读取后台 customer_service 配置的客服微信/热线) - 保留派单实时通知与雷达/大厅轮询 - 114 套件/742 用例全绿;聊天接口线上已 404
61 行
2.0 KiB
JavaScript
61 行
2.0 KiB
JavaScript
// pwuniapp/common/support.js
|
||
// 统一客服入口:平台沟通仅通过官方客服微信/热线,不在买卖双方之间直接建立联系。
|
||
import { getPlatformConfigs } from '@/common/api.js';
|
||
|
||
let cachedContact = null;
|
||
let cachedAt = 0;
|
||
|
||
export async function getSupportContact() {
|
||
if (cachedContact && Date.now() - cachedAt < 5 * 60 * 1000) {
|
||
return cachedContact;
|
||
}
|
||
let hotline = '';
|
||
let wechat = '';
|
||
try {
|
||
const configs = await getPlatformConfigs();
|
||
const cs = (configs && configs.customer_service) || {};
|
||
hotline = String(cs.hotline || '').trim();
|
||
wechat = String(cs.wechat || '').trim();
|
||
} catch (_) {
|
||
// 配置拉取失败时使用空值,避免展示写死的客服账号
|
||
}
|
||
cachedContact = { hotline, wechat };
|
||
cachedAt = Date.now();
|
||
return cachedContact;
|
||
}
|
||
|
||
export async function openSupportSheet() {
|
||
const contact = await getSupportContact();
|
||
const actions = [];
|
||
if (contact.wechat) actions.push({ key: 'wechat', label: `复制客服微信(${contact.wechat})` });
|
||
if (contact.hotline) actions.push({ key: 'hotline', label: `拨打客服热线(${contact.hotline})` });
|
||
|
||
if (actions.length === 0) {
|
||
uni.showToast({ title: '客服信息暂未配置,请稍后再试', icon: 'none' });
|
||
return;
|
||
}
|
||
|
||
uni.showActionSheet({
|
||
itemList: actions.map((a) => a.label),
|
||
success: (res) => {
|
||
const picked = actions[res.tapIndex];
|
||
if (!picked) return;
|
||
if (picked.key === 'wechat') {
|
||
uni.setClipboardData({
|
||
data: contact.wechat,
|
||
success: () => {
|
||
uni.showToast({ title: '客服微信已复制,请前往微信添加', icon: 'none', duration: 2200 });
|
||
}
|
||
});
|
||
} else if (picked.key === 'hotline') {
|
||
uni.makePhoneCall({
|
||
phoneNumber: contact.hotline.replace(/[^0-9+]/g, ''),
|
||
fail: () => {
|
||
uni.showToast({ title: `客服热线:${contact.hotline}`, icon: 'none' });
|
||
}
|
||
});
|
||
}
|
||
}
|
||
});
|
||
}
|