Compare commits

...

7 Commits

9 changed files with 705 additions and 564 deletions

View File

@@ -453,6 +453,206 @@ export class CustomerService {
return { ...config, openType }; return { ...config, openType };
} }
/**
* 获取客服按钮图标
* @returns {String} 图标URL
*/
getKefuButtonIcon() {
const shopInfo = this.vm.shopInfo || {};
const config = this.getPlatformConfig();
if (config?.type === 'aikefu') {
return shopInfo.aiAgentimg || '';
} else if (config?.type === 'wxwork' || config?.type === 'qyweixin') {
return shopInfo.aiAgentimg || '';
}
return shopInfo.kefuimg || this.vm.$util?.getDefaultImage()?.kefu || '';
}
/**
* 判断是否为微信官方客服
* @returns {Boolean}
*/
isWeappOfficialKefu() {
const config = this.getPlatformConfig();
return config?.type === 'weapp';
}
/**
* 判断是否需要同时显示小程序系统客服
* @returns {Boolean}
*/
shouldShowExtraWeappSystemKefu() {
const config = this.getPlatformConfig();
return (config?.show_system_service === true || config?.show_system_service === '1') && config?.type !== 'weapp';
}
/**
* 计算容器高度
* @param {Boolean} isLanguageSwitchEnabled 是否启用语言切换
* @param {Boolean} showWeappSystemKefu 是否显示小程序系统客服
* @param {Boolean} fixBtnShow 是否显示按钮
* @returns {String} 高度值px
*/
getContainerHeight(isLanguageSwitchEnabled, showWeappSystemKefu, fixBtnShow) {
if (!fixBtnShow) return '160px';
let buttonCount = 1;
if (isLanguageSwitchEnabled) buttonCount++;
if (showWeappSystemKefu) buttonCount++;
const totalRpx = 94 * buttonCount - 14;
const pxValue = Math.round(totalRpx * 0.5);
return `${pxValue}px`;
}
/**
* 获取未读消息数量
* @returns {Number}
*/
getUnreadCount() {
return this.vm.$store?.state?.aiUnreadCount || 0;
}
/**
* 拨打电话联系客服
* @param {String} phoneNumber 电话号码
*/
makePhoneCallByNumber(phoneNumber) {
if (phoneNumber) {
uni.makePhoneCall({ phoneNumber });
} else {
this.makePhoneCall();
}
}
/**
* 打开 AI 智能助手
*/
openAIChat() {
try {
if (typeof this.vm.setAiUnreadCount === 'function') {
this.vm.setAiUnreadCount(0);
}
const aiChatUrl = '/pages_tool/ai-chat/index';
uni.navigateTo({
url: aiChatUrl,
fail: (err) => {
console.error('跳转 AI 客服失败:', err);
// #ifdef H5
window.location.href = aiChatUrl;
// #endif
uni.showToast({ title: '打开客服失败', icon: 'none' });
}
});
} catch (e) {
console.error('跳转 AI 客服异常:', e);
uni.showToast({ title: '打开客服失败', icon: 'none' });
}
}
/**
* 打开客服选择对话框(预留方法)
*/
openCustomerSelectPopupDialog() {
uni.showToast({ title: '客服选择功能开发中', icon: 'none' });
}
/**
* 打开客服选择弹出层ActionSheet
* @param {Array} kefuList 客服列表
*/
openKefuSelectPopup(kefuList) {
const kefuNames = kefuList.map(item => item.name);
uni.showActionSheet({
itemList: kefuNames,
success: (res) => {
const selectedKefu = kefuList[res.tapIndex];
const cs = createCustomerService(this.vm, selectedKefu);
if (selectedKefu.isOfficial) {
uni.openCustomerServiceConversation({
sessionFrom: 'weapp',
showMessageCard: true
});
} else if (selectedKefu.id === 'qyweixin-kefu') {
if (uni.getSystemInfoSync().platform === 'wechat') {
uni.navigateTo({
url: '/pages_tool/qyweixin-kefu/index'
});
} else {
const qyweixinUrl = this.vm.shopInfo?.qyweixinUrl;
if (qyweixinUrl) {
window.location.href = qyweixinUrl;
} else {
uni.showToast({ title: '企业微信客服未配置', icon: 'none' });
}
}
} else {
cs.handleCustomerClick();
}
}
});
}
/**
* 核心方法:统一客服入口(带验证和配置检查)
* @param {Object} options 选项参数
*/
handleUnifiedKefuClick(options = {}) {
const validation = this.validateConfig();
console.log('【客服配置验证】', validation);
if (!validation.isValid) {
console.error('客服配置无效:', validation.errors);
uni.showToast({ title: '客服暂不可用', icon: 'none' });
return;
}
if (validation.warnings.length > 0) {
console.warn('客服配置警告:', validation.warnings);
}
const platformConfig = this.getPlatformConfig();
console.log('【当前客服配置】', platformConfig);
// 检查企业微信配置
if (platformConfig.type === 'wxwork') {
const wxworkConfig = this.getWxworkConfig();
console.log('【企业微信配置】', wxworkConfig);
// #ifdef MP-WEIXIN
if (!wxworkConfig?.enable || !wxworkConfig?.contact_url) {
console.warn('企业微信配置不完整,使用原生客服');
uni.showToast({ title: '企业微信配置不完整', icon: 'none' });
}
// #endif
// #ifdef H5
if (!wxworkConfig?.contact_url && !platformConfig.wxwork_url) {
console.error('企业微信链接未配置');
uni.showToast({ title: '企业微信链接未配置', icon: 'none' });
return;
}
// #endif
}
// 直接调用统一处理方法,由 CustomerService 内部根据配置路由
try {
this.handleCustomerClick({
sendMessageTitle: options.sendMessageTitle || '来自悬浮按钮的咨询',
sendMessagePath: options.sendMessagePath || '/pages/index/index'
});
} catch (error) {
console.error('客服处理失败:', error);
uni.showToast({ title: '打开客服失败', icon: 'none' });
}
}
} }
/** /**

View File

@@ -7,7 +7,7 @@ export default {
computed: { computed: {
// 是否是英文环境 // 是否是英文环境
isEnEnv() { isEnEnv() {
return uni.getStorageSync('lang') === 'en-us'; return this.$langConfig.getCurrentLocale() === 'en-us';
}, },
themeStyle() { themeStyle() {
return this.$store.state.themeStyle; return this.$store.state.themeStyle;

View File

@@ -1,5 +1,6 @@
import { langConfig } from './config-external.js'; import { langConfig } from './config-external.js';
// 缓存已加载的语言包 // 缓存已加载的语言包
const loadedLangPacks = {}; const loadedLangPacks = {};
@@ -8,15 +9,21 @@ function processRoutePath(route) {
let routeParts = route.split("/"); let routeParts = route.split("/");
// ---- 处理页面目录映射 <begin> 分包造成的,需要根据实际目录结构进行映射---- // ---- 处理页面目录映射 <begin> 分包造成的,需要根据实际目录结构进行映射----
// 先处理特殊的分包路径
if (routeParts[0] === 'pages_tool') { if (routeParts[0] === 'pages_tool') {
// pages_tool 分包下的页面,直接使用子目录作为语言包路径
routeParts = [routeParts[1], ...routeParts.slice(2)]; routeParts = [routeParts[1], ...routeParts.slice(2)];
} else if (routeParts[0] === 'pages_goods') { } else if (routeParts[0] === 'pages_goods') {
// pages_goods 分包映射到 goods 目录
routeParts[0] = 'goods'; routeParts[0] = 'goods';
} else if (routeParts[0] === 'pages_member') { } else if (routeParts[0] === 'pages_member') {
// pages_member 分包映射到 member 目录
routeParts[0] = 'member'; routeParts[0] = 'member';
} else if (routeParts[0] === 'pages_order') { } else if (routeParts[0] === 'pages_order') {
// pages_order 分包映射到 order 目录
routeParts[0] = 'order'; routeParts[0] = 'order';
} else if (routeParts[0] === 'pages_promotion') { } else if (routeParts[0] === 'pages_promotion') {
// pages_promotion 分包特殊处理
const promotionModules = ['point', 'fenxiao', 'merch']; const promotionModules = ['point', 'fenxiao', 'merch'];
if (routeParts[1] && promotionModules.includes(routeParts[1])) { if (routeParts[1] && promotionModules.includes(routeParts[1])) {
routeParts = [routeParts[1], ...routeParts.slice(2)]; routeParts = [routeParts[1], ...routeParts.slice(2)];
@@ -24,6 +31,7 @@ function processRoutePath(route) {
} }
// ---- 处理页面目录映射 <end>---- // ---- 处理页面目录映射 <end>----
// 去掉pages目录只保留子目录
if (routeParts[0] === 'pages') { if (routeParts[0] === 'pages') {
routeParts = routeParts.slice(1); routeParts = routeParts.slice(1);
} }
@@ -46,32 +54,51 @@ function loadLangPackSync(lang, path) {
} }
} }
function getCurrentLocale() {
return uni.getStorageSync('lang') || "zh-cn";
}
export default { export default {
langList: langConfig.langList, langList: langConfig.langList,
/** /**
* 解析多语言 * 获得当前本地语言
* @returns
*/
getCurrentLocale,
/**
* * 解析多语言
* @param {Object} field
*/ */
lang(field) { lang(field) {
let _this = getCurrentPages()[getCurrentPages().length - 1]; let _page = getCurrentPages()[getCurrentPages().length - 1];
if (!_this) return; if (!_page) return;
const locale = uni.getStorageSync('lang') || "zh-cn"; const locale = getCurrentLocale(); // 获得当前本地语言
let value = ''; let value = ''; // 存放解析后的语言值
let langPath = ''; let langPath = ''; // 存放当前页面语言包路径
try { try {
//公共语言包(同步加载)
var lang = loadLangPackSync(locale, 'common'); var lang = loadLangPackSync(locale, 'common');
let route = _this.route; //当前页面语言包(同步加载)
let route = _page.route;
langPath = processRoutePath(route); langPath = processRoutePath(route);
// 加载当前页面语言包
let currentPageLang = loadLangPackSync(locale, langPath); let currentPageLang = loadLangPackSync(locale, langPath);
// 合并语言包
let mergedLang = { ...lang, ...currentPageLang }; let mergedLang = { ...lang, ...currentPageLang };
// 解析字段
var arr = field.split("."); var arr = field.split(".");
if (arr.length > 1) { if (arr.length > 1) {
// 处理嵌套属性,如 common.currencySymbol
let temp = mergedLang; let temp = mergedLang;
let found = true; let found = true;
for (let key of arr) { for (let key of arr) {
@@ -93,12 +120,14 @@ export default {
} }
if (arguments.length > 1) { if (arguments.length > 1) {
//有参数,需要替换
for (var i = 1; i < arguments.length; i++) { for (var i = 1; i < arguments.length; i++) {
value = value.replace("{" + (i - 1) + "}", arguments[i]); value = value.replace("{" + (i - 1) + "}", arguments[i]);
} }
} }
if (value == undefined || (value == 'title' && field == 'title')) value = ''; if (value == undefined || (value == 'title' && field == 'title')) value = ''; // field
// 多语言调试,注释后可以关闭控制台输出
if (field == value) { if (field == value) {
console.warn(`警告: 字段 ${field} 在语言包 ${langPath} 中未找到对应值,使用默认值 ${field} 当前语言: ${locale}`); console.warn(`警告: 字段 ${field} 在语言包 ${langPath} 中未找到对应值,使用默认值 ${field} 当前语言: ${locale}`);
} }
@@ -106,19 +135,23 @@ export default {
return value; return value;
}, },
/** /**
* 切换语言 * * 切换语言
* @param {String} value 语言值
* @param {String} url 切换后跳转的页面url
*/ */
change(value, url = '/pages_tool/member/index') { change(value, url = '/pages_tool/member/index') {
let _this = getCurrentPages()[getCurrentPages().length - 1]; let _page = getCurrentPages()[getCurrentPages().length - 1];
if (!_this) return; if (!_page) return;
uni.setStorageSync("lang", value); uni.setStorageSync("lang", value);
const locale = uni.getStorageSync('lang') || "zh-cn"; const locale = getCurrentLocale();
// ✅ 关键修复:清空所有语言包缓存(不再保留任何旧缓存) // 清空已加载的语言包缓存
for (let key in loadedLangPacks) { for (let key in loadedLangPacks) {
if (!key.startsWith(locale)) {
delete loadedLangPacks[key]; delete loadedLangPacks[key];
} }
}
this.refresh(); this.refresh();
@@ -128,16 +161,39 @@ export default {
}, },
//刷新标题、tabbar //刷新标题、tabbar
refresh() { refresh() {
let _this = getCurrentPages()[getCurrentPages().length - 1]; let _page = getCurrentPages()[getCurrentPages().length - 1];
if (!_this) return; if (!_page) return;
const locale = uni.getStorageSync('lang') || "zh-cn";
const locale = getCurrentLocale();
this.title(this.lang("title")); this.title(this.lang("title"));
//设置tabbar的文字语言
// uni.setTabBarItem({
// index: 0,
// text: this.lang("tabBar.home")
// });
// uni.setTabBarItem({
// index: 1,
// text: this.lang("tabBar.category")
// });
// uni.setTabBarItem({
// index: 2,
// text: this.lang("tabBar.cart")
// });
// uni.setTabBarItem({
// index: 3,
// text: this.lang("tabBar.member")
// });
}, },
title(str) { title(str) {
if (str) { if (str) {
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: str title: str,
success: function (res) {
},
fail: function (err) {
}
}); });
} }
}, },
@@ -145,6 +201,7 @@ export default {
list() { list() {
var list = []; var list = [];
try { try {
//公共语言包
for (var i = 0; i < langConfig.langList.length; i++) { for (var i = 0; i < langConfig.langList.length; i++) {
let langType = langConfig.langList[i]; let langType = langConfig.langList[i];
let item = loadLangPackSync(langType, 'common'); let item = loadLangPackSync(langType, 'common');

View File

@@ -156,11 +156,11 @@
</script> </script>
<style lang="scss"> <style lang="scss">
/deep/.uni-popup__wrapper.uni-custom .uni-popup__wrapper-box { ::v-deep .uni-popup__wrapper.uni-custom .uni-popup__wrapper-box {
background-color: #000; background-color: #000;
} }
/deep/.uni-popup__wrapper.uni-custom.center .uni-popup__wrapper-box { ::v-deep .uni-popup__wrapper.uni-custom.center .uni-popup__wrapper-box {
max-width: 100%; max-width: 100%;
width: 100%; width: 100%;
} }

View File

@@ -1,41 +1,10 @@
<template> <template>
<view v-if="pageCount == 1 || need" class="fixed-box" <view v-if="pageCount === 1 || need" class="fixed-box"
:style="[customContainerStyle, { :style="[customContainerStyle, {
height: containerHeight, height: containerHeight,
backgroundImage: bgUrl ? `url( $ {bgUrl})` : '', backgroundImage: bgUrl ? `url(${bgUrl})` : '',
backgroundSize: 'cover' backgroundSize: 'cover'
}]"> }]">
<!-- 统一客服入口根据后台配置自动适配 AI / 企业微信 / 第三方等 -->
<!-- 微信官方客服需要使用 button open-type="contact" -->
<button
v-if="fixBtnShow && isWeappOfficialKefu"
class="btn-item common-bg"
open-type="contact"
:style="{ backgroundImage: currentKefuImg ? `url( $ {currentKefuImg})` : '', backgroundSize: '100% 100%' }"
>
<text class="ai-icon" v-if="!currentKefuImg">🤖</text>
</button>
<!-- 其他类型客服使用普通 view -->
<view
v-else-if="fixBtnShow"
class="btn-item common-bg"
@click="handleUnifiedKefuClick"
:style="{ backgroundImage: currentKefuImg ? `url( $ {currentKefuImg})` : '', backgroundSize: '100% 100%' }"
>
<text class="ai-icon" v-if="!currentKefuImg">🤖</text>
</view>
<!-- 新增小程序系统客服按钮当附加设置开启时显示 -->
<button
v-if="fixBtnShow && showWeappSystemKefu"
class="btn-item common-bg"
open-type="contact"
:style="{ backgroundImage: currentKefuImg ? `url( $ {currentKefuImg})` : '', backgroundSize: '100% 100%' }"
>
<text class="ai-icon" v-if="!currentKefuImg">💬</text>
</button>
<!-- 中英文切换按钮 --> <!-- 中英文切换按钮 -->
<view <view
v-if="isLanguageSwitchEnabled && fixBtnShow" v-if="isLanguageSwitchEnabled && fixBtnShow"
@@ -44,13 +13,44 @@
> >
<text>{{ currentLangDisplayName }}</text> <text>{{ currentLangDisplayName }}</text>
</view> </view>
<!-- 微信官方客服按钮-->
<button
v-if="fixBtnShow && isWeappOfficialKefu"
class="btn-item common-bg"
open-type="contact"
:style="{ backgroundImage: currentKefuImg ? `url(${currentKefuImg})` : '', backgroundSize: '100% 100%' }"
>
<text class="ai-icon" v-if="!currentKefuImg">🤖</text>
</button>
<!-- 电话按钮始终显示 --> <!-- 其他类型客服按钮 -->
<view
v-else-if="fixBtnShow"
class="btn-item common-bg"
@click="handleUnifiedKefuClick"
:style="{ backgroundImage: currentKefuImg ? `url(${currentKefuImg})` : '', backgroundSize: '100% 100%' }"
>
<text class="ai-icon" v-if="!currentKefuImg">🤖</text>
</view>
<!-- 小程序系统客服按钮 -->
<button
v-if="fixBtnShow && showWeappSystemKefu"
class="btn-item common-bg"
open-type="contact"
:style="{ backgroundImage: currentKefuImg ? `url(${currentKefuImg})` : '', backgroundSize: '100% 100%' }"
>
<text class="ai-icon" v-if="!currentKefuImg">💬</text>
</button>
<!-- 电话按钮 -->
<view <view
v-if="fixBtnShow" v-if="fixBtnShow"
class="btn-item common-bg" class="btn-item common-bg"
@click="call()" @click="call"
:style="[{ backgroundImage: phoneimg ? `url( $ {phoneimg})` : '', backgroundSize: '100% 100%' }, customButtonStyle]" :style="[{ backgroundImage: phoneimg ? `url(${phoneimg})` : '', backgroundSize: '100% 100%' }, customButtonStyle]"
> >
<text class="iconfont icon-dianhua" v-if="!phoneimg"></text> <text class="iconfont icon-dianhua" v-if="!phoneimg"></text>
</view> </view>
@@ -73,12 +73,7 @@ export default {
shopInfo: null, shopInfo: null,
currentLangIndex: 0, currentLangIndex: 0,
langIndexMap: {}, langIndexMap: {},
kefuList: [ customerService: null,
{ id: 'weixin-official', name: '微信官方客服', isOfficial: true, type: 'weapp' },
{ id: 'custom-kefu', name: '自定义在线客服', isOfficial: false, type: 'custom' },
{ id: 'qyweixin-kefu', name: '企业微信客服', isOfficial: false, type: 'qyweixin' }
],
selectedKefu: null,
}; };
}, },
computed: { computed: {
@@ -89,10 +84,10 @@ export default {
return this.shopInfo?.aiAgentimg || ''; return this.shopInfo?.aiAgentimg || '';
}, },
kefuimg() { kefuimg() {
return this.shopInfo?.kefuimg || this. $util.getDefaultImage().kefu; return this.shopInfo?.kefuimg || this.$util.getDefaultImage().kefu;
}, },
phoneimg() { phoneimg() {
return this.shopInfo?.phoneimg || this. $util.getDefaultImage().phone; return this.shopInfo?.phoneimg || this.$util.getDefaultImage().phone;
}, },
tel() { tel() {
return this.shopInfo?.mobile || ''; return this.shopInfo?.mobile || '';
@@ -111,39 +106,16 @@ export default {
return this.shopInfo?.floatingButton?.button || {}; return this.shopInfo?.floatingButton?.button || {};
}, },
unreadCount() { unreadCount() {
return this. $store.state.aiUnreadCount || 0; return this.customerService?.getUnreadCount() || 0;
}, },
// ✅ 新增:根据当前客服类型动态返回图标
currentKefuImg() { currentKefuImg() {
if (!this.shopInfo) return ''; return this.customerService?.getKefuButtonIcon() || '';
const customerService = createCustomerService(this);
const config = customerService.getPlatformConfig();
if (config?.type === 'aikefu') {
return this.aiAgentimg;
} else if (config?.type === 'wxwork' || config?.type === 'qyweixin') {
// 企业微信客服专用图标
return this.aiAgentimg;
}
// 默认客服图标
return this.kefuimg;
}, },
// ✅ 新增:判断是否为微信官方客服
isWeappOfficialKefu() { isWeappOfficialKefu() {
if (!this.shopInfo) return false; return this.customerService?.isWeappOfficialKefu() || false;
const customerService = createCustomerService(this);
const config = customerService.getPlatformConfig();
return config?.type === 'weapp';
}, },
// ✅ 新增:判断是否需要同时显示小程序系统客服
showWeappSystemKefu() { showWeappSystemKefu() {
if (!this.shopInfo) return false; return this.customerService?.shouldShowExtraWeappSystemKefu() || false;
const customerService = createCustomerService(this);
const config = customerService.getPlatformConfig();
// 检查附加设置是否开启了同时显示小程序系统客服,且当前客服类型不是小程序系统客服
return (config?.show_system_service === true || config?.show_system_service === '1') && config?.type !== 'weapp';
}, },
//根据显示的按钮数量动态计算容器高度 //根据显示的按钮数量动态计算容器高度
containerHeight() { containerHeight() {
@@ -155,14 +127,12 @@ export default {
buttonCount++; buttonCount++;
const totalRpx = 94 * buttonCount - 14; const totalRpx = 94 * buttonCount - 14;
const pxValue = Math.round(totalRpx * 0.5); const pxValue = Math.round(totalRpx * 0.5);
return ` $ {pxValue}px`; return ` $ {pxValue}px`;
} }
}, },
watch: { watch: {
shopInfo: { shopInfo: {
handler(newVal) { handler(newVal) {
// 可在此添加额外逻辑(如埋点、通知等),当前无需操作
}, },
immediate: true immediate: true
} }
@@ -170,7 +140,6 @@ export default {
created() { created() {
this.initLanguage(); this.initLanguage();
this.pageCount = getCurrentPages().length; this.pageCount = getCurrentPages().length;
uni.getStorage({ uni.getStorage({
key: 'shopInfo', key: 'shopInfo',
success: (e) => { success: (e) => {
@@ -181,15 +150,17 @@ export default {
console.warn('未获取到 shopInfo使用默认设置'); console.warn('未获取到 shopInfo使用默认设置');
} }
}); });
// 初始化 customerService 实例
this.customerService = createCustomerService(this);
}, },
methods: { methods: {
initLanguage() { initLanguage() {
this.langList = this. $langConfig.list(); this.langList = this.$langConfig.list();
this.langIndexMap = {}; this.langIndexMap = {};
for (let i = 0; i < this.langList.length; i++) { for (let i = 0; i < this.langList.length; i++) {
this.langIndexMap[i] = this.langList[i].value; this.langIndexMap[i] = this.langList[i].value;
} }
const savedLang = uni.getStorageSync('lang'); const savedLang = this.$langConfig.getCurrentLocale();
if (savedLang) { if (savedLang) {
for (let i = 0; i < this.langList.length; i++) { for (let i = 0; i < this.langList.length; i++) {
if (this.langList[i].value === savedLang) { if (this.langList[i].value === savedLang) {
@@ -201,118 +172,30 @@ export default {
this.currentLangIndex = 0; this.currentLangIndex = 0;
} }
}, },
call() { call() {
if (this.tel) { this.customerService.makePhoneCallByNumber(this.tel);
uni.makePhoneCall({ phoneNumber: this.tel + '' });
} else {
uni.showToast({ title: '暂无联系电话', icon: 'none' });
}
}, },
toggleLanguage() { toggleLanguage() {
this.currentLangIndex = this.currentLangIndex === 0 ? 1 : 0; this.currentLangIndex = this.currentLangIndex === 0 ? 1 : 0;
const targetLang = this.langIndexMap[this.currentLangIndex]; const targetLang = this.langIndexMap[this.currentLangIndex];
this. $langConfig.change(targetLang);
if (uni.getSystemInfoSync().platform === 'browser') { // 调用语言切换逻辑(设置 storage + 清空缓存)
setTimeout(() => { this.$langConfig.change(targetLang);
window.location.reload();
}, 100);
}
}, },
// ✅ 核心方法:统一客服入口
handleUnifiedKefuClick() { handleUnifiedKefuClick() {
const customerService = createCustomerService(this); this.customerService.handleUnifiedKefuClick({
const validation = customerService.validateConfig();
console.log('【客服配置验证】', validation);
if (!validation.isValid) {
console.error('客服配置无效:', validation.errors);
uni.showToast({ title: '客服暂不可用', icon: 'none' });
return;
}
if (validation.warnings.length > 0) {
console.warn('客服配置警告:', validation.warnings);
}
const platformConfig = customerService.getPlatformConfig();
console.log('【当前客服配置】', platformConfig);
// 检查企业微信配置
if (platformConfig.type === 'wxwork') {
const wxworkConfig = customerService.getWxworkConfig();
console.log('【企业微信配置】', wxworkConfig);
// #ifdef MP-WEIXIN
if (!wxworkConfig?.enable || !wxworkConfig?.contact_url) {
console.warn('企业微信配置不完整,使用原生客服');
uni.showToast({ title: '企业微信配置不完整', icon: 'none' });
}
// #endif
// #ifdef H5
if (!wxworkConfig?.contact_url && !platformConfig.wxwork_url) {
console.error('企业微信链接未配置');
uni.showToast({ title: '企业微信链接未配置', icon: 'none' });
return;
}
// #endif
}
// 直接调用统一处理方法,由 CustomerService 内部根据配置路由
try {
customerService.handleCustomerClick({
sendMessageTitle: '来自悬浮按钮的咨询', sendMessageTitle: '来自悬浮按钮的咨询',
sendMessagePath: '/pages/index/index' sendMessagePath: '/pages/index/index'
}); });
} catch (error) {
console.error('客服处理失败:', error);
uni.showToast({ title: '打开客服失败', icon: 'none' });
}
},
// 以下方法保留用于 actionSheet如仍需手动选择
openKefuSelectPopup() {
const kefuNames = this.kefuList.map(item => item.name);
uni.showActionSheet({
itemList: kefuNames,
success: (res) => {
this.selectedKefu = this.kefuList[res.tapIndex];
const cs = createCustomerService(this, this.selectedKefu);
if (this.selectedKefu.isOfficial) {
uni.openCustomerServiceConversation({
sessionFrom: 'weapp',
showMessageCard: true
});
} else if (this.selectedKefu.id === 'qyweixin-kefu') {
// 处理企业微信客服
if (uni.getSystemInfoSync().platform === 'wechat') {
// 小程序端:跳转到企业微信客服
uni.navigateTo({
url: '/pages_tool/qyweixin-kefu/index'
});
} else {
// H5端跳转到企业微信链接
const qyweixinUrl = this.shopInfo.qyweixinUrl; // 后端返回的企业微信链接
if (qyweixinUrl) {
window.location.href = qyweixinUrl;
} else {
uni.showToast({ title: '企业微信客服未配置', icon: 'none' });
}
}
} else {
cs.handleCustomerClick();
}
}
});
} }
} }
} }
</script> </script>
<style scoped> <style lang="scss" scoped>
.fixed-box { .fixed-box {
position: fixed; position: fixed;
right: 0rpx; right: 0rpx;
@@ -333,16 +216,25 @@ export default {
} }
.btn-item { .btn-item {
display: flex;
justify-content: center;
text-align: center;
flex-direction: column;
line-height: 1;
margin: 14rpx 0;
transition: 0.1s;
color: var(--hover-nav-text-color);
border-radius: 50%;
width: 80rpx; width: 80rpx;
height: 80rpx; height: 80rpx;
background: #fff; padding: 0;
border-radius: 50%; overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
margin: 14rpx 0;
box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.1);
} }
.common-bg {
background-color: var(--hover-nav-bg-color);
}
.btn-item text { .btn-item text {
font-size: 28rpx; font-size: 28rpx;
} }
@@ -357,7 +249,6 @@ export default {
justify-content: center; justify-content: center;
align-items: center; align-items: center;
margin: 14rpx 0; margin: 14rpx 0;
background: #fff;
border-radius: 50rpx; border-radius: 50rpx;
width: 80rpx; width: 80rpx;
height: 80rpx; height: 80rpx;
@@ -371,22 +262,6 @@ export default {
font-weight: bold; font-weight: bold;
} }
.unread-badge {
position: absolute;
top: -5rpx;
right: -5rpx;
background-color: #ff4544;
color: white;
border-radius: 20rpx;
min-width: 30rpx;
height: 30rpx;
font-size: 20rpx;
line-height: 30rpx;
text-align: center;
padding: 0 8rpx;
box-shadow: 0 2rpx 10rpx rgba(255, 69, 68, 0.3);
}
.ai-icon { .ai-icon {
font-size: 40rpx; font-size: 40rpx;
width: 100%; width: 100%;

View File

@@ -321,6 +321,12 @@
"navigationBarTitleText": "AI 客服" "navigationBarTitleText": "AI 客服"
} }
}, },
{
"path": "agreement/contenr",
"style": {
"navigationBarTitleText": ""
}
},
{ {
"path": "vr/index", "path": "vr/index",
"style": { "style": {
@@ -919,6 +925,12 @@
// #endif // #endif
"navigationBarTitleText": "查看文件" "navigationBarTitleText": "查看文件"
} }
},
{
"path": "file-preview/file-preview",
"style": {
"navigationBarTitleText": "文件预览"
}
} }
] ]
} }

View File

@@ -17,7 +17,11 @@
}}</view> }}</view>
</view> </view>
<diy-index-page v-if="topIndexValue" ref="indexPage" :value="topIndexValue" :bgUrl="safeBgUrl" <!-- <view class="page-header" v-if="diyData.global && diyData.global.navBarSwitch" :style="{ backgroundImage: bgImg }">
<ns-navbar :title-color="textNavColor" :data="diyData.global" :scrollTop="scrollTop" :isBack="false"/>
</view> -->
<diy-index-page v-if="topIndexValue" ref="indexPage" :value="topIndexValue" :bgUrl="bgUrl"
:scrollTop="scrollTop" :diyGlobal="diyData.global" class="diy-index-page"> :scrollTop="scrollTop" :diyGlobal="diyData.global" class="diy-index-page">
<template v-slot:components> <template v-slot:components>
<diy-group ref="diyGroup" v-if="diyData.value" :diyData="diyData" :scrollTop="scrollTop" <diy-group ref="diyGroup" v-if="diyData.value" :diyData="diyData" :scrollTop="scrollTop"
@@ -29,7 +33,7 @@
</diy-index-page> </diy-index-page>
<view v-else class="bg-index" <view v-else class="bg-index"
:style="{ backgroundImage: backgroundUrlStyle, paddingTop: paddingTop, marginTop: marginTop }"> :style="{ backgroundImage: backgroundUrl, paddingTop: paddingTop, marginTop: marginTop }">
<diy-group ref="diyGroup" v-if="diyData.value" :diyData="diyData" :scrollTop="scrollTop" <diy-group ref="diyGroup" v-if="diyData.value" :diyData="diyData" :scrollTop="scrollTop"
:followOfficialAccount="followOfficialAccount" /> :followOfficialAccount="followOfficialAccount" />
<ns-copyright v-show="isShowCopyRight" /> <ns-copyright v-show="isShowCopyRight" />
@@ -39,17 +43,35 @@
<view @touchmove.prevent.stop> <view @touchmove.prevent.stop>
<uni-popup ref="uniPopupWindow" type="center" class="wap-floating" :maskClick="false"> <uni-popup ref="uniPopupWindow" type="center" class="wap-floating" :maskClick="false">
<view class="small-bot"> <view class="small-bot">
<!-- <view class="adver-time" wx:if="{{startadv.params.style=='default'&&startadv.params.canclose==1}}">
<view bindtap="adverclose">跳过</view>
<view class="time">{{clock}}s</view>
</view>
<view class="adver-time" wx:if="{{startadv.params.style=='default'&&startadv.params.canclose==0}}">
<view class="time" style="line-height: 64rpx;">{{clock}}s</view>
</view> -->
<swiper autoplay="true" :circular="true" indicator-active-color="#fff" <swiper autoplay="true" :circular="true" indicator-active-color="#fff"
indicator-color="rgba(255,255,255,0.6)" :indicator-dots="true" interval="3000"> indicator-color="rgba(255,255,255,0.6)" :indicator-dots="true" interval="3000">
<swiper-item v-for="(item, index) in adv.list" :key="index"> <swiper-item v-for="(item, index) in adv.list" :key="index">
<image class="slide-image" @click="$util.diyRedirectTo(item.link)" height="100%" <image class="slide-image" @click="$util.diyRedirectTo(item.link)" height="100%"
:src="$util.img(item.imageUrl)" width="100%"></image> :src="$util.img(item.imageUrl)" width="100%"></image>
<!-- <image bindtap="adverclose" class="slide-image" height="100%" src="{{item.imgurl}}" width="100%" wx:if="{{item.click==1}}"></image> -->
</swiper-item> </swiper-item>
</swiper> </swiper>
<view class="small-bot-close" @click="closePopupWindow"> <view bindtap="adverclose" class="small-bot-close" @click="closePopupWindow">
<i class="iconfont icon-round-close" style="color:#fff"></i> <i class="iconfont icon-round-close" style="color:#fff"></i>
</view> </view>
</view> </view>
<!-- <view class="image-wrap">
<swiper class="swiper" style="width:100%;height: 1200rpx;" :autoplay="true" interval="3000" circular="true" :indicator-dots="true" indicator-color="#000" indicator-active-color="red">
<swiper-item class="swiper-item" v-for="(item, index) in adv.list" :key="index" v-if="item.imageUrl" @click="$util.diyRedirectTo(item.link)">
<view class="item">
<image :src="$util.img(item.imageUrl)" mode="aspectFit" :show-menu-by-longpress="true"/>
</view>
</swiper-item>
</swiper>
</view>
<text class="iconfont icon-round-close" @click="closePopupWindow"></text> -->
</uni-popup> </uni-popup>
</view> </view>
</template> </template>
@@ -79,7 +101,7 @@
</view> </view>
</uni-popup> </uni-popup>
<!-- 选择门店弹出框 --> <!-- 选择门店弹出框定位当前位置展示最近的一个门店 -->
<view @touchmove.prevent.stop class="choose-store"> <view @touchmove.prevent.stop class="choose-store">
<uni-popup ref="chooseStorePopup" type="center" :maskClick="false" class="choose-store"> <uni-popup ref="chooseStorePopup" type="center" :maskClick="false" class="choose-store">
<view class="choose-store-popup"> <view class="choose-store-popup">
@@ -115,6 +137,7 @@
</uni-popup> </uni-popup>
</view> </view>
<hover-nav :need="true"></hover-nav> <hover-nav :need="true"></hover-nav>
<!-- 隐私协议 -->
<privacy-popup ref="privacyPopup"></privacy-popup> <privacy-popup ref="privacyPopup"></privacy-popup>
<to-top v-if="showTop" @toTop="scrollToTopNative()"></to-top> <to-top v-if="showTop" @toTop="scrollToTopNative()"></to-top>
<ns-login ref="login"></ns-login> <ns-login ref="login"></ns-login>
@@ -123,45 +146,14 @@
</template> </template>
<script> <script>
import diyJs from '@/common/js/diy.js'; import diyJs from '@/common/js/diy.js';
import scroll from '@/common/js/scroll-view.js'; import scroll from '@/common/js/scroll-view.js';
import indexJs from './public/js/index.js'; import indexJs from './public/js/index.js';
export default { export default {
mixins: [diyJs, scroll, indexJs], mixins: [diyJs, scroll, indexJs]
data() {
return {
diyData: { global: {}, value: null },
followOfficialAccount: {},
wechatQrcode: '',
adv: { advshow: -1, list: [] },
// ❌ 不要定义 siteInfo、bgUrl除非你明确知道它们不会冲突
};
},
computed: {
// ✅ 安全获取 bgUrl用于 diy-index-page 的 prop
safeBgUrl() {
// 优先取全局配置中的 bgUrl没有则用组件自己的 bgUrl如有否则为空
return this.diyData?.global?.bgUrl || this.bgUrl || '';
},
// ✅ 安全生成 background-image 样式字符串(用于 fallback 区域)
backgroundUrlStyle() {
const url = this.diyData?.global?.bgUrl || this.bgUrl || '';
return url ? `url(${url})` : 'none';
}
},
// 如果你的 mixin 中已经处理了数据加载,这里可以留空
// 否则建议在 created/mounted 中初始化默认值或请求数据
created() {
// 可选:如果 mixin 没有初始化 diyData这里再兜底一次
if (!this.diyData) {
this.diyData = { global: {}, value: null };
}
}
}; };
</script> </script>
@@ -208,9 +200,8 @@ export default {
font-size: 60rpx; font-size: 60rpx;
} }
</style> </style>
<style scoped> <style scoped>
.swiper /deep/ .uni-swiper-dots-horizontal { .swiper ::v-deep .uni-swiper-dots-horizontal {
left: 40%; left: 40%;
bottom: 40px bottom: 40px
} }
@@ -223,26 +214,26 @@ export default {
width: 80%; width: 80%;
} }
/deep/.diy-index-page .uni-popup .uni-popup__wrapper-box { ::v-deep .diy-index-page .uni-popup .uni-popup__wrapper-box {
border-radius: 0; border-radius: 0;
} }
/deep/ .placeholder { ::v-deep .placeholder {
height: 0; height: 0;
} }
/deep/::-webkit-scrollbar { ::v-deep ::-webkit-scrollbar {
width: 0; width: 0;
height: 0; height: 0;
background-color: transparent; background-color: transparent;
display: none; display: none;
} }
/deep/ .sku-layer .uni-popup__wrapper.uni-custom .uni-popup__wrapper-box { ::v-deep .sku-layer .uni-popup__wrapper.uni-custom .uni-popup__wrapper-box {
max-height: unset !important; max-height: unset !important;
} }
/deep/ .mescroll-totop { ::v-deep .mescroll-totop {
/* #ifdef H5 */ /* #ifdef H5 */
right: 28rpx !important; right: 28rpx !important;
bottom: 200rpx !important; bottom: 200rpx !important;

View File

@@ -7,7 +7,7 @@
"setting": { "setting": {
"urlCheck": true, "urlCheck": true,
"es6": true, "es6": true,
"enhance": false, "enhance": true,
"postcss": true, "postcss": true,
"preloadBackgroundData": false, "preloadBackgroundData": false,
"minified": true, "minified": true,
@@ -39,19 +39,27 @@
"packNpmManually": false, "packNpmManually": false,
"packNpmRelationList": [], "packNpmRelationList": [],
"minifyWXSS": true, "minifyWXSS": true,
"compileWorklet": false, "condition": true,
"swc": false,
"disableSWC": true,
"minifyWXML": true, "minifyWXML": true,
"compileWorklet": true,
"localPlugins": false, "localPlugins": false,
"disableUseStrict": false, "disableUseStrict": false,
"useCompilerPlugins": false, "useCompilerPlugins": false
"condition": false,
"swc": false,
"disableSWC": true
}, },
"compileType": "miniprogram", "compileType": "miniprogram",
"libVersion": "3.12.0", "libVersion": "2.16.1",
"appid": "wx29215aa1bd97bbd6", "appid": "wx29215aa1bd97bbd6",
"projectname": "uniapp", "projectname": "uniapp",
"debugOptions": {
"hidedInDevtools": []
},
"scripts": {},
"staticServerOptions": {
"baseURL": "",
"servePath": ""
},
"isGameTourist": false, "isGameTourist": false,
"condition": { "condition": {
"search": { "search": {
@@ -72,7 +80,5 @@
"miniprogram": { "miniprogram": {
"list": [] "list": []
} }
}, }
"simulatorPluginLibVersion": {},
"editorSetting": {}
} }

View File

@@ -416,7 +416,7 @@ const store = new Vuex.Store({
}, },
// 生成主题颜色CSS变量 // 生成主题颜色CSS变量
themeColorSet() { themeColorSet() {
console.log('样式颜色设置...'); // console.log('样式颜色设置...');
let theme = this.state.themeStyle; let theme = this.state.themeStyle;
if (!theme?.main_color || !theme?.aux_color) return; if (!theme?.main_color || !theme?.aux_color) return;
try { try {
@@ -440,7 +440,7 @@ const store = new Vuex.Store({
} catch (e) { } catch (e) {
console.error('设置主题颜色失败', e); console.error('设置主题颜色失败', e);
} }
console.log('themeColor => ', this.state.themeColor); // console.log('themeColor => ', this.state.themeColor);
} }
} }
}) })