服装生成

This commit is contained in:
X1627315083
2025-10-28 13:57:48 +08:00
parent 2a1023aea0
commit 74aa41d26c
11 changed files with 101 additions and 39 deletions

View File

@@ -3,12 +3,9 @@ import { onMounted, onUnmounted, reactive, toRefs, computed } from "vue";
import SelectItem from "@/components/selectStyle/selectItem.vue";
import HeaderTitle from '@/components/HeaderTitle.vue'
import { useRouter } from 'vue-router'
import editProfile1 from '@/assets/images/workshop/selectStyle/selectStyle1.png'
import editProfile2 from '@/assets/images/workshop/selectStyle/selectStyle2.png'
import editProfile3 from '@/assets/images/workshop/selectStyle/selectStyle3.png'
import editProfile4 from '@/assets/images/workshop/selectStyle/selectStyle4.png'
import { useGenerateStore } from '@/stores'
import { useGenerateStore, useUserInfoStore } from '@/stores'
import { showNotify } from 'vant';
import { generateRequestOutfit, getRequestOutfit } from '@/api/workshop'
const router = useRouter()
//const props = defineProps({
@@ -17,43 +14,26 @@ const emit = defineEmits([
'view-type'
])
const generateStore = useGenerateStore()
const userInfoStore = useUserInfoStore()
let data = reactive({
selectList:
[
{
id:1,
imgUrl:editProfile1,
},
{
id:2,
imgUrl:editProfile2,
},
{
id:3,
imgUrl:editProfile3,
},
{
id:4,
imgUrl:editProfile4,
},
],
select:computed(()=>generateStore.style)
select:computed(()=>generateStore.style),
styleList:computed(()=>generateStore.styleList),
})
const selectItem = (item)=>{
if((item.id == data.select?.oldId) || !item.id || item.status != 'SUCCEEDED'){
return
}
generateStore.selectStyle(item)
}
const updateStyle = ({item,index})=>{
generateStore.updateStyle(item)
data.selectList[index] = {
id:9,
imgUrl:item.imgUrl,
}
data.styleList[index] = {}
requestOutfit({num:1,index})
}
const toProduct = ()=>{
console.log(generateStore.style)
if(!generateStore.style.id && !generateStore.style.oldId){
showNotify({ message: 'Please select a style.', type:'warning' });
return
@@ -63,14 +43,59 @@ const toProduct = ()=>{
}
router.push({ path: 'product' })
}
const requestOutfit = ({num,index})=>{
let value = {
"customerId": 1 || generateStore.customerId,
"checkInId": 1 || generateStore.visitRecordId,
"stylist": "mini",
"gender": userInfoStore.state.generateParams.sex,
num,
}
generateRequestOutfit(value).then((rv)=>{
let rvIndex = 0
data.styleList.forEach((item,styleIndex)=>{
if(styleIndex < index)return
item.taskId = rv[rvIndex]
rvIndex++
})
getRequestOutfitList(rv)
})
}
const getRequestOutfitList = (generateList)=>{
let value = {requestIDs:generateList.join(',')}
getRequestOutfit(value).then((rv:any)=>{
let pendingList = []
rv.forEach((item)=>{
if(['RUNNING','PENDING'].includes(item.status))pendingList.push(item.requestId)
let index = data.styleList.findIndex((styleItem)=>styleItem.taskId == item.requestId)
console.log(index,data.styleList,rv)
if(index != -1){
data.styleList[index].id = item.id
data.styleList[index].path = item.path
data.styleList[index].status = item.status
}
})
if(pendingList.length > 0){
setTimeout(()=>{
getRequestOutfitList(pendingList)
},3000)
}
})
}
onMounted(()=>{
// generateStore.clearProductData()
emit('view-type', 1)
// if(!data.styleList[0]?.id)getRequestOutfitList(0)
if(!data.styleList[0]?.id)requestOutfit({num:4,index:0})
})
onUnmounted(()=>{
})
defineExpose({})
const { selectList, select } = toRefs(data);
const { styleList, select } = toRefs(data);
</script>
<template>
<header-title style-type="2" />
@@ -84,7 +109,7 @@ const { selectList, select } = toRefs(data);
</div>
</div>
<div class="selectContent">
<SelectItem :selectList="selectList" v-model:select="select" @selectItem="selectItem" @updateStyle="updateStyle" />
<SelectItem :selectList="styleList" v-model:select="select" @selectItem="selectItem" @updateStyle="updateStyle" />
</div>
</div>
<div class="footer placeholder"></div>