From 7ac30532d9523063a84ef6c899ab36eb1a3c35ec 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, 19 Sep 2024 15:31:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=95=B0=E6=8D=AE=E9=AD=94?= =?UTF-8?q?=E6=96=B9=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/js/common/common.js | 14 +- components/diy/data-magic.vue | 338 ++++++++++++++++++ components/diy/diy.vue | 100 ++---- components/diy/float-window.vue | 4 +- .../diy/modules/data-magic/magic-carousel.vue | 59 +++ .../modules/data-magic/product-list-show.vue | 179 ++++++++++ components/diy/modules/image-empty.vue | 10 +- components/diy/nav-group.vue | 28 +- 8 files changed, 650 insertions(+), 82 deletions(-) create mode 100644 components/diy/data-magic.vue create mode 100644 components/diy/modules/data-magic/magic-carousel.vue create mode 100644 components/diy/modules/data-magic/product-list-show.vue diff --git a/common/js/common/common.js b/common/js/common/common.js index 349c750f..6cd2a9fb 100644 --- a/common/js/common/common.js +++ b/common/js/common/common.js @@ -181,4 +181,16 @@ export function get_math () { randomString = randomString.length >= 6 ? randomString : randomString.padStart(6, '0'); // 截取掉随机字符串开头的'0.'部分,获得最终的6位随机字符串。 return randomString.substring(2); -} \ No newline at end of file +} + +/** + * 将大小计算成百分比 + * + * @param num 当前的大小或位置。 + * @param size 容器的大小。 + * @returns 计算后的百分比值,含4位小数 + */ +export const percentage_count = (num, container_size) => { + const marks = (num / container_size) * 100; + return marks.toFixed(4) + '%'; +}; \ No newline at end of file diff --git a/components/diy/data-magic.vue b/components/diy/data-magic.vue new file mode 100644 index 00000000..5bdb7a07 --- /dev/null +++ b/components/diy/data-magic.vue @@ -0,0 +1,338 @@ + + + + + + + + + + + {{ item.data_content.heading_title || '' }} + {{ item.data_content.subtitle || '' }} + + + + + + + + + + + + + {{ item.actived_index + 1 }}/{{ item.data_content.list.length }} + + + + + + + + + + + + + + + {{ item.data_content.heading_title || '' }} + {{ item.data_content.subtitle || '' }} + + + + + + + + + + + + + {{ item.actived_index + 1 }}/{{ item.data_content.list.length }} + + + + + + + + + + + + + + + diff --git a/components/diy/diy.vue b/components/diy/diy.vue index a69ad597..46cebdfa 100644 --- a/components/diy/diy.vue +++ b/components/diy/diy.vue @@ -2,34 +2,26 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + @@ -37,32 +29,25 @@ + + \ No newline at end of file diff --git a/components/diy/modules/data-magic/product-list-show.vue b/components/diy/modules/data-magic/product-list-show.vue new file mode 100644 index 00000000..9ee1ceb4 --- /dev/null +++ b/components/diy/modules/data-magic/product-list-show.vue @@ -0,0 +1,179 @@ + + + + + + + + + + + + + {{ item.title }} + + {{ item.show_price_symbol }}{{ item.min_price }} + + {{ item.show_price_unit }} + + + + + + + + + + + + + + + + {{ item.show_price_symbol }}{{ item.min_price }} + + {{ item.show_price_unit }} + + + + {{ item.title }} + + + + + + + + + + + + {{ item.title }} + + {{ item.show_price_symbol }}{{ item.min_price }} + + {{ item.show_price_unit }} + + + + + + + + + + + + + + + + + + + {{ item.title }} + + {{ item.show_price_symbol }}{{ item.min_price }} + + {{ item.show_price_unit }} + + + + + + + + + + + + \ No newline at end of file diff --git a/components/diy/modules/image-empty.vue b/components/diy/modules/image-empty.vue index 7355d8ac..3663cef9 100644 --- a/components/diy/modules/image-empty.vue +++ b/components/diy/modules/image-empty.vue @@ -1,5 +1,5 @@ - + @@ -19,6 +19,14 @@ img_fit: { type: String, default: () => 'aspectFill', + }, + type_style: { + type: String, + default: () => '', + }, + type_class: { + type: String, + default: () => '', } }, data() { diff --git a/components/diy/nav-group.vue b/components/diy/nav-group.vue index 0bf8abfe..d0865159 100644 --- a/components/diy/nav-group.vue +++ b/components/diy/nav-group.vue @@ -2,7 +2,7 @@ - + @@ -50,7 +50,7 @@ img_style: '', text_style: '', indicator_style: '', - newHeight: '200rpx', + newHeight: '300rpx', actived_index: 0, group_width: '', nav_content_list: [], @@ -61,15 +61,9 @@ form: this.value.content, new_style: this.value.style, }); - this.init(); }, mounted() { - this.$nextTick(() => { - this.newHeight = this.$refs.bannerImg[0].$el.clientHeight * 2 + 'rpx'; - }); - window.onresize = () => { - this.newHeight = this.$refs.bannerImg[0].$el.clientHeight * 2 + 'rpx'; - }; + this.init(); }, methods: { init() { @@ -83,6 +77,21 @@ nav_style: this.form.nav_style || 'image_with_text', // 是否显示文字和图片 nav_content_list: this.get_nav_content_list(), }); + setTimeout(() => { + const query = uni.createSelectorQuery().in(this); + // 选择我们想要的元素 + query + .select('.bannerImg') + .boundingClientRect((res) => { + if ((res || null) != null) { + // data包含元素的宽度、高度等信息 + this.setData({ + newHeight: res.height * 2 + 'rpx', + }); + } + }) + .exec(); // 执行查询 + }, 0) }, get_nav_content_list() { // 深拷贝一下,确保不会出现问题 @@ -148,6 +157,7 @@ height: 100rpx; width: 100rpx; border-radius: 8rpx; + background-color: #f4fcff; } .dot {
{{ item.data_content.heading_title || '' }}
{{ item.data_content.subtitle || '' }}