Files
lucky_shop/components/hover-nav/hover-nav.vue
2025-12-05 16:47:53 +08:00

188 lines
3.5 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<!-- 悬浮按钮 -->
<view v-if="pageCount == 1 || need" class="fixed-box" :style="{ height: fixBtnShow ? '120rpx' : '120rpx' }">
<!-- #ifdef MP-WEIXIN -->
<button
class="btn-item"
v-if="fixBtnShow"
hoverClass="none"
openType="contact"
sessionFrom="weapp"
showMessageCard="true"
:style="{backgroundImage:'url('+(kefuimg?kefuimg:'')+')',backgroundSize:'100% 100%'}"
>
<text class="icox icox-kefu" v-if="!kefuimg"></text>
</button>
<!-- #endif -->
<!-- 其他按钮AI 电话已隐藏 -->
</view>
</template>
<script>
import { mapGetters, mapMutations } from 'vuex'
export default {
name: 'hover-nav',
props: {
need: {
type: Boolean,
default: false
},
},
data() {
return {
pageCount: 0,
fixBtnShow: true,
tel: '',
kefuimg: '',
phoneimg: ''
};
},
created() {
this.kefuimg = this.$util.getDefaultImage().kefu
this.phoneimg = this.$util.getDefaultImage().phone
this.pageCount = getCurrentPages().length;
var that = this
uni.getStorage({
key: 'shopInfo',
success(e) {
that.tel = e.data.mobile
}
})
},
computed: {
...mapGetters([
'globalAIAgentConfig',
'aiUnreadCount'
]),
aiAgentimg() {
return this.globalAIAgentConfig?.icon || this.$util.getDefaultImage().aiAgent || ''
},
unreadCount() {
return this.aiUnreadCount
},
enableAIChat() {
return this.globalAIAgentConfig?.enable || true
},
},
methods: {
...mapMutations([
'setAiUnreadCount'
]),
// 拨打电话(已无调用,可保留或删除)
call() {
uni.makePhoneCall({
phoneNumber: this.tel + ''
})
},
// 打开AI聊天已无调用可保留或删除
openAIChat() {
if (this.enableAIChat) {
this.setAiUnreadCount(0);
}
this.$util.redirectTo('/pages_tool/ai-chat/index')
}
}
};
</script>
<style lang="scss">
.container-box {
width: 100%;
.item-wrap {
border-radius: 10rpx;
.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;
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 {
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;
position: relative;
text {
font-size: 36rpx;
font-weight: bold;
}
view {
font-size: 26rpx;
font-weight: bold;
}
&.show {
transform: rotate(180deg);
}
&.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
}
}
}
}
</style>