修复detail打开有时候没有添加衣服成功

This commit is contained in:
X1627315083
2024-01-10 17:20:08 +08:00
parent 838d6e86bd
commit c43c73e270
3 changed files with 30 additions and 18 deletions

View File

@@ -431,7 +431,7 @@ export default defineComponent({
}else{ }else{
this.designShowPrview = 1 this.designShowPrview = 1
} }
await this.setImgSize() // await this.setImgSize()
this.generateHighDesignImg = rv.highDesignUrl this.generateHighDesignImg = rv.highDesignUrl
this.designDetailShow = true this.designDetailShow = true
this.loadingShow = false this.loadingShow = false
@@ -468,11 +468,13 @@ export default defineComponent({
designItemDetail?.others?.forEach((item:any) => { designItemDetail?.others?.forEach((item:any) => {
if(item.type == 'Body'){ if(item.type == 'Body'){
body = item body = item
this.frontBack.body = item
} }
}); });
let ratio:any = await this?.setPostition(body?.layersObject?.[0]?.imageUrl) let ratio:any = await this?.setPostition(body?.layersObject?.[0]?.imageUrl)
if( Number.isNaN(ratio)){ if(Number.isNaN(ratio) || ratio == 0){
this.setImgSize() this.setImgSize()
return
} }
let frontIndex = 6 let frontIndex = 6
let backIndex = 3 let backIndex = 3
@@ -697,28 +699,30 @@ export default defineComponent({
}, },
//按比设置单件衣服宽高位置 //按比设置单件衣服宽高位置
async setPostition(url:any){ async setPostition(url:any){
let modal_body:any
let num:any let num:any
let img:any = await loadImage(url).then((img:any)=>{ await nextTick().then(async ()=>{
modal_body = document.getElementsByClassName('detail_modal_model')[0] let modal_body:any= document.getElementsByClassName('detail_modal_model')[0]
if(modal_body == undefined){ let imgWidth:any
this.setPostition(url) await new Promise((resolve, reject) => {
}
num = modal_body?.offsetWidth / img.width;
})
// nextTick().then(()=>{
// })
function loadImage(url:any) {
return new Promise((resolve, reject) => {
const img = new Image(); const img = new Image();
img.onload = () => { img.onload = () => {
imgWidth = img.width
resolve(img) resolve(img)
}; };
img.onerror = reject; img.onerror = reject;
img.src = url; 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 return num
}, },
//切换上一张或下一张图的详情 //切换上一张或下一张图的详情

View File

@@ -83,7 +83,7 @@
</div> </div>
</div> </div>
</div> </div>
<div v-show="type_ == 1 || type_ == 3" @click.stop="setPreview" class="subitOkPreviewBtn">{{ $t('DesignDetailEnd.preview') }}</div> <div v-show="type_ == 1 || type_ == 3" @click.stop="setPreview" class="subitOkPreviewBtn" :class="[ !sketchImg.id?!current.id?'active':'':'' ]">{{ $t('DesignDetailEnd.preview') }}</div>
<div v-if="type_ == 2 && current?.printObject?.prints?.[0]?.path != null" @click.stop="setPrint" class="subitOkPreviewBtn Guide_1_23">{{ $t('DesignDetailEnd.Layout') }}</div> <div v-if="type_ == 2 && current?.printObject?.prints?.[0]?.path != null" @click.stop="setPrint" class="subitOkPreviewBtn Guide_1_23">{{ $t('DesignDetailEnd.Layout') }}</div>
<div v-else-if="type_ == 2 && designItemDetail?.clothes?.[currentIndex]?.printObject?.prints?.[0]?.path != null && current?.printObject?.prints?.[0]?.path == null" @click.stop="setPreview" class="subitOkPreviewBtn">{{ $t('DesignDetailEnd.preview') }}</div> <div v-else-if="type_ == 2 && designItemDetail?.clothes?.[currentIndex]?.printObject?.prints?.[0]?.path != null && current?.printObject?.prints?.[0]?.path == null" @click.stop="setPreview" class="subitOkPreviewBtn">{{ $t('DesignDetailEnd.preview') }}</div>
<DesignPrintOperation v-if="!moible" ref="DesignPrintOperation"></DesignPrintOperation> <DesignPrintOperation v-if="!moible" ref="DesignPrintOperation"></DesignPrintOperation>
@@ -548,6 +548,10 @@ export default defineComponent({
.subitOkPreviewBtn{ .subitOkPreviewBtn{
bottom: calc(4rem*1.2); bottom: calc(4rem*1.2);
position: absolute; position: absolute;
&.active{
opacity: .5;
pointer-events:none;
}
} }
} }

View File

@@ -348,7 +348,11 @@ export default defineComponent({
this.robotTop = false this.robotTop = false
this.robotInput = false this.robotInput = false
}else{ }else{
window.location.reload() // window.location.reload()
this.$router.push("/home");
setTimeout(() => {
this.$router.go(0);
}, 500);
setCookie("isBeginner", true); setCookie("isBeginner", true);
setCookie("isBeginnerNum", 1); setCookie("isBeginnerNum", 1);
} }