Files
lanecarford_front/src/views/Workshop/selectStyle.vue

207 lines
5.1 KiB
Vue
Raw Normal View History

2025-10-09 10:42:45 +08:00
<script setup lang="ts">
import { onMounted, onUnmounted, reactive, toRefs, computed, onActivated } from "vue";
2025-10-09 13:56:00 +08:00
import SelectItem from "@/components/selectStyle/selectItem.vue";
2025-10-10 16:03:12 +08:00
import HeaderTitle from '@/components/HeaderTitle.vue'
2025-11-17 11:24:46 +08:00
import FooterNavigation from '@/components/FooterNavigation.vue'
2025-10-10 16:03:12 +08:00
import { useRouter } from 'vue-router'
2025-10-28 13:57:48 +08:00
import { useGenerateStore, useUserInfoStore } from '@/stores'
2025-10-30 15:15:23 +08:00
import { showToast } from 'vant';
2025-10-28 13:57:48 +08:00
import { generateRequestOutfit, getRequestOutfit } from '@/api/workshop'
2025-12-22 13:51:13 +08:00
import { FlowType } from '@/types/enum'
2025-10-10 16:03:12 +08:00
const router = useRouter()
2025-10-09 10:42:45 +08:00
//const props = defineProps({
//})
const emit = defineEmits([
'view-type'
])
2025-10-21 13:46:27 +08:00
const generateStore = useGenerateStore()
2025-10-28 13:57:48 +08:00
const userInfoStore = useUserInfoStore()
2025-10-09 10:42:45 +08:00
let data = reactive({
2025-10-28 13:57:48 +08:00
select:computed(()=>generateStore.style),
styleList:computed(()=>generateStore.styleList),
2025-10-09 10:42:45 +08:00
})
2025-10-21 10:20:57 +08:00
2025-10-30 15:52:11 +08:00
let getGenerateTime = null as any
2025-10-21 13:46:27 +08:00
const selectItem = (item)=>{
if(!item.id || item.status != 'SUCCEEDED'){
2025-10-28 13:57:48 +08:00
return
}
2025-10-21 13:46:27 +08:00
generateStore.selectStyle(item)
}
const updateStyle = ({item,index})=>{
generateStore.updateStyle(item)
2025-10-28 13:57:48 +08:00
data.styleList[index] = {}
requestOutfit({num:1,index})
2025-10-21 13:46:27 +08:00
}
2025-10-21 10:20:57 +08:00
2025-10-21 13:46:27 +08:00
const toProduct = ()=>{
if(!generateStore.style.id){
2025-10-30 15:15:23 +08:00
showToast({ message: 'Please select a style.' });
2025-10-24 11:48:15 +08:00
return
}
if(generateStore.style.id != generateStore.style.oldId){
2025-10-24 11:48:15 +08:00
generateStore.setIsGenerate(true)
}
const query = router.currentRoute.value.query
2025-12-22 13:51:13 +08:00
if(query?.flowType == FlowType.MAIN){
router.push({ path: 'product', query: {...query} })
}else{
router.push({ path: 'creation', query: {...query} })
}
2025-10-10 16:03:12 +08:00
}
2025-10-28 13:57:48 +08:00
const requestOutfit = ({num,index})=>{
let value = {
2025-10-28 14:17:57 +08:00
"customerId": generateStore.customerId,
"checkInId": generateStore.visitRecordId,
2025-11-03 11:35:55 +08:00
"stylist": userInfoStore.state.generateParams.stylist,
2025-10-28 13:57:48 +08:00
"gender": userInfoStore.state.generateParams.sex,
2025-11-03 15:59:28 +08:00
"sessionId": generateStore.sessionId,
2025-10-28 13:57:48 +08:00
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)
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){
2025-10-30 15:52:11 +08:00
getGenerateTime = setTimeout(()=>{
2025-10-28 13:57:48 +08:00
getRequestOutfitList(pendingList)
},3000)
}
})
}
2025-10-09 10:42:45 +08:00
onMounted(()=>{
2025-10-28 13:57:48 +08:00
// generateStore.clearProductData()
emit('view-type', 1)
2025-10-28 13:57:48 +08:00
// if(!data.styleList[0]?.id)getRequestOutfitList(0)
2025-10-30 15:52:11 +08:00
if(getGenerateTime)clearTimeout(getGenerateTime)
if(!data.styleList[0]?.taskId){
requestOutfit({num:4,index:0})
}else if(data.styleList.filter((item)=>item?.status != 'SUCCEEDED').length > 0){
let generateList = data.styleList.map((item)=>item.taskId)
getRequestOutfitList(generateList)
}
2025-10-09 10:42:45 +08:00
})
onUnmounted(()=>{
2025-10-30 15:52:11 +08:00
if(getGenerateTime)clearTimeout(getGenerateTime)
2025-10-09 10:42:45 +08:00
})
defineExpose({})
2025-10-28 13:57:48 +08:00
const { styleList, select } = toRefs(data);
2025-10-09 10:42:45 +08:00
</script>
<template>
<div class="selectStyle">
2025-10-09 16:04:55 +08:00
<div class="text">
<div class="title">
Whats your Style?
2025-10-09 13:56:00 +08:00
</div>
2025-10-09 16:04:55 +08:00
<div class="info">
Select the outfit that matches you the most.
</div>
</div>
2025-12-09 15:12:25 +08:00
<div class="selectContent flex-1">
2025-10-28 13:57:48 +08:00
<SelectItem :selectList="styleList" v-model:select="select" @selectItem="selectItem" @updateStyle="updateStyle" />
2025-10-09 10:42:45 +08:00
</div>
2025-12-01 13:15:43 +08:00
<div class="footer">
2025-12-09 15:12:25 +08:00
<button class="flex flex-center" @click.stop="toProduct">Continue</button>
2025-12-01 13:15:43 +08:00
</div>
2025-10-09 10:42:45 +08:00
</div>
2025-11-17 11:24:46 +08:00
<!-- <div class="footer placeholder"></div> -->
2025-10-09 10:42:45 +08:00
</template>
<style lang="less" scoped>
.header-title {
2025-11-17 11:24:46 +08:00
// --header-title-background: #f6f6f6;
}
2025-10-09 10:42:45 +08:00
.selectStyle{
width: 100%;
flex: 1;
2025-10-10 16:03:12 +08:00
// height: 100%;
2025-10-09 10:42:45 +08:00
position: relative;
display: flex;
flex-direction: column;
background-color: #f6f6f6;
overflow: hidden;
2025-10-09 16:04:55 +08:00
> .text{
text-align: center;
width: 100%;
2025-12-01 13:15:43 +08:00
margin-top: 3rem;
2025-11-17 11:24:46 +08:00
margin-bottom: 4.9rem;
2025-10-09 16:04:55 +08:00
> .title{
font-family: satoshiBold;
font-weight: 700;
font-size: 9.6rem;
line-height: 124%;
2025-12-09 15:12:25 +08:00
color: #000;
2025-10-09 16:04:55 +08:00
}
> .info{
font-size: 4rem;
font-weight: 400;
line-height: 124%;
margin-top: 1.3rem;
2025-12-09 15:12:25 +08:00
color: rgba(0, 0, 0, 0.6);
2025-10-09 16:04:55 +08:00
}
}
.selectContent{
2025-11-17 11:24:46 +08:00
padding: 0 4rem;
overflow: auto;
2025-10-09 16:04:55 +08:00
}
2025-10-09 10:42:45 +08:00
}
2025-10-10 16:03:12 +08:00
.footer {
2025-11-17 11:24:46 +08:00
// position: fixed;
2025-12-09 15:12:25 +08:00
// margin-top: 4.4rem;
2025-12-09 16:21:01 +08:00
// padding: 4rem 4rem 0 0;
margin-top: auto;
margin-bottom: 5.6rem;
margin-right: 4rem;
2025-10-10 16:03:12 +08:00
display: flex;
align-items: center;
justify-content: flex-end;
2025-12-09 16:21:01 +08:00
// position: absolute;
// right: 4rem;
// bottom: 4rem;
height: 6.7rem;
2025-12-09 15:12:25 +08:00
// background-color: #f6f6f6;
&.placeholder{
position: relative;
}
2025-10-10 16:03:12 +08:00
> button {
2025-12-09 15:12:25 +08:00
// margin-right: 5rem;
2025-12-01 13:15:43 +08:00
border-radius: .7rem;
border: 3px solid #000;
background-color: #000;
text-align: center;
color: #fff;
font-family: satoshiMedium;
font-size: 3.6rem;
width: 24.6rem;
2025-12-09 15:12:25 +08:00
height: 6.7rem;
box-sizing: border-box;
2025-12-01 13:15:43 +08:00
line-height: 6.7rem;
2025-10-10 16:03:12 +08:00
}
}
2025-10-09 10:42:45 +08:00
</style>