From c43c73e270266f3a127feeb710eb776faba4ac4c Mon Sep 17 00:00:00 2001 From: X1627315083 <1627315083@qq.com> Date: Wed, 10 Jan 2024 17:20:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Ddetail=E6=89=93=E5=BC=80?= =?UTF-8?q?=E6=9C=89=E6=97=B6=E5=80=99=E6=B2=A1=E6=9C=89=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=A1=A3=E6=9C=8D=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/component/Detail/DesignDetail.vue | 36 +++++++++++++----------- src/component/Detail/DesignDetailEnd.vue | 6 +++- src/component/HomePage/RobotAssist.vue | 6 +++- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/component/Detail/DesignDetail.vue b/src/component/Detail/DesignDetail.vue index 2ed36653..7d970e9d 100644 --- a/src/component/Detail/DesignDetail.vue +++ b/src/component/Detail/DesignDetail.vue @@ -431,7 +431,7 @@ export default defineComponent({ }else{ this.designShowPrview = 1 } - await this.setImgSize() + // await this.setImgSize() this.generateHighDesignImg = rv.highDesignUrl this.designDetailShow = true this.loadingShow = false @@ -468,11 +468,13 @@ export default defineComponent({ designItemDetail?.others?.forEach((item:any) => { if(item.type == 'Body'){ body = item + this.frontBack.body = item } }); let ratio:any = await this?.setPostition(body?.layersObject?.[0]?.imageUrl) - if( Number.isNaN(ratio)){ + if(Number.isNaN(ratio) || ratio == 0){ this.setImgSize() + return } let frontIndex = 6 let backIndex = 3 @@ -697,28 +699,30 @@ export default defineComponent({ }, //按比设置单件衣服宽高位置 async setPostition(url:any){ - let modal_body:any let num:any - let img:any = await loadImage(url).then((img:any)=>{ - modal_body = document.getElementsByClassName('detail_modal_model')[0] - if(modal_body == undefined){ - this.setPostition(url) - } - num = modal_body?.offsetWidth / img.width; - }) - // nextTick().then(()=>{ - // }) - - function loadImage(url:any) { - return new Promise((resolve, reject) => { + await nextTick().then(async ()=>{ + let modal_body:any= document.getElementsByClassName('detail_modal_model')[0] + let imgWidth:any + await new Promise((resolve, reject) => { const img = new Image(); img.onload = () => { + imgWidth = img.width resolve(img) }; img.onerror = reject; img.src = url; }); - } + // await loadImage(url).then((img:any)=>{ + // console.log(2); + // // modal_body = document.getElementsByClassName('detail_modal_model')[0] + // if(modal_body == undefined){ + // this.setPostition(url) + // } + // console.log( modal_body?.offsetWidth,imgWidth, img.width); + // return num + // }) + num = modal_body?.offsetWidth / imgWidth; + }) return num }, //切换上一张或下一张图的详情 diff --git a/src/component/Detail/DesignDetailEnd.vue b/src/component/Detail/DesignDetailEnd.vue index 63072b0e..a51d7a8c 100644 --- a/src/component/Detail/DesignDetailEnd.vue +++ b/src/component/Detail/DesignDetailEnd.vue @@ -83,7 +83,7 @@ -