This commit is contained in:
zpc 2025-08-04 18:10:22 +08:00
parent 3d596e462d
commit e474d68188

View File

@ -5,6 +5,32 @@
</image>
<uniNoticeBar showIcon single scrollable text="赠品仅限线下购买设备的用户领取需人工审核预计3个工作日内完成"
style="width: 100%;position:fixed;top:10%" background-color="transparent" color="#000" />
<view class="auto-scroll-container" catchtouchmove="return false">
<!-- 滚动容器 -->
<scroll-view class="scroll-view" scroll-x :scroll-with-animation="false" ref="scrollView"
@scroll="onScroll">
<!-- 图片列表容器 (复制一份实现无缝滚动) -->
<view class="scroll-content" :style="{ transform: `translateX(${translateX}px)` }"
catchtouchmove="return false">
<view class="image-list" ref="imageList">
<view class="image-item" v-for="(item, index) in imageList" :key="index">
<image :src="item.url" mode="aspectFill" class="item-image" :alt="item.alt"></image>
</view>
</view>
<!-- 复制一份列表用于无缝衔接 -->
<view class="image-list copy-list" catchtouchmove="return false">
<view class="image-item" v-for="(item, index) in imageList" :key="'copy-' + index">
<image :src="item.url" mode="aspectFill" class="item-image" :alt="item.alt"></image>
</view>
</view>
</view>
</scroll-view>
</view>
<view class="center" @click="openReceivePop"
style="width: 386rpx; height: 102rpx; background-color: #0877FF; border-radius: 16rpx; position: absolute; bottom: 200rpx;">
<text style="font-size: 35rpx; color: white;">设备专属权益兑换</text>
@ -170,8 +196,56 @@ export default {
createTime: "",
number: "",
model: "",
recordList: []
recordList: [],
//
imageList: [{
url: 'https://picsum.photos/300/200?random=1',
alt: '图片1'
},
{
url: 'https://picsum.photos/300/200?random=2',
alt: '图片2'
},
{
url: 'https://picsum.photos/300/200?random=3',
alt: '图片3'
},
{
url: 'https://picsum.photos/300/200?random=4',
alt: '图片4'
},
{
url: 'https://picsum.photos/300/200?random=5',
alt: '图片5'
},
{
url: 'https://picsum.photos/300/200?random=6',
alt: '图片6'
}
],
scrollTimer: null, //
scrollSpeed: 1, // (px/)
translateX: 0, //
listWidth: 0, //
isScrolling: false //
}
},
onReady() {
//
this.$nextTick(() => {
const query = uni.createSelectorQuery().in(this);
query.select('.image-list').boundingClientRect(data => {
this.listWidth = data.width;
//
this.startAutoScroll();
}).exec();
});
},
onUnload() {
//
this.stopAutoScroll();
},
methods: {
@ -471,20 +545,45 @@ export default {
});
}
},
async getBannerList() {
const res = await this.request('getBannerList', 'GET', {});
console.log(res);
if (res.code == 200) {
this.bannerList = res.data;
//
startAutoScroll() {
this.stopAutoScroll(); //
// 16ms (60/)
this.scrollTimer = setInterval(() => {
this.translateX -= this.scrollSpeed;
//
if (Math.abs(this.translateX) >= this.listWidth) {
this.translateX = 0;
}
this.isScrolling = true;
}, 16);
},
//
stopAutoScroll() {
if (this.scrollTimer) {
clearInterval(this.scrollTimer);
this.scrollTimer = null;
this.isScrolling = false;
}
},
// ()
onScroll() {
//
}
}
}
</script>
<style>
<style scoped>
.content {
width: 100%;
height: 100vh;
@ -502,4 +601,40 @@ export default {
border-bottom: 0.86px solid #e3e3e3;
}
.auto-scroll-container {
width: 100%;
overflow: hidden;
/* 隐藏滚动条 */
padding: 20rpx 0;
}
.scroll-view {
width: 100%;
white-space: nowrap;
/* 防止换行 */
}
.scroll-content {
display: flex;
}
.image-list {
display: flex;
flex-direction: row;
}
.image-item {
width: 240rpx;
height: 200rpx;
margin-right: 20rpx;
border-radius: 8rpx;
overflow: hidden;
}
.item-image {
width: 100%;
height: 100%;
display: block;
}
</style>