From d25084485817a94ded740059293a44d7232c18c9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BA=8E=E8=82=96=E7=A3=8A?= <18851179580@163.com>
Date: Fri, 13 Dec 2024 16:52:58 +0800
Subject: [PATCH 1/3] =?UTF-8?q?=E9=80=89=E9=A1=B9=E5=8D=A1=E5=92=8C?=
=?UTF-8?q?=E8=BD=AE=E6=92=AD=E5=9B=BE=E6=95=B0=E6=8D=AE=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
common/js/common/common.js | 6 +-
.../choice-location/choice-location.vue | 2 +-
components/diy/carousel.vue | 58 ++++++++----
components/diy/diy.vue | 67 ++++++++------
components/diy/modules/tabs-view.vue | 89 ++++++++++++++++---
components/diy/search.vue | 2 +-
components/diy/tabs-carousel.vue | 50 +++++++++--
components/diy/tabs.vue | 9 +-
8 files changed, 219 insertions(+), 64 deletions(-)
diff --git a/common/js/common/common.js b/common/js/common/common.js
index d59e391b..246c101f 100644
--- a/common/js/common/common.js
+++ b/common/js/common/common.js
@@ -32,7 +32,7 @@ export function get_nested_property(obj, path) {
// 使用reduce方法遍历属性键数组,逐层访问对象属性
// 如果当前对象存在且拥有下一个属性键,则继续访问;否则返回空字符串
- return keys.reduce((o, key) => (o && o[key] ? o[key] : ''), obj) || '';
+ return keys.reduce((o, key) => (o != null && o[key] != null ? o[key] : ''), obj) ?? '';
}
/**
@@ -344,6 +344,10 @@ export function background_computer(new_style) {
* 这些样式包括渐变色、内边距、外边距、圆角和阴影等,为组件提供了一套完整的外观定义。
*
* @param new_style 组件的新样式对象,包含了需要计算的样式属性。
+ * @param scale 一个缩放比例,用于控制样式的缩放,默认为1。
+ * @param scale 用于控制样式的缩放比例,默认为1,表示不进行缩放。
+ * @param is_custom 一个布尔值,用于判断是否为自定义样式,默认为false。
+ * @param index 用于标识组件的索引,默认为0。
* @returns 返回一个字符串,包含了计算后的样式定义,可以被直接应用于组件的样式属性。
*/
export function common_styles_computer(new_style) {
diff --git a/components/choice-location/choice-location.vue b/components/choice-location/choice-location.vue
index 31c922c6..717572f9 100644
--- a/components/choice-location/choice-location.vue
+++ b/components/choice-location/choice-location.vue
@@ -10,7 +10,7 @@
- {{ location.text || '' }}
+ {{ location.text || '' }}
diff --git a/components/diy/carousel.vue b/components/diy/carousel.vue
index ab77adc0..65c167b4 100644
--- a/components/diy/carousel.vue
+++ b/components/diy/carousel.vue
@@ -1,6 +1,6 @@
-
-
+
+
@@ -129,6 +129,9 @@
// hackReset: true,
// 轮播图的高度
swiper_height: 50,
+ // 轮播时的背景样式
+ swiper_bg_style: '',
+ swiper_bg_img_style: '',
};
},
watch: {
@@ -179,6 +182,8 @@
img_fit: fit, // 图片风格 默认为aspectFill
video_style: this.get_video_style(new_style), // 视频播放按钮显示逻辑
swiper_height: new_form.height * scale + 'px', // 轮播图高度
+ swiper_bg_style: this.get_swiper_bg_style(new_form, 0),
+ swiper_bg_img_style: this.get_swiper_bg_img_style(new_form, 0),
});
// 风格二显示逻辑
if (new_form.carousel_type == 'card') {
@@ -198,17 +203,37 @@
});
// });
}
- // this.setData({
- // hackReset: false,
- // });
- // this.$nextTick(() => {
- // this.setData({
- // hackReset: true,
- // });
- // });
+ },
+ get_swiper_bg_style(form, actived_index) {
+ if (!this.propIsCommon) {
+ return '';
+ }
+ const style = form?.carousel_list?.[actived_index]?.style;
+ if (style && !isEmpty(style.color_list)) {
+ const color_list = style.color_list;
+ const list = color_list.filter((item) => !isEmpty(item.color));
+ if (list.length > 0) {
+ try {
+ return gradient_computer(style);
+ } catch (error) {
+ return '';
+ }
+ }
+ return '';
+ }
+ return '';
+ },
+ get_swiper_bg_img_style(form, actived_index) {
+ if (!this.propIsCommon) {
+ return '';
+ }
+ if (!isEmpty(form.carousel_list[actived_index].style.background_img)) {
+ return background_computer(form.carousel_list[actived_index].style);
+ }
+ return '';
},
get_seat_list(form) {
- if (form.carousel_list.length > 3) {
+ if (form.carousel_list.length > 3 || form.carousel_type !== 'card') {
return [];
} else {
let seat_list = [];
@@ -231,19 +256,22 @@
},
slideChange(e) {
let actived_index = e.detail.current;
- if (e.detail.current > this.form.carousel_list.length - 1) {
+ if (e.detail.current > this.form.carousel_list.length - 1 && this.form.carousel_type == 'card') {
const seat_length = this.seat_list.length;
if (seat_length == 2 && e.detail.current == 3) {
actived_index = 1;
- } else if (seat_length == 3) {
- actived_index = 0;
} else {
- actived_index = e.detail.current - this.seat_list.length;
+ actived_index = 0;
}
}
+ if (!this.propIsCommon) {
+ this.$emit('slideChange', actived_index);
+ }
this.setData({
animationData: e.detail.current,
actived_index: actived_index,
+ swiper_bg_style: this.get_swiper_bg_style(this.form, actived_index),
+ swiper_bg_img_style: this.get_swiper_bg_img_style(this.form, actived_index),
});
},
get_video_style(new_style) {
diff --git a/components/diy/diy.vue b/components/diy/diy.vue
index 183725ab..a02d2087 100644
--- a/components/diy/diy.vue
+++ b/components/diy/diy.vue
@@ -10,8 +10,8 @@
-
-
+
+
@@ -288,38 +288,41 @@
// 初始化
init() {
- let header = this.propValue.header;
+ const { header = {}, diy_data = [], tabs_data = []} = this.propValue;
let header_style = header.com_data.style;
- let diy_data = JSON.parse(JSON.stringify(this.propValue.diy_data));
let new_diy_index = 0;
+ let new_tabs_data = [];
let new_diy_data = [];
- diy_data.forEach((item) => {
- // 判断是否是商品列表
- if (item.com_name == 'float-window') {
- item.index = -1;
- } else {
- if (new_diy_index == 0) {
- // 判断是否开启沉浸模式和是否开启安全距离 如果为true则除了选项卡和选项卡轮播外, 第一个组件则加上安全距离样式的padding_top加上顶部导航的高度和安全距离的高度
- if (header_style.immersive_style == '1' && header_style.general_safe_distance_value == '1') {
- let new_data = JSON.parse(JSON.stringify(item));
- // 顶部导航的高度
- let header_top_height = (header.com_data.content.data_alone_row_value.length > 0 ? parseInt(header.com_data.style.data_alone_row_space || 5) : 0) + 33 + (header.com_data.content.data_alone_row_value.length > 0 ? 33 : 0);
- new_data.com_data.style.common_style.padding_top = parseInt(new_data.com_data.style.common_style.padding_top) + header_top_height;
- item = new_data;
- }
- }
- item.index = new_diy_index;
- new_diy_data.push(item);
+ if (tabs_data.length > 0) {
+ tabs_data.forEach((item) => {
+ // 修改item的内容
+ item = this.get_index_content(new_diy_index, header, header_style, item);
+ new_tabs_data.push(item);
new_diy_index++;
- }
- });
+ });
+ new_diy_data = diy_data;
+ } else {
+ new_tabs_data = tabs_data;
+ // 过滤数据
+ diy_data.forEach((item) => {
+ // 判断是否是商品列表
+ if (item.com_name == 'float-window') {
+ item.index = -1;
+ } else {
+ // 修改item的内容
+ item = this.get_index_content(new_diy_index, header, header_style, item);
+ new_diy_data.push(item);
+ new_diy_index++;
+ }
+ });
+ }
const { padding_right = 0, padding_left = 0} = header.com_data.style.common_style;
// tabs选项卡数据过滤
this.setData({
header_data: header,
footer_data: this.propValue.footer,
diy_data: new_diy_data,
- tabs_data: this.propValue.tabs_data,
+ tabs_data: new_tabs_data,
page_style: common_styles_computer(header.com_data.style.common_style),
page_img_style: background_computer(header.com_data.style.common_style),
// 内间距
@@ -344,7 +347,21 @@
is_immersion_model: bool,
});
},
-
+ get_index_content(new_diy_index, header, header_style, item) {
+ item.index = new_diy_index;
+ if (new_diy_index == 0) {
+ // 判断是否开启沉浸模式和是否开启安全距离 如果为true则除了选项卡和选项卡轮播外, 第一个组件则加上安全距离样式的padding_top加上顶部导航的高度和安全距离的高度
+ if (header_style.immersive_style == '1' && header_style.general_safe_distance_value == '1') {
+ let new_data = JSON.parse(JSON.stringify(item));
+ // 顶部导航的高度
+ let header_top_height = (header.com_data.content.data_alone_row_value.length > 0 ? parseInt(header.com_data.style.data_alone_row_space || 5) : 0) + 33 + (header.com_data.content.data_alone_row_value.length > 0 ? 33 : 0);
+ new_data.com_data.style.common_style.padding_top = parseInt(new_data.com_data.style.common_style.padding_top) + header_top_height;
+ return new_data;
+ }
+ return item;
+ }
+ return item;
+ },
// 选项卡回调更新数据
tabs_click_event(tabs_id, bool, params = {}) {
let new_data = [];
diff --git a/components/diy/modules/tabs-view.vue b/components/diy/modules/tabs-view.vue
index c210727e..78569d52 100644
--- a/components/diy/modules/tabs-view.vue
+++ b/components/diy/modules/tabs-view.vue
@@ -6,11 +6,27 @@
-
+
-
- {{ item.title }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ item.title }}
+
{{ item.desc }}
@@ -51,15 +67,19 @@
diff --git a/components/diy/tabs.vue b/components/diy/tabs.vue
index 275e1fea..63611f60 100644
--- a/components/diy/tabs.vue
+++ b/components/diy/tabs.vue
@@ -70,7 +70,12 @@
propContentPadding: {
type: String,
default: '',
- }
+ },
+ // 组件渲染的下标
+ propIndex: {
+ type: Number,
+ default: 1000000,
+ },
},
components: {
componentDiyModulesTabsView,
@@ -145,7 +150,7 @@
this.setData({
tabs_data: new_tabs_data,
style_container: this.propIsCommon ? common_styles_computer(new_style.common_style) + new_tabs_background : new_content.tabs_top_up == '1' ? gradient_computer(new_style.common_style) + new_tabs_background : '', // 如果是选项卡轮播,不需要走默认样式
- style_img_container: this.propIsCommon ? common_img_computer(new_style.common_style) : new_content.tabs_top_up == '1' ? background_computer(new_style.common_style) + margin_computer(this.propSpacingCommonStyle) + padding_computer(this.propSpacingCommonStyle, 1, true) + 'box-sizing: border-box;' : '', // 如果是选项卡轮播,不需要走默认样式
+ style_img_container: this.propIsCommon ? common_img_computer(new_style.common_style, this.propIndex) : new_content.tabs_top_up == '1' ? background_computer(new_style.common_style) + margin_computer(this.propSpacingCommonStyle) + padding_computer(this.propSpacingCommonStyle, 1, true) + 'box-sizing: border-box;' : '', // 如果是选项卡轮播,不需要走默认样式
tabs_top_style: new_tabs_top_style,
// 判断是否置顶
top_up: new_top_up,
From 905d3944b3087e43148df9db939094a0a6d18f11 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BA=8E=E8=82=96=E7=A3=8A?= <18851179580@163.com>
Date: Fri, 13 Dec 2024 16:57:34 +0800
Subject: [PATCH 2/3] =?UTF-8?q?=E9=80=89=E9=A1=B9=E6=95=88=E6=9E=9C?=
=?UTF-8?q?=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components/diy/modules/tabs-view.vue | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/components/diy/modules/tabs-view.vue b/components/diy/modules/tabs-view.vue
index 78569d52..65dfa04d 100644
--- a/components/diy/modules/tabs-view.vue
+++ b/components/diy/modules/tabs-view.vue
@@ -7,7 +7,7 @@
-
+
From 82f73ff7dee3b11610f9099ba0f6f9f12064b915 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BA=8E=E8=82=96=E7=A3=8A?= <18851179580@163.com>
Date: Fri, 13 Dec 2024 17:20:44 +0800
Subject: [PATCH 3/3] =?UTF-8?q?=E8=BD=AE=E6=92=AD=E5=9B=BE=E5=8E=86?=
=?UTF-8?q?=E5=8F=B2=E6=95=B0=E6=8D=AE=E5=85=BC=E5=AE=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components/diy/carousel.vue | 2 +-
components/diy/tabs-carousel.vue | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/components/diy/carousel.vue b/components/diy/carousel.vue
index 65c167b4..00b7ffe1 100644
--- a/components/diy/carousel.vue
+++ b/components/diy/carousel.vue
@@ -227,7 +227,7 @@
if (!this.propIsCommon) {
return '';
}
- if (!isEmpty(form.carousel_list[actived_index].style.background_img)) {
+ if (!isEmpty(form.carousel_list[actived_index]?.style?.background_img)) {
return background_computer(form.carousel_list[actived_index].style);
}
return '';
diff --git a/components/diy/tabs-carousel.vue b/components/diy/tabs-carousel.vue
index 5bdfb4dc..5dc8769f 100644
--- a/components/diy/tabs-carousel.vue
+++ b/components/diy/tabs-carousel.vue
@@ -170,7 +170,7 @@
return '';
},
get_swiper_bg_img_style(form, actived_index) {
- if (!isEmpty(form.carousel_list[actived_index].style.background_img)) {
+ if (!isEmpty(form.carousel_list[actived_index]?.style?.background_img)) {
return background_computer(form.carousel_list[actived_index].style);
}
return '';