111
This commit is contained in:
@@ -1,48 +1,52 @@
|
|||||||
// 每一个存储的模块,命名规则use开头,store结尾
|
// 每一个存储的模块,命名规则use开头,store结尾
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
export const useGenerateStore = defineStore({
|
export const useGenerateStore = defineStore({
|
||||||
id: 'generate', // 必须指明唯一的pinia仓库的id
|
id: 'generate', // 必须指明唯一的pinia仓库的id
|
||||||
state: () => {
|
state: () => {
|
||||||
return {
|
return {
|
||||||
userData:{
|
userData: {
|
||||||
title: '123123',
|
title: '123123',
|
||||||
name: '123123',
|
name: '123123',
|
||||||
describe: '',
|
describe: '',
|
||||||
id:'',
|
id: '',
|
||||||
style:{
|
style: {
|
||||||
id:-1,
|
id: -1,
|
||||||
oldId:-1,//表示从生成页面返回回来,需要调整的样式id
|
oldId: -1,//表示从生成页面返回回来,需要调整的样式id
|
||||||
|
},
|
||||||
|
model: {
|
||||||
|
id: -1,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
model:{
|
queryList: []
|
||||||
id:-1,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
queryList:[]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getters: {
|
|
||||||
// doubleCount: (state) => state.num * 2
|
|
||||||
},
|
|
||||||
actions: {
|
|
||||||
selectStyle(data:any) {
|
|
||||||
this.userData.style.id = data.id
|
|
||||||
console.log(this.userData)
|
|
||||||
},
|
|
||||||
//生成后去掉id 设置oldId来修改样式
|
|
||||||
useStyleGenerate(){
|
|
||||||
this.userData.style.oldId = this.userData.style.id
|
|
||||||
this.userData.style.id = -1
|
|
||||||
},
|
|
||||||
updateStyle(data){
|
|
||||||
console.log(data)
|
|
||||||
if(data.id == this.userData.style.oldId){
|
|
||||||
this.userData.style.oldId = -1
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//模特相关
|
getters: {
|
||||||
selectModel(data:any){
|
customerId: (state) => state.userData.style.id,//顾客id
|
||||||
this.userData.model.id = data.id
|
visitRecordId: (state) => state.userData.style.id,//进店记录id
|
||||||
console.log(this.userData)
|
styleId: (state) => state.userData.style.id,//服装id
|
||||||
|
modelPhotoId: (state) => state.userData.model.id,//模特照片id
|
||||||
|
originalTryOnId: (state) => state.userData.style.id,//原始试穿id
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
selectStyle(data: any) {
|
||||||
|
this.userData.style.id = data.id
|
||||||
|
console.log(this.userData)
|
||||||
|
},
|
||||||
|
//生成后去掉id 设置oldId来修改样式
|
||||||
|
useStyleGenerate() {
|
||||||
|
this.userData.style.oldId = this.userData.style.id
|
||||||
|
this.userData.style.id = -1
|
||||||
|
},
|
||||||
|
updateStyle(data) {
|
||||||
|
console.log(data)
|
||||||
|
if (data.id == this.userData.style.oldId) {
|
||||||
|
this.userData.style.oldId = -1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
//模特相关
|
||||||
|
selectModel(data: any) {
|
||||||
|
this.userData.model.id = data.id
|
||||||
|
console.log(this.userData)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -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