From 50e82a7d33a89ebf9615062aa6b8998742c90dbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E8=82=96=E7=A3=8A?= <18851179580@163.com> Date: Thu, 12 Sep 2024 14:27:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BC=A0=E9=80=92=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E4=B8=BAsetData?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/diy/auxiliary-blank.vue | 26 +++++++++++------- components/diy/carousel.vue | 22 ++++++++++------ components/diy/float-window.vue | 27 ++++++++++++------- components/diy/search.vue | 24 ++++++++--------- components/diy/text-title.vue | 42 ++++++++++++++++++------------ 5 files changed, 83 insertions(+), 58 deletions(-) diff --git a/components/diy/auxiliary-blank.vue b/components/diy/auxiliary-blank.vue index ba3db34b..38c2e9b6 100644 --- a/components/diy/auxiliary-blank.vue +++ b/components/diy/auxiliary-blank.vue @@ -25,17 +25,23 @@ }; }, created() { - const { - height - } = this.value.content; - const { - line_color, - common_style - } = this.value.style; - this.style = `height: ${height * 2 }rpx;background: ${line_color || 'transparent'};`; - this.style_container = common_styles_computer(common_style); + this.init(); + }, + methods: { + init() { + const { + height + } = this.value.content; + const { + line_color, + common_style + } = this.value.style; + this.setData({ + style: `height: ${height * 2 }rpx;background: ${line_color || 'transparent'};`, + style_container: common_styles_computer(common_style) + }); + } }, - methods: {}, }; diff --git a/components/diy/carousel.vue b/components/diy/carousel.vue index 4dc290ae..ad0ed6a9 100644 --- a/components/diy/carousel.vue +++ b/components/diy/carousel.vue @@ -184,19 +184,21 @@ } }, slideChange(e) { - this.animationData = e.target.current; + let actived_index = e.target.current; if (e.target.current > this.form.carousel_list.length - 1) { const seat_length = this.seat_list.length; if (seat_length == 2 && e.target.current == 3) { - this.actived_index = 1; + actived_index = 1; } else if (seat_length == 3) { - this.actived_index = 0; + actived_index = 0; } else { - this.actived_index = e.target.current - this.seat_list.length; + actived_index = e.target.current - this.seat_list.length; } - } else { - this.actived_index = e.target.current; } + this.setData({ + animationData: e.target.current, + actived_index: actived_index + }) }, get_video_style() { const { video_bottom, video_radius, video_color_list, video_direction, video_title_color, video_padding} = this.new_style; @@ -217,11 +219,15 @@ }) this.$refs.popup.open(); const videoContext = uni.createVideoContext('carousel_video'); - videoContext.play(); + if (!is_obj_empty(videoContext)) { + videoContext.play(); + } }, video_close() { const videoContext = uni.createVideoContext('carousel_video'); - videoContext.pause(); + if (!is_obj_empty(videoContext)) { + videoContext.pause(); + } this.$refs.popup.close(); } }, diff --git a/components/diy/float-window.vue b/components/diy/float-window.vue index 2fd00999..98aa5936 100644 --- a/components/diy/float-window.vue +++ b/components/diy/float-window.vue @@ -33,18 +33,25 @@ export default { }; }, created() { - this.form = this.value.content; - this.new_style = this.value.style; - const { float_style, float_style_color, display_location, offset_number } = this.value.style; - this.color = float_style == 'shadow' ? `box-shadow: 0 10rpx 40rpx ${ float_style_color }` : `background-color: ${ float_style_color }`; - let location = `right: 20rpx;`; - if (display_location == 'left') { - location = `left: 20rpx;`; - } - const { windowHeight } = uni.getSystemInfoSync(); - this.style = `bottom: ${((offset_number / windowHeight) * 100).toFixed(4) + '%'};` + location; + this.setData({ + form: this.value.content, + new_style: this.value.style + }); + this.init(); }, methods: { + init() { + const { float_style, float_style_color, display_location, offset_number } = this.value.style; + let location = `right: 20rpx;`; + if (display_location == 'left') { + location = `left: 20rpx;`; + } + const { windowHeight } = uni.getSystemInfoSync(); + this.setData({ + color: float_style == 'shadow' ? `box-shadow: 0 10rpx 40rpx ${ float_style_color }` : `background-color: ${ float_style_color }`, + style: `bottom: ${((offset_number / windowHeight) * 100).toFixed(4) + '%'};` + location + }); + }, url_open() { const { button_jump, button_link} = this.form; if (button_jump == 'link' && !is_obj_empty(button_link)) { diff --git a/components/diy/search.vue b/components/diy/search.vue index 643fef73..646a3dda 100644 --- a/components/diy/search.vue +++ b/components/diy/search.vue @@ -60,24 +60,23 @@ }; }, created() { - this.form = this.value.content; - this.new_style = this.value.style; + this.setData({ + form: this.value.content, + new_style: this.value.style + }); this.init(); }, methods: { is_obj_empty, init() { const { search_button_radius, common_style } = this.new_style; - // 内部样式 - this.style = this.get_style(); - // 全局样式 - this.style_container = this.isPageSettings ? '' : common_styles_computer(common_style); - // 按钮圆角 - this.search_button_radius = radius_computer(search_button_radius); - // 搜索框设置 - this.box_style = this.get_box_style(); - // 搜索按钮显示 - this.search_button = this.get_search_button(); + this.setData({ + style: this.get_style(), // 内部样式 + style_container: this.isPageSettings ? '' : common_styles_computer(common_style), // 全局样式 + search_button_radius: radius_computer(search_button_radius), // 按钮圆角 + box_style: this.get_box_style(), // 搜索框设置 + search_button: this.get_search_button(), // 搜索按钮显示 + }); }, get_style() { let common_styles = ''; @@ -107,7 +106,6 @@ } style += gradient_computer(data) + background_computer(data) + `color: ${ this.new_style.button_inner_color };`; } - console.log(style); return style; } }, diff --git a/components/diy/text-title.vue b/components/diy/text-title.vue index a702300a..bb364d9e 100644 --- a/components/diy/text-title.vue +++ b/components/diy/text-title.vue @@ -41,26 +41,30 @@ export default { }; }, created() { - this.form = this.value.content; - this.new_style = this.value.style; - // 是否居中 - this.title_center = this.form.is_title_center == '1' ? 'jc-c' : ''; - // 关键字 - this.set_keyword_list(); - // 样式设置 - this.set_common_styles(); + this.setData({ + form: this.value.content, + new_style: this.value.style + }); + this.init(); }, methods: { + init() { + // 是否居中 + this.setData({ + title_center: this.form.is_title_center == '1' ? 'jc-c' : '' + }); + // 关键字 + this.set_keyword_list(); + // 样式设置 + this.set_common_styles(); + }, set_keyword_list() { - this.keyword_list = this.form.keyword_list.filter(item => item.is_show == '1'); + this.setData({ + keyword_list: this.form.keyword_list.filter(item => item.is_show == '1') + }); }, set_common_styles() { const { keyword_color, keyword_size, right_color, right_size, common_style, title_weight, title_color, title_size } = this.new_style; - // 关键字设置 - this.keyword_style = `color:${ keyword_color }; font-size: ${ keyword_size * 2 }rpx;`; - // 右边按钮设置 - this.right_size = right_size * 2 + 'rpx'; - this.right_style = `color:${ right_color }; font-size: ${ right_size * 2 }rpx;`; // 标题样式设置 let common_styles = ''; if (title_weight == 'italic') { @@ -68,9 +72,13 @@ export default { } else if (title_weight == '500') { common_styles += `font-weight: 500`; } - this.title_style = `color:${ title_color }; font-size: ${ title_size * 2 }rpx; ${ common_styles }`; - // 通用样式区 - this.style_container = common_styles_computer(common_style); + this.setData({ + keyword_style: `color:${ keyword_color }; font-size: ${ keyword_size * 2 }rpx;`, // 关键字设置 + right_size: right_size * 2 + 'rpx' ,// 右边按钮设置 + right_style: `color:${ right_color }; font-size: ${ right_size * 2 }rpx;`, + title_style: `color:${ title_color }; font-size: ${ title_size * 2 }rpx; ${ common_styles }`, + style_container: common_styles_computer(common_style) // 通用样式区 + }) }, url_open_event(link) { if (!is_obj_empty(link)) {