chore:智能体客服正常运行

This commit is contained in:
2026-01-13 18:26:11 +08:00
parent 286fcc2142
commit e8fb35b310
2 changed files with 39 additions and 20 deletions

View File

@@ -2,7 +2,6 @@
<view v-if="pageCount == 1 || need" class="fixed-box"
:style="[{ height: fixBtnShow ? '400rpx' : '320rpx' }, customContainerStyle]">
<!-- AI 智能助手优先显示 -->
<view
v-if="fixBtnShow && enableAIChat"
@@ -11,9 +10,8 @@
:style="{ backgroundImage: aiAgentimg ? `url(${aiAgentimg})` : '', backgroundSize: '100% 100%' }"
>
<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>
<!-- 普通客服仅当未启用 AI 时显示 -->
@@ -72,10 +70,8 @@ export default {
kefuimg: '',
phoneimg: '',
shopInfo: null,
enableAIChat: false,
enableAIChat: false, // 默认关闭,但会在 created 中智能判断
aiAgentimg: '',
// 从 Vuex 获取未读数
// 注意:这里不要在 data 里定义 unreadCount用 computed 更好
currentLangIndex: 0,
langIndexMap: {},
isLanguageSwitchEnabled: false,
@@ -98,11 +94,25 @@ export default {
uni.getStorage({
key: 'shopInfo',
success: (e) => {
console.log('【调试】当前 shopInfo:', e.data);
this.shopInfo = e.data;
this.tel = e.data.mobile;
this.tel = e.data.mobile || '';
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 || '';
console.log('【调试】AI 客服是否启用:', this.enableAIChat);
},
fail: () => {
console.warn('未获取到 shopInfo使用默认设置');
// 如果完全没有 shopInfo也可以默认开启 AI
this.enableAIChat = true;
}
});
},
@@ -120,7 +130,6 @@ export default {
customTextStyle() {
return this.shopInfo?.floatingButton?.text || {};
},
// 👇 关键:从 Vuex 读取未读消息数
unreadCount() {
return this.$store.state.aiUnreadCount || 0;
}
@@ -145,7 +154,11 @@ export default {
}
},
call() {
uni.makePhoneCall({ phoneNumber: this.tel + '' });
if (this.tel) {
uni.makePhoneCall({ phoneNumber: this.tel + '' });
} else {
uni.showToast({ title: '暂无联系电话', icon: 'none' });
}
},
toggleLanguage() {
this.currentLangIndex = this.currentLangIndex === 0 ? 1 : 0;
@@ -184,13 +197,19 @@ export default {
}
},
openAIChat() {
if (this.enableAIChat) {
this.$store.commit('setAiUnreadCount', 0);
}
this.$util.redirectTo('/pages_tool/ai-chat/index');
uni.navigateTo({
url: '/pages_tool/ai-chat/index',
success: () => {
console.log('✅ AI 客服跳转成功');
},
fail: (err) => {
console.error('❌ 跳转失败:', err);
uni.showToast({ title: '跳转失败,请重试', icon: 'none' });
}
});
}
}
};
}
}
</script>
<style scoped>