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/custom.vue b/components/diy/custom.vue new file mode 100644 index 00000000..baa772e6 --- /dev/null +++ b/components/diy/custom.vue @@ -0,0 +1,86 @@ + + + + + diff --git a/components/diy/data-magic.vue b/components/diy/data-magic.vue new file mode 100644 index 00000000..f4496cdb --- /dev/null +++ b/components/diy/data-magic.vue @@ -0,0 +1,320 @@ + + + + + diff --git a/components/diy/diy.vue b/components/diy/diy.vue index 0ac30d8a..b0a58236 100644 --- a/components/diy/diy.vue +++ b/components/diy/diy.vue @@ -18,6 +18,8 @@ + + @@ -39,38 +41,31 @@ + diff --git a/components/diy/modules/custom/model-lines.vue b/components/diy/modules/custom/model-lines.vue new file mode 100644 index 00000000..0146b1b5 --- /dev/null +++ b/components/diy/modules/custom/model-lines.vue @@ -0,0 +1,44 @@ + + + diff --git a/components/diy/modules/custom/model-text.vue b/components/diy/modules/custom/model-text.vue new file mode 100644 index 00000000..17bb9389 --- /dev/null +++ b/components/diy/modules/custom/model-text.vue @@ -0,0 +1,101 @@ + + + diff --git a/components/diy/modules/data-magic/magic-carousel.vue b/components/diy/modules/data-magic/magic-carousel.vue new file mode 100644 index 00000000..2b588ac0 --- /dev/null +++ b/components/diy/modules/data-magic/magic-carousel.vue @@ -0,0 +1,58 @@ + + + + + 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..888f30ff --- /dev/null +++ b/components/diy/modules/data-magic/product-list-show.vue @@ -0,0 +1,182 @@ + + + + + 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 {