111
This commit is contained in:
@@ -21,7 +21,11 @@ export const useGenerateStore = defineStore({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
// doubleCount: (state) => state.num * 2
|
customerId: (state) => state.userData.style.id,//顾客id
|
||||||
|
visitRecordId: (state) => state.userData.style.id,//进店记录id
|
||||||
|
styleId: (state) => state.userData.style.id,//服装id
|
||||||
|
modelPhotoId: (state) => state.userData.model.id,//模特照片id
|
||||||
|
originalTryOnId: (state) => state.userData.style.id,//原始试穿id
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
selectStyle(data: any) {
|
selectStyle(data: any) {
|
||||||
|
|||||||
@@ -3,28 +3,69 @@
|
|||||||
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 { 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'
|
||||||
const router = useRouter()
|
import { useGenerateStore } from '@/stores'
|
||||||
|
const store = useGenerateStore()
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
const inputText = ref('')
|
const inputText = ref('')
|
||||||
const isLoved = ref(false)
|
const isLoved = ref(false)
|
||||||
const loading = ref(true)
|
const loading = ref(false)
|
||||||
setTimeout(() => {
|
|
||||||
loading.value = false
|
|
||||||
}, 500)
|
|
||||||
const onSend = () => {
|
const onSend = () => {
|
||||||
if (inputText.value === '') return
|
if (inputText.value === '') return
|
||||||
|
generate();
|
||||||
const text = inputText.value
|
const text = inputText.value
|
||||||
inputText.value = ''
|
inputText.value = ''
|
||||||
console.log('发送消息:', text)
|
console.log('发送消息:', text)
|
||||||
}
|
}
|
||||||
const onLove = () => {
|
|
||||||
isLoved.value = !isLoved.value
|
|
||||||
}
|
|
||||||
const onReload = () => {
|
const onReload = () => {
|
||||||
console.log('reload')
|
inputText.value = ''
|
||||||
|
generate(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 生成结果
|
||||||
|
const generate = (isRegenerated = false) => {
|
||||||
|
const data = {
|
||||||
|
customerId: store.customerId,
|
||||||
|
visitRecordId: store.visitRecordId,
|
||||||
|
styleId: store.styleId,
|
||||||
|
modelPhotoId: store.modelPhotoId,
|
||||||
|
customerPhotoId: store.userData.id,
|
||||||
|
originalTryOnId: store.originalTryOnId,
|
||||||
|
isRegenerated: isRegenerated ? 1 : 0,
|
||||||
|
prompt: inputText.value,
|
||||||
|
|
||||||
|
};
|
||||||
|
loading.value = true
|
||||||
|
generateTryOnEffect(data)
|
||||||
|
.then(res => {
|
||||||
|
console.log(res)
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error(err)
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
generate();
|
||||||
|
|
||||||
|
// 喜欢
|
||||||
|
const isLoveLoading = ref(false)
|
||||||
|
const onLove = () => {
|
||||||
|
if (isLoveLoading.value) return
|
||||||
|
const http = isLoved.value ? cancelTryOnEffectFavorite : setTryOnEffectFavorite
|
||||||
|
isLoveLoading.value = true
|
||||||
|
isLoved.value = !isLoved.value
|
||||||
|
http("tryOnId")
|
||||||
|
.then(() => {
|
||||||
|
isLoveLoading.value = false
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(err)
|
||||||
|
isLoveLoading.value = false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
const onDownload = () => {
|
const onDownload = () => {
|
||||||
console.log('download')
|
console.log('download')
|
||||||
|
|||||||
@@ -36,15 +36,15 @@
|
|||||||
}
|
}
|
||||||
// 生成照片
|
// 生成照片
|
||||||
const handleGenerate = () => {
|
const handleGenerate = () => {
|
||||||
console.log('生成照片')
|
|
||||||
if (!fileData.file) return
|
if (!fileData.file) return
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.append('customerId', "1")
|
formData.append('customerId', "1")
|
||||||
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)
|
console.log(res, res.photoUrl)
|
||||||
// router.push({ name: 'customize' })
|
|
||||||
|
router.push({ name: 'customize' })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user