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

187 lines
4.4 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'
import { useRouter } from 'vue-router'
2025-10-28 13:57:48 +08:00
import { useGenerateStore, useUserInfoStore } from '@/stores'
2025-10-24 11:48:15 +08:00
import { showNotify } from 'vant';
2025-10-28 13:57:48 +08:00
import { generateRequestOutfit, getRequestOutfit } from '@/api/workshop'
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-21 13:46:27 +08:00
const selectItem = (item)=>{
2025-10-28 13:57:48 +08:00
if((item.id == data.select?.oldId) || !item.id || item.status != 'SUCCEEDED'){
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 = ()=>{
2025-10-24 15:18:23 +08:00
if(!generateStore.style.id && !generateStore.style.oldId){
showNotify({ message: 'Please select a style.', type:'warning', color:'#fff', background:'#ff976a' });
2025-10-24 11:48:15 +08:00
return
}
if(generateStore.style.id){
generateStore.setIsGenerate(true)
}
2025-10-21 13:46:27 +08:00
router.push({ path: 'product' })
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-10-28 13:57:48 +08:00
"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)
}
})
}
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)
if(!data.styleList[0]?.id)requestOutfit({num:4,index:0})
2025-10-09 10:42:45 +08:00
})
onUnmounted(()=>{
})
defineExpose({})
2025-10-28 13:57:48 +08:00
const { styleList, select } = toRefs(data);
2025-10-09 10:42:45 +08:00
</script>
<template>
<header-title style-type="2" />
2025-10-09 10:42:45 +08:00
<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>
<div class="selectContent">
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>
</div>
<div class="footer placeholder"></div>
2025-10-10 16:03:12 +08:00
<div class="footer">
2025-10-21 13:46:27 +08:00
<button @click.stop="toProduct">Continue</button>
2025-10-10 16:03:12 +08:00
</div>
2025-10-09 10:42:45 +08:00
</template>
<style lang="less" scoped>
.header-title {
--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%;
margin-top: 3.4rem;
margin-bottom: 7.2rem;
2025-10-09 16:04:55 +08:00
> .title{
font-family: satoshiBold;
font-weight: 700;
font-size: 9.6rem;
line-height: 124%;
}
> .info{
font-size: 4rem;
font-weight: 400;
line-height: 124%;
margin-top: 1.3rem;
}
}
.selectContent{
padding: 0 3.5rem;
flex: 1;
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 {
position: fixed;
width: 100%;
bottom: 0;
left: 0;
height: 11.2rem;
display: flex;
align-items: center;
justify-content: flex-end;
background-color: #f6f6f6;
&.placeholder{
position: relative;
}
2025-10-10 16:03:12 +08:00
> button {
width: 24.6rem;
height: 5.9rem;
border-radius: 0.7rem;
box-sizing: content-box;
border: 0.3rem solid #000;
background-color: #000;
font-family: satoshiBold;
font-weight: 700;
font-size: 3.6rem;
2025-10-10 16:03:12 +08:00
color: #fff;
margin-right: 5rem;
&:active {
opacity: 0.7;
}
}
}
2025-10-09 10:42:45 +08:00
</style>