chore:合并成一个客服按钮

This commit is contained in:
2025-12-19 11:59:52 +08:00
parent 8103f4c897
commit 3a455bd644
3 changed files with 40 additions and 5 deletions

View File

@@ -14,6 +14,7 @@ export class CustomerService {
*/
getPlatformConfig() {
const servicerConfig = this.vm.$store.state.servicerConfig;
console.log(`客服配置:`, servicerConfig)
if (!servicerConfig) return null;
// #ifdef H5

View File

@@ -1,18 +1,23 @@
<template>
<!-- 悬浮按钮 -->
<view v-if="pageCount == 1 || need" class="fixed-box" :style="{ height: fixBtnShow ? '330rpx' : '120rpx' }">
<button class="btn-item" v-if="fixBtnShow && useOfficialService" hoverClass="none" open-type="contact"
<!-- #ifdef MP-WEIXIN -->
<button class="btn-item" v-if="fixBtnShow" hoverClass="none" open-type="contact"
sessionFrom="weapp" showMessageCard="true"
:style="{ backgroundImage: 'url(' + (kefuimg ? kefuimg : '') + ')', backgroundSize: '100% 100%' }">
<text class="icox icox-kefu" v-if="!kefuimg"></text>
</button>
<!-- #endif -->
<!-- #ifdef H5 -->
<!-- 自定义客服按钮 -->
<button class="btn-item" v-if="fixBtnShow && !useOfficialService" hoverClass="none" @click="contactServicer"
<button class="btn-item" v-if="fixBtnShow" hoverClass="none" @click="contactServicer"
:style="{ backgroundImage: 'url(' + (kefuimg ? kefuimg : '') + ')', backgroundSize: '100% 100%' }">
<text class="icox icox-kefu" v-if="!kefuimg"></text>
</button>
<!-- #endif -->
<!-- AI智能助手 -->
<view class="btn-item" v-if="fixBtnShow && enableAIChat" @click="openAIChat"
<view class="btn-item" v-if="fixBtnShow && enableAIKefuButton" @click="openAIChat"
:style="{ backgroundImage: 'url(' + (aiAgentimg ? aiAgentimg : '') + ')', backgroundSize: '100% 100%' }">
<!-- 核心修改添加🤖表情保留原有判断逻辑 -->
<text class="ai-icon" v-if="!aiAgentimg">🤖</text>
@@ -30,7 +35,7 @@
</template>
<script>
import { createCustomerService } from '@/common/js/ai-service.js';
import { createCustomerService } from '@/common/js/customer-service.js';
import { mapGetters, mapMutations } from 'vuex';
export default {
@@ -60,6 +65,8 @@ export default {
this.customerService = createCustomerService(this);
this.buttonConfig = this.customerService.getButtonConfig();
console.log(`buttonConfig: `, this.buttonConfig);
const that = this;
uni.getStorage({
key: 'shopInfo',
@@ -80,6 +87,9 @@ export default {
'globalAIKefuConfig',
'aiUnreadCount'
]),
enableAIKefuButton() {
return this.buttonConfig?.type === 'aikefu' && this.enableAIChat;
},
aiAgentimg() {
return this.globalAIKefuConfig?.icon || this.$util.getDefaultImage().aiAgent || '';
},
@@ -141,6 +151,7 @@ export default {
this.$util.redirectTo('/pages_tool/ai-chat/index');
},
contactServicer() {
this.customerService.handleCustomerClick();
}
}

View File

@@ -146,8 +146,31 @@
nsNavbar,
toTop
},
mixins: [diyJs, scroll, indexJs]
mixins: [diyJs, scroll, indexJs],
methods: {
// 新增:电话按钮点击事件-弹出对话框
openCallDialog() {
uni.showModal({
title: "拨打?【仅为模拟】", // 弹窗标题
content: "", // 弹窗内容(可留空)
confirmText: "确定", // 确定按钮文字
cancelText: "取消", // 取消按钮文字
success: (res) => {
if (res.confirm) {
// 点击“确定”后的操作(比如实际拨号)
uni.makePhoneCall({
phoneNumber: "13800138000" // 替换为实际要拨打的号码
});
} else if (res.cancel) {
// 点击“取消”后的操作(可留空)
console.log('用户取消拨打');
}
}
});
}
}
};
</script>
<style lang="scss">