vr-shopxo-uniapp/components/diy/custom.vue

103 lines
3.9 KiB
Vue
Raw Normal View History

2024-09-19 08:46:09 +00:00
<template>
2024-09-26 02:50:30 +00:00
<view ref="container" :style="style_container + 'height:' + form.height * 2 + 'rpx;'">
2024-09-19 08:46:09 +00:00
<view class="wh-auto ht-auto pr">
2024-09-26 02:50:30 +00:00
<view v-for="item in form.custom_list" :key="item.id" class="main-content" :style="{ left: get_percentage_count(item.location.x, div_width), top: get_percentage_count(item.location.y, div_height), width: get_percentage_count(item.com_data.com_width, div_width), height: get_percentage_count(item.com_data.com_height, div_height) }">
2024-09-19 08:46:09 +00:00
<template v-if="item.key == 'text'">
2024-10-08 02:43:11 +00:00
<model-text :key="item.com_data" :propValue="item.com_data" :propSourceList="form.data_source_content" @url_event="url_event"></model-text>
2024-09-19 08:46:09 +00:00
</template>
<template v-else-if="item.key == 'img'">
2024-10-08 02:43:11 +00:00
<model-image :key="item.com_data" :propValue="item.com_data" :propSourceList="form.data_source_content" @url_event="url_event"></model-image>
2024-09-19 08:46:09 +00:00
</template>
<template v-else-if="item.key == 'auxiliary-line'">
2024-09-26 02:50:30 +00:00
<model-lines :key="item.com_data" :propValue="item.com_data" :propSourceList="form.data_source_content"></model-lines>
2024-09-19 08:46:09 +00:00
</template>
2024-09-24 02:17:40 +00:00
<template v-else-if="item.key == 'icon'">
2024-10-08 02:43:11 +00:00
<model-icon :key="item.com_data" :propValue="item.com_data" :propSourceList="form.data_source_content" @url_event="url_event"></model-icon>
2024-09-24 02:17:40 +00:00
</template>
2024-09-19 08:46:09 +00:00
</view>
</view>
</view>
</template>
<script>
import { common_styles_computer, percentage_count } from '@/common/js/common/common.js';
const app = getApp();
var system = app.globalData.get_system_info(null, null, true);
var sys_width = app.globalData.window_width_handle(system.windowWidth);
import modelText from '@/components/diy/modules/custom/model-text.vue';
import modelLines from '@/components/diy/modules/custom/model-lines.vue';
import modelImage from '@/components/diy/modules/custom/model-image.vue';
2024-09-24 02:17:40 +00:00
import modelIcon from '@/components/diy/modules/custom/model-icon.vue';
2024-09-26 02:50:30 +00:00
2024-09-19 08:46:09 +00:00
export default {
components: {
modelText,
modelLines,
2024-09-24 02:17:40 +00:00
modelImage,
2024-09-26 02:50:30 +00:00
modelIcon,
2024-09-19 08:46:09 +00:00
},
props: {
2024-09-26 01:59:23 +00:00
propValue: {
2024-09-19 08:46:09 +00:00
type: Object,
default: () => {
return {};
},
},
2024-10-08 06:48:12 +00:00
propkey: {
type: String,
default: '',
}
2024-09-19 08:46:09 +00:00
},
data() {
return {
form: {},
new_style: {},
2024-09-24 02:17:40 +00:00
scale: sys_width / 390,
2024-09-19 08:46:09 +00:00
style_container: '',
2024-09-24 02:17:40 +00:00
div_width: 0,
2024-09-26 02:50:30 +00:00
div_height: 0,
2024-09-19 08:46:09 +00:00
};
},
2024-09-19 08:57:10 +00:00
computed: {
2024-09-26 02:50:30 +00:00
get_percentage_count() {
return (num, container_size) => {
return this.percentage_count(num * this.scale, container_size);
};
},
2024-09-19 08:57:10 +00:00
},
2024-10-08 06:48:12 +00:00
watch: {
propkey(val) {
// 初始化
this.init();
}
},
2024-09-19 08:46:09 +00:00
created() {
this.init();
},
methods: {
2024-09-19 08:57:10 +00:00
percentage_count,
2024-09-19 08:46:09 +00:00
init() {
2024-10-08 06:48:12 +00:00
this.setData({
form: this.propValue.content,
new_style: this.propValue.style,
});
2024-09-19 08:46:09 +00:00
this.setData({
style_container: common_styles_computer(this.new_style.common_style) + 'box-sizing: border-box;', // 用于样式显示
2024-09-24 02:17:40 +00:00
div_width: sys_width,
2024-10-08 02:12:22 +00:00
div_height: this.form.height,
2024-09-19 08:46:09 +00:00
});
},
2024-10-08 02:43:11 +00:00
url_event(e) {
app.globalData.url_event(e);
2024-09-19 08:46:09 +00:00
},
},
};
</script>
<style scoped lang="scss">
2024-09-26 02:50:30 +00:00
.main-content {
position: absolute;
overflow: hidden;
}
2024-09-19 08:46:09 +00:00
</style>