feat(fittingRoom): 更新试衣间衣物部位选项与标签文案 - 为 pattern 中的每个对象添加尾随空格,以符合代码风格- 新增“套装”选项到 tabs 数组,并更新 disableTabs 索引- 添加 clothes 字段注释说明其用途 - 更新获取衣物列表接口地址,去除前缀 '/api'- 在 README 中新增 Figma 设计链接 ```
85 lines
2.5 KiB
JavaScript
85 lines
2.5 KiB
JavaScript
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: '腰部以上' },
|
|
{ value: 'waist', label: '腰' },
|
|
{ value: 'thigh', label: '跨' },
|
|
{ value: 'thigh1', label: '大腿上部1/3' },
|
|
{ value: 'thigh2', label: '大腿中部' },
|
|
{ value: 'knee', label: '膝盖' },
|
|
{ value: 'leg', label: '小腿' },
|
|
{ value: 'leg1', label: '小腿上部1/3' },
|
|
{ value: 'foot', label: '脚踝' },
|
|
{ value: 'mopping', label: '拖地' },
|
|
];
|
|
|
|
const fittingRoom = defineStore({
|
|
id: 'fittingRoom',
|
|
state: () => ({
|
|
visable: false, // 上传模特, 选模特的
|
|
type: true, // true: 我的衣橱, false: 衣服库
|
|
tab: 0, // 对应下面tabs的序号
|
|
tabs: ['全部', '上衣', '下装', '连衣裙', '外套', '套装', '发型'],
|
|
disableTabs: [6], // 不允许上传图的tab索引
|
|
clothes: [], // 接口返回的衣服数据
|
|
clothes: [], // 接口返回的衣服数据
|
|
currentClothes: [], // 当前选的衣服
|
|
selectClothesType: 1, // 选中的衣服类型, 默认选中上衣
|
|
selectPattern: pattern[0].value,
|
|
}),
|
|
getters: {
|
|
// 能上传图片的场景
|
|
canUpload(state) {
|
|
console.log(this.type, this.tab, state.type, '123');
|
|
// 除了发型其他都能上传
|
|
return this.type && !this.disableTabs.includes(this.tab);
|
|
},
|
|
},
|
|
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 🐶36 ~ visable: ', visable);
|
|
this.visable = visable ?? !this.visable;
|
|
},
|
|
// 我的衣服库和衣橱的切换
|
|
changeType(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() {
|
|
console.log('切换衣服');
|
|
},
|
|
},
|
|
persist: {
|
|
enabled: true,
|
|
strategies: [
|
|
{
|
|
key: 'fittingRoom-store',
|
|
},
|
|
],
|
|
},
|
|
});
|
|
|
|
export default fittingRoom;
|