diff --git a/common/js/customer-service.js b/common/js/customer-service.js index ba09912..1e59c59 100644 --- a/common/js/customer-service.js +++ b/common/js/customer-service.js @@ -76,6 +76,15 @@ export class CustomerService { return config && typeof config === 'object' && config.type; } + /** + * 检查是否有有效的客服配置(用于判断是否显示客服按钮) + * @returns {Boolean} + */ + hasValidKefuConfig() { + const config = this.getPlatformConfig(); + return config && typeof config === 'object' && config.type && config.type !== 'none'; + } + /** * 验证客服配置完整性 * @returns {Object} 验证结果 diff --git a/components/hover-nav/hover-nav.vue b/components/hover-nav/hover-nav.vue index 00b9dac..7eff341 100644 --- a/components/hover-nav/hover-nav.vue +++ b/components/hover-nav/hover-nav.vue @@ -15,7 +15,7 @@ @@ -106,30 +106,39 @@ export default { return this.shopInfo?.floatingButton?.button || {}; }, unreadCount() { - return this.customerService?.getUnreadCount() || 0; + const customerService = createCustomerService(this); + return customerService.getUnreadCount(); }, currentKefuImg() { - return this.customerService?.getKefuButtonIcon() || ''; + const customerService = createCustomerService(this); + return customerService.getKefuButtonIcon(); }, isWeappOfficialKefu() { - return this.customerService?.isWeappOfficialKefu() || false; + const customerService = createCustomerService(this); + return customerService.isWeappOfficialKefu(); }, showWeappSystemKefu() { - return this.customerService?.shouldShowExtraWeappSystemKefu() || false; + const customerService = createCustomerService(this); + return customerService.shouldShowExtraWeappSystemKefu(); }, - //根据显示的按钮数量动态计算容器高度 - containerHeight() { - if (!this.fixBtnShow) return '320rpx'; - - let buttonCount = 1; - if (this.isLanguageSwitchEnabled) buttonCount++; - if (this.showWeappSystemKefu) buttonCount++; - buttonCount++; - const totalRpx = 94 * buttonCount - 14; - const pxValue = Math.round(totalRpx * 0.5); - return ` $ {pxValue}px`; - } - }, + hasValidKefuConfig() { + const customerService = createCustomerService(this); + return customerService.hasValidKefuConfig(); + }, + //根据显示的按钮数量动态计算容器高度 + containerHeight() { + if (!this.fixBtnShow) return '320rpx'; + + let buttonCount = 1; + if (this.isLanguageSwitchEnabled) buttonCount++; + if (this.showWeappSystemKefu) buttonCount++; + buttonCount++; + const totalRpx = 94 * buttonCount - 14; + const pxValue = Math.round(totalRpx * 0.5); + + return ` $ {pxValue}px`; + } + }, watch: { shopInfo: { handler(newVal) {