Files
aida_front/src/component/Detail/setDesignItem.vue

759 lines
25 KiB
Vue
Raw Normal View History

2023-09-12 10:09:02 +08:00
<template>
2023-10-12 17:09:05 +08:00
<div class="design_compile_content" id="design_compile_content">
2023-09-12 10:09:02 +08:00
<div class="designOpenrtion_centent" id="designOpenrtionCentent">
2024-01-24 16:43:54 +08:00
<div class="detail_modal_body_title">
<div class="detail_modal_body_nav">
2024-09-03 16:39:06 +08:00
<div v-for="item,index in designItemDetail?.clothes" v-show="item.id" :class="{active:item.clothesOpenItem}" @click="clothesOpen(index)">
2023-12-13 16:09:17 +08:00
<img :src="item?.path" alt="">
</div>
</div>
2024-01-24 16:43:54 +08:00
</div>
2023-10-11 17:34:14 +08:00
<div class="designOpenrtion_imgMask" :style="frontBack?.body?.style">
<!-- <div
v-for="item,index in frontBack.back"
:key="item"
:style="item.style"
@mousedown.stop="itemMoveMousedown(index,$event)"
class="modal_imgItem"
@click="setpitch(item,index)" ref="content" >
<img crossOrigin="anonymous" :src="item.path" class="designOpenrtion_imgItme" draggable="false">
</div> -->
2024-09-06 13:48:16 +08:00
<div class="designOpenrtion_print" v-for="item,index in frontBack.back" @mousedown.stop="itemMoveMousedown(index,getMousePosition($event,false))" @touchstart.passive="itemMoveMousedown(index,getMousePosition($event,true))" @click="setpitch(item,index)" :style="frontBack.front[index].style">
2023-10-11 17:34:14 +08:00
<img :style="item.imageUrl?'':'display:none;'" :src="item.imageUrl" alt="">
</div>
<img class="perview_img" :style="'width:'+ frontBack?.body?.layersObject?.[0].imageSize?.[0] +';height:' + frontBack?.body?.layersObject?.[0].imageSize?.[0] +';'" v-lazy="frontBack?.body?.layersObject?.[0].imageUrl || ''" :key="designItemDetail.designItemUrl">
2024-09-06 13:48:16 +08:00
<div class="detail_modal_item_front" v-for="item,index in frontBack.front" @mousedown.stop="itemMoveMousedown(index,getMousePosition($event,false))" @touchstart.passive="itemMoveMousedown(index,getMousePosition($event,true))" @click="setpitch(item,index)" :style="item.style">
2023-10-11 17:34:14 +08:00
<img :src="item.imageUrl" alt="">
2023-09-12 10:09:02 +08:00
</div>
<div class="designOpenrtion_btn" v-if="!isBody">
2024-09-06 13:48:16 +08:00
<ul v-for="item,index in frontBack.front" :key="item" :class="{active:item.designOpenrtionBtn}" class="designOpenrtion_btn" :style="item.style" @mousedown.stop="itemMoveMousedown(index,getMousePosition($event,false))" @touchstart.passive="itemMoveMousedown(index,getMousePosition($event,true))">
2024-09-11 16:36:08 +08:00
<li class="designOpenrtion_btn_top" @mousedown.stop="itemSizeMousedown('top',getMousePosition($event,false))" @touchstart.passive="itemSizeMousedown('top',getMousePosition($event,true))"></li>
<li class="designOpenrtion_btn_bottom" @mousedown.stop="itemSizeMousedown('bottom',getMousePosition($event,false))" @touchstart.passive="itemSizeMousedown('bottom',getMousePosition($event,true))"></li>
<li class="designOpenrtion_btn_left" @mousedown.stop="itemSizeMousedown('left',getMousePosition($event,false))" @touchstart.passive="itemSizeMousedown('left',getMousePosition($event,true))"></li>
<li class="designOpenrtion_btn_right" @mousedown.stop="itemSizeMousedown('right',getMousePosition($event,false))" @touchstart.passive="itemSizeMousedown('right',getMousePosition($event,true))"></li>
2023-09-12 10:09:02 +08:00
<!-- <li class="designOpenrtion_rotote" v-rotote.stop="[index,item.transform]"></li> -->
</ul>
</div>
</div>
2024-01-24 16:49:07 +08:00
<div class="subitOkPreviewBtn" @click="imgClear">{{ $t('LibraryPage.Reset') }}</div>
2023-10-11 17:34:14 +08:00
<div @click="setPreviewData" class="subitOkPreviewBtn">OK</div>
2023-09-12 10:09:02 +08:00
</div>
2023-10-12 17:09:05 +08:00
<div class="designOpenrtion_imgMask_open" @click.stop="deleteBorder"></div>
2023-09-12 10:09:02 +08:00
</div>
2024-08-23 10:19:02 +08:00
<div class="design_compile_content">
2024-09-03 16:39:06 +08:00
<editFrontBack :patchData="frontBack" :imgDomIndex="imgDomIndex" ref="editFrontBack"></editFrontBack>
2024-08-23 10:19:02 +08:00
</div>
2023-11-02 11:00:38 +08:00
2023-09-12 10:09:02 +08:00
</template>
<script >
import { defineComponent, h,createVNode, ref ,computed, inject,nextTick} from "vue";
2023-12-15 15:23:34 +08:00
// import { LoadingOutlined } from "@ant-design/icons-vue";
2023-09-12 10:09:02 +08:00
import { useStore } from "vuex";
2023-12-15 15:23:34 +08:00
// import { Modal,message } from 'ant-design-vue';
2023-10-11 17:34:14 +08:00
import { Https } from "@/tool/https";
2024-08-23 10:19:02 +08:00
import editFrontBack from '@/component/Detail/editFrontBack.vue'
2024-09-06 13:48:16 +08:00
import { getMousePosition } from "@/tool/mdEvent";
2023-09-12 10:09:02 +08:00
export default defineComponent({
props: ["isBody"],
2024-08-23 10:19:02 +08:00
emits:['setParentLoadingShow','setDesignCoverage','setSubmit'],
components:{editFrontBack},
2023-09-12 10:09:02 +08:00
setup(prop) {
const store = useStore();
2023-10-11 17:34:14 +08:00
let designItemDetail = computed(()=>{
return store.state.DesignDetailModule.designItemDetail
})
2023-09-12 10:09:02 +08:00
let current = inject('current')//父组件传过来的数据
let setRevocation = inject('setRevocation')//父组件传过来的数据
2023-10-11 17:34:14 +08:00
let printZIndex = ref(4)//印花优先级
2023-09-12 10:09:02 +08:00
let printStyleList = ref([
{
centers:{
left:0,
top:0,
},
style:{
left:0+"px",
top:0+"px",
right:"auto",
bottom:"auto",
width:100+'px',
height:100+'px',
2023-10-11 17:34:14 +08:00
// zIndex:1,
2023-09-12 10:09:02 +08:00
},
transform:{
scale:1,
rotateZ:0,
},
designOpenrtionBtn:false
}
]);
let direction = ref('')
let imgDom = ref()
2024-09-03 16:39:06 +08:00
let imgDomIndex = ref(-1)
2023-10-11 17:34:14 +08:00
let frontBack = ref({})
2024-01-24 16:43:54 +08:00
let frontBackOld = ref({})
2024-09-03 16:39:06 +08:00
let editFrontBack = ref(null)
2023-09-12 10:09:02 +08:00
return {
designItemDetail,
current,
printZIndex,
printStyleList,
direction,//判断点击的是li那个边
imgDom,
imgDomIndex,
frontBack,
2024-01-24 16:43:54 +08:00
setRevocation,
frontBackOld,
2024-09-03 16:39:06 +08:00
editFrontBack,
2024-09-06 13:48:16 +08:00
getMousePosition,
2023-09-12 10:09:02 +08:00
};
},
data() {
return {
2023-10-11 17:34:14 +08:00
loadingShow:false,//加载中
2023-09-12 10:09:02 +08:00
store: useStore(),
2024-08-13 09:36:13 +08:00
setImgSizeTimeout:null
2023-09-12 10:09:02 +08:00
};
},
2024-08-13 09:36:13 +08:00
mounted () {
window.addEventListener('resize', this.setImgSizeTime);
},
2023-09-12 10:09:02 +08:00
methods: {
init(){
let DesignParent = this.$parent
// this.clearModal()
2023-09-26 15:05:14 +08:00
// console.log(this.current,DesignParent.frontBack);
2023-09-12 10:09:02 +08:00
this.printStyleList.push({
centers:{
left:0,
top:0,
},
style:{
left:0+"px",
top:0+"px",
right:"auto",
bottom:"auto",
width:100+'px',
height:100+'px',
2023-10-11 17:34:14 +08:00
// zIndex:1,
2023-09-12 10:09:02 +08:00
},
transform:{
scale:1,
rotateZ:0,
},
designOpenrtionBtn:false
})
2023-10-11 17:34:14 +08:00
this.setImgSize()
},
2024-08-13 09:36:13 +08:00
setImgSizeTime(){
clearTimeout(this.setImgSizeTimeout)
this.setImgSizeTimeout = setTimeout(()=>{
this.setImgSize()
},300)
},
2023-10-11 17:34:14 +08:00
async setImgSize(){
2024-08-13 09:36:13 +08:00
this.frontBack.body = null
2023-10-11 17:34:14 +08:00
let designItemDetail = JSON.parse(JSON.stringify(this.store.state.DesignDetailModule.designItemDetail))
let front = []
let back = []
2024-09-03 16:39:06 +08:00
let body = {}
if(designItemDetail.others.length > 0){
designItemDetail.others.forEach((item) => {
if(item.type == 'Body'){
body = item
}
});
}else{
designItemDetail.clothes.forEach((item) => {
2023-10-11 17:34:14 +08:00
body = item
});
}
2023-10-11 17:34:14 +08:00
let ratio = await this.setPostition(body.layersObject[0]?.imageUrl)
let frontIndex = 6
let backIndex = 3
// let front = 3
// let back = 3
designItemDetail.clothes.forEach((v,index)=>{
for (let i = v.layersObject.length-1; i >= 0; i--) {
v.layersObject[i].style = {
top:v.layersObject[i].position?.[0]*ratio+'px',
left:v.layersObject[i].position?.[1]*ratio+'px',
2024-07-25 13:08:25 +08:00
width:v.layersObject[i].imageSize?.[0]*ratio+'px',
2023-10-11 17:34:14 +08:00
height:v.layersObject[i].imageSize?.[1]*ratio+'px',
// zIndex:zIndex-=1
}
v.layersObject[i].centers={
left:0,
top:0,
}
v.layersObject[i].designOpenrtionBtn = false
if(v.layersObject[i].imageCategory.indexOf("back") == -1){
front[index] = v.layersObject[i]
2023-12-13 16:09:17 +08:00
front[index].style.zIndex = v.priority
front[index].id = v.id
2024-09-03 16:39:06 +08:00
front[index].undividedLayer = v.undividedLayer
2023-10-11 17:34:14 +08:00
}else{
back[index] = v.layersObject[i]
2023-12-13 16:09:17 +08:00
back[index].style.zIndex = v.priority
back[index].id = v.id
2024-09-03 16:39:06 +08:00
back[index].undividedLayer = v.undividedLayer
2023-10-11 17:34:14 +08:00
// back[index].style.zIndex = backIndex==0?v.layersObject[i]:backIndex++
}
2023-12-13 16:09:17 +08:00
if(this.printZIndex < v.priority){
this.printZIndex = v.priority
}
2023-10-11 17:34:14 +08:00
}
2023-12-13 16:09:17 +08:00
this.printZIndex++
2023-10-11 17:34:14 +08:00
})
2024-09-03 16:39:06 +08:00
if(body){
body.style = {
width:body.layersObject[0].imageSize?.[0]*ratio+'px',
height:body.layersObject[0].imageSize?.[1]*ratio+'px',
}
2023-10-11 17:34:14 +08:00
}
2024-09-03 16:39:06 +08:00
2023-10-11 17:34:14 +08:00
this.frontBack = {
front:front,
back:back,
body:body,
}
2024-01-24 16:43:54 +08:00
this.frontBackOld = JSON.parse(JSON.stringify({
front:front,
back:back,
body:body,
}))
},
imgClear(){
this.frontBack = JSON.parse(JSON.stringify(this.frontBackOld))
2023-10-11 17:34:14 +08:00
},
//按比设置单件衣服宽高位置
async setPostition(url){
let img = await loadImage(url)
let modal_body = document.getElementsByClassName('designOpenrtion_imgMask')[0]
const num = modal_body?.offsetHeight / img.height;
function loadImage(url) {
return new Promise((resolve, reject) => {
const img = new Image();
img.onload = () => {
resolve(img)
2024-06-17 09:39:01 +08:00
img.remove()
2023-10-11 17:34:14 +08:00
};
img.onerror = reject;
img.src = url;
});
}
return num
2023-09-12 10:09:02 +08:00
},
2024-08-13 09:36:13 +08:00
clear(){
2024-09-03 16:39:06 +08:00
this.imgDomIndex = -1
this.clothesOpenActive(-1)
this.editFrontBack.setClone()
2024-08-13 09:36:13 +08:00
window.removeEventListener('resize', this.setImgSizeTime);
},
2023-09-12 10:09:02 +08:00
setpitch(item,index){
2023-10-11 17:34:14 +08:00
this.frontBack.front.forEach((v)=>{
2023-09-12 10:09:02 +08:00
v.designOpenrtionBtn = false
})
2023-10-11 17:34:14 +08:00
this.frontBack.front[index].designOpenrtionBtn = true
this.frontBack.front[index].style.zIndex = this.printZIndex++
this.frontBack.back[index].style.zIndex = this.printZIndex
2023-12-13 16:09:17 +08:00
this.clothesOpenActive(index)
2023-09-12 10:09:02 +08:00
},
// 设置移动
2023-12-13 16:09:17 +08:00
itemMoveMousedown(index,e){
2023-09-12 10:09:02 +08:00
this.imgDomIndex = index
2023-10-11 17:34:14 +08:00
this.frontBack.front.forEach((v)=>{
2023-09-12 10:09:02 +08:00
v.designOpenrtionBtn = false
})
2023-12-13 16:09:17 +08:00
this.clothesOpenActive(index)
let event = e||window.event
2023-10-11 17:34:14 +08:00
this.imgDom = document.getElementsByClassName('design_compile_content')[0].getElementsByClassName("detail_modal_item_front")[this.imgDomIndex]
this.frontBack.front[index].designOpenrtionBtn = true
this.frontBack.front[index].style.zIndex = this.printZIndex++
this.frontBack.back[index].style.zIndex = this.printZIndex
2023-09-12 10:09:02 +08:00
let imgDomWH = this.imgDom.getBoundingClientRect()
2023-10-11 17:34:14 +08:00
let left = Number(this.frontBack.front[index].style.left.replace(/px/g,''))
let top = Number(this.frontBack.front[index].style.top.replace(/px/g,''))
this.frontBack.front[index].centers.left = imgDomWH.x+event.offsetX-left
this.frontBack.front[index].centers.top = imgDomWH.y+event.offsetY-top
2024-09-06 13:48:16 +08:00
// document.addEventListener("mouseup", this.mouseup);
// document.addEventListener("mousemove", this.moveMousemove);
document.addEventListener('mousemove', this.mouseMove);
document.addEventListener('touchmove', this.touchmove);
document.addEventListener('mouseup', this.mouseup);
document.addEventListener('touchend', this.mouseup);
2023-09-12 10:09:02 +08:00
},
//设置尺寸
itemSizeMousedown(direction,event){
this.direction = direction
2023-10-11 17:34:14 +08:00
this.imgDom = document.getElementsByClassName('design_compile_content')[0].getElementsByClassName("detail_modal_item_front")[this.imgDomIndex]
this.frontBack.front[this.imgDomIndex].designOpenrtionBtn = true
2023-09-12 10:09:02 +08:00
let imgDomWH = this.imgDom.getBoundingClientRect()
let li = document.getElementsByClassName('design_compile_content')[0].getElementsByClassName("designOpenrtion_btn_top")[0].offsetWidth/2
if(this.direction == 'right' || this.direction == 'bottom'){
2023-10-11 17:34:14 +08:00
this.frontBack.front[this.imgDomIndex].centers.left = imgDomWH.x+event.offsetX-li
this.frontBack.front[this.imgDomIndex].centers.top = imgDomWH.y+event.offsetY-li
2023-09-12 10:09:02 +08:00
}else{
2023-10-11 17:34:14 +08:00
this.frontBack.front[this.imgDomIndex].centers.left = imgDomWH.x+event.offsetX+imgDomWH.width-li
this.frontBack.front[this.imgDomIndex].centers.top = imgDomWH.y+event.offsetY+imgDomWH.height-li
2023-09-12 10:09:02 +08:00
}
2024-09-06 13:48:16 +08:00
document.addEventListener('mousemove', this.sizeMouseMove);
document.addEventListener('touchmove', this.sizeTouchmove);
document.addEventListener('mouseup', this.sizeMouseup);
document.addEventListener('touchend', this.sizeMouseup);
},
mouseMove(event){
let e = getMousePosition(event,false)
this.mouseMoveOperation(e)
},
touchmove(event){
let e = getMousePosition(event,true)
this.mouseMoveOperation(e)
2023-09-12 10:09:02 +08:00
},
//鼠标移动
2024-09-06 13:48:16 +08:00
mouseMoveOperation(e) {
2023-09-12 10:09:02 +08:00
let imgDomWH = this.imgDom.getBoundingClientRect()
let parentNode = document.getElementsByClassName('design_compile_content')[0].getElementsByClassName("designOpenrtion_imgMask")[0].getBoundingClientRect()
2024-09-06 13:48:16 +08:00
let x = (e.clientX - this.frontBack.front[this.imgDomIndex].centers.left)+'px'
let y = ( e.clientY - this.frontBack.front[this.imgDomIndex].centers.top)+'px'
2023-10-11 17:34:14 +08:00
this.frontBack.front[this.imgDomIndex].style.left = x
this.frontBack.front[this.imgDomIndex].style.top = y
// if(x.replace(/px/g,'') >= parentNode.width - imgDomWH.width){
// this.frontBack.front[this.imgDomIndex].style.left = parentNode.width - imgDomWH.width+'px'
// }
// if(x.replace(/px/g,'') <= 0){
// this.frontBack.front[this.imgDomIndex].style.left = 0+'px'
// }
// if(y.replace(/px/g,'') >= parentNode.height - imgDomWH.height){
// this.frontBack.front[this.imgDomIndex].style.top = parentNode.height - imgDomWH.height+'px'
// }
// if(y.replace(/px/g,'') <= 0){
// this.frontBack.front[this.imgDomIndex].style.top = 0+'px'
// }
2023-09-12 10:09:02 +08:00
},
2024-09-06 13:48:16 +08:00
sizeMouseMove(event){
let e = getMousePosition(event,false)
this.sizeMouseMoveOperation(e)
},
sizeTouchmove(event){
let e = getMousePosition(event,true)
this.sizeMouseMoveOperation(e)
},
sizeMouseMoveOperation(e) {
2023-09-12 10:09:02 +08:00
let imgDomWH = this.imgDom.getBoundingClientRect()
let parentNode =this.imgDom.parentNode
let width = imgDomWH.width
let height = imgDomWH.height
let w,h
2023-10-11 17:34:14 +08:00
let num = height/width
2023-09-12 10:09:02 +08:00
//判断移动四个边
if(this.direction == 'right'){
2024-09-06 13:48:16 +08:00
w = (e.clientX - this.frontBack.front[this.imgDomIndex].centers.left)
h = (e.clientX - this.frontBack.front[this.imgDomIndex].centers.left)*num
2023-09-12 10:09:02 +08:00
width = w+'px'
2024-05-27 17:57:37 +08:00
// height = w*num+'px'
2023-09-12 10:09:02 +08:00
}else if(this.direction == 'top'){
2023-10-11 17:34:14 +08:00
num = width/height
this.frontBack.front[this.imgDomIndex].style.top = 'auto'
2023-09-12 10:09:02 +08:00
// this.printStyleList[this.imgDomIndex].style.left = 'auto'
2023-10-11 17:34:14 +08:00
this.frontBack.front[this.imgDomIndex].style.bottom = parentNode.offsetHeight -imgDomWH.height - this.imgDom.offsetTop+'px'
2024-09-06 13:48:16 +08:00
w = (e.clientX - this.frontBack.front[this.imgDomIndex].centers.left)*num
h = (this.frontBack.front[this.imgDomIndex].centers.top - e.clientY)
2023-09-12 10:09:02 +08:00
height = h+'px'
2024-05-27 17:57:37 +08:00
// width = h*num+'px'
2023-09-12 10:09:02 +08:00
}else if(this.direction == 'bottom'){
2023-10-11 17:34:14 +08:00
num = width/height
2024-09-06 13:48:16 +08:00
h = (e.clientY - this.frontBack.front[this.imgDomIndex].centers.top)
2023-09-12 10:09:02 +08:00
height = h+'px'
2024-05-27 17:57:37 +08:00
// width = h*num+'px'
2023-09-12 10:09:02 +08:00
}else if(this.direction == 'left'){
2023-10-11 17:34:14 +08:00
this.frontBack.front[this.imgDomIndex].style.left = 'auto'
this.frontBack.front[this.imgDomIndex].style.right = parentNode.offsetWidth -imgDomWH.width - this.imgDom.offsetLeft+'px'
2024-09-06 13:48:16 +08:00
w = (this.frontBack.front[this.imgDomIndex].centers.left - e.clientX)
2023-10-11 17:34:14 +08:00
2023-09-12 10:09:02 +08:00
width = w+'px'
2024-05-27 17:57:37 +08:00
// height = w*num+'px'
2023-09-12 10:09:02 +08:00
}
//判断尺寸是否到边
2023-10-11 17:34:14 +08:00
this.frontBack.front[this.imgDomIndex].style.width = width
this.frontBack.front[this.imgDomIndex].style.height = height
2023-09-12 10:09:02 +08:00
},
//鼠标抬起
sizeMouseup(e){
2023-10-11 17:34:14 +08:00
this.frontBack.front[this.imgDomIndex].style={
2023-09-12 10:09:02 +08:00
right:'auto',
left:this.imgDom.offsetLeft+'px',
bottom:'auto',
top:this.imgDom.offsetTop+'px',
height:this.imgDom.offsetHeight+'px',
width:this.imgDom.offsetWidth+'px',
zIndex:this.printZIndex
}
2023-10-11 17:34:14 +08:00
this.frontBack.back[this.imgDomIndex].style.zIndex = this.printZIndex
2024-09-06 13:48:16 +08:00
document.removeEventListener('mousemove',this.sizeMouseMove)
document.removeEventListener('touchmove',this.sizeTouchmove)
document.removeEventListener('mouseup',this.sizeMouseup)
document.removeEventListener('touchend',this.sizeMouseup)
2023-09-12 10:09:02 +08:00
},
mouseup(e) {
2024-09-06 13:48:16 +08:00
// document.removeEventListener("mouseup", this.mouseup);
// document.removeEventListener("mousemove", this.moveMousemove);
document.removeEventListener('mousemove',this.mouseMove)
document.removeEventListener('touchmove',this.touchmove)
document.removeEventListener('mouseup',this.mouseup)
document.removeEventListener('touchend',this.mouseup)
2023-09-12 10:09:02 +08:00
},
clearModal(){
this.printZIndex = 2//点击图片z-index
this.imgDomIndex = 0//点击图片下标
this.clothes = []
this.printStyleList.splice(1,this.printStyleList.length-1)
},
2023-10-11 17:34:14 +08:00
capitalizeFirstLetter(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
},
setPreviewData(){
this.$emit('setSubmit','preview');
},
2023-10-12 17:09:05 +08:00
deleteBorder(){
this.frontBack?.front?.forEach((item)=>{
item.designOpenrtionBtn = false
})
},
2023-12-13 16:09:17 +08:00
clothesOpen(index){
this.imgDomIndex = index
this.clothesOpenActive(index)
this.setpitch('',index)
},
clothesOpenActive(index){
this.designItemDetail.clothes.forEach((item)=>{
2024-09-03 16:39:06 +08:00
item.clothesOpenItem = false
2023-12-13 16:09:17 +08:00
})
2024-09-03 16:39:06 +08:00
if(index != -1){
this.designItemDetail.clothes[index].clothesOpenItem = true
}
2023-12-13 16:09:17 +08:00
},
sort(arr){
arr.sort((a, b) => {
var a_num = a.style.zIndex;
var b_num = b.style.zIndex;
return a_num - b_num;
});
return arr
},
2023-10-11 17:34:14 +08:00
async setPreview(data){
let ratio = this.frontBack.body.layersObject[0].imageSize[0]/this.frontBack.body.style.width.replace(/px/g,'')
let designItemDetail = this.store.state.DesignDetailModule.designItemDetail
// this.frontBack.back.sort((a, b) => {
// var a_num = a.style.zIndex;
// var b_num = b.style.zIndex;
// return a_num - b_num;
// });
2023-12-13 16:09:17 +08:00
let arr = this.sort(JSON.parse(JSON.stringify(this.frontBack.front)))
let num = 10
arr.forEach((item)=>{
item.priority = num++
item.similarity = false//新增衣服传的是衣服id会存在两件衣服id相同所以设置为false让每次赋值都是不一样的
2023-12-13 16:09:17 +08:00
})
2024-09-03 16:39:06 +08:00
let front = arr
let imageCategory1
2023-10-11 17:34:14 +08:00
data.designSingleItemDTOList.forEach((item)=>{
2024-01-04 09:40:28 +08:00
if(arr.length > 1){
imageCategory1 = arr[1].imageCategory
}
for (let index = 0; index < arr.length; index++) {
if(item.id == arr[index].id && !arr[index].similarity){
let y = ((arr[index]?.style?.top.replace(/px/g,'')*ratio).toFixed(0) - arr[index]?.position[0])
let x = ((arr[index]?.style?.left.replace(/px/g,'')*ratio).toFixed(0) - arr[index]?.position[1])
2024-05-27 17:57:37 +08:00
let scaleWidth = arr[index]?.imageSize?Number(((arr[index]?.style?.width.replace(/px/g,'')*ratio)/(arr[index]?.imageSize[0]/arr[index].scale[0])).toFixed(2)):1
let scaleHeight = arr[index]?.imageSize?Number(((arr[index]?.style?.height.replace(/px/g,'')*ratio)/(arr[index]?.imageSize[1]/arr[index].scale[1])).toFixed(2)):1
// let widthScale = (arr[index].style.width.replace(/px/g,'')/arr[index].style.height.replace(/px/g,'')).toFixed(2)
item.scale = [scaleWidth,scaleHeight]
2023-10-11 17:34:14 +08:00
let top = y == 0 ? item.offset[1]:y+item.offset[1]
let left = x == 0 ? item.offset[0]:x+item.offset[0]
item.offset = [left,top]
2024-09-03 16:39:06 +08:00
item.maskUrl = arr[index].maskUrl
item.priority = arr[index].priority
arr[index].similarity = true
// item.offset = [(arr[index]?.style?.left.replace(/px/g,'')*ratio).toFixed(0),(i?.style?.top.replace(/px/g,'')*ratio).toFixed(0)]
break
2023-10-11 17:34:14 +08:00
}
}
2024-01-04 09:40:28 +08:00
if(arr.length > 1 && item.type == this.capitalizeFirstLetter(imageCategory1)){
2023-10-11 17:34:14 +08:00
item.scale = front?.imageSize?Number(((front?.style?.width.replace(/px/g,'')*ratio)/front?.imageSize[0]).toFixed(2)):1
}
})
Https.axiosPost(Https.httpUrls.designSingle, data).then(
(rv) => {
2023-12-21 17:49:41 +08:00
// this.$parent.loadingShow = false
// let designItemDetail = JSON.parse(JSON.stringify(this.store.state.DesignDetailModule.designItemDetail))
// designItemDetail.designItemUrl = rv.designItemUrl
// designItemDetail.ifSubmit = true
// designItemDetail.currentFullBodyView = rv.currentFullBodyView
// rv.clothes.forEach((item)=>{
// designItemDetail.clothes.forEach((i)=>{
// if(item.id === i.id){
// i.layersObject = item.layersObject
// i.priority = item.layersObject[0].priority
// }
// })
// })
2023-10-11 17:34:14 +08:00
let designItemDetail = JSON.parse(JSON.stringify(this.store.state.DesignDetailModule.designItemDetail))
2023-12-22 10:57:12 +08:00
rv.clothes.forEach((i)=>{
i.similarity = false//新增衣服传的是衣服id会存在两件衣服id相同所以设置为false让每次赋值都是不一样的
2023-12-21 17:49:41 +08:00
})
2023-10-11 17:34:14 +08:00
designItemDetail.designItemUrl = rv.designItemUrl
2023-10-13 17:06:44 +08:00
designItemDetail.ifSubmit = true
2023-10-11 17:34:14 +08:00
designItemDetail.currentFullBodyView = rv.currentFullBodyView
2023-12-22 10:57:12 +08:00
designItemDetail.clothes.forEach((item)=>{
for (let index = 0; index < rv.clothes.length; index++) {
if(rv.clothes[index].id === item.id && !rv.clothes[index].similarity){
item.layersObject = rv.clothes[index].layersObject
item.priority = rv.clothes[index].layersObject[0].priority
rv.clothes[index].similarity = true
2023-12-21 17:49:41 +08:00
break
2023-10-11 17:34:14 +08:00
}
2023-12-21 17:49:41 +08:00
}
2023-10-11 17:34:14 +08:00
})
2023-12-22 10:57:12 +08:00
// rv.clothes.forEach((item)=>{
// for (let index = 0; index < designItemDetail.clothes.length; index++) {
// if(item.id === designItemDetail.clothes[index].id && !designItemDetail.clothes[index].similarity){
// designItemDetail.clothes[index].layersObject = item.layersObject
// designItemDetail.clothes[index].priority = item.layersObject[0].priority
// break
// }
// }
// })
2023-10-11 17:34:14 +08:00
this.$emit('setDesignCoverage');
this.store.commit("setDesignItemDetail", designItemDetail);
this.setRevocation(designItemDetail,data)
2024-08-13 09:36:13 +08:00
this.clear()
2023-10-11 17:34:14 +08:00
}
).catch(res=>{
2024-04-26 17:36:30 +08:00
// this.$parent.loadingShow = false
this.$emit('setParentLoadingShow');
2023-10-11 17:34:14 +08:00
});
2023-09-12 10:09:02 +08:00
},
},
});
</script>
<style lang="less" scoped>
.designOpenrtion_modal {
2023-09-25 10:09:00 +08:00
// max-width: 1440px;
2023-09-12 10:09:02 +08:00
.ant-modal-body{
padding: calc(4rem*1.2) calc(5rem*1.2) calc(0rem*1.2)!important;
// height: calc(65vh - 6.4rem*1.2));
height: calc(65rem*1.2);
2023-09-12 10:09:02 +08:00
display: flex;
overflow-y: hidden;
flex-direction: column;
}
.ant-modal-content{
border-radius: calc(1rem*1.2);
2023-09-12 10:09:02 +08:00
overflow: hidden;
}
}
.design_compile_content {
// background: #f2f3fb;
// padding-bottom: 2.9rem*1.2);
2023-09-12 10:09:02 +08:00
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
2024-08-23 10:19:02 +08:00
width: 50%;
position: relative;
overflow: hidden;
2023-09-12 10:09:02 +08:00
.designOpenrtion_centent{
2024-08-13 09:36:13 +08:00
// flex: 1;
height: 100%;
2023-09-12 10:09:02 +08:00
display: flex;
flex-direction: column;
align-content: space-around;
flex-wrap: nowrap;
margin: 0 auto;
2024-08-13 09:36:13 +08:00
// overflow: hidden;
2023-09-12 10:09:02 +08:00
justify-content: space-between;
user-select:none;
2023-10-12 17:09:05 +08:00
z-index: 2;
2023-09-12 10:09:02 +08:00
&.active{
flex-direction: row;
}
.designOpenrtion_imgMask{
width: auto;
height: auto;
position: relative;
2024-08-13 09:36:13 +08:00
height: calc(100% - 1.2rem - 4.8rem - 20%);
// overflow: hidden;
2023-09-12 10:09:02 +08:00
>img{
z-index: 2;
position: relative;
}
>div{
position: absolute;
width: 100%;
height: 100%;
top: 0;
}
}
2023-12-13 16:09:17 +08:00
.detail_modal_body_nav{
display: flex;
position: relative;
top: 0;
left: 50%;
z-index: 999;
transform: translate(-50%,-0%);
transition: all .3s;
justify-content: center;
margin-bottom: calc(1rem*1.2);
2023-12-13 16:09:17 +08:00
>div{
width: calc(4rem*1.2);
height: calc(4rem*1.2);
2023-12-13 16:09:17 +08:00
cursor: pointer;
text-align: center;
margin-left: calc(.3rem*1.2);
2023-12-13 16:09:17 +08:00
img{
// width: 100%;
height: 100%;
max-width: 100%;
object-fit: cover;
}
&.active{
border: 2px solid rgba(0,0,0,0.4);
img{
transform: scale(.8);
opacity: .8;
}
}
}
>div:nth-child(1){
margin-left: calc(0rem*1.2);
2023-12-13 16:09:17 +08:00
}
}
2023-10-11 17:34:14 +08:00
.designOpenrtion_print,.detail_modal_item_front{
2023-09-12 10:09:02 +08:00
z-index: 1;
2023-10-11 17:34:14 +08:00
img{
width: 100%;
height: 100%;
float: left;
user-select:none;
-webkit-user-drag: none;
}
2023-09-12 10:09:02 +08:00
.modal_imgItem{
position: absolute;
overflow: hidden;
top: 0;
2023-10-11 17:34:14 +08:00
2023-09-12 10:09:02 +08:00
}
}
2023-10-11 17:34:14 +08:00
.designOpenrtion_print{
z-index: 1 !important;
}
2023-09-12 10:09:02 +08:00
.designOpenrtion_btn{
2023-10-11 17:34:14 +08:00
z-index: 9999;
2023-09-12 10:09:02 +08:00
ul{
list-style: none;
// width: 100%;
// height: 100%;
position: absolute;
top: 0;
left: 0;
box-sizing: border-box;
border: 2px solid rgb(20, 188, 255);
padding: 0;
-webkit-user-drag: none;
user-select:none;
opacity: 0;
margin: 0;
li{
cursor: pointer;
// border-radius: 50%;
width: calc(1rem*1.2);
height: calc(1rem*1.2);
2023-09-12 10:09:02 +08:00
background-color: rgb(20, 188, 255);
position: absolute;
pointer-events: none;
}
&.active{
opacity: 1;
li{
pointer-events: auto;
}
}
.designOpenrtion_btn_top,.designOpenrtion_btn_bottom{
left: 50%;
transform: translate(-50%,-50%) ;
cursor: n-resize;
}
.designOpenrtion_btn_top{
top: 0;
}
.designOpenrtion_btn_bottom{
top: 100%;
}
.designOpenrtion_btn_left,.designOpenrtion_btn_right{
top: 50%;
transform: translate(-50%,-50%) ;
cursor: e-resize;
}
.designOpenrtion_btn_left{
left: 0;
}
.designOpenrtion_btn_right{
left: 100%;
}
.designOpenrtion_rotote{
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
width: 0;
height: 0;
}
.designOpenrtion_rotote::after{
position: absolute;
content: "";
background-color: #14bcff;
width: 2px;
height: 30px;
left: 50%;
bottom: 0;
transform: translateX(-50%);
}
.designOpenrtion_rotote::before{
position: absolute;
content: "";
background-color: #14bcff;
top: calc(50% - 30px);
left: 50%;
transform: translate(-50%,-50%) ;
width: calc(1.5rem*1.2);
height: calc(1.5rem*1.2);
2023-09-12 10:09:02 +08:00
border-radius: 50%;
}
}
}
.subitOkPreviewBtn{
z-index: 2;
2024-01-24 16:43:54 +08:00
margin-bottom: calc(1rem*1.2);
width: calc(10rem*1.2);
2023-09-12 10:09:02 +08:00
text-align: center;
bottom: 0;
position: relative;
}
}
2023-10-12 17:09:05 +08:00
.designOpenrtion_imgMask_open{
position: absolute;
width: 100%;
height: 100%;
}
2023-09-12 10:09:02 +08:00
}
</style>