chore:智能体客服正常运行
This commit is contained in:
@@ -2,7 +2,6 @@
|
|||||||
<view v-if="pageCount == 1 || need" class="fixed-box"
|
<view v-if="pageCount == 1 || need" class="fixed-box"
|
||||||
:style="[{ height: fixBtnShow ? '400rpx' : '320rpx' }, customContainerStyle]">
|
:style="[{ height: fixBtnShow ? '400rpx' : '320rpx' }, customContainerStyle]">
|
||||||
|
|
||||||
|
|
||||||
<!-- AI 智能助手(优先显示) -->
|
<!-- AI 智能助手(优先显示) -->
|
||||||
<view
|
<view
|
||||||
v-if="fixBtnShow && enableAIChat"
|
v-if="fixBtnShow && enableAIChat"
|
||||||
@@ -11,9 +10,8 @@
|
|||||||
:style="{ backgroundImage: aiAgentimg ? `url(${aiAgentimg})` : '', backgroundSize: '100% 100%' }"
|
:style="{ backgroundImage: aiAgentimg ? `url(${aiAgentimg})` : '', backgroundSize: '100% 100%' }"
|
||||||
>
|
>
|
||||||
<text class="ai-icon" v-if="!aiAgentimg">🤖</text>
|
<text class="ai-icon" v-if="!aiAgentimg">🤖</text>
|
||||||
<view v-if="unreadCount > 0" class="unread-badge">
|
|
||||||
<text class="badge-text">{{ unreadCount > 99 ? '99+' : unreadCount }}</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 普通客服(仅当未启用 AI 时显示) -->
|
<!-- 普通客服(仅当未启用 AI 时显示) -->
|
||||||
@@ -72,10 +70,8 @@ export default {
|
|||||||
kefuimg: '',
|
kefuimg: '',
|
||||||
phoneimg: '',
|
phoneimg: '',
|
||||||
shopInfo: null,
|
shopInfo: null,
|
||||||
enableAIChat: false,
|
enableAIChat: false, // 默认关闭,但会在 created 中智能判断
|
||||||
aiAgentimg: '',
|
aiAgentimg: '',
|
||||||
// 从 Vuex 获取未读数
|
|
||||||
// 注意:这里不要在 data 里定义 unreadCount,用 computed 更好
|
|
||||||
currentLangIndex: 0,
|
currentLangIndex: 0,
|
||||||
langIndexMap: {},
|
langIndexMap: {},
|
||||||
isLanguageSwitchEnabled: false,
|
isLanguageSwitchEnabled: false,
|
||||||
@@ -98,11 +94,25 @@ export default {
|
|||||||
uni.getStorage({
|
uni.getStorage({
|
||||||
key: 'shopInfo',
|
key: 'shopInfo',
|
||||||
success: (e) => {
|
success: (e) => {
|
||||||
|
console.log('【调试】当前 shopInfo:', e.data);
|
||||||
this.shopInfo = e.data;
|
this.shopInfo = e.data;
|
||||||
this.tel = e.data.mobile;
|
this.tel = e.data.mobile || '';
|
||||||
this.isLanguageSwitchEnabled = !!e.data.ischina;
|
this.isLanguageSwitchEnabled = !!e.data.ischina;
|
||||||
this.enableAIChat = !!e.data.enableAIChat;
|
|
||||||
|
// 🔧 关键修复:如果后台没传 enableAIChat,默认开启(方便测试)
|
||||||
|
// 正式环境建议由后台控制,此处可改为 false
|
||||||
|
const defaultEnableAI = true; // ← 改成 false 可关闭默认开启
|
||||||
|
this.enableAIChat = e.data.hasOwnProperty('enableAIChat')
|
||||||
|
? !!e.data.enableAIChat
|
||||||
|
: defaultEnableAI;
|
||||||
|
|
||||||
this.aiAgentimg = e.data.aiAgentimg || '';
|
this.aiAgentimg = e.data.aiAgentimg || '';
|
||||||
|
console.log('【调试】AI 客服是否启用:', this.enableAIChat);
|
||||||
|
},
|
||||||
|
fail: () => {
|
||||||
|
console.warn('未获取到 shopInfo,使用默认设置');
|
||||||
|
// 如果完全没有 shopInfo,也可以默认开启 AI
|
||||||
|
this.enableAIChat = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -120,7 +130,6 @@ export default {
|
|||||||
customTextStyle() {
|
customTextStyle() {
|
||||||
return this.shopInfo?.floatingButton?.text || {};
|
return this.shopInfo?.floatingButton?.text || {};
|
||||||
},
|
},
|
||||||
// 👇 关键:从 Vuex 读取未读消息数
|
|
||||||
unreadCount() {
|
unreadCount() {
|
||||||
return this.$store.state.aiUnreadCount || 0;
|
return this.$store.state.aiUnreadCount || 0;
|
||||||
}
|
}
|
||||||
@@ -145,7 +154,11 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
call() {
|
call() {
|
||||||
uni.makePhoneCall({ phoneNumber: this.tel + '' });
|
if (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;
|
||||||
@@ -184,13 +197,19 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
openAIChat() {
|
openAIChat() {
|
||||||
if (this.enableAIChat) {
|
uni.navigateTo({
|
||||||
this.$store.commit('setAiUnreadCount', 0);
|
url: '/pages_tool/ai-chat/index',
|
||||||
}
|
success: () => {
|
||||||
this.$util.redirectTo('/pages_tool/ai-chat/index');
|
console.log('✅ AI 客服跳转成功');
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
console.error('❌ 跳转失败:', err);
|
||||||
|
uni.showToast({ title: '跳转失败,请重试', icon: 'none' });
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -316,9 +316,9 @@
|
|||||||
"root": "pages_tool",
|
"root": "pages_tool",
|
||||||
"pages": [
|
"pages": [
|
||||||
{
|
{
|
||||||
"path": "agreement/contenr",
|
"path": "ai-chat/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": ""
|
"navigationBarTitleText": "AI 客服"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user