diff --git a/sheep/store/fittingRoom.js b/sheep/store/fittingRoom.js index 9346b84..378aaae 100644 --- a/sheep/store/fittingRoom.js +++ b/sheep/store/fittingRoom.js @@ -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('切换衣服'); }, },