文件
shanghaipeiwan/pwuniapp/common/support.js
xcbyy be1c7be5d3 revert(order): 移除订单站内聊天,沟通统一走官方客服
- 删除 pages/order/chat、聊天接口/仓储方法/order_messages 建表与客户端 API

- 买家「联系大神」、大神「联系老板」、大神详情「在线客服」、组局「私聊」统一改为 openSupportSheet(读取后台 customer_service 配置的客服微信/热线)

- 保留派单实时通知与雷达/大厅轮询

- 114 套件/742 用例全绿;聊天接口线上已 404
2026-10-22 09:10:16 +08:00

61 行
2.0 KiB
JavaScript

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

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

// 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' });
}
});
}
}
});
}