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: {
|
|
|
|
|
|
id: -1,
|
|
|
|
|
|
oldId: -1,//表示从生成页面返回回来,需要调整的样式id
|
2025-10-21 13:46:27 +08:00
|
|
|
|
},
|
2025-10-24 11:48:15 +08:00
|
|
|
|
model: {
|
|
|
|
|
|
id: -1,
|
|
|
|
|
|
},
|
|
|
|
|
|
tryOnId:{//生成穿好衣服的回参
|
|
|
|
|
|
id: -1,
|
|
|
|
|
|
isLike: false,//是否喜欢
|
|
|
|
|
|
},
|
|
|
|
|
|
isGenerate: false,//点击继续按钮后是否需要生成
|
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 13:19:01 +08:00
|
|
|
|
styleId: (state) => 1,
|
2025-10-23 16:41:38 +08:00
|
|
|
|
/** 模特照片id */
|
2025-10-24 13:19:01 +08:00
|
|
|
|
modelPhotoId: (state) => 1,
|
2025-10-23 16:41:38 +08:00
|
|
|
|
/** 原始试穿id */
|
2025-10-24 13:19:01 +08:00
|
|
|
|
originalTryOnId: (state) => 1,
|
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 11:48:15 +08:00
|
|
|
|
this.style.oldId = this.style.id
|
|
|
|
|
|
this.style.id = -1
|
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) {
|
|
|
|
|
|
this.style.oldId = -1
|
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
|
|
|
|
|
|
console.log(this)
|
|
|
|
|
|
},
|
|
|
|
|
|
setIsGenerate(isGenerate: boolean) {
|
|
|
|
|
|
this.isGenerate = isGenerate
|
2025-10-23 17:01:13 +08:00
|
|
|
|
},
|
|
|
|
|
|
/** 更新顾客照片信息 */
|
|
|
|
|
|
updatePhotoInfo(data: any) {
|
|
|
|
|
|
this.photoInfo.id = data.visitRecordId || ""
|
|
|
|
|
|
this.photoInfo.url = data.defaultImageUrl || ""
|
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
|
|
|
|
})
|