<template>
|
|
<view>
|
|
<swiper
|
|
class="swiper"
|
|
:current="current"
|
|
:autoplay="autoplay"
|
|
@change="onChange"
|
|
>
|
|
<swiper-item v-for="item in list" :key="item.id">
|
|
<view class="swiper-item">
|
|
<view class="swiper-item-content">
|
|
|
|
<image class="bg" :src="item.imageUrl" mode="aspectFill"></image>
|
|
|
|
<view class="content">
|
|
|
|
<!-- <view class="flex flex-column">
|
|
<view
|
|
v-for="(line, lIdx) in item.arr"
|
|
:key="lIdx"
|
|
:class="line.class"
|
|
>
|
|
{{ line.text }}
|
|
</view>
|
|
</view> -->
|
|
|
|
<view class="btns">
|
|
<button class="btn btn-left flex" @click="jumpToProduct">
|
|
全部产品
|
|
</button>
|
|
<button class="btn btn-right flex" :style="{ background: item.color }" @click="jumpToReport">
|
|
定制健康档案
|
|
</button>
|
|
</view>
|
|
</view>
|
|
|
|
</view>
|
|
</view>
|
|
</swiper-item>
|
|
</swiper>
|
|
|
|
<indicator :current="current" :length="list.length" @click="current = $event"></indicator>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import indicator from '@/components/home/indicator.vue'
|
|
|
|
export default {
|
|
components: {
|
|
indicator,
|
|
},
|
|
data() {
|
|
return {
|
|
current: 0,
|
|
list: [],
|
|
last: null,
|
|
autoplay: true,
|
|
}
|
|
},
|
|
created() {
|
|
this.getData()
|
|
},
|
|
methods: {
|
|
async getData() {
|
|
try {
|
|
this.list = await this.$fetch('getBanner')
|
|
} catch (err) {
|
|
|
|
}
|
|
},
|
|
jumpToProduct() {
|
|
uni.navigateTo({
|
|
url: '/pages/index/product'
|
|
})
|
|
},
|
|
jumpToReport() {
|
|
uni.navigateTo({
|
|
url: '/pages/index/report'
|
|
})
|
|
},
|
|
onChange(e) {
|
|
this.current = e.detail.current
|
|
const currentTime = this.$dayjs()
|
|
|
|
if (this.last) {
|
|
const diff = currentTime.diff(this.last, 'millisecond')
|
|
console.log('diff', diff, e.detail.source)
|
|
if (diff < 2500 && e.detail.source === 'autoplay') {
|
|
console.log('autoplay abnormal')
|
|
this.autoplay = false
|
|
setTimeout(() => {
|
|
console.log('autoplay restart')
|
|
this.autoplay = true
|
|
}, 3000 - diff)
|
|
}
|
|
}
|
|
|
|
this.last = currentTime
|
|
},
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
|
|
.swiper {
|
|
width: 100vw;
|
|
height: calc(100vw * 578 / 375);
|
|
|
|
&-item {
|
|
width: 100%;
|
|
height: 100%;
|
|
padding: 10rpx 32rpx 40rpx 32rpx;
|
|
box-sizing: border-box;
|
|
|
|
&-content {
|
|
position: relative;
|
|
width: 100%;
|
|
height: 100%;
|
|
border-radius: 64rpx;
|
|
box-shadow: -5rpx -5rpx 10rpx 0 #FFFFFF,
|
|
10rpx 10rpx 20rpx 0 #AAAACC80,
|
|
4rpx 4rpx 10rpx 0 #AAAACC40,
|
|
-2rpx -2rpx 5rpx 0 #FFFFFF;
|
|
}
|
|
|
|
.bg {
|
|
width: 100%;
|
|
height: 100%;
|
|
border-radius: 64rpx;
|
|
}
|
|
|
|
.content {
|
|
position: absolute;
|
|
bottom: 0;
|
|
|
|
width: 100%;
|
|
// height: 592rpx;
|
|
padding: 170rpx 60rpx 80rpx 60rpx;
|
|
box-sizing: border-box;
|
|
background-image: linear-gradient(#FFFFFF00, #FFFFFF);
|
|
border-radius: 64rpx;
|
|
}
|
|
|
|
.font1 {
|
|
font-size: 48rpx;
|
|
font-weight: 600;
|
|
line-height: 1.4;
|
|
font-family: PingFang SC;
|
|
color: #252545;
|
|
}
|
|
.font2 {
|
|
font-size: 48rpx;
|
|
font-weight: 600;
|
|
line-height: 1.4;
|
|
font-family: PingFang SC;
|
|
color: transparent;
|
|
background-image: linear-gradient(to right, #4B348F, #845CFA);
|
|
background-clip: text;
|
|
display: inline-block;
|
|
}
|
|
.font3 {
|
|
font-size: 32rpx;
|
|
font-weight: 400;
|
|
line-height: 1.4;
|
|
font-family: PingFang SC;
|
|
color: #252545;
|
|
}
|
|
|
|
.btns {
|
|
margin-top: 72rpx;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
|
|
.btn {
|
|
width: 264rpx;
|
|
box-sizing: border-box;
|
|
font-size: 30rpx;
|
|
font-family: PingFang SC;
|
|
line-height: 1.4;
|
|
border-radius: 45rpx;
|
|
|
|
&-left {
|
|
padding: 23rpx 0;
|
|
font-weight: 400;
|
|
color: #252545;
|
|
border: 1rpx solid #252545;
|
|
}
|
|
|
|
&-right {
|
|
padding: 24rpx 0;
|
|
font-weight: 600;
|
|
color: #FFFFFF;
|
|
// background-image: linear-gradient(to right, #4B348F, #845CFA);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
</style>
|