This commit is contained in:
李志鹏
2025-10-23 17:01:13 +08:00
parent 86091b8e40
commit c1d57f2347
4 changed files with 43 additions and 25 deletions

View File

@@ -6,7 +6,7 @@ const request = (config: any) => {
if (config.loading) useOverallStore().setLoading(true)
setTimeout(() => {
res({})
if (!config.loading) useOverallStore().setLoading(false)
if (config.loading) useOverallStore().setLoading(false)
}, 1000)
})
}
@@ -42,6 +42,7 @@ export function uploadCustomerPhoto(data: FormData) {
url: '/api/customer-photos/upload',
method: 'post',
data,
loading: true,
})
}
/**

View File

@@ -17,7 +17,13 @@ export const useGenerateStore = defineStore({
id: -1,
}
},
queryList: []
queryList: [],
/** 顾客照片信息 */
photoInfo: {
id: "",
url: "",
}
}
},
getters: {
@@ -32,7 +38,7 @@ export const useGenerateStore = defineStore({
/** 原始试穿id */
originalTryOnId: (state) => state.userData.style.id,
/** 顾客照片id */
customerPhotoId: (state) => state.userData.id,
customerPhotoId: (state) => state.photoInfo.id,
},
actions: {
selectStyle(data: any) {
@@ -54,6 +60,11 @@ export const useGenerateStore = defineStore({
selectModel(data: any) {
this.userData.model.id = data.id
console.log(this.userData)
}
},
/** 更新顾客照片信息 */
updatePhotoInfo(data: any) {
this.photoInfo.id = data.visitRecordId || ""
this.photoInfo.url = data.defaultImageUrl || ""
},
}
})

View File

@@ -3,7 +3,11 @@
import FooterNavigation from '@/components/FooterNavigation.vue'
import GenerateLoading from '@/views/asistant/components/GenerateLoading.vue'
import { ref, onMounted } from 'vue'
import { generateTryOnEffect, setTryOnEffectFavorite, cancelTryOnEffectFavorite } from '@/api/workshop'
import {
generateTryOnEffect,
setTryOnEffectFavorite,
cancelTryOnEffectFavorite
} from '@/api/workshop'
const emit = defineEmits(['viewType'])
import { useRouter } from 'vue-router'
import { useGenerateStore } from '@/stores'
@@ -11,18 +15,19 @@
const router = useRouter()
const inputText = ref('')
const isLoved = ref(false)
const isFavorite = ref(false)
const tryOnUrl = ref('')
const loading = ref(false)
const onSend = () => {
if (inputText.value === '') return
generate();
generate()
const text = inputText.value
inputText.value = ''
console.log('发送消息:', text)
// console.log('发送消息:', text)
}
const onReload = () => {
inputText.value = ''
generate(true);
generate(true)
}
// 生成结果
@@ -35,30 +40,30 @@
customerPhotoId: store.customerPhotoId,
originalTryOnId: store.originalTryOnId,
isRegenerated: isRegenerated ? 1 : 0,
prompt: inputText.value,
};
prompt: inputText.value
}
loading.value = true
generateTryOnEffect(data)
.then(res => {
console.log(res)
.then((res) => {
tryOnUrl.value = res.tryOnUrl
isFavorite.value = !!res.isFavorite
loading.value = false
})
.catch(err => {
.catch((err) => {
console.error(err)
loading.value = false
})
}
generate();
generate()
// 喜欢
const isLoveLoading = ref(false)
const onLove = () => {
if (isLoveLoading.value) return
const http = isLoved.value ? cancelTryOnEffectFavorite : setTryOnEffectFavorite
const http = isFavorite.value ? cancelTryOnEffectFavorite : setTryOnEffectFavorite
isLoveLoading.value = true
isLoved.value = !isLoved.value
http("tryOnId")
isFavorite.value = !isFavorite.value
http('tryOnId')
.then(() => {
isLoveLoading.value = false
})
@@ -96,14 +101,14 @@
<div class="send" @click="onSend"><SvgIcon name="send" size="48" /></div>
</div>
<div class="card">
<img src="@/assets/images/workshop/posture/posture_1.png" />
<img :src="tryOnUrl" />
<!-- <div class="select-box">
<div class="icon"><SvgIcon name="history" size="35" /></div>
<div class="label">History</div>
<div class="icon"><SvgIcon name="xialajiantou" size="29" /></div>
</div> -->
<div class="icons">
<div @click="onLove"><SvgIcon :name="`love_${isLoved ? 1 : 0}`" size="35" /></div>
<div @click="onLove"><SvgIcon :name="`love_${isFavorite ? 1 : 0}`" size="35" /></div>
<div @click="onReload"><SvgIcon name="reload" size="35" /></div>
<!-- <div @click="onDownload"><SvgIcon name="download" size="35" /></div> -->
</div>

View File

@@ -4,6 +4,9 @@
import { ref, reactive, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { uploadCustomerPhoto } from '@/api/workshop'
import { useGenerateStore } from '@/stores'
const generateStore = useGenerateStore()
const emit = defineEmits(['view-type'])
onMounted(() => {
emit('view-type', 1)
@@ -13,13 +16,12 @@
url:"",
file: null,
});
console.log(fileData)
// 上传照片
const handleUploadFace = () => {
const input = document.createElement('input')
input.type = 'file'
input.accept = 'image/*'
input.capture = 'camera'
// input.capture = 'camera'
input.click()
input.onchange = (e: any) => {
const file = e.target.files[0]
@@ -42,8 +44,7 @@
formData.append('visitRecordId', "1")
formData.append('file', fileData.file)
uploadCustomerPhoto(formData).then(res => {
console.log(res, res.photoUrl)
generateStore.updatePhotoInfo(res);
router.push({ name: 'customize' })
})
}