This commit is contained in:
zhangyh
2025-10-27 11:46:45 +08:00
5 changed files with 123 additions and 96 deletions

View File

@@ -1 +0,0 @@
VITE_APP_URL = http://18.167.251.121:10095

View File

@@ -4,7 +4,6 @@
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"test": "vite --mode test",
"build": "run-p type-check build-only", "build": "run-p type-check build-only",
"preview": "vite preview", "preview": "vite preview",
"build-only": "vite build", "build-only": "vite build",

View File

@@ -1,9 +1,10 @@
// 每一个存储的模块命名规则use开头store结尾 // 每一个存储的模块命名规则use开头store结尾
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { useUserInfoStore } from './userInfo'
export const useGenerateStore = defineStore({ export const useGenerateStore = defineStore({
id: 'generate', // 必须指明唯一的pinia仓库的id id: 'generate', // 必须指明唯一的pinia仓库的id
state: () => { state: () => {
return { return {
style: { style: {
id: '', id: '',
oldId: '' //表示从生成页面返回回来需要调整的样式id oldId: '' //表示从生成页面返回回来需要调整的样式id
@@ -37,65 +38,86 @@ export const useGenerateStore = defineStore({
}, },
customerInfo: { customerInfo: {
customerId: '', customerId: '',
visitRecordId:'' visitRecordId: ''
} }
} }
}, },
getters: { getters: {
/** 顾客id */ /** 顾客id */
customerId: (state) => state.customerInfo.customerId, customerId: (state) => state.customerInfo.customerId,
/** 进店记录id */ /** 进店记录id */
visitRecordId: (state) => state.customerInfo.visitRecordId, visitRecordId: (state) => state.customerInfo.visitRecordId,
/** 服装id */ /** 服装id */
styleId: (state) => state.style.id || state.style.oldId, styleId: (state) => state.style.id || state.style.oldId,
/** 模特照片id */ /** 模特照片id */
modelPhotoId: (state) => state.model.id, modelPhotoId: (state) => state.model.id,
/** 原始试穿id-优先AI魔改 */ /** 原始试穿id-优先AI魔改 */
originalTryOnId: (state) => state.customizeInfo.tryOnId || state.originalTryOn.id, originalTryOnId: (state) => state.customizeInfo.tryOnId || state.originalTryOn.id,
/** 顾客照片id */ /** 顾客照片id */
customerPhotoId: (state) => state.photoInfo.id, customerPhotoId: (state) => state.photoInfo.id
}, },
actions: { actions: {
selectStyle(data: any) { selectStyle(data: any) {
this.style.id = data.id this.style.id = data.id
console.log(this) console.log(this)
}, },
//生成后去掉id 设置oldId来修改样式 //生成后去掉id 设置oldId来修改样式
useStyleGenerate() { useStyleGenerate() {
if(!this.style.id)return if (!this.style.id) return
this.style.oldId = this.style.id this.style.oldId = this.style.id
this.style.id = '' this.style.id = ''
}, },
updateStyle(data) { updateStyle(data) {
console.log(data) console.log(data)
if (data.id == this.style.oldId) { if (data.id == this.style.oldId) {
this.style.oldId = '' this.style.oldId = ''
} }
}, },
//模特相关 //模特相关
selectModel(data: any) { selectModel(data: any) {
this.model.id = data.id this.model.id = data.id
}, },
setIsGenerate(isGenerate: boolean) { setIsGenerate(isGenerate: boolean) {
this.isGenerate = isGenerate this.isGenerate = isGenerate
}, },
/** 更新顾客照片信息 */ clearProductData() {
updatePhotoInfo(data: any) { this.style = {
this.photoInfo.id = data.id || "" id: '',
if (!data.photoUrl) this.photoInfo.url = "" oldId: ''
this.photoInfo.file = null }
}, this.model = {
/** 清空 AI魔改信息 */ id: ''
clearCustomizeInfo() { }
this.customizeInfo.inputText = "" this.originalTryOn = {
this.customizeInfo.tryOnId = "" id: '',
this.customizeInfo.tryOnUrl = "" isLike: false,
this.customizeInfo.styleUrl = "" tryOnUrl: ''
this.customizeInfo.isRegenerated = "" }
this.customizeInfo.isFavorite = false this.isGenerate = false
}, },
setCustomerInfo(data: any) { /** 更新顾客照片信息 */
this.customerInfo = data updatePhotoInfo(data: any) {
} this.photoInfo.id = data.id || ''
} if (!data.photoUrl) this.photoInfo.url = ''
}) this.photoInfo.file = null
},
/** 清空 AI魔改信息 */
clearCustomizeInfo() {
this.customizeInfo.inputText = ''
this.customizeInfo.tryOnId = ''
this.customizeInfo.tryOnUrl = ''
this.customizeInfo.styleUrl = ''
this.customizeInfo.isRegenerated = ''
this.customizeInfo.isFavorite = false
},
//设置默认数据
clearGenerateData() {
this.clearProductData()
this.updatePhotoInfo({})
this.clearCustomizeInfo()
},
setCustomerInfo(data: any) {
this.customerInfo = data
}
}
})

View File

@@ -4,7 +4,7 @@ import { useUserInfoStore } from '@/stores/modules/userInfo'
const store = useUserInfoStore() const store = useUserInfoStore()
import { getLocal } from '@/utils/local' import { getLocal } from '@/utils/local'
import router from '@/router/index' import router from '@/router/index'
import { useOverallStore } from '@/stores' import { useOverallStore, useGenerateStore } from '@/stores'
// 扩展 AxiosRequestConfig 接口 // 扩展 AxiosRequestConfig 接口
declare module 'axios' { declare module 'axios' {
@@ -98,35 +98,38 @@ service.interceptors.response.use(
} }
}, },
(error) => { (error) => {
if (error?.response) { if(error?.response){
if (error?.response?.status === 401) { if(error?.response?.status === 401){//如果是记录浏览器页面就不跳转login
//如果是记录浏览器页面就不跳转login // showConfirmDialog({
// showConfirmDialog({ // title: '确定登出',
// title: '确定登出', // message: '你已被登出,可以取消继续留在该页面,或者重新登录',
// message: '你已被登出,可以取消继续留在该页面,或者重新登录', // confirmButtonText: '重新登录',
// confirmButtonText: '重新登录', // cancelButtonText: '取消'
// cancelButtonText: '取消' // }).then(() => {
// }).then(() => { // store.loginOut().then(() => {
// store.loginOut().then(() => { // location.reload() // 为了重新实例化vue-router对象 避免bug
// location.reload() // 为了重新实例化vue-router对象 避免bug // })
// }) // })
// }) showToast({
router.replace('/login') message: 'Please log in and try again.',
return Promise.reject(error) duration: 5000
} })
error.config && removePending(error.config) router.push('/welcome')
// 关闭loading useGenerateStore().clearGenerateData()
if (error.config?.loading) { return Promise.reject(false)
closeLoading() }
} error.config && removePending(error.config)
console.log('err' + error) // for debug // 关闭loading
showToast({ if (error.config?.loading) {
message: error.message, closeLoading()
// type: 'fail', }
duration: 5000, console.log('err' + error) // for debug
position:'top' showToast({
}) message: error.message,
} type: 'fail',
duration: 5000
})
}
return Promise.reject(error) return Promise.reject(error)
} }
) )

View File

@@ -54,7 +54,11 @@ const startGenerate = ()=>{
generateStore.setIsGenerate(false) generateStore.setIsGenerate(false)
generateStore.clearCustomizeInfo() generateStore.clearCustomizeInfo()
}).catch(()=>{ }).catch((error)=>{
console.log(error)
if(error === false){
return
}
data.isLoading = false; data.isLoading = false;
if(generateStore.originalTryOn.id){ if(generateStore.originalTryOn.id){
router.back() router.back()