1、首页轮播图跳转

2、招租详情的轮播图的当前页数调整
This commit is contained in:
wangzimeng 2025-08-06 11:57:31 +08:00
parent 0c34797e9a
commit 986eee5e7f
2 changed files with 63 additions and 20 deletions

View File

@ -4,26 +4,20 @@
<!-- 顶部banner -->
<view class="swiper-box">
<view class="swiper_s">
<swiper class="swiper_s" :circular="true" :autoplay="true" indicator-active-color="#0DAE11"
indicator-color="#ffffff" :indicator-dots="false" :current="currentImgIndex"
@animationfinish="swiperChange">
<swiper class="swiper_s" :circular="true" :autoplay="true" :indicator-dots="false" :current="currentImgIndex"
@change="swiperChange" :duration="2000" @animationfinish="animationfinish">
<!-- v-for="(item, index) in swiperList" :key="index" @click="openSwiper(item)"-->
<swiper-item style="margin: 0 auto;">
<swiper-item style="margin: 0 auto;" v-for="(item,index) in imageList" :key="index">
<view style="position: relative;width: 100%;height: 100%;"
v-for="(item,index) in detailRent.images" :key="index">
<image class="swiper-image" :src="item" mode="scaleToFill" />
>
<image class="swiper-image" :src="item" />
</view>
</swiper-item>
<!-- <swiper-item style="margin: 0 auto;">
<view style="position: relative;width: 100%;height: 100%">
<image class="swiper-image" src="/static/cart-empty.png" mode="scaleToFill" />
</view>
</swiper-item> -->
</swiper>
<view class="bannerNum">
{{currentImgIndex}}/{{imagesNum}}
{{currentShowImgIndex}}/{{imagesNum}}
</view>
</view>
</view>
@ -184,7 +178,8 @@
const rentId = ref('');
const detailRent = ref('')
const imagesNum = ref(0);
const currentImgIndex = ref(1)
const currentImgIndex = ref(0)
const currentShowImgIndex = ref(1)
const showContacted = ref(false)
const showContactNo = ref(false)
onLoad((options) => {
@ -201,6 +196,7 @@
}
})
const imageList = ref([])
async function getDetail() {
const res = await sheep.$api.rent.rentInfo(rentId.value)
console.log('获取招租详情', res);
@ -208,9 +204,9 @@
detailRent.value = res.data.detail
detailRent.value.release_time_text = detailRent.value.release_time_text.substring(0, 10);
const imageList = res.data.detail.images
console.log('imageList:', imageList.length);
imagesNum.value = imageList.length
imageList.value = res.data.detail.images
console.log('imageList:', imageList.value);
imagesNum.value = imageList.value.length
console.log('imagesNum:', imagesNum.value);
} else {
uni.showToast({
@ -220,6 +216,28 @@
}
}
function swiperChange(e) {
console.log('切换轮播图',e.detail.current);
if(e.detail.current<imagesNum.value) {
// if(e.detail.current == 0){
// currentImgIndex.value = imagesNum.value
// }else {
// currentImgIndex.value = e.detail.current;
// }
currentImgIndex.value = e.detail.current;
currentShowImgIndex.value = e.detail.current + 1;
}
// if(e.detail.source =='autoplay' || e.detail.source == 'touch' || e.detail.source === ''){
// currentImgIndex.value = e.detail.current + 1;
// }else {
// // currentImgIndex.value = e.detail.current + 1; //
// }
}
function animationfinish(e) {
console.log('animationfinish',e);
};
//
function backHome() {
uni.switchTab({

View File

@ -50,9 +50,9 @@
<view class="swiper_s">
<swiper class="swiper_s" :circular="true" :autoplay="true" indicator-active-color="#0DAE11"
indicator-color="#ffffff" :indicator-dots="false" :current="swiperCurrent"
@animationfinish="swiperChange" v-for="(item, index) in bannerList" :key="index">
@animationfinish="swiperChange">
<!-- v-for="(item, index) in swiperList" :key="index" @click="openSwiper(item)"-->
<swiper-item style="margin: 0 auto;" >
<swiper-item style="margin: 0 auto;" v-for="(item, index) in bannerList" :key="index" @click="swiperJump(item)">
<view style="position: relative;width: 100%;height: 100%;">
<!--<view class="fnon_tit"></view>
<view class="text">{{ item.title ? item.title : '' }}</view>
@ -299,6 +299,30 @@
}
});
//
function swiperJump(item) {
console.log('轮播图跳转事件:',item.url);
const tabBarPages = [
'/pages/index/index',
'/pages/index/fabu',
'/pages/index/user'
];
console.log('tabbarsList',tabBarPages);
if(item.type == "in") {
console.log('跳进内页');
if(tabBarPages.includes(item.url)) {
console.log('导航页');
uni.switchTab({
url: item.url,
})
}else {
uni.navigateTo({
url: item.url,
})
}
}
}
//
onPullDownRefresh(() => {
sheep.$store('app').init();
@ -315,6 +339,7 @@
console.log('banner',res);
if(res.code == 1) {
bannerList.value = res.data.list
console.log('bannerList',bannerList.value);
}
}