From 9a73a20b8261eb117d94f07da9f03686c2977ed7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BA=8E=E8=82=96=E7=A3=8A?= <18851179580@163.com>
Date: Mon, 9 Dec 2024 14:22:32 +0800
Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?=
=?UTF-8?q?=E9=AD=94=E6=96=B9=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components/diy/custom.vue | 83 +++----------------
components/diy/data-magic.vue | 6 +-
.../diy/modules/custom/data-rendering.vue | 25 ++++--
components/diy/modules/custom/model-icon.vue | 8 +-
components/diy/modules/custom/model-image.vue | 14 ++--
components/diy/modules/custom/model-text.vue | 16 ++--
.../diy/modules/data-magic/custom/index.vue | 6 +-
.../diy/modules/data-magic/video/index.vue | 6 +-
8 files changed, 61 insertions(+), 103 deletions(-)
diff --git a/components/diy/custom.vue b/components/diy/custom.vue
index 0804062e..f8c4ec24 100644
--- a/components/diy/custom.vue
+++ b/components/diy/custom.vue
@@ -5,7 +5,7 @@
-
+
@@ -16,7 +16,7 @@
-
+
@@ -88,70 +88,12 @@
div_height: 0,
custom_list_length: 0,
source_list: {
- goods: {
- // 存放手动输入的id
- data_ids: [],
- // 手动输入
- data_list: [],
- // 自动
- data_auto_list: [],
- // 商品类型
- data_type: '0',
- // 商品分类
- category_ids: [],
- // 品牌
- brand_ids: [],
- // 显示数量
- number: 4,
- // 排序类型
- order_by_type: '0',
- // 排序规则
- order_by_rule: '0',
- },
- article: {
- // 存放手动输入的id
- data_ids: [],
- // 手动输入
- data_list: [],
- // 自动
- data_auto_list: [],
- data_type: '0',
- number: 4,
- order_by_type: '0',
- order_by_rule: '0',
- // 文章封面
- is_cover: '0',
- // 分类id
- category_ids: [],
- },
- brand: {
- // 存放手动输入的id
- data_ids: [],
- // 手动输入
- data_list: [],
- // 自动
- data_auto_list: [],
- // 商品类型
- data_type: '0',
- // 商品分类
- category_ids: [],
- // 品牌
- brand_ids: [],
- // 显示数量
- number: 4,
- // 排序类型
- order_by_type: '0',
- // 排序规则
- order_by_rule: '0',
- },
- common: {
- // 存放手动输入的id
- data_ids: [],
- // 手动输入
- data_list: [],
- // 自动
- data_auto_list: [],
- }
+ // 存放手动输入的id
+ data_ids: [],
+ // 手动输入
+ data_list: [],
+ // 自动
+ data_auto_list: [],
},
data_source_content_list: [],
data_source: '',
@@ -167,6 +109,7 @@
indicator_location_style: '',
indicator_style: '',
slides_per_view: 1,
+ show_data: { data_key: 'id', data_name: 'name' },
old_data_style: {
color_list: [{ color: 'rgb(244, 252, 255)', color_percentage: undefined }],
direction: '180deg',
@@ -208,12 +151,7 @@
if (!Object.keys(new_form.data_source_content).includes('data_auto_list') && !Object.keys(new_form.data_source_content).includes('data_list')) {
//深拷贝一下,保留历史数据
const data = JSON.parse(JSON.stringify(new_form.data_source_content));
- // 判断是否有符合条件的数据源,如何没有的话取公共数据源
- if (!isEmpty(this.source_list[new_form.data_source])) {
- new_form.data_source_content = this.source_list[new_form.data_source];
- } else {
- new_form.data_source_content = this.source_list['common'];
- }
+ new_form.data_source_content = this.source_list;
// 如果老数组中有数据,将数据放到新数组中
if (!isEmpty(data)) {
new_form.data_source_content.data_list = [ data ];
@@ -272,6 +210,7 @@
swiper_height: swiper_height,
swiper_width: swiper_width,
slides_per_view: new_style.rolling_fashion == 'translation' ? (new_form.data_source_direction != 'horizontal' ? col : new_form.data_source_carousel_col ) : 1,
+ show_data: new_form?.show_data || { data_key: 'id', data_name: 'name' }
});
},
get_list(list, form, new_style) {
diff --git a/components/diy/data-magic.vue b/components/diy/data-magic.vue
index 53f9d3f1..ea6d221d 100644
--- a/components/diy/data-magic.vue
+++ b/components/diy/data-magic.vue
@@ -238,7 +238,7 @@
if (data_content.data_type == 'goods') {
data_content.list = this.commodity_list(data_content.goods_list, data_content.goods_num, data_content, data_style);
- } else if (data_content.data_type == 'custom' && ['1', '2'].includes(data_content.data_source_direction)) {
+ } else if (data_content.data_type == 'custom' && ['vertical-scroll', 'horizontal'].includes(data_content.data_source_direction)) {
// 是自定义并且是轮播状态的时候,添加数据
const list = this.data_source_content_list(data_content);
const carousel_col = data_content?.data_source_carousel_col || 1;
@@ -252,8 +252,8 @@
},
// 数据来源的内容
data_source_content_list(data_content){
- if (['goods', 'article', 'brand'].includes(data_content.data_source)) {
- if (data_content.data_source_content.data_type == '0') {
+ if (data_content.is_custom_data == '1') {
+ if (Number(data_content.data_source_content.data_type) === 0) {
return data_content.data_source_content.data_list;
} else {
return data_content.data_source_content.data_auto_list.map((item) => ({
diff --git a/components/diy/modules/custom/data-rendering.vue b/components/diy/modules/custom/data-rendering.vue
index baa07600..8b75f3df 100644
--- a/components/diy/modules/custom/data-rendering.vue
+++ b/components/diy/modules/custom/data-rendering.vue
@@ -2,19 +2,19 @@
-
+
-
+
-
+
-
+
-
+
@@ -48,10 +48,6 @@ export default {
return {};
}
},
- propSourceType: {
- type: String,
- default: ''
- },
propDataHeight: {
type: Number,
default: 0,
@@ -68,6 +64,17 @@ export default {
type: Number,
default: 1,
},
+ propIsCustom: {
+ type: Boolean,
+ default: false,
+ },
+ propShowData: {
+ type: Object,
+ default: () => ({
+ data_key: 'id',
+ data_name: 'name'
+ }),
+ },
},
data() {
return {};
diff --git a/components/diy/modules/custom/model-icon.vue b/components/diy/modules/custom/model-icon.vue
index 721a4b3e..04f403ee 100644
--- a/components/diy/modules/custom/model-icon.vue
+++ b/components/diy/modules/custom/model-icon.vue
@@ -29,9 +29,9 @@
type: Number,
default: 1,
},
- propSourceType: {
- type: String,
- default: ''
+ propIsCustom: {
+ type: Boolean,
+ default: false
}
},
data() {
@@ -61,7 +61,7 @@
// 不输入商品, 文章和品牌时,从外层处理数据
let icon = this.propSourceList[this.propValue.data_source_id];
// 如果是商品,品牌,文章的图片, 其他的切换为从data中取数据
- if (['goods', 'article', 'brand'].includes(this.propSourceType) && !isEmpty(this.propSourceList.data)) {
+ if (this.propIsCustom && !isEmpty(this.propSourceList.data)) {
icon = this.propSourceList.data[this.propValue.data_source_id];
}
icon_class_value = icon;
diff --git a/components/diy/modules/custom/model-image.vue b/components/diy/modules/custom/model-image.vue
index c286152d..c96015a8 100644
--- a/components/diy/modules/custom/model-image.vue
+++ b/components/diy/modules/custom/model-image.vue
@@ -32,10 +32,14 @@
type: Number,
default: 1
},
- propSourceType: {
+ propIsCustom: {
+ type: Boolean,
+ default: false
+ },
+ propImgParams: {
type: String,
default: ''
- }
+ },
},
data() {
return {
@@ -85,11 +89,11 @@
// 不输入商品, 文章和品牌时,从外层处理数据
let image_url = this.propSourceList[form.data_source_id];
// 如果是商品,品牌,文章的图片, 其他的切换为从data中取数据
- if (['goods', 'article', 'brand'].includes(this.propSourceType) && !isEmpty(this.propSourceList.data)) {
+ if (this.propIsCustom && !isEmpty(this.propSourceList.data)) {
// 判断是否是同一标志
- if (form.data_source_id == this.keyMap[this.propSourceType]) {
+ if (form.data_source_id == this.propImgParams) {
// 如果是符合条件的标志,先判断新的图片是否存在,存在就取新的图片,否则的话取原来的图片
- image_url = !isEmpty(this.propSourceList.new_cover)? this.propSourceList.new_cover[0]?.url || '' : this.propSourceList.data[this.keyMap[this.propSourceType]];
+ image_url = !isEmpty(this.propSourceList.new_cover)? this.propSourceList.new_cover[0]?.url || '' : this.propSourceList.data[this.propImgParams];
} else {
image_url = this.propSourceList.data[form.data_source_id];
}
diff --git a/components/diy/modules/custom/model-text.vue b/components/diy/modules/custom/model-text.vue
index 9a3a141c..1af7db10 100644
--- a/components/diy/modules/custom/model-text.vue
+++ b/components/diy/modules/custom/model-text.vue
@@ -36,10 +36,14 @@
type: Number,
default: 1
},
- propSourceType: {
+ propIsCustom: {
+ type: Boolean,
+ default: false
+ },
+ propTitleParams: {
type: String,
- default: ''
- }
+ default: 'name'
+ },
},
data() {
return {
@@ -88,11 +92,11 @@
} else {
text = this.propSourceList[form.data_source_id];
// 如果是商品的标题或者是品牌的名称,需要判断是否有新的标题,没有的话就取原来的标题
- if (['goods', 'article', 'brand'].includes(this.propSourceType) && !isEmpty(this.propSourceList.data)) {
+ if (this.propIsCustom && !isEmpty(this.propSourceList.data)) {
// 其他的切换为从data中取数据
- if (form.data_source_id == this.keyMap[this.propSourceType]) {
+ if (form.data_source_id == this.propTitleParams) {
// 如果是符合条件的标志,先判断新的标题是否存在,存在就取新的标题,否则的话取原来的标题
- text = !isEmpty(this.propSourceList.new_title) ? this.propSourceList.new_title : this.propSourceList.data[this.keyMap[this.propSourceType]];
+ text = !isEmpty(this.propSourceList.new_title) ? this.propSourceList.new_title : this.propSourceList.data[this.propTitleParams];
} else {
text = this.propSourceList.data[form.data_source_id];
}
diff --git a/components/diy/modules/data-magic/custom/index.vue b/components/diy/modules/data-magic/custom/index.vue
index 59bf2dda..a4aba2b7 100644
--- a/components/diy/modules/data-magic/custom/index.vue
+++ b/components/diy/modules/data-magic/custom/index.vue
@@ -3,7 +3,7 @@
-
+
@@ -15,7 +15,7 @@
-
+
@@ -77,6 +77,7 @@ export default {
// 轮播高度
swiper_height: 0,
swiper_width: 'width: 100%;',
+ show_data: { data_key: 'id', data_name: 'name' },
};
},
computed: {
@@ -151,6 +152,7 @@ export default {
slides_per_view: new_style.rolling_fashion == 'translation' ? (new_form.data_source_direction != 'horizontal' ? col : new_form.data_source_carousel_col) : 1,
swiper_height: swiper_height,
swiper_width: swiper_width,
+ show_data: new_form?.show_data || { data_key: 'id', data_name: 'name' }
});
}
},
diff --git a/components/diy/modules/data-magic/video/index.vue b/components/diy/modules/data-magic/video/index.vue
index e4987613..f345f363 100644
--- a/components/diy/modules/data-magic/video/index.vue
+++ b/components/diy/modules/data-magic/video/index.vue
@@ -2,7 +2,7 @@
-
+
@@ -25,6 +25,7 @@
style_container: '',
video_img: '',
video: '',
+ video_style: '',
};
},
created() {
@@ -38,7 +39,8 @@
this.setData({
video_img: new_content.video_img.length > 0 ? new_content.video_img[0].url : '',
video: new_content.video.length > 0 ? new_content.video[0].url : '',
- style_container: padding_computer(this.propDataStyle.chunk_padding) + radius_computer(this.propDataStyle.img_radius) + 'box-sizing: border-box;',
+ style_container: padding_computer(this.propDataStyle.chunk_padding) + 'box-sizing: border-box;',
+ video_style: radius_computer(this.propDataStyle.img_radius),
});
}
},
From b9e92f3073d6bb9bfb9bdcf3a302641b86f0c9a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BA=8E=E8=82=96=E7=A3=8A?= <18851179580@163.com>
Date: Mon, 9 Dec 2024 17:29:48 +0800
Subject: [PATCH 2/3] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=95=B0?=
=?UTF-8?q?=E6=8D=AE=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
common/js/common/common.js | 22 ++++++++++
components/diy/modules/custom/model-icon.vue | 28 ++++++++----
components/diy/modules/custom/model-image.vue | 44 +++++++++++++------
components/diy/modules/custom/model-text.vue | 44 ++++++++++++++-----
4 files changed, 105 insertions(+), 33 deletions(-)
diff --git a/common/js/common/common.js b/common/js/common/common.js
index 568c6730..5dcf8068 100644
--- a/common/js/common/common.js
+++ b/common/js/common/common.js
@@ -13,6 +13,28 @@ export function is_obj_empty(obj) {
return Object.keys(obj).length === 0;
}
+/**
+ * 获取嵌套对象的属性值
+ *
+ * 该函数旨在通过指定的属性路径获取嵌套对象中的属性值它接受一个对象和一个属性路径字符串作为参数,
+ * 并返回对应路径的属性值如果输入的路径无效或对象中不存在该路径,则返回空字符串
+ *
+ * @param {Object} obj - 要从中获取属性的嵌套对象
+ * @param {string} path - 属性路径,使用点号分隔的字符串表示
+ * @returns {string} - 返回指定路径的属性值,如果路径无效则返回空字符串
+ */
+export function get_nested_property(obj, path) {
+ // 检查路径参数是否为字符串且非空,若不满足条件则返回空字符串
+ if (typeof path !== 'string' || !path) return '';
+
+ // 将属性路径字符串拆分为属性键数组
+ const keys = path.split('.');
+
+ // 使用reduce方法遍历属性键数组,逐层访问对象属性
+ // 如果当前对象存在且拥有下一个属性键,则继续访问;否则返回空字符串
+ return keys.reduce((o, key) => (o && o[key] ? o[key] : ''), obj) || '';
+}
+
/**
* 指示器的样式
*
diff --git a/components/diy/modules/custom/model-icon.vue b/components/diy/modules/custom/model-icon.vue
index 04f403ee..ffb76f16 100644
--- a/components/diy/modules/custom/model-icon.vue
+++ b/components/diy/modules/custom/model-icon.vue
@@ -4,7 +4,7 @@