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 @@ -