feat(fittingRoom): 支持上下装搭配试穿功能- 修改试穿接口参数,支持分别传入上衣和下装图片URL- 新增suit字段标识是否为套装试穿

-优化衣服切换逻辑,支持上衣和下装的组合选择- 增加对不同类型服装的选择判断-和数组管理 移除旧的clothingImageUrl参数,使用clothUrl替代- 完善当前衣服数组的更新逻辑,确保数据结构正确性
This commit is contained in:
liguigong
2025-10-10 16:32:43 +08:00
parent 2201566768
commit 9247daf878
+55 -2
View File
@@ -114,10 +114,13 @@ const fittingRoom = defineStore({
sheep.$helper.toast('请选择衣服');
return;
}
// 那改成 clothUrl 和 kuziUrl 吧,当 kuziUrl 有值时,再传个 suit: true
const httpResponse = await FittingRoomApi.tryOnApi({
modelId: this.currentModel.id,
modelImageUrl: this.currentModel.fileUrl,
clothingImageUrl: this.currentClothes[0]?.fileUrl,
clothUrl: this.currentClothes[0]?.fileUrl,
kuziUrl: this.currentClothes?.[1]?.fileUrl ? this.currentClothes[1]?.fileUrl : undefined,
suit: this.currentClothes?.[1]?.fileUrl ? true : undefined,
});
if (httpResponse.code !== 0) {
sheep.$helper.toast(httpResponse.msg);
@@ -170,8 +173,58 @@ const fittingRoom = defineStore({
},
// 点击衣服
changeClothes(data) {
console.log('🚀 ~ changeClothes ~ data: ', data);
const shangyi = '95'; // 上衣
const xiazhuang = '96'; // 上衣
console.log('🚀 ~ changeClothes ~ data: ', data.clothType);
if (this.currentClothes?.length === 0) {
this.currentClothes = [data];
return;
}
// 如果选了一个, 第一个是上衣
if (this.currentClothes?.length === 1 && this.currentClothes[0].clothType === shangyi) {
if (data.clothType === shangyi) {
this.currentClothes = [data];
return;
}
if (data.clothType === xiazhuang) {
this.currentClothes = [...this.currentClothes, data];
return;
}
if (data.clothType !== xiazhuang && data.clothType !== shangyi) {
this.currentClothes = [data];
return;
}
}
if (this.currentClothes?.length === 1 && this.currentClothes[0].clothType === xiazhuang) {
if (data.clothType === shangyi) {
this.currentClothes = [data, this.currentClothes[0]];
return;
}
if (data.clothType === xiazhuang) {
this.currentClothes = [data];
return;
}
if (data.clothType !== xiazhuang && data.clothType !== shangyi) {
this.currentClothes = [data];
return;
}
}
if (this.currentClothes?.length === 2) {
if (data.clothType === shangyi) {
this.currentClothes = [data, this.currentClothes[1]];
return;
}
if (data.clothType === xiazhuang) {
this.currentClothes = [this.currentClothes[0], data];
return;
}
if (data.clothType !== xiazhuang && data.clothType !== shangyi) {
this.currentClothes = [data];
return;
}
}
this.currentClothes = [data];
console.log('切换衣服');
},
},