123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- <template>
- <view class="main">
- <view class="swiper" v-if="!launchFlagStatus">
- <swiper class="swiper-list" :indicator-dots="swiperList && swiperList.length > 1" indicator-color="#ffffff"
- indicator-active-color="rgb(3,160,168)" interval="5000" :autoplay="autoplay" :duration="duration"
- @change="swiperChange">
- <swiper-item v-for="(item, index) in swiperList" :key="index">
- <view class="swiper-item">
- <view class="swiper-item-img">
- <!-- aspectFill -->
- <image :src="item.image" mode="aspectFit"></image>
- </view>
- </view>
- </swiper-item>
- </swiper>
- <!-- <view class="jumpover" @tap="launchFlag()" v-if="swiperCurrent+1 < swiperLength">{{ jumpover }}</view> -->
- <view class="jumpover">
- <div class="jumpover_l">{{ countDown }}s</div>
- <div class="jumpover_r" @click="goPage()">跳过</div>
- </view>
- <!-- <view class="experience" @tap="launchFlag()" v-if="swiperCurrent+1 == swiperLength">{{ experience }}</view> -->
- </view>
- </view>
- </template>
- <script>
- import {
- getBannerList
- } from "@/api/government.js"
- export default {
- data() {
- return {
- launchFlagStatus: false,
- titleNViewBackground: '',
- swiperCurrent: 0,
- swiperLength: 0,
- swiperList: [
- // {
- // imgUrl: '/static/guide/1-1.png',
- // bgColor: ''
- // },
- // {
- // imgUrl: '/static/guide/2-2.png',
- // bgColor: ''
- // },
- // {
- // imgUrl: '/static/guide/3-3.png',
- // bgColor: ''
- // },
- // {
- // imgUrl: '/static/guide/4-4.png',
- // bgColor: ''
- // }
- ],
- autoplay: false,
- duration: 500,
- jumpover: '跳过',
- experience: '立即体验',
- countDown: 3,
- countDownInterval: null
- };
- },
- onLoad() {
- // try {
- // this.launchFlagStatus = uni.getStorageSync('launchFlag');
- // } catch (e) {
- // //TODO handle the exception
- // }
- // this.launchFlagStatus = this.launchFlagStatus ? true : false;
- console.log('this.launchFlagStatus = ', this.launchFlagStatus)
- if (this.launchFlagStatus) {
- uni.switchTab({
- url: '/pages/home',
- success: res => {
- // push.navigator.closeSplashscreen();
- console.log('111 = res ', res)
- },
- fail: err => {
- // push.navigator.closeSplashscreen();
- console.log('111 = err ', err)
- }
- });
- } else {
- this.swiperLength = this.swiperList.length;
- this.getList();
- this.countDown = 3;
- this.countDownInterval = setInterval(() => {
- this.countDown--;
- if (this.countDown <= 0) {
- clearInterval(this.countDownInterval)
- this.launchFlag();
- }
- }, 1000)
- }
- // this.swiperLength = this.swiperList.length;
- // this.getList()
- // this.titleNViewBackground = this.swiperList[0].bgColor;
- },
- onUnload() {
- try {
- clearInterval(this.countDownInterval)
- } catch (e) {
- //TODO handle the exception
- }
- },
- methods: {
- goPage(){
- clearInterval(this.countDownInterval)
- this.launchFlag();
- },
- getList() {
- getBannerList('guanggaoyd').then(res => {
- this.swiperList = res.data
- })
- },
- //轮播图切换修改背景色
- swiperChange(e) {
- const index = e.detail.current;
- this.swiperCurrent = index;
- this.swiperLength = this.swiperList.length;
- // this.titleNViewBackground = this.swiperList[index].bgColor;
- },
- launchFlag: function() {
- /**
- * 向本地存储中设置launchFlag的值,即启动标识;
- */
- // uni.setStorage({
- // key: 'launchFlag',
- // data: true
- // });
- uni.switchTab({
- url: '/pages/home'
- });
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- page,
- .main {
- width: 100%;
- height: 100%;
- padding: 0;
- background-size: 100% auto;
- }
- .swiper {
- flex-direction: column;
- width: 100%;
- height: 100vh;
- background: #fff;
- }
- .swiper-list {
- width: 100%;
- height: 100%;
- }
- .swiper-item {
- position: relative;
- display: flex;
- align-items: center;
- flex-direction: column;
- width: 100%;
- height: 100%;
- text-align: center;
- }
- .swiper-item-img {
- justify-content: center;
- width: 100%;
- height: 100%;
- margin: 0 auto;
- }
- .swiper-item-img image {
- width: 100%;
- height: 100%;
- }
- .jumpover,
- .experience {
- position: absolute;
- z-index: 999;
- height: 60rpx;
- line-height: 56rpx;
- padding: 0 40rpx;
- font-size: 32rpx;
- color: rgb(3, 160, 168);
- border: 2rpx solid rgb(3, 160, 168);
- border-radius: 30rpx;
- }
- .jumpover {
- right: 20rpx;
- top: 90rpx;
- padding: 0 20rpx;
- display: flex;
- .jumpover_l{
-
- }
- .jumpover_r{
- font-size: 28rpx;
- margin-left: 20rpx;
- // padding-top: 2rpx;
- position: relative;
- &::before{
- content: "";
- display: block;
- position: absolute;
- width: 2rpx;
- height: 36rpx;
- background: rgb(3, 160, 168);
- top: 12rpx;
- left: -10rpx;
- }
- }
- }
- .experience {
- width: 300rpx;
- height: 80rpx;
- right: 50%;
- bottom: 20vh !important;
- margin-right: -20%;
- padding: 0;
- background: rgb(3, 160, 168);
- color: #fff;
- line-height: 80rpx;
- text-align: center;
- border-radius: 40rpx;
- }
- /deep/ uni-swiper .uni-swiper-dot {
- border: 1rpx solid rgb(3, 160, 168);
- }
- /deep/ uni-swiper .uni-swiper-dots-horizontal {
- bottom: 10vh !important;
- }
- </style>
|