feat(fittingRoom): 实现衣服数据获取与tab切换功能

新增 fittingRoom 接口调用逻辑,支持根据 tab 类型加载对应衣服列表。
在 store 中增加 `clothes` 数据字段,并通过 `getCloths` 方法请求数据。页面组件中更新 tab 切换逻辑以触发数据刷新,并调整模板绑定方式。
添加 `tabsMap` 映射表用于匹配接口所需 clothType 参数。
This commit is contained in:
liguigong
2025-09-23 09:41:34 +08:00
parent 8f68f9b0c8
commit dc2426936c
7 changed files with 142 additions and 56 deletions
+25 -3
View File
@@ -1,5 +1,8 @@
import { defineStore } from 'pinia';
import app from './app';
import FittingRoomApi from '../api/fittingRoom';
const tabsMap = [undefined, 'topCloth', 'bottomCloth', 'dress', 'suit', 'hair'];
export const pattern = [
{ value: 'body', label: '腰部以上'},
@@ -21,7 +24,8 @@ const fittingRoom = defineStore({
type: true, // true: 我的衣橱, false: 衣服库
tab: 0, // 对应下面tabs的序号
tabs: ['全部', '上衣', '下装', '连衣裙', '外套', '发型'],
disableTabs: [5], // 不允许上传图的tab索引
disableTabs: [5], // 不允许上传图的tab索引
clothes: [], // 接口返回的衣服数据
currentClothes: [], // 当前选的衣服
selectClothesType: 1, // 选中的衣服类型, 默认选中上衣
selectPattern: pattern[0].value,
@@ -35,13 +39,31 @@ const fittingRoom = defineStore({
},
},
actions: {
// 获取衣服类型数据查询
async getCloths(templateId = null) {
const httpResponse = await FittingRoomApi.getClothList({
sex: 'female',
isPerson: this.type ? 'yes' : 'no',
clothType: tabsMap[this.tab],
});
console.log('🚀 ~ getCloths 🐶33 ~ httpResponse: ', httpResponse.result);
this.clothes = httpResponse.result || [];
},
setVisable(visable) {
console.log('🚀 ~ setVisable 🐶15 ~ visable: ', visable);
console.log('🚀 ~ setVisable 🐶36 ~ visable: ', visable);
this.visable = visable ?? !this.visable;
},
// 我的衣服库和衣橱的切换
changeType(visable) {
console.log('🚀 ~ setVisable 🐶15 ~ visable: ', visable);
console.log('🚀 ~ setVisable 🐶40 ~ visable: ', visable);
this.type = visable ?? !this.type;
this.getCloths();
},
changeTab(index) {
console.log('切换tab');
this.tab = index;
this.getCloths();
},
// 点击衣服
changeClothes() {