2025-10-09 09:29:36 +08:00
|
|
|
|
// 每一个存储的模块,命名规则use开头,store结尾
|
|
|
|
|
|
import { defineStore } from 'pinia'
|
2025-10-21 10:20:57 +08:00
|
|
|
|
export const useGenerateStore = defineStore({
|
2025-10-23 16:37:59 +08:00
|
|
|
|
id: 'generate', // 必须指明唯一的pinia仓库的id
|
|
|
|
|
|
state: () => {
|
|
|
|
|
|
return {
|
2025-10-24 11:48:15 +08:00
|
|
|
|
style: {
|
2025-10-24 15:18:23 +08:00
|
|
|
|
id: '',
|
|
|
|
|
|
oldId: '',//表示从生成页面返回回来,需要调整的样式id
|
2025-10-21 13:46:27 +08:00
|
|
|
|
},
|
2025-10-24 11:48:15 +08:00
|
|
|
|
model: {
|
2025-10-24 15:18:23 +08:00
|
|
|
|
id: '',
|
2025-10-24 11:48:15 +08:00
|
|
|
|
},
|
2025-10-24 14:36:30 +08:00
|
|
|
|
originalTryOn:{//生成穿好衣服的回参
|
2025-10-24 15:18:23 +08:00
|
|
|
|
id: '',
|
2025-10-24 11:48:15 +08:00
|
|
|
|
isLike: false,//是否喜欢
|
2025-10-24 14:36:30 +08:00
|
|
|
|
tryOnUrl:'',
|
2025-10-24 11:48:15 +08:00
|
|
|
|
},
|
|
|
|
|
|
isGenerate: false,//点击继续按钮后是否需要生成
|
2025-10-24 15:19:29 +08:00
|
|
|
|
|
2025-10-23 17:01:13 +08:00
|
|
|
|
/** 顾客照片信息 */
|
|
|
|
|
|
photoInfo: {
|
|
|
|
|
|
id: "",
|
|
|
|
|
|
url: "",
|
2025-10-24 11:47:07 +08:00
|
|
|
|
file: null,
|
|
|
|
|
|
},
|
|
|
|
|
|
/** AI魔改信息 */
|
|
|
|
|
|
customizeInfo: {
|
2025-10-24 13:19:01 +08:00
|
|
|
|
inputText: "",
|
|
|
|
|
|
|
2025-10-24 11:47:07 +08:00
|
|
|
|
tryOnId: "",
|
|
|
|
|
|
tryOnUrl: "",
|
|
|
|
|
|
styleUrl: "",
|
|
|
|
|
|
isRegenerated: "",
|
|
|
|
|
|
isFavorite: false,
|
|
|
|
|
|
},
|
2025-10-23 16:37:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
getters: {
|
2025-10-23 16:41:38 +08:00
|
|
|
|
/** 顾客id */
|
2025-10-24 13:19:01 +08:00
|
|
|
|
customerId: (state) => 1,
|
2025-10-23 16:41:38 +08:00
|
|
|
|
/** 进店记录id */
|
2025-10-24 13:19:01 +08:00
|
|
|
|
visitRecordId: (state) => 1,
|
2025-10-23 16:41:38 +08:00
|
|
|
|
/** 服装id */
|
2025-10-24 16:21:04 +08:00
|
|
|
|
styleId: (state) => state.style.id || state.style.oldId,
|
2025-10-23 16:41:38 +08:00
|
|
|
|
/** 模特照片id */
|
2025-10-24 15:19:29 +08:00
|
|
|
|
modelPhotoId: (state) => state.model.id,
|
|
|
|
|
|
/** 原始试穿id-优先AI魔改 */
|
2025-10-24 16:21:04 +08:00
|
|
|
|
originalTryOnId: (state) => state.customizeInfo.tryOnId || state.originalTryOn.id,
|
2025-10-23 16:41:38 +08:00
|
|
|
|
/** 顾客照片id */
|
2025-10-23 17:01:13 +08:00
|
|
|
|
customerPhotoId: (state) => state.photoInfo.id,
|
2025-10-23 16:37:59 +08:00
|
|
|
|
},
|
|
|
|
|
|
actions: {
|
|
|
|
|
|
selectStyle(data: any) {
|
2025-10-24 11:48:15 +08:00
|
|
|
|
this.style.id = data.id
|
|
|
|
|
|
console.log(this)
|
2025-10-23 16:37:59 +08:00
|
|
|
|
},
|
|
|
|
|
|
//生成后去掉id 设置oldId来修改样式
|
|
|
|
|
|
useStyleGenerate() {
|
2025-10-24 15:18:23 +08:00
|
|
|
|
if(!this.style.id)return
|
2025-10-24 11:48:15 +08:00
|
|
|
|
this.style.oldId = this.style.id
|
2025-10-24 15:18:23 +08:00
|
|
|
|
this.style.id = ''
|
2025-10-23 16:37:59 +08:00
|
|
|
|
},
|
|
|
|
|
|
updateStyle(data) {
|
|
|
|
|
|
console.log(data)
|
2025-10-24 11:48:15 +08:00
|
|
|
|
if (data.id == this.style.oldId) {
|
2025-10-24 15:18:23 +08:00
|
|
|
|
this.style.oldId = ''
|
2025-10-23 13:43:42 +08:00
|
|
|
|
}
|
2025-10-09 09:29:36 +08:00
|
|
|
|
},
|
2025-10-23 16:37:59 +08:00
|
|
|
|
//模特相关
|
|
|
|
|
|
selectModel(data: any) {
|
2025-10-24 11:48:15 +08:00
|
|
|
|
this.model.id = data.id
|
|
|
|
|
|
},
|
|
|
|
|
|
setIsGenerate(isGenerate: boolean) {
|
|
|
|
|
|
this.isGenerate = isGenerate
|
2025-10-23 17:01:13 +08:00
|
|
|
|
},
|
|
|
|
|
|
/** 更新顾客照片信息 */
|
|
|
|
|
|
updatePhotoInfo(data: any) {
|
2025-10-24 15:19:29 +08:00
|
|
|
|
this.photoInfo.id = data.id || ""
|
|
|
|
|
|
if (!data.photoUrl) this.photoInfo.url = ""
|
2025-10-24 11:47:07 +08:00
|
|
|
|
this.photoInfo.file = null
|
|
|
|
|
|
},
|
2025-10-24 13:19:01 +08:00
|
|
|
|
/** 清空 AI魔改信息 */
|
|
|
|
|
|
clearCustomizeInfo() {
|
|
|
|
|
|
this.customizeInfo.inputText = ""
|
|
|
|
|
|
this.customizeInfo.tryOnId = ""
|
|
|
|
|
|
this.customizeInfo.tryOnUrl = ""
|
|
|
|
|
|
this.customizeInfo.styleUrl = ""
|
|
|
|
|
|
this.customizeInfo.isRegenerated = ""
|
|
|
|
|
|
this.customizeInfo.isFavorite = false
|
2025-10-23 17:01:13 +08:00
|
|
|
|
},
|
2025-10-21 13:46:27 +08:00
|
|
|
|
}
|
2025-10-24 11:47:07 +08:00
|
|
|
|
})
|