chore:优化了hover
This commit is contained in:
@@ -1,13 +1,12 @@
|
|||||||
<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
|
<button
|
||||||
v-if="fixBtnShow && isWeappOfficialKefu"
|
v-if="fixBtnShow && isWeappOfficialKefu"
|
||||||
class="btn-item common-bg"
|
class="btn-item common-bg"
|
||||||
@@ -16,7 +15,8 @@
|
|||||||
>
|
>
|
||||||
<text class="ai-icon" v-if="!currentKefuImg">🤖</text>
|
<text class="ai-icon" v-if="!currentKefuImg">🤖</text>
|
||||||
</button>
|
</button>
|
||||||
<!-- 其他类型客服使用普通 view -->
|
|
||||||
|
<!-- 其他类型客服按钮 -->
|
||||||
<view
|
<view
|
||||||
v-else-if="fixBtnShow"
|
v-else-if="fixBtnShow"
|
||||||
class="btn-item common-bg"
|
class="btn-item common-bg"
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
<text class="ai-icon" v-if="!currentKefuImg">🤖</text>
|
<text class="ai-icon" v-if="!currentKefuImg">🤖</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- ✅ 新增:小程序系统客服按钮(当附加设置开启时显示) -->
|
<!-- 小程序系统客服按钮 -->
|
||||||
<button
|
<button
|
||||||
v-if="fixBtnShow && showWeappSystemKefu"
|
v-if="fixBtnShow && showWeappSystemKefu"
|
||||||
class="btn-item common-bg"
|
class="btn-item common-bg"
|
||||||
@@ -45,11 +45,11 @@
|
|||||||
<text>{{ currentLangDisplayName }}</text>
|
<text>{{ currentLangDisplayName }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 电话按钮(始终显示) -->
|
<!-- 电话按钮 -->
|
||||||
<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>
|
||||||
@@ -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,43 +106,33 @@ export default {
|
|||||||
return this.shopInfo?.floatingButton?.button || {};
|
return this.shopInfo?.floatingButton?.button || {};
|
||||||
},
|
},
|
||||||
unreadCount() {
|
unreadCount() {
|
||||||
const customerService = createCustomerService(this);
|
return this.customerService?.getUnreadCount() || 0;
|
||||||
return customerService.getUnreadCount();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
currentKefuImg() {
|
currentKefuImg() {
|
||||||
const customerService = createCustomerService(this);
|
return this.customerService?.getKefuButtonIcon() || '';
|
||||||
return customerService.getKefuButtonIcon();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
isWeappOfficialKefu() {
|
isWeappOfficialKefu() {
|
||||||
const customerService = createCustomerService(this);
|
return this.customerService?.isWeappOfficialKefu() || false;
|
||||||
return customerService.isWeappOfficialKefu();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
showWeappSystemKefu() {
|
showWeappSystemKefu() {
|
||||||
const customerService = createCustomerService(this);
|
return this.customerService?.shouldShowExtraWeappSystemKefu() || false;
|
||||||
return customerService.shouldShowExtraWeappSystemKefu();
|
|
||||||
},
|
},
|
||||||
|
//根据显示的按钮数量动态计算容器高度
|
||||||
//根据显示的按钮数量动态计算容器高度
|
containerHeight() {
|
||||||
containerHeight() {
|
if (!this.fixBtnShow) return '320rpx';
|
||||||
if (!this.fixBtnShow) return '320rpx';
|
|
||||||
|
let buttonCount = 1;
|
||||||
let buttonCount = 1;
|
if (this.isLanguageSwitchEnabled) buttonCount++;
|
||||||
if (this.isLanguageSwitchEnabled) buttonCount++;
|
if (this.showWeappSystemKefu) buttonCount++;
|
||||||
if (this.showWeappSystemKefu) buttonCount++;
|
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
|
||||||
}
|
}
|
||||||
@@ -155,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) => {
|
||||||
@@ -166,12 +150,10 @@ 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 = {};
|
||||||
@@ -191,17 +173,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* 电话联系客服
|
|
||||||
*/
|
|
||||||
call() {
|
call() {
|
||||||
const customerService = createCustomerService(this);
|
this.customerService.makePhoneCallByNumber(this.tel);
|
||||||
customerService.makePhoneCallByNumber(this.tel);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* 切换中英文语言,并刷新当前页面(保留所有参数)
|
|
||||||
*/
|
|
||||||
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];
|
||||||
@@ -209,40 +184,12 @@ export default {
|
|||||||
// 调用语言切换逻辑(设置 storage + 清空缓存)
|
// 调用语言切换逻辑(设置 storage + 清空缓存)
|
||||||
this.$langConfig.change(targetLang);
|
this.$langConfig.change(targetLang);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* 打开 AI 智能助手
|
|
||||||
*/
|
|
||||||
openAIChat() {
|
|
||||||
const customerService = createCustomerService(this);
|
|
||||||
customerService.openAIChat();
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 打开客服选择对话框
|
|
||||||
*/
|
|
||||||
openCustomerSelectPopup() {
|
|
||||||
const customerService = createCustomerService(this);
|
|
||||||
customerService.openCustomerSelectPopupDialog();
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 核心方法:统一客服入口
|
|
||||||
*/
|
|
||||||
handleUnifiedKefuClick() {
|
handleUnifiedKefuClick() {
|
||||||
const customerService = createCustomerService(this);
|
this.customerService.handleUnifiedKefuClick({
|
||||||
customerService.handleUnifiedKefuClick({
|
|
||||||
sendMessageTitle: '来自悬浮按钮的咨询',
|
sendMessageTitle: '来自悬浮按钮的咨询',
|
||||||
sendMessagePath: '/pages/index/index'
|
sendMessagePath: '/pages/index/index'
|
||||||
});
|
});
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 打开客服选择弹出层(ActionSheet)
|
|
||||||
*/
|
|
||||||
openKefuSelectPopup() {
|
|
||||||
const customerService = createCustomerService(this);
|
|
||||||
customerService.openKefuSelectPopup(this.kefuList);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -284,10 +231,8 @@ export default {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 定义共同的背景颜色 */
|
|
||||||
.common-bg {
|
.common-bg {
|
||||||
background-color: var(--hover-nav-bg-color);
|
background-color: var(--hover-nav-bg-color);
|
||||||
/* 使用变量以保持一致性 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-item text {
|
.btn-item text {
|
||||||
@@ -317,8 +262,6 @@ export default {
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.ai-icon {
|
.ai-icon {
|
||||||
font-size: 40rpx;
|
font-size: 40rpx;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
Reference in New Issue
Block a user