Files
meida_front/pages/fittingRoom/index.vue
T
liguigong dc2426936c feat(fittingRoom): 实现衣服数据获取与tab切换功能
新增 fittingRoom 接口调用逻辑,支持根据 tab 类型加载对应衣服列表。
在 store 中增加 `clothes` 数据字段,并通过 `getCloths` 方法请求数据。页面组件中更新 tab 切换逻辑以触发数据刷新,并调整模板绑定方式。
添加 `tabsMap` 映射表用于匹配接口所需 clothType 参数。
2025-09-23 09:41:34 +08:00

205 lines
4.3 KiB
Vue

<template>
<view v-if="template">
<view class="uni-margin-wrap">
<!-- https://ext.dcloud.net.cn/plugin?id=22930-->
<hbxw-stack-carousel
:key="state.info"
:height="680"
:interval="15000"
:list="state.info"
:width="430"
indicatorStyle="line"
loop
@change="handleChange"
@click="handleItemClick"
>
<template #default="{ item, index }">
<view class="custom-item">
<image :src="item.image" class="swiper-image" mode="aspectFill" />
</view>
</template>
</hbxw-stack-carousel>
<s-select-mote />
</view>
<uv-sticky :customNavHeight="0" :offset-top="0">
<s-tabs />
</uv-sticky>
<s-grid-clothes />
<view class="height1" @click="dian"></view>
</view>
</template>
<script setup>
import { computed, reactive, ref } from 'vue';
import { onLoad, onPageScroll, onPullDownRefresh } from '@dcloudio/uni-app';
import sheep from '@/sheep';
import SSelectMote from './components/s-select-mote.vue';
import STabs from './components/STabs.vue';
import SGridClothes from './components/s-grid-clothes.vue';
import FittingRoomApi from '../../sheep/api/fittingRoom'; // 隐藏原生tabBar
const fittingRoomStore = sheep.$store('fittingRoom');
sheep.$helper.toast('请选择是否同意协议');
// 隐藏原生tabBar
uni.hideTabBar({
fail: () => {},
});
function handleItemClick(index, item) {
console.log(index, item, '12');
}
fittingRoomStore.getCloths().then((res) => {
console.log(res, 'res');
});
const state = reactive({
info: [
{
image: 'https://picsum.photos/600/300?random=1',
},
{
image: 'https://picsum.photos/600/300?random=2',
},
{
image: 'https://picsum.photos/600/300?random=3',
},
],
current: 0,
});
function handleChange(index, oldIndex) {
// state.current = index;
console.log('---- change ----', index, oldIndex);
}
function dian() {
state.info = [
{
image: 'https://picsum.photos/600/300?random=1',
},
{
image: 'https://picsum.photos/600/300?random=2',
},
{
image: 'https://picsum.photos/600/300?random=3',
},
{
image: 'https://picsum.photos/600/300?random=4',
},
{
image: 'https://picsum.photos/600/300?random=5',
},
];
}
const swiperChange = (e) => {
state.current = e.detail.current;
};
const template = computed(() => sheep.$store('app').template?.home);
onLoad((options) => {
// #ifdef MP
// 小程序识别二维码
if (options.scene) {
const sceneParams = decodeURIComponent(options.scene).split('=');
console.log('sceneParams=>', sceneParams);
options[sceneParams[0]] = sceneParams[1];
}
// #endif
// 预览模板
if (options.templateId) {
sheep.$store('app').init(options.templateId);
}
// 解析分享信息
if (options.spm) {
$share.decryptSpm(options.spm);
}
// 进入指定页面(完整页面路径)
if (options.page) {
sheep.$router.go(decodeURIComponent(options.page));
}
});
// 下拉刷新
onPullDownRefresh(() => {
sheep.$store('app').init();
setTimeout(function () {
uni.stopPullDownRefresh();
}, 800);
});
onPageScroll(() => {});
</script>
<style lang="scss" scoped>
.uni-margin-wrap {
width: 100%;
position: relative;
}
.swiper {
height: 680rpx;
}
.swiper-item {
display: block;
height: 680rpx;
line-height: 300rpx;
text-align: center;
background: #ffffff;
}
.custom-item {
width: 100%;
height: 100%;
}
.swiper-image {
width: 430rpx;
height: 680rpx;
}
.swiper-item-card {
//width: 92% !important;
height: 100%;
margin: 0 4%;
overflow: hidden;
box-sizing: border-box;
display: flex;
align-items: flex-start;
justify-content: center;
}
.swiper-item-card-margin {
padding: 4% 0;
}
.height1 {
height: 2000px;
}
.swiper-list {
margin-top: 40rpx;
margin-bottom: 0;
}
.uni-common-mt {
margin-top: 60rpx;
position: relative;
}
.info {
position: absolute;
right: 20rpx;
}
.uni-padding-wrap {
width: 550rpx;
padding: 0 100rpx;
}
</style>