chore:能正常运行

This commit is contained in:
2025-12-17 11:17:50 +08:00
parent ca74d4f8e5
commit 2a0489d4b2
21 changed files with 5928 additions and 127 deletions

View File

@@ -1,6 +1,19 @@
<template>
<!-- 悬浮按钮 -->
<view v-if="pageCount == 1 || need" class="fixed-box" :style="{ height: fixBtnShow ? '330rpx' : '120rpx' }">
<!-- AI智能助手 -->
<view class="btn-item" v-if="fixBtnShow && enableAIChat" @click="openAIChat"
:style="{backgroundImage:'url('+(aiAgentimg?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>
<!-- <view class="btn-item" v-if="fixBtnShow" @click="$util.redirectTo('/pages/index/index')"> -->
<!-- #ifdef MP-WEIXIN -->
<!-- 微信小程序默认客服按钮 -->
@@ -9,7 +22,7 @@
:style="{ backgroundImage: 'url(' + (kefuimg ? kefuimg : '') + ')', backgroundSize: '100% 100%' }">
<text class="icox icox-kefu" v-if="!kefuimg"></text>
</button>
<!-- 自定义客服按钮 -->
<button class="btn-item" v-if="fixBtnShow && !useOfficialService" hoverClass="none" @click="contactServicer"
:style="{ backgroundImage: 'url(' + (kefuimg ? kefuimg : '') + ')', backgroundSize: '100% 100%' }">
@@ -34,151 +47,216 @@
</template>
<script>
import { createCustomerService } from '@/common/js/customer-service.js';
import {
mapGetters,
mapMutations
} from 'vuex'
import {
createCustomerService
} from '@/common/js/customer-service.js';
export default {
name: 'hover-nav',
props: {
need: {
type: Boolean,
default: false
export default {
name: 'hover-nav',
props: {
need: {
type: Boolean,
default: false
},
},
},
data() {
return {
pageCount: 0,
fixBtnShow: true,
tel: '',
kefuimg: '',
phoneimg: '',
customerService: null, // 客服服务实例
buttonConfig: null // 按钮配置
};
},
created() {
this.kefuimg = this.$util.getDefaultImage().kefu
this.phoneimg = this.$util.getDefaultImage().phone
this.pageCount = getCurrentPages().length;
data() {
return {
pageCount: 0,
fixBtnShow: true,
tel: '',
kefuimg: '',
phoneimg: '',
customerService: null, // 客服服务实例
buttonConfig: null // 按钮配置
};
},
created() {
this.kefuimg = this.$util.getDefaultImage().kefu
this.phoneimg = this.$util.getDefaultImage().phone
this.pageCount = getCurrentPages().length;
// 初始化客服服务
this.customerService = createCustomerService(this);
this.buttonConfig = this.customerService.getButtonConfig();
// 初始化客服服务
this.customerService = createCustomerService(this);
this.buttonConfig = this.customerService.getButtonConfig();
var that = this
uni.getStorage({
key: 'shopInfo',
success(e) {
that.tel = e.data.mobile
}
})
},
computed: {
/**
* 是否使用官方客服
*/
useOfficialService() {
if (!this.buttonConfig) return true;
// #ifdef MP-WEIXIN
// 如果是微信小程序,检查配置
if (this.buttonConfig.type === 'weapp') {
// 默认使用官方客服除非明确设置为false
return this.buttonConfig.useOfficial !== false;
}
// #endif
return false;
}
},
methods: {
//拨打电话
call() {
uni.makePhoneCall({
phoneNumber: this.tel + ''
var that = this
uni.getStorage({
key: 'shopInfo',
success(e) {
that.tel = e.data.mobile
}
})
},
computed: {
...mapGetters([
'globalAIKefuConfig',
'aiUnreadCount'
]),
aiAgentimg() {
return this.globalAIKefuConfig?.icon || this.$util.getDefaultImage().aiAgent || '' // AI智能助手的头像
},
unreadCount() {
return this.aiUnreadCount
},
enableAIChat() {
return this.globalAIKefuConfig?.enable || true // 是否开启AI智能助手
},
/**
* 是否使用官方客服
*/
useOfficialService() {
if (!this.buttonConfig) return true;
//处理客服点击事件
contactServicer() {
// 使用统一客服处理
this.customerService.handleCustomerClick();
// #ifdef MP-WEIXIN
// 如果是微信小程序,检查配置
if (this.buttonConfig.type === 'weapp') {
// 默认使用官方客服除非明确设置为false
return this.buttonConfig.useOfficial !== false;
}
// #endif
return false;
}
},
methods: {
...mapMutations([
'setAiUnreadCount'
]),
//拨打电话
call() {
uni.makePhoneCall({
phoneNumber: this.tel + ''
})
},
//处理客服点击事件
contactServicer() {
// 使用统一客服处理
this.customerService.handleCustomerClick();
},
// 打开AI聊天弹窗
openAIChat() {
if (this.enableAIChat) {
this.setAiUnreadCount(0);
}
this.$util.redirectTo('/pages_tool/ai-chat/index')
}
}
}
};
};
</script>
<style lang="scss">
.container-box {
width: 100%;
.container-box {
width: 100%;
.item-wrap {
border-radius: 10rpx;
.image-box {
.item-wrap {
border-radius: 10rpx;
}
image {
width: 100%;
height: auto;
border-radius: 10rpx;
will-change: transform;
.image-box {
border-radius: 10rpx;
}
image {
width: 100%;
height: auto;
border-radius: 10rpx;
will-change: transform;
}
}
}
}
//悬浮按钮
.fixed-box {
position: fixed;
right: 0rpx;
bottom: 200rpx;
z-index: 10;
// background: #fff;
// box-shadow: 2rpx 2rpx 22rpx rgba(0, 0, 0, 0.3);
border-radius: 120rpx;
padding: 20rpx 0;
display: flex;
justify-content: center;
flex-direction: column;
width: 100rpx;
box-sizing: border-box;
transition: 0.3s;
overflow: hidden;
.btn-item {
//悬浮按钮
.fixed-box {
position: fixed;
right: 0rpx;
bottom: 200rpx;
z-index: 10;
border-radius: 120rpx;
padding: 20rpx 0;
display: flex;
justify-content: center;
text-align: center;
flex-direction: column;
line-height: 1;
margin: 14rpx 0;
transition: 0.1s;
background: #fff;
border-radius: 50rpx;
width: 80rpx;
height: 80rpx;
padding: 0;
width: 100rpx;
box-sizing: border-box;
transition: 0.3s;
overflow: hidden;
text {
font-size: 36rpx;
font-weight: bold;
}
.btn-item {
display: flex;
justify-content: center;
align-items: center; /* 新增:让🤖表情垂直居中 */
text-align: center;
flex-direction: column;
line-height: 1;
margin: 14rpx 0;
transition: 0.1s;
background: #fff;
border-radius: 50rpx;
width: 80rpx;
height: 80rpx;
padding: 0;
position: relative;
text {
font-size: 36rpx;
font-weight: bold;
}
view {
font-size: 26rpx;
font-weight: bold;
}
view {
font-size: 26rpx;
font-weight: bold;
}
&.show {
transform: rotate(180deg);
}
&.show {
transform: rotate(180deg);
}
&.switch {}
&.switch {}
&.icon-xiala {
margin: 0;
margin-top: 0.1rpx;
&.icon-xiala {
margin: 0;
margin-top: 0.1rpx;
}
// 未读消息小红点
.unread-badge {
position: absolute;
top: -5rpx;
right: -5rpx;
background-color: #ff4544;
color: white;
border-radius: 20rpx;
min-width: 30rpx;
height: 30rpx;
font-size: 10rpx;
line-height: 30rpx;
text-align: center;
padding: 0 8rpx;
z-index: 1;
box-shadow: 0 2rpx 10rpx rgba(255, 69, 68, 0.3);
.badge-text {
font-size: 8rpx;
// #ifdef MP-WEIXIN
font-size: 20rpx;
// #endif
}
}
// AI图标样式优化让🤖表情居中显示
.ai-icon {
font-size: 40rpx; // 调整🤖表情大小
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
}
}
}
}
</style>