- 移除未使用的点击事件和相关函数 - 调整轮播图获取结果的定时器间隔从2秒至6秒 - 更新下拉刷新逻辑,仅在存在模型ID时请求数据 - 修改页面卸载钩子为onUnload并清理定时器- 禁用服饰上传页的下拉刷新功能 -优化网格组件中衣物切换判断条件 - 更新文件最后编辑时间和作者信息- 调整试衣间页面结构与样式高度单位统一为rpx- 注释掉部分冗余或调试用途的代码逻辑 - 全局函数updateToken语法规范化并移除初始化调用
178 lines
4.0 KiB
Vue
178 lines
4.0 KiB
Vue
<template>
|
|
<view>
|
|
<view class="uni-margin-wrap">
|
|
<!-- https://ext.dcloud.net.cn/plugin?id=22930-->
|
|
<hbxw-stack-carousel
|
|
:key="fittingRoomStore.testResults"
|
|
:height="680"
|
|
:interval="15000"
|
|
:list="fittingRoomStore.testResults"
|
|
:width="430"
|
|
indicatorStyle="line"
|
|
loop
|
|
@change="handleChange"
|
|
@click="handleItemClick"
|
|
>
|
|
<template #default="{ item, index }">
|
|
<view class="custom-item">
|
|
<image :src="item.tryOnResultUrl" class="swiper-image" mode="aspectFill" />
|
|
</view>
|
|
</template>
|
|
</hbxw-stack-carousel>
|
|
<s-select-mote />
|
|
<Clothespic />
|
|
</view>
|
|
<uv-sticky :customNavHeight="0" :offset-top="0">
|
|
<s-tabs />
|
|
</uv-sticky>
|
|
<s-grid-clothes />
|
|
<view class="height1"></view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { computed, onMounted, reactive, ref } from 'vue';
|
|
import { onLoad, onPageScroll, 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;
|
|
|
|
// sheep.$helper.toast('请选择是否同意协议');
|
|
// 隐藏原生tabBar
|
|
uni.hideTabBar({
|
|
fail: () => {},
|
|
});
|
|
|
|
function handleItemClick(index, item) {
|
|
console.log(index, item, '12');
|
|
}
|
|
|
|
onMounted(() => {
|
|
fittingRoomStore.getCategory();
|
|
fittingRoomStore.getCloths();
|
|
fittingRoomStore.getModelList();
|
|
timer = setInterval(() => {
|
|
// TODO: 检测到还有没生成图的, 获取最新数据
|
|
// fittingRoomStore.currentModel?.id &&
|
|
// 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 ?? 'e84526c0f7a3457da54e663fb4396beb');
|
|
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 ~ L100');
|
|
uni.stopPullDownRefresh();
|
|
});
|
|
} else {
|
|
uni.stopPullDownRefresh();
|
|
}
|
|
});
|
|
|
|
// 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: 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;
|
|
}
|
|
</style>
|