vr-uniapp/src/components/model-data-magic/model-data-magic-content.vue

282 lines
11 KiB
Vue
Raw Normal View History

2024-08-13 02:48:05 +00:00
<template>
2024-08-29 07:23:52 +00:00
<div class="w h">
2024-08-26 08:51:20 +00:00
<el-form :model="form" label-width="80">
2024-08-29 07:23:52 +00:00
<card-container>
2024-08-13 02:48:05 +00:00
<div class="mb-12">展示风格</div>
2024-09-06 02:57:34 +00:00
<el-form-item label="选择风格" label-width="60">
2024-08-13 02:48:05 +00:00
<div class="flex align-c flex-wrap gap-10">
<div v-for="(item, index) in style_list" :key="index" :class="['flex-item', {'flex-item-actived': form.style_actived === index }]" @click="style_click(index)">
2024-09-05 07:00:29 +00:00
<icon :name="item" :color="`${ form.style_actived === index ? '#E1EEF9' : '#EDEDED'}`" size="30"></icon>
2024-08-13 02:48:05 +00:00
</div>
</div>
</el-form-item>
</card-container>
2024-08-29 07:23:52 +00:00
<div class="bg-f5 divider-line" />
<card-container>
2024-08-13 02:48:05 +00:00
<div class="mb-12">展示设置</div>
<el-form-item label-width="0" class="show-config">
<!-- 风格9 -->
2024-08-13 10:43:12 +00:00
<template v-if="form.style_actived == 7">
2024-08-13 02:48:05 +00:00
<div class="flex-row align-c jc-c gap-2 style-size flex-wrap">
2024-08-13 10:43:12 +00:00
<div v-for="(item, index) in form.data_magic_list" :key="index" :class="['bg-f5', {'cube-selected-active': selected_active == index, 'style9-top': [0, 1].includes(index), 'style9-bottom': ![0, 1].includes(index)}]" @click="selected_click(index)">
2024-08-13 11:00:52 +00:00
<div class="cube-selected-text">
<template v-if="[0, 1].includes(index)">375 x 375 </template>
2024-08-14 09:03:33 +00:00
<template v-else>250 x 375 </template>
2024-08-15 03:58:23 +00:00
<div>{{ data_title(item) }}</div>
2024-08-13 11:00:52 +00:00
</div>
2024-08-13 02:48:05 +00:00
</div>
</div>
</template>
<template v-else>
2024-08-13 10:43:12 +00:00
<magic-cube :key="form.style_actived" :list="form.data_magic_list" :flag="false" :cube-width="cubeWidth" type="data" :cube-height="cubeHeight" @selected_click="selected_click"></magic-cube>
2024-08-13 02:48:05 +00:00
</template>
</el-form-item>
</card-container>
2024-08-29 07:23:52 +00:00
<div class="bg-f5 divider-line" />
2024-08-13 08:18:39 +00:00
<el-tabs v-model="tabs_name" class="content-tabs">
<el-tab-pane label="内容设置" name="content">
2024-08-15 09:09:34 +00:00
<tabs-content :value="form.data_magic_list[selected_active].data_content" :is-show-title="is_show_title"></tabs-content>
2024-08-13 08:18:39 +00:00
</el-tab-pane>
<el-tab-pane label="样式设置" name="styles">
2024-08-15 09:09:34 +00:00
<tabs-styles :value="form.data_magic_list[selected_active].data_style" :content="form.data_magic_list[selected_active].data_content" :is-show-title="is_show_title"></tabs-styles>
2024-08-13 08:18:39 +00:00
</el-tab-pane>
</el-tabs>
2024-08-13 02:48:05 +00:00
</el-form>
</div>
</template>
<script setup lang="ts">
2024-08-14 09:03:33 +00:00
import { get_math } from '@/utils';
2024-08-13 02:48:05 +00:00
import { isEmpty, cloneDeep } from 'lodash';
const props = defineProps({
value: {
type: Object,
default: () => {},
},
});
2024-08-14 02:48:42 +00:00
// 风格数组
2024-08-13 02:48:05 +00:00
const style_list = ['heng2', 'shu2', 'shang2xia1', 'shang1xia2', 'zuo1you2', 'zuo2you1', 'tianzige', 'shang2xia3', 'zuo1youshang1youxia2'];
2024-08-14 02:48:42 +00:00
// 每个小模块独立的样式
2024-08-13 09:42:32 +00:00
const data_style = {
2024-08-29 05:47:53 +00:00
color_list: [{ color: '#FFD9C3', color_percentage: 0 }, { color: '#FFECE2', color_percentage: 12 }, { color: '#FFFFFF', color_percentage: 30 }],
2024-08-14 09:03:33 +00:00
direction: '180deg',
2024-10-10 08:16:31 +00:00
background_img_style: '2',
background_img: [],
2024-09-05 05:58:21 +00:00
is_roll: '0',
2024-08-13 09:42:32 +00:00
rotation_direction: 'horizontal',
interval_time: 3,
2024-08-13 09:42:32 +00:00
heading_color: '#000',
2024-08-27 02:52:15 +00:00
heading_typeface: '400',
2024-08-15 03:58:23 +00:00
heading_size: 20,
subtitle_color: '#FF852A',
2024-08-27 02:52:15 +00:00
subtitle_typeface: '400',
2024-08-15 03:58:23 +00:00
subtitle_size: 14,
2024-08-15 10:48:07 +00:00
chunk_padding: {
padding: 0,
padding_top: 20,
padding_bottom: 20,
padding_left: 15,
padding_right: 15,
},
2024-09-05 05:58:21 +00:00
is_show: '1',
2024-08-13 09:42:32 +00:00
indicator_style: 'dot',
indicator_location: 'center',
indicator_size: 5,
2024-09-11 06:10:35 +00:00
indicator_bottom: 6,
2024-08-13 09:42:32 +00:00
indicator_radius: {
2024-09-11 06:10:35 +00:00
radius: 4,
radius_top_left: 4,
radius_top_right: 4,
radius_bottom_left: 4,
radius_bottom_right: 4,
2024-08-13 09:42:32 +00:00
},
actived_color: '#2A94FF',
color: '#DDDDDD',
}
2024-08-14 02:48:42 +00:00
// 每个小模块独立的内容
2024-08-13 10:43:12 +00:00
const data_content = {
2024-08-23 08:13:41 +00:00
data_type: 'goods',
2024-08-15 08:48:13 +00:00
heading_title: '主标题',
subtitle: '副标题',
2024-08-23 08:13:41 +00:00
goods_list:[],
goods_ids: '',
2024-08-23 08:13:41 +00:00
is_show: ['title', 'price'],
images_list:[
2024-08-14 09:03:33 +00:00
{
carousel_img: [],
carousel_link: {},
}
]
2024-08-13 10:43:12 +00:00
}
2024-08-14 02:48:42 +00:00
// 不同风格的数据
2024-08-13 02:48:05 +00:00
const style_show_list = [
2024-08-15 06:50:48 +00:00
[{ start: {x: 1, y: 1}, end: {x: 4, y: 2}, num: 2, flex: 'row', outerflex: 'row' }, { start: {x: 1, y: 3}, end: {x: 4, y: 4}, num: 2, flex: 'row', outerflex: 'row'}], // 风格1
[{ start: {x: 1, y: 1}, end: {x: 2, y: 4}, num: 3, flex: 'row', outerflex: 'col' }, { start: {x: 3, y: 1}, end: {x: 4, y: 4}, num: 3, flex: 'row', outerflex: 'col' }], // 风格2
[{ start: {x: 1, y: 1}, end: {x: 2, y: 2}, num: 2, flex: 'col', outerflex: 'row' }, { start: {x: 3, y: 1}, end: {x: 4, y: 2}, num: 2, flex: 'col', outerflex: 'row' }, { start: {x: 1, y: 3}, end: {x: 4, y: 4}, num: 2, flex: 'row', outerflex: 'row' }],// 风格3
[{ start: {x: 1, y: 1}, end: {x: 4, y: 2}, num: 2, flex: 'row', outerflex: 'row' }, { start: {x: 1, y: 3}, end: {x: 2, y: 4}, num: 2, flex: 'col', outerflex: 'row' }, { start: {x: 3, y: 3}, end: {x: 4, y: 4}, num: 2, flex: 'col', outerflex: 'row' }],// 风格4
[{ start: {x: 1, y: 1}, end: {x: 2, y: 4}, num: 3, flex: 'row', outerflex: 'col' }, { start: {x: 3, y: 1}, end: {x: 4, y: 2}, num: 2, flex: 'col', outerflex: 'row' }, { start: {x: 3, y: 3}, end: {x: 4, y: 4}, num: 2, flex: 'col', outerflex: 'row' }],// 风格5
[{ start: {x: 1, y: 1}, end: {x: 2, y: 2}, num: 2, flex: 'col', outerflex: 'row' }, { start: {x: 1, y: 3}, end: {x: 2, y: 4}, num: 2, flex: 'col', outerflex: 'row' }, { start: {x: 3, y: 1}, end: {x: 4, y: 4}, num: 3, flex: 'row', outerflex: 'col' }],// 风格6
[{ start: {x: 1, y: 1}, end: {x: 2, y: 2}, num: 2, flex: 'col', outerflex: 'row' }, { start: {x: 3, y: 1}, end: {x: 4, y: 2}, num: 2, flex: 'col', outerflex: 'row' }, { start: {x: 1, y: 3}, end: {x: 2, y: 4}, num: 2, flex: 'col', outerflex: 'row' }, { start: {x: 3, y: 3}, end: {x: 4, y: 4}, num: 2, flex: 'col', outerflex: 'row' }],// 风格7
[{ start: {x: 1, y: 1}, end: {x: 2, y: 4}, num: 2, flex: 'col', outerflex: 'row' }, { start: {x: 3, y: 1}, end: {x: 4, y: 2}, num: 2, flex: 'col', outerflex: 'row' }, { start: {x: 3, y: 3}, end: {x: 3, y: 4}, num: 1, flex: 'col', outerflex: 'row' }, { start: {x: 4, y: 3}, end: {x: 4, y: 4}, num: 1, flex: 'col', outerflex: 'row' }, { start: {x: 4, y: 3}, end: {x: 4, y: 4}, num: 1, flex: 'col', outerflex: 'row' }],// 风格8
[{ start: {x: 1, y: 1}, end: {x: 2, y: 4}, num: 3, flex: 'row', outerflex: 'col' }, { start: {x: 3, y: 1}, end: {x: 4, y: 2}, num: 2, flex: 'col', outerflex: 'row' }, { start: {x: 3, y: 3}, end: {x: 3, y: 4}, num: 1, flex: 'col', outerflex: 'row' }, { start: {x: 4, y: 3}, end: {x: 4, y: 4}, num: 1, flex: 'col', outerflex: 'row' }],// 风格9
2024-08-13 02:48:05 +00:00
]
2024-08-13 08:18:39 +00:00
const tabs_name = ref('content');
2024-08-13 10:43:12 +00:00
const state = reactive({
form: props.value
});
const { form } = toRefs(state);
2024-08-13 02:48:05 +00:00
//#region 容器大小变更
const cubeWidth = ref(400);
const cubeHeight = ref(400);
const style_width = computed(() => cubeWidth.value + 'px');
const style_height = computed(() => cubeHeight.value + 'px');
2024-08-13 10:43:12 +00:00
onBeforeMount(() => {
if (isEmpty(form.value.data_magic_list)) {
form.value.data_magic_list = magic_list(0);
}
})
2024-08-13 02:48:05 +00:00
onMounted(() => {
handleResize();
window.addEventListener('resize', handleResize);
});
2024-08-13 10:43:12 +00:00
2024-08-13 02:48:05 +00:00
onUnmounted(() => {
window.removeEventListener('resize', handleResize);
});
2024-08-14 02:48:42 +00:00
const handleResize = () => {
2024-08-30 10:48:27 +00:00
if (window.innerWidth <= 1560) {
2024-08-14 02:48:42 +00:00
cubeWidth.value = 330;
cubeHeight.value = 330;
} else {
cubeWidth.value = 390;
cubeHeight.value = 390;
}
}
2024-08-13 02:48:05 +00:00
//#endregion
2024-08-15 03:58:23 +00:00
//#region 选中切换数据
2024-08-13 02:48:05 +00:00
const selected_active = ref(0);
2024-08-15 03:58:23 +00:00
// 切换风格
2024-08-13 02:48:05 +00:00
const style_click = (index: number) => {
2024-08-13 11:00:52 +00:00
form.value.data_magic_list = magic_list(index);
2024-08-13 10:43:12 +00:00
2024-08-13 02:48:05 +00:00
form.value.style_actived = index;
selected_active.value = 0;
2024-08-14 02:48:42 +00:00
tabs_name.value = 'content';
2024-08-13 02:48:05 +00:00
}
2024-08-15 03:58:23 +00:00
// 规整复制的数据
2024-08-13 10:43:12 +00:00
const magic_list = (index: number) => {
2024-08-15 10:48:07 +00:00
return cloneDeep(style_show_list[index]).map((item, map_index) => ({
2024-08-13 10:43:12 +00:00
...item,
2024-08-14 09:03:33 +00:00
actived_index: 0,
2024-08-13 10:43:12 +00:00
data_content: cloneDeep(data_content),
2024-08-14 09:03:33 +00:00
data_style: {
...cloneDeep(data_style),
2024-08-15 10:48:07 +00:00
chunk_padding: {
padding: show_padding(index, map_index) ? 10 : 0,
padding_top: show_padding(index, map_index) ? 10 : 20,
padding_bottom: show_padding(index, map_index) ? 10 : 20,
padding_left: show_padding(index, map_index) ? 10 : 15,
padding_right: show_padding(index, map_index) ? 10 : 15,
},
2024-08-14 09:03:33 +00:00
carouselKey: get_math(),
}
2024-08-13 10:43:12 +00:00
}));
}
2024-08-15 03:58:23 +00:00
// 选中风格内不同的块
2024-08-13 02:48:05 +00:00
const selected_click = (index: number) => {
selected_active.value = index;
2024-08-14 02:48:42 +00:00
tabs_name.value = 'content';
2024-08-13 02:48:05 +00:00
}
2024-08-15 10:48:07 +00:00
const show_padding = (index:number, map_index:number) => {
return index == 7 && ![0, 1].includes(map_index)
}
2024-08-15 03:58:23 +00:00
//#endregion
const data_title = (item: any) => {
let title = `共有`;
if (item.data_content) {
2024-08-23 08:13:41 +00:00
if (item.data_content.data_type == 'goods') {
title += `${ item.data_content.goods_list.length }个商品`;
2024-08-15 03:58:23 +00:00
} else {
2024-08-23 08:13:41 +00:00
title += `${ item.data_content.images_list.length }个图片`;
2024-08-15 03:58:23 +00:00
}
}
return title;
};
2024-08-15 06:50:48 +00:00
// 除了第8个风格下的后3个不显示标题其他的都显示
const is_show_title = computed(() => !(form.value.style_actived == 7 && ![0, 1].includes(selected_active.value)));
2024-08-13 02:48:05 +00:00
</script>
<style lang="scss" scoped>
.card.mb-8 {
.el-form-item:last-child {
margin-bottom: 0;
}
}
.flex-item {
2024-09-05 07:00:29 +00:00
width: 4.7rem;
height: 4.7rem;
2024-08-13 02:48:05 +00:00
background: #F7F7F7;
border-radius: 0.4rem;
border: 1px solid #E4E4E4;
padding: 1.4rem;
display: flex;
align-items: center;
justify-content: center;
}
.flex-item-actived {
background: #F5F9FF;
border-radius: 4px;
border: 1px solid #2A94FF;
}
.show-config {
:deep(.el-form-item__content) {
justify-content: center;
}
}
.style-size {
width: v-bind(style_width);
height: v-bind(style_height);
.style9-top {
width: calc(50% - 0.2rem);
height: 50%;
position: relative;
}
.style9-bottom {
width: calc(33% - 0.1rem);
height: 50%;
position: relative;
}
}
.cube-selected-active {
border: 1px solid $cr-primary;
}
.cube-selected-text {
font-size: 12px;
width: 100%;
position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
text-align: center;
color: $cr-primary;
}
2024-08-13 08:18:39 +00:00
:deep(.el-tabs.content-tabs) {
.el-tabs__header.is-top {
background: #fff;
margin: 0;
padding-top: 2rem;
}
.el-tabs__item.is-top {
padding: 0;
align-items: center;
width: 10rem;
font-size: 1.4rem;
2024-08-13 02:48:05 +00:00
}
2024-08-13 08:18:39 +00:00
.el-tabs__active-bar{
width: 100%;
2024-08-13 02:48:05 +00:00
}
}
</style>