This commit is contained in:
李志鹏
2025-10-24 15:19:29 +08:00
parent 40ec2ce775
commit 114cea1a29
6 changed files with 35 additions and 26 deletions

View File

@@ -1 +1 @@
VITE_APP_URL = https://b0cd77b2f755.ngrok-free.app VITE_APP_URL = http://192.168.31.82:8771

View File

@@ -11,11 +11,12 @@ export const useGenerateStore = defineStore({
model: { model: {
id: -1, id: -1,
}, },
tryOnId:{//生成穿好衣服的回参 tryOnId: {//生成穿好衣服的回参
id: -1, id: -1,
isLike: false,//是否喜欢 isLike: false,//是否喜欢
}, },
isGenerate: false,//点击继续按钮后是否需要生成 isGenerate: false,//点击继续按钮后是否需要生成
/** 顾客照片信息 */ /** 顾客照片信息 */
photoInfo: { photoInfo: {
id: "", id: "",
@@ -40,11 +41,11 @@ export const useGenerateStore = defineStore({
/** 进店记录id */ /** 进店记录id */
visitRecordId: (state) => 1, visitRecordId: (state) => 1,
/** 服装id */ /** 服装id */
styleId: (state) => 1, styleId: (state) => state.style.id,
/** 模特照片id */ /** 模特照片id */
modelPhotoId: (state) => 1, modelPhotoId: (state) => state.model.id,
/** 原始试穿id */ /** 原始试穿id-优先AI魔改 */
originalTryOnId: (state) => 1, originalTryOnId: (state) => state.customizeInfo.tryOnId || state.tryOnId.id,
/** 顾客照片id */ /** 顾客照片id */
customerPhotoId: (state) => state.photoInfo.id, customerPhotoId: (state) => state.photoInfo.id,
}, },
@@ -74,8 +75,8 @@ export const useGenerateStore = defineStore({
}, },
/** 更新顾客照片信息 */ /** 更新顾客照片信息 */
updatePhotoInfo(data: any) { updatePhotoInfo(data: any) {
this.photoInfo.id = data.visitRecordId || "" this.photoInfo.id = data.id || ""
this.photoInfo.url = data.defaultImageUrl || "" if (!data.photoUrl) this.photoInfo.url = ""
this.photoInfo.file = null this.photoInfo.file = null
}, },
/** 清空 AI魔改信息 */ /** 清空 AI魔改信息 */

View File

@@ -14,6 +14,8 @@
const emit = defineEmits(['view-type']) const emit = defineEmits(['view-type'])
const query = computed(() => router.currentRoute.value.query) const query = computed(() => router.currentRoute.value.query)
const visitRecordId = computed(() => query.value.visitRecordId) const visitRecordId = computed(() => query.value.visitRecordId)
import { useGenerateStore } from '@/stores'
const generateStore = useGenerateStore()
onMounted(() => { onMounted(() => {
emit('view-type', 1) emit('view-type', 1)
@@ -28,7 +30,8 @@
const onLoad = () => { const onLoad = () => {
loading.value = true loading.value = true
const http = visitRecordId.value ? getTryOnEffectFavoriteList : getTryOnEffectStyleList const http = visitRecordId.value ? getTryOnEffectFavoriteList : getTryOnEffectStyleList
http(visitRecordId.value) const id = visitRecordId.value || generateStore.visitRecordId;
http(id)
.then((data) => { .then((data) => {
data?.forEach((v) => { data?.forEach((v) => {
const obj = { const obj = {

View File

@@ -11,9 +11,9 @@
const emit = defineEmits(['viewType']) const emit = defineEmits(['viewType'])
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { useGenerateStore } from '@/stores' import { useGenerateStore } from '@/stores'
const store = useGenerateStore() const generateStore = useGenerateStore()
const customizeInfo = store.customizeInfo const customizeInfo = generateStore.customizeInfo
const router = useRouter() const router = useRouter()
const loading = ref(false) const loading = ref(false)
const onSend = () => { const onSend = () => {
@@ -26,21 +26,21 @@
} }
const onReload = () => { const onReload = () => {
customizeInfo.inputText = '' customizeInfo.inputText = ''
generate(true) generate()
} }
// 生成结果 // 生成结果
const generate = (isRegenerated = false) => { const generate = () => {
const data = { const data = {
customerId: store.customerId, customerId: generateStore.customerId,
visitRecordId: store.visitRecordId, visitRecordId: generateStore.visitRecordId,
styleId: store.styleId, styleId: generateStore.styleId,
modelPhotoId: store.modelPhotoId, // modelPhotoId: generateStore.modelPhotoId,
customerPhotoId: store.customerPhotoId, originalTryOnId: generateStore.originalTryOnId,
originalTryOnId: store.originalTryOnId, isRegenerated: 1,
isRegenerated: isRegenerated ? 1 : 0,
prompt: customizeInfo.inputText prompt: customizeInfo.inputText
} }
if (generateStore.customerPhotoId) data.customerPhotoId = generateStore.customerPhotoId
loading.value = true loading.value = true
generateTryOnEffect(data) generateTryOnEffect(data)
.then((res) => { .then((res) => {
@@ -65,7 +65,7 @@
const http = customizeInfo.isFavorite ? cancelTryOnEffectFavorite : setTryOnEffectFavorite const http = customizeInfo.isFavorite ? cancelTryOnEffectFavorite : setTryOnEffectFavorite
customizeInfo.isFavorite = !customizeInfo.isFavorite customizeInfo.isFavorite = !customizeInfo.isFavorite
isLoveLoading.value = true isLoveLoading.value = true
http('tryOnId') http(customizeInfo.tryOnId)
.then(() => { .then(() => {
isLoveLoading.value = false isLoveLoading.value = false
}) })

View File

@@ -8,6 +8,8 @@
import { getCustomerPhotos, deleteCustomerPhoto } from '@/api/workshop' import { getCustomerPhotos, deleteCustomerPhoto } from '@/api/workshop'
const emit = defineEmits(['view-type']) const emit = defineEmits(['view-type'])
import { showConfirmDialog } from 'vant' import { showConfirmDialog } from 'vant'
import { useGenerateStore } from '@/stores'
const generateStore = useGenerateStore()
onMounted(() => { onMounted(() => {
emit('view-type', 1) emit('view-type', 1)
@@ -18,8 +20,7 @@
const onLoad = () => { const onLoad = () => {
loading.value = true loading.value = true
const customerId = '123123123' getCustomerPhotos(generateStore.customerId)
getCustomerPhotos(customerId)
.then((data) => { .then((data) => {
data?.forEach((v) => { data?.forEach((v) => {
const obj = { const obj = {

View File

@@ -39,8 +39,8 @@
if (fileData.id) return router.push({ name: 'customize' }) if (fileData.id) return router.push({ name: 'customize' })
if (!fileData.file) return if (!fileData.file) return
const formData = new FormData() const formData = new FormData()
formData.append('customerId', '1') formData.append('customerId', generateStore.customerId + '')
formData.append('visitRecordId', '1') formData.append('visitRecordId', generateStore.visitRecordId + '')
formData.append('file', fileData.file) formData.append('file', fileData.file)
uploadCustomerPhoto(formData).then((res) => { uploadCustomerPhoto(formData).then((res) => {
generateStore.updatePhotoInfo(res) generateStore.updatePhotoInfo(res)
@@ -48,6 +48,10 @@
router.push({ name: 'customize' }) router.push({ name: 'customize' })
}) })
} }
// 处理照片加载错误
const pictureLoadError = (e: any) => {
// generateStore.updatePhotoInfo({})
}
</script> </script>
<template> <template>
@@ -62,7 +66,7 @@
</div> </div>
<!-- 照片 --> <!-- 照片 -->
<div class="picture" v-if="fileData.url"> <div class="picture" v-if="fileData.url">
<img :src="fileData.url" /> <img :src="fileData.url" @error="pictureLoadError" />
</div> </div>
<div class="btns"> <div class="btns">
<template v-if="fileData.url"> <template v-if="fileData.url">