diff --git a/src/api/workshop.ts b/src/api/workshop.ts index 2816953..da13a5d 100644 --- a/src/api/workshop.ts +++ b/src/api/workshop.ts @@ -1,5 +1,35 @@ import request from '@/utils/request' +/** + * 生成穿搭风格 + * @param data 生成穿搭风格数据 + * @param data.customerId 模型照片id + * @param data.checkInId 顾客照片id + * @param data.stylist 提示词 + * @param data.gender 原始试穿效果id + * @param data.num 是否重新生成 0-否,1-是 +*/ +export function generateRequestOutfit(data: Object) { + return request({ + url: '/api/style/requestOutfit', + method: 'post', + data, + }) +} + +/** + * 获取传达风格 + * @param data 获取传达风格数据 + * @param data.requestIDs 获取生成结果的taskId +*/ +export function getRequestOutfit(data: Object) { + return request({ + url: '/api/style/getOutfitResult', + method: 'get', + params:data + }) +} + /** * 生成试穿效果 * @param data 试穿效果数据 diff --git a/src/assets/css/style.css b/src/assets/css/style.css index f1fc58c..b27916f 100644 --- a/src/assets/css/style.css +++ b/src/assets/css/style.css @@ -54,10 +54,16 @@ html:root { --van-dialog-confirm-button-text-color: #1B73E7; --van-notify-font-size: 3.5rem; --van-notify-line-height: 10rem; + --van-toast-default-width: 88rem; +} +.van-toast { + min-height: fit-content; + max-width: none; } .van-toast__text { font-size: 4rem; height: 5rem; line-height: 5rem; padding: 0 2rem; + min-height: fit-content; } diff --git a/src/assets/css/style.less b/src/assets/css/style.less index 6524dc1..11dcf72 100644 --- a/src/assets/css/style.less +++ b/src/assets/css/style.less @@ -63,7 +63,8 @@ html:root { --van-dialog-confirm-button-text-color: #1B73E7; //消息提示 --van-notify-font-size: 3.5rem; - --van-notify-line-height: 10rem + --van-notify-line-height: 10rem; + --van-toast-default-width: 88rem; } .van-toast{ diff --git a/src/assets/images/workshop/selectStyle/selectStyle1.png b/src/assets/images/workshop/selectStyle/selectStyle1.png deleted file mode 100644 index 2070af0..0000000 Binary files a/src/assets/images/workshop/selectStyle/selectStyle1.png and /dev/null differ diff --git a/src/assets/images/workshop/selectStyle/selectStyle2.png b/src/assets/images/workshop/selectStyle/selectStyle2.png deleted file mode 100644 index e28cb07..0000000 Binary files a/src/assets/images/workshop/selectStyle/selectStyle2.png and /dev/null differ diff --git a/src/assets/images/workshop/selectStyle/selectStyle3.png b/src/assets/images/workshop/selectStyle/selectStyle3.png deleted file mode 100644 index 49b6e50..0000000 Binary files a/src/assets/images/workshop/selectStyle/selectStyle3.png and /dev/null differ diff --git a/src/assets/images/workshop/selectStyle/selectStyle4.png b/src/assets/images/workshop/selectStyle/selectStyle4.png deleted file mode 100644 index a8fd5b0..0000000 Binary files a/src/assets/images/workshop/selectStyle/selectStyle4.png and /dev/null differ diff --git a/src/components/selectStyle/selectItem.vue b/src/components/selectStyle/selectItem.vue index 088508a..e04cec7 100644 --- a/src/components/selectStyle/selectItem.vue +++ b/src/components/selectStyle/selectItem.vue @@ -25,9 +25,6 @@ const setLike = (item,str)=>{ } const setSelectList = (item)=>{ - if(item.id == props.select?.oldId){ - return - } emit('selectItem', item) } @@ -51,7 +48,8 @@ const {} = toRefs(data);
look {{ index + 1 }}
- + +
diff --git a/src/stores/modules/generate.ts b/src/stores/modules/generate.ts index 11c4fa8..d0b48ff 100644 --- a/src/stores/modules/generate.ts +++ b/src/stores/modules/generate.ts @@ -9,6 +9,7 @@ export const useGenerateStore = defineStore({ id: '', oldId: '' //表示从生成页面返回回来,需要调整的样式id }, + styleList: [{},{},{},{}], model: { id: '' }, @@ -81,6 +82,7 @@ export const useGenerateStore = defineStore({ this.isGenerate = isGenerate }, clearProductData() { + this.styleList = [{},{},{},{}] this.style = { id: '', oldId: '' diff --git a/src/utils/request.ts b/src/utils/request.ts index 0e552bd..3f00765 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -21,7 +21,7 @@ declare module 'axios' { const service = axios.create({ // baseURL: import.meta.env.VITE_APP_URL, // api的base_url - timeout: 20000 // 请求超时时间 + timeout: 60000 // 请求超时时间 }) if (import.meta.env.MODE != 'development') { service.defaults.baseURL = import.meta.env.VITE_APP_URL diff --git a/src/views/Workshop/selectStyle.vue b/src/views/Workshop/selectStyle.vue index 7f1f6a7..0da27eb 100644 --- a/src/views/Workshop/selectStyle.vue +++ b/src/views/Workshop/selectStyle.vue @@ -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);