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

View File

@@ -17,7 +17,13 @@ export const useGenerateStore = defineStore({
id: -1, id: -1,
} }
}, },
queryList: [] queryList: [],
/** 顾客照片信息 */
photoInfo: {
id: "",
url: "",
}
} }
}, },
getters: { getters: {
@@ -32,7 +38,7 @@ export const useGenerateStore = defineStore({
/** 原始试穿id */ /** 原始试穿id */
originalTryOnId: (state) => state.userData.style.id, originalTryOnId: (state) => state.userData.style.id,
/** 顾客照片id */ /** 顾客照片id */
customerPhotoId: (state) => state.userData.id, customerPhotoId: (state) => state.photoInfo.id,
}, },
actions: { actions: {
selectStyle(data: any) { selectStyle(data: any) {
@@ -54,6 +60,11 @@ export const useGenerateStore = defineStore({
selectModel(data: any) { selectModel(data: any) {
this.userData.model.id = data.id this.userData.model.id = data.id
console.log(this.userData) 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 FooterNavigation from '@/components/FooterNavigation.vue'
import GenerateLoading from '@/views/asistant/components/GenerateLoading.vue' import GenerateLoading from '@/views/asistant/components/GenerateLoading.vue'
import { ref, onMounted } from 'vue' import { ref, onMounted } from 'vue'
import { generateTryOnEffect, setTryOnEffectFavorite, cancelTryOnEffectFavorite } from '@/api/workshop' import {
generateTryOnEffect,
setTryOnEffectFavorite,
cancelTryOnEffectFavorite
} from '@/api/workshop'
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'
@@ -11,18 +15,19 @@
const router = useRouter() const router = useRouter()
const inputText = ref('') const inputText = ref('')
const isLoved = ref(false) const isFavorite = ref(false)
const tryOnUrl = ref('')
const loading = ref(false) const loading = ref(false)
const onSend = () => { const onSend = () => {
if (inputText.value === '') return if (inputText.value === '') return
generate(); generate()
const text = inputText.value const text = inputText.value
inputText.value = '' inputText.value = ''
console.log('发送消息:', text) // console.log('发送消息:', text)
} }
const onReload = () => { const onReload = () => {
inputText.value = '' inputText.value = ''
generate(true); generate(true)
} }
// 生成结果 // 生成结果
@@ -35,30 +40,30 @@
customerPhotoId: store.customerPhotoId, customerPhotoId: store.customerPhotoId,
originalTryOnId: store.originalTryOnId, originalTryOnId: store.originalTryOnId,
isRegenerated: isRegenerated ? 1 : 0, isRegenerated: isRegenerated ? 1 : 0,
prompt: inputText.value, prompt: inputText.value
}
};
loading.value = true loading.value = true
generateTryOnEffect(data) generateTryOnEffect(data)
.then(res => { .then((res) => {
console.log(res) tryOnUrl.value = res.tryOnUrl
isFavorite.value = !!res.isFavorite
loading.value = false loading.value = false
}) })
.catch(err => { .catch((err) => {
console.error(err) console.error(err)
loading.value = false loading.value = false
}) })
} }
generate(); generate()
// 喜欢 // 喜欢
const isLoveLoading = ref(false) const isLoveLoading = ref(false)
const onLove = () => { const onLove = () => {
if (isLoveLoading.value) return if (isLoveLoading.value) return
const http = isLoved.value ? cancelTryOnEffectFavorite : setTryOnEffectFavorite const http = isFavorite.value ? cancelTryOnEffectFavorite : setTryOnEffectFavorite
isLoveLoading.value = true isLoveLoading.value = true
isLoved.value = !isLoved.value isFavorite.value = !isFavorite.value
http("tryOnId") http('tryOnId')
.then(() => { .then(() => {
isLoveLoading.value = false isLoveLoading.value = false
}) })
@@ -96,14 +101,14 @@
<div class="send" @click="onSend"><SvgIcon name="send" size="48" /></div> <div class="send" @click="onSend"><SvgIcon name="send" size="48" /></div>
</div> </div>
<div class="card"> <div class="card">
<img src="@/assets/images/workshop/posture/posture_1.png" /> <img :src="tryOnUrl" />
<!-- <div class="select-box"> <!-- <div class="select-box">
<div class="icon"><SvgIcon name="history" size="35" /></div> <div class="icon"><SvgIcon name="history" size="35" /></div>
<div class="label">History</div> <div class="label">History</div>
<div class="icon"><SvgIcon name="xialajiantou" size="29" /></div> <div class="icon"><SvgIcon name="xialajiantou" size="29" /></div>
</div> --> </div> -->
<div class="icons"> <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="onReload"><SvgIcon name="reload" size="35" /></div>
<!-- <div @click="onDownload"><SvgIcon name="download" size="35" /></div> --> <!-- <div @click="onDownload"><SvgIcon name="download" size="35" /></div> -->
</div> </div>

View File

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