- 新增CurrentIndex 状态管理当前轮播索引 - 移除数组反转逻辑,调整模特展示顺序 - 添加 generatingLoading 计算属性检测试穿结果生成状态 - 更新轮播图组件绑定状态为 store 中的 swiperCurrentIndex - 修复轮播切换事件更新 store 状态的逻辑 - 调整定时任务检测条件为 generatingLoading 状态- 微调轮播图片样式位置
235 lines
5.4 KiB
Vue
235 lines
5.4 KiB
Vue
<template>
|
|
<uv-sticky :customNavHeight="0" :offset-top="0">
|
|
<view class="uni-margin-wrap">
|
|
<uni-swiper-dot
|
|
:current="fittingRoomStore.swiperCurrentIndex"
|
|
:dots-styles="dotsStyles"
|
|
:info="fittingRoomStore.testResults"
|
|
:mode="'default'"
|
|
field="content"
|
|
>
|
|
<swiper
|
|
:autoplay="false"
|
|
:duration="500"
|
|
:interval="5000"
|
|
:next-margin="'160rpx'"
|
|
:previous-margin="'160rpx'"
|
|
circular
|
|
class="swiper"
|
|
current="0"
|
|
@change="swiperChange"
|
|
>
|
|
<swiper-item v-for="(item, index) in fittingRoomStore.testResults" :key="index">
|
|
<view class="swiper-item">
|
|
<image
|
|
:class="[
|
|
'swiper-image',
|
|
fittingRoomStore.swiperCurrentIndex === index ? 'active' : '',
|
|
]"
|
|
:src="item.tryOnResultUrl || '/static/uploads/loading12.gif'"
|
|
mode="aspectFill"
|
|
></image>
|
|
</view>
|
|
</swiper-item>
|
|
</swiper>
|
|
</uni-swiper-dot>
|
|
<s-select-mote />
|
|
<Clothespic />
|
|
</view>
|
|
|
|
<s-tabs />
|
|
</uv-sticky>
|
|
<scroll-view class="scroll" scroll-y="true">
|
|
<s-grid-clothes />
|
|
<view class="height1"></view>
|
|
</scroll-view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { onMounted, reactive, ref } from 'vue';
|
|
import { onLoad, onPullDownRefresh, onUnload } 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 Clothespic from './components/Clothespic.vue'; // 隐藏原生tabBar
|
|
|
|
const fittingRoomStore = sheep.$store('fittingRoom');
|
|
let timer = null;
|
|
const dotsStyles = {
|
|
backgroundColor: 'rgba(255, 255, 255)',
|
|
border: '0px rgba(83, 200, 249,0.3) solid',
|
|
selectedBackgroundColor: 'rgba(23, 23, 23)',
|
|
selectedBorder: '0px rgba(83, 200, 249,0.9) solid',
|
|
};
|
|
|
|
// sheep.$helper.toast('请选择是否同意协议');
|
|
// 隐藏原生tabBar
|
|
uni.hideTabBar({
|
|
fail: () => {},
|
|
});
|
|
|
|
function swiperChange(event) {
|
|
console.log('🚀 ~ swiperChange 🐶75 ~ event: ', event);
|
|
fittingRoomStore.swiperCurrentIndex = event.detail.current;
|
|
}
|
|
|
|
onMounted(() => {
|
|
fittingRoomStore.getCategory();
|
|
fittingRoomStore.getCloths();
|
|
fittingRoomStore.getModelList();
|
|
timer = setInterval(() => {
|
|
// TODO: 检测到还有没生成图的, 获取最新数据
|
|
fittingRoomStore.generatingLoading &&
|
|
fittingRoomStore.getTestResults(fittingRoomStore.currentModel?.id);
|
|
}, 6000);
|
|
});
|
|
onUnload(() => {
|
|
// 移除全局监听
|
|
clearInterval(timer);
|
|
});
|
|
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);
|
|
}
|
|
|
|
// const template = computed(() => sheep.$store('app').template?.home);
|
|
|
|
onLoad((options) => {
|
|
uni.setStorageSync('token', options?.token ?? '92d2805a85ca422e90dd7d50eef49a85');
|
|
console.log('🚀 ~ URL上的token ~ options?.token: ', options?.token);
|
|
});
|
|
|
|
// 下拉刷新
|
|
onPullDownRefresh(() => {
|
|
// sheep.$store('app').init();
|
|
if (fittingRoomStore.currentModel?.id) {
|
|
fittingRoomStore.getTestResults(fittingRoomStore.currentModel?.id).then(() => {
|
|
console.log('➤➤➤ ~ index.vue ~ L124');
|
|
uni.stopPullDownRefresh();
|
|
});
|
|
} else {
|
|
uni.stopPullDownRefresh();
|
|
}
|
|
});
|
|
|
|
// onPageScroll(() => {});
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.uni-margin-wrap {
|
|
width: 100%;
|
|
position: relative;
|
|
background: #ffffff;
|
|
}
|
|
|
|
.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;
|
|
box-shadow: 0px 0px 30rpx rgba(0, 0, 0, 0.2);
|
|
transform: scale(0.9) translate(0, 20px);
|
|
opacity: 0.3;
|
|
transition: all 0.2s ease-in 0.1s;
|
|
}
|
|
.active {
|
|
transform: scale(1) translate(0, 0);
|
|
z-index: 20;
|
|
opacity: 1;
|
|
}
|
|
:deep() {
|
|
.uni-swiper__dots-item {
|
|
height: 1px !important;
|
|
}
|
|
}
|
|
|
|
.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: 400rpx;
|
|
}
|
|
|
|
.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;
|
|
}
|
|
.custom-indicators {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
.custom-indicator {
|
|
width: 10rpx;
|
|
height: 1px;
|
|
opacity: 0.5;
|
|
background: #fff;
|
|
margin: 0 5rpx;
|
|
}
|
|
.active {
|
|
width: 30rpx;
|
|
height: 1px;
|
|
background: #171717;
|
|
}
|
|
}
|
|
.scroll {
|
|
overflow-y: scroll;
|
|
}
|
|
</style>
|