vr-shopxo-uniapp/components/diy/float-window.vue

143 lines
4.2 KiB
Vue
Raw Normal View History

2024-09-09 07:09:54 +00:00
<template>
2024-09-26 10:09:56 +00:00
<movable-area class="online-service-movable-container">
<movable-view :x="x" :y="y" direction="all" class="float-window-spread flex-row align-c jc-c">
<block v-if="new_style.float_style == 'diffuse'">
<view class="ring" :style="color"></view>
<view class="ring" :style="color"></view>
</block>
<view class="img">
<imageEmpty :propImageSrc="form.button_img[0]" :propStyle="color" propImgFit="aspectFill" propErrorStyle="width: 60rpx;height: 60rpx;"></imageEmpty>
2024-09-09 07:09:54 +00:00
</view>
2024-09-26 10:09:56 +00:00
</movable-view>
</movable-area>
2024-09-09 07:09:54 +00:00
</template>
<script>
2024-09-13 08:47:46 +00:00
const app = getApp();
import { isEmpty } from '@/common/js/common/common.js';
import imageEmpty from '@/components/diy/modules/image-empty.vue';
export default {
components: {
imageEmpty,
},
props: {
2024-09-26 01:59:23 +00:00
propValue: {
2024-09-13 08:47:46 +00:00
type: Object,
default: () => {
return {};
},
2024-09-09 07:09:54 +00:00
},
2024-10-08 06:48:12 +00:00
propkey: {
type: String,
default: '',
}
2024-09-09 07:09:54 +00:00
},
2024-09-13 08:47:46 +00:00
data() {
return {
form: {},
new_style: {},
2024-09-26 10:09:56 +00:00
x: 0,
y: 0,
2024-09-13 08:47:46 +00:00
style: '',
color: '',
};
},
2024-10-08 06:48:12 +00:00
watch: {
propkey(val) {
// 初始化
this.init();
}
},
2024-09-13 08:47:46 +00:00
created() {
this.init();
2024-09-12 06:27:14 +00:00
},
2024-09-13 08:47:46 +00:00
methods: {
init() {
2024-10-08 06:48:12 +00:00
this.setData({
form: this.propValue.content,
new_style: this.propValue.style,
});
2024-09-26 10:09:56 +00:00
const { float_style, float_style_color, display_location, offset_number_percentage } = this.propValue.style;
const { windowWidth, windowHeight } = uni.getSystemInfoSync();
let x = windowWidth - 10;
2024-09-13 08:47:46 +00:00
if (display_location == 'left') {
2024-09-26 10:09:56 +00:00
x = 10;
2024-09-13 08:47:46 +00:00
}
2024-09-26 10:09:56 +00:00
// 计算出距离顶部的距离
const num = Math.ceil(windowHeight * (1 - Number(offset_number_percentage)));
2024-09-13 08:47:46 +00:00
this.setData({
2024-09-19 07:31:18 +00:00
color: float_style == 'shadow' ? `box-shadow: 0 10rpx 40rpx ${float_style_color};border-radius: 50%;` : `background-color: ${float_style_color};border-radius: 50%;`,
2024-09-26 10:09:56 +00:00
x: x,
y: num
2024-09-13 08:47:46 +00:00
});
},
url_open() {
const { button_jump, button_link } = this.form;
if (button_jump == 'link' && !isEmpty(button_link)) {
app.globalData.url_open(button_link.page);
} else {
console.log('客服');
}
},
},
};
2024-09-09 07:09:54 +00:00
</script>
<style scoped lang="scss">
2024-09-13 08:47:46 +00:00
.img {
2024-09-26 08:00:26 +00:00
width: 90rpx;
height: 90rpx;
2024-09-13 08:47:46 +00:00
border-radius: 50%;
}
2024-09-26 08:00:26 +00:00
.float-window {
z-index: 103;
}
2024-09-26 10:09:56 +00:00
.online-service-movable-container {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
background: transparent;
pointer-events: none;
z-index: 103;
}
2024-09-13 08:47:46 +00:00
/**
2024-09-26 08:00:26 +00:00
* 呼吸灯
*/
.float-window-spread {
2024-09-13 08:47:46 +00:00
position: relative;
2024-09-26 10:09:56 +00:00
pointer-events: auto;
2024-09-13 08:47:46 +00:00
z-index: 1;
2024-09-26 08:00:26 +00:00
width: 120rpx;
height: 120rpx;
2024-09-13 08:47:46 +00:00
border-radius: 50%;
}
2024-09-26 08:00:26 +00:00
.float-window-spread .ring {
2024-09-13 08:47:46 +00:00
/* 速度为1.5 * 层数 = 实际运行速度,速度修改则 animation-delay 属性也修改相同速度 */
animation: pulsing 1.5s ease-out infinite;
border-radius: 100%;
width: 100rpx;
height: 100rpx;
position: absolute;
}
/* 速度为1*层数 */
2024-09-26 08:00:26 +00:00
.float-window-spread .ring:nth-of-type(1) {
2024-09-13 08:47:46 +00:00
-webkit-animation-delay: -1.5s;
animation-delay: -1.5s;
}
2024-09-09 07:09:54 +00:00
2024-09-13 08:47:46 +00:00
/* 速度为1*层数 */
2024-09-26 08:00:26 +00:00
.float-window-spread .ring:nth-of-type(2) {
2024-09-13 08:47:46 +00:00
-webkit-animation-delay: -2s;
animation-delay: -2s;
}
@keyframes pulsing {
100% {
transform: scale(1.35);
opacity: 0;
}
2024-09-09 07:09:54 +00:00
}
</style>