首页招生官轮播图的指示器样式

This commit is contained in:
A1300399510 2025-01-10 18:54:42 +08:00
parent 5e13566b42
commit 4706c324be
5 changed files with 100 additions and 17 deletions

View File

@ -88,10 +88,43 @@ Component({
urls, urls,
}) })
this.calculateIndicator()
if (urls.length != 0) this.setCountDown(0) if (urls.length != 0) this.setCountDown(0)
}) })
}, },
// 0是小 1是大
calculateIndicator() {
const urls = this.data.urls
const current = this.data.admissionCurrent
let length = urls.length
let startIndex = current - 2
let endIndex = current + 2
urls[this.data.admissionCurrent]['current'] = 2
if (startIndex < 0) {
endIndex = endIndex + Math.abs(startIndex)
startIndex = 0
}
if (endIndex >= length) {
startIndex = length - 5
endIndex = length - 1
}
urls.forEach((element, index) => {
element['current'] = -1
if (index == startIndex || index == endIndex) element['current'] = 0
if (index > startIndex && index < endIndex) element['current'] = 1
if ((index == startIndex && index == 0) || (index == endIndex && index == length - 1)) element['current'] = 1
if (index == current) element['current'] = 2
})
this.setData({
urls,
})
},
bindanimationfinish(e) { bindanimationfinish(e) {
const current = e.detail.current || 0 const current = e.detail.current || 0
this.setData({ this.setData({
@ -99,6 +132,7 @@ Component({
}) })
this.setCountDown(current) this.setCountDown(current)
this.calculateIndicator(current)
}, },
setCountDown(index) { setCountDown(index) {

View File

@ -143,22 +143,47 @@
} }
} }
.indicator-box {
height: 55rpx;
padding: 20rpx 0;
position: relative;
display: flex;
justify-content: center;
}
.indicator { .indicator {
height: 27rpx; position: absolute;
top: 50%;
transform: translateY(-50%);
.item { .item {
width: 7.5rpx;
height: 7.5rpx;
background-color: rgba(215, 215, 215, 1); background-color: rgba(215, 215, 215, 1);
border-radius: 30rpx; border-radius: 30rpx;
width: 0;
&:not(:last-of-type) { height: 0;
margin-right: 7.5rpx; transition: all .3s;
}
&.pitch { &.pitch {
background-color: rgba(250, 107, 17, 1); background-color: rgba(250, 107, 17, 1);
} }
&.tiny {
width: 10rpx;
height: 10rpx;
}
&.pitch,
&.tiny1 {
width: 15rpx;
height: 15rpx;
}
&.pitch,
&.tiny,
&.tiny1 {
margin-right: 7.5rpx;
display: block;
}
} }
} }
} }

View File

@ -36,7 +36,9 @@
</swiper-item> </swiper-item>
</swiper> </swiper>
<view class="indicator flexcenter"> <view class="indicator-box">
<view class="item {{ admissionCurrent == index ? 'pitch' : '' }}" wx:for="{{ urls }}" wx:key="index"></view> <view class="indicator flexcenter">
<view class="item {{ item.current == 2 ? 'pitch' : '' }} {{ item.current == 1 ? 'tiny1' : '' }} {{ item.current == 0 ? 'tiny' : '' }}" wx:for="{{ urls }}" wx:key="index"></view>
</view>
</view> </view>
</view> </view>

View File

@ -123,21 +123,43 @@
text-overflow: ellipsis; text-overflow: ellipsis;
-webkit-line-clamp: 2; -webkit-line-clamp: 2;
} }
.admission-box .indicator-box {
height: 55rpx;
padding: 20rpx 0;
position: relative;
display: flex;
justify-content: center;
}
.admission-box .indicator { .admission-box .indicator {
height: 27rpx; position: absolute;
top: 50%;
transform: translateY(-50%);
} }
.admission-box .indicator .item { .admission-box .indicator .item {
width: 7.5rpx;
height: 7.5rpx;
background-color: #d7d7d7; background-color: #d7d7d7;
border-radius: 30rpx; border-radius: 30rpx;
} width: 0;
.admission-box .indicator .item:not(:last-of-type) { height: 0;
margin-right: 7.5rpx; transition: all 0.3s;
} }
.admission-box .indicator .item.pitch { .admission-box .indicator .item.pitch {
background-color: #fa6b11; background-color: #fa6b11;
} }
.admission-box .indicator .item.tiny {
width: 10rpx;
height: 10rpx;
}
.admission-box .indicator .item.pitch,
.admission-box .indicator .item.tiny1 {
width: 15rpx;
height: 15rpx;
}
.admission-box .indicator .item.pitch,
.admission-box .indicator .item.tiny,
.admission-box .indicator .item.tiny1 {
margin-right: 7.5rpx;
display: block;
}
.admissionState { .admissionState {
width: 120rpx; width: 120rpx;
height: 36rpx; height: 36rpx;

View File

@ -494,7 +494,7 @@ function statistics(obj) {
const currentPage = pages[pages.length - 1]; // 当前页面对象 const currentPage = pages[pages.length - 1]; // 当前页面对象
url = currentPage?.route || 'pages/newIndex/index' url = currentPage?.route || 'pages/newIndex/index'
// console.log("url", url); // console.log("url", url);
options = currentPage.options if (currentPage) options = currentPage.options
} }
// 当页面显示时执行 // 当页面显示时执行