feat(f增模特ittingRoom): 新选择与上传功能- 添加模特列表状态管理与当前模特选中逻辑- 实现获取模特列表及切换模特功能
- 新增上传模特图片接口及调用逻辑- 更新模特展示组件,支持动态显示模特缩略图 - 添加获取衣服分类接口及初始化调用- 配置.editorconfig统一代码风格 - 移除调试用的console.log及token写死逻辑 - 修复部分组件引用及生命周期调用问题
This commit is contained in:
@@ -3,7 +3,11 @@
|
|||||||
<view :class="['mote', { unfold: fittingRoom.visable }]">
|
<view :class="['mote', { unfold: fittingRoom.visable }]">
|
||||||
<view class="item" @click="expansion">
|
<view class="item" @click="expansion">
|
||||||
<view class="item-text">模特</view>
|
<view class="item-text">模特</view>
|
||||||
<image class="item-image" mode="widthFix" src="/static/mote.png"></image>
|
<image
|
||||||
|
:src="fittingRoom.currentModel.thumbnailFileUrl"
|
||||||
|
class="item-image"
|
||||||
|
mode="aspectFill"
|
||||||
|
></image>
|
||||||
</view>
|
</view>
|
||||||
<view class="item">
|
<view class="item">
|
||||||
<image class="shangchuan" mode="heightFix" src="/static/shangchuan.png"></image>
|
<image class="shangchuan" mode="heightFix" src="/static/shangchuan.png"></image>
|
||||||
@@ -17,33 +21,36 @@
|
|||||||
limit="1"
|
limit="1"
|
||||||
mode="grid"
|
mode="grid"
|
||||||
@select="selectPic"
|
@select="selectPic"
|
||||||
>选择
|
>选择
|
||||||
</uni-file-picker>
|
</uni-file-picker>
|
||||||
</view>
|
</view>
|
||||||
<view class="item" @click="switchModels">
|
<view v-for="item of fittingRoom.modelList" class="item" @click="switchModels(item)">
|
||||||
<view class="item-text"></view>
|
<view class="item-text"></view>
|
||||||
<image class="item-image" mode="widthFix" src="/static/mote.png"></image>
|
<image :src="item.thumbnailFileUrl" class="item-image" mode="aspectFill"></image>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { onMounted, reactive, ref } from 'vue';
|
||||||
import sheep from '../../../sheep';
|
import sheep from '../../../sheep';
|
||||||
|
import FittingRoomApi from '../../../sheep/api/fittingRoom'; // 隐藏
|
||||||
const sizeType = ['original'];
|
const sizeType = ['original'];
|
||||||
const imageStyle = {
|
const imageStyle = {
|
||||||
width: 200,
|
width: 200,
|
||||||
height: 50,
|
height: 50,
|
||||||
};
|
};
|
||||||
|
|
||||||
const fittingRoom = sheep.$store('fittingRoom');
|
const fittingRoom = sheep.$store('fittingRoom');
|
||||||
|
console.log(fittingRoom.currentModel);
|
||||||
|
|
||||||
function selectPic(...data) {
|
function selectPic(...data) {
|
||||||
console.log(fittingRoom.tab);
|
FittingRoomApi.uploadModel(data[0].tempFiles[0].path, { sex: fittingRoom.sex }).then(() =>
|
||||||
console.log('🚀 ~ selectPic 🐶47 ~ data: ', data);
|
fittingRoom.getModelList(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function switchModels(item) {
|
||||||
function switchModels() {
|
fittingRoom.switchModels(item);
|
||||||
console.log("🚀 ~ ~ fittingRoom: ", 12);
|
console.log('🚀 ~ ~ fittingRoom: ', item);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('🚀 ~ 🐶9 ~ fittingRoom: ', fittingRoom);
|
console.log('🚀 ~ 🐶9 ~ fittingRoom: ', fittingRoom);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, reactive, ref } from 'vue';
|
import { computed, reactive, onMounted } from 'vue';
|
||||||
import { onLoad, onPageScroll, onPullDownRefresh } from '@dcloudio/uni-app';
|
import { onLoad, onPageScroll, onPullDownRefresh } from '@dcloudio/uni-app';
|
||||||
import sheep from '@/sheep';
|
import sheep from '@/sheep';
|
||||||
import SSelectMote from './components/s-select-mote.vue';
|
import SSelectMote from './components/s-select-mote.vue';
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
import FittingRoomApi from '../../sheep/api/fittingRoom'; // 隐藏原生tabBar
|
import FittingRoomApi from '../../sheep/api/fittingRoom'; // 隐藏原生tabBar
|
||||||
|
|
||||||
const fittingRoomStore = sheep.$store('fittingRoom');
|
const fittingRoomStore = sheep.$store('fittingRoom');
|
||||||
|
uni.setStorageSync('token', '42be01f1a6c54ea591c991b5da0977c0');
|
||||||
sheep.$helper.toast('请选择是否同意协议');
|
sheep.$helper.toast('请选择是否同意协议');
|
||||||
// 隐藏原生tabBar
|
// 隐藏原生tabBar
|
||||||
uni.hideTabBar({
|
uni.hideTabBar({
|
||||||
@@ -50,10 +50,11 @@
|
|||||||
console.log(index, item, '12');
|
console.log(index, item, '12');
|
||||||
}
|
}
|
||||||
|
|
||||||
fittingRoomStore.getCloths().then((res) => {
|
onMounted(() => {
|
||||||
console.log(res, 'res');
|
fittingRoomStore.getCategory();
|
||||||
|
fittingRoomStore.getCloths();
|
||||||
|
fittingRoomStore.getModelList();
|
||||||
});
|
});
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
info: [
|
info: [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,20 +2,73 @@
|
|||||||
* @Author: liguigong liguigong@shopline.com
|
* @Author: liguigong liguigong@shopline.com
|
||||||
* @Date: 2025-09-23 09:41:10
|
* @Date: 2025-09-23 09:41:10
|
||||||
* @LastEditors: liguigong liguigong@shopline.com
|
* @LastEditors: liguigong liguigong@shopline.com
|
||||||
* @LastEditTime: 2025-09-23 09:44:50
|
* @LastEditTime: 2025-09-25 18:01:03
|
||||||
* @FilePath: sheep/api/fittingRoom/index.js
|
* @FilePath: sheep/api/fittingRoom/index.js
|
||||||
* @Description: 这是默认设置,可以在设置》工具》File Description中进行配置
|
* @Description: 这是默认设置,可以在设置》工具》File Description中进行配置
|
||||||
*/
|
*/
|
||||||
import request from '@/sheep/request';
|
import request, { getAccessToken } from '@/sheep/request';
|
||||||
|
import { apiPath, baseUrl, tenantId } from '../../config';
|
||||||
|
|
||||||
const FittingRoomApi = {
|
const FittingRoomApi = {
|
||||||
getClothList: (data) => {
|
getClothList: (data) => {
|
||||||
return request({
|
return request({
|
||||||
url: 'cloth/list',
|
url: '/cloth/list',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: data,
|
data: data,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
// 上传模特
|
||||||
|
uploadModel: (file, formData = {}) => {
|
||||||
|
uni.showLoading({
|
||||||
|
title: '上传中',
|
||||||
|
});
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
uni.uploadFile({
|
||||||
|
url: baseUrl + apiPath + '/cloth/uploadModel',
|
||||||
|
filePath: file,
|
||||||
|
name: 'file',
|
||||||
|
header: {
|
||||||
|
Accept: '*/*',
|
||||||
|
Authorization: getAccessToken(),
|
||||||
|
},
|
||||||
|
formData,
|
||||||
|
success: (uploadFileRes) => {
|
||||||
|
console.log('🚀 ~ success 🐶43 ~ uploadFileRes: ', uploadFileRes);
|
||||||
|
let result = JSON.parse(uploadFileRes.data);
|
||||||
|
if (result.error === 1) {
|
||||||
|
uni.showToast({
|
||||||
|
icon: 'none',
|
||||||
|
title: result.msg,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return resolve(result);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: (error) => {
|
||||||
|
console.log('上传失败:', error);
|
||||||
|
return resolve(false);
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
uni.hideLoading();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
getModelList: (data) => {
|
||||||
|
return request({
|
||||||
|
url: '/cloth/getModelList',
|
||||||
|
method: 'POST',
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 得到分类
|
||||||
|
getCategory: () => {
|
||||||
|
return request({
|
||||||
|
url: '/product/category/tree',
|
||||||
|
method: 'GET',
|
||||||
|
});
|
||||||
|
},
|
||||||
addHairApi: (data) => {
|
addHairApi: (data) => {
|
||||||
return request({
|
return request({
|
||||||
url: '/userinfo/add_hair_data',
|
url: '/userinfo/add_hair_data',
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# editorconfig.org
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = false
|
||||||
@@ -21,15 +21,17 @@ const fittingRoom = defineStore({
|
|||||||
id: 'fittingRoom',
|
id: 'fittingRoom',
|
||||||
state: () => ({
|
state: () => ({
|
||||||
visable: false, // 上传模特, 选模特的
|
visable: false, // 上传模特, 选模特的
|
||||||
|
modelList: [], // 模特列表
|
||||||
|
currentModel: {},
|
||||||
type: true, // true: 我的衣橱, false: 衣服库
|
type: true, // true: 我的衣橱, false: 衣服库
|
||||||
tab: 0, // 对应下面tabs的序号
|
tab: 0, // 对应下面tabs的序号
|
||||||
tabs: ['全部', '上衣', '下装', '连衣裙', '外套', '套装', '发型'],
|
tabs: ['全部', '上衣', '下装', '连衣裙', '外套', '套装', '发型'],
|
||||||
disableTabs: [6], // 不允许上传图的tab索引
|
disableTabs: [6], // 不允许上传图的tab索引
|
||||||
clothes: [], // 接口返回的衣服数据
|
clothes: [], // 接口返回的衣服数据
|
||||||
clothes: [], // 接口返回的衣服数据
|
|
||||||
currentClothes: [], // 当前选的衣服
|
currentClothes: [], // 当前选的衣服
|
||||||
selectClothesType: 1, // 选中的衣服类型, 默认选中上衣
|
selectClothesType: 1, // 选中的衣服类型, 默认选中上衣
|
||||||
selectPattern: pattern[0].value,
|
selectPattern: pattern[0].value,
|
||||||
|
sex: 'female',
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
// 能上传图片的场景
|
// 能上传图片的场景
|
||||||
@@ -40,6 +42,11 @@ const fittingRoom = defineStore({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
// 获取衣服分类
|
||||||
|
async getCategory(templateId = null) {
|
||||||
|
const httpResponse = await FittingRoomApi.getCategory();
|
||||||
|
this.clothes = httpResponse.result || [];
|
||||||
|
},
|
||||||
// 获取衣服类型数据查询
|
// 获取衣服类型数据查询
|
||||||
async getCloths(templateId = null) {
|
async getCloths(templateId = null) {
|
||||||
const httpResponse = await FittingRoomApi.getClothList({
|
const httpResponse = await FittingRoomApi.getClothList({
|
||||||
@@ -47,16 +54,33 @@ const fittingRoom = defineStore({
|
|||||||
isPerson: this.type ? 'yes' : 'no',
|
isPerson: this.type ? 'yes' : 'no',
|
||||||
clothType: tabsMap[this.tab],
|
clothType: tabsMap[this.tab],
|
||||||
});
|
});
|
||||||
console.log('🚀 ~ getCloths 🐶33 ~ httpResponse: ', httpResponse.result);
|
|
||||||
this.clothes = httpResponse.result || [];
|
this.clothes = httpResponse.result || [];
|
||||||
},
|
},
|
||||||
|
// 获取模特数据查询
|
||||||
|
async getModelList(templateId = null) {
|
||||||
|
const httpResponse = await FittingRoomApi.getModelList({
|
||||||
|
sex: this.sex,
|
||||||
|
});
|
||||||
|
let modelList = (httpResponse.result || []).slice(0, 4);
|
||||||
|
this.modelList = modelList;
|
||||||
|
this.currentModel = modelList?.[0] ?? {};
|
||||||
|
},
|
||||||
|
// 切换模特
|
||||||
|
switchModels(item) {
|
||||||
|
if (item.id === this.currentModel.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// TODO:
|
||||||
|
console.log('🚀 ~ switchModels 🐶70 ~ item: ', item);
|
||||||
|
this.currentModel = item;
|
||||||
|
},
|
||||||
setVisable(visable) {
|
setVisable(visable) {
|
||||||
console.log('🚀 ~ setVisable 🐶36 ~ visable: ', visable);
|
console.log('🚀 ~ setVisable 🐶77 ~ visable: ', visable);
|
||||||
this.visable = visable ?? !this.visable;
|
this.visable = visable ?? !this.visable;
|
||||||
},
|
},
|
||||||
// 我的衣服库和衣橱的切换
|
// 我的衣服库和衣橱的切换
|
||||||
changeType(visable) {
|
changeType(visable) {
|
||||||
console.log('🚀 ~ setVisable 🐶40 ~ visable: ', visable);
|
console.log('🚀 ~ setVisable 🐶82 ~ visable: ', visable);
|
||||||
this.type = visable ?? !this.type;
|
this.type = visable ?? !this.type;
|
||||||
this.getCloths();
|
this.getCloths();
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user