<template>
	<view class="center">
		<view class="top">
			<view class="vheigh"></view>
			<image class="top-bg" src="../../static/img/top-bg.png" mode=""></image>
			<view class="top-main flex">
				<view class="search-box flex" @click="clickSearch()">
					<image class="search" src="../../static/img/search.png" mode=""></image>
					<view class="search-font">输入关键词搜索</view>
				</view>
			</view>
		</view>
		<swiper class="carousel" autoplay="true" duration="400" interval="5000" @change="swiperChange">
			<swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"
				@click="bannerNavToUrl(item)">
				<image :src="item.pic" />
			</swiper-item>
		</swiper>
		<view class="tongz flex">
			<view>
				<view class="tongz-bg">
					<image src="../../static/img/tongz-bg.png" mode=""></image>
				</view>
				<view class="tongz-left flex">
					<image class="image-left" src="../../static/img/ling.png" mode=""></image>
					<u-notice-bar style="width: 100%;" mode="vertical" type="none" :volume-icon="false"
						:more-icon="false" :list="text"></u-notice-bar>
				</view>
			</view>
		</view>
		<view class="navbar">
			<view class="nav-item" @click="nav('/pages/index/index')">
				<image class="nav-img" src="../../static/img/newbanner.png" mode=""></image>
			</view>
			<view class="nav-item" @click="nav('/pages/navigation/main')">
				<image class="nav-img" src="../../static/img/oldbanner.png" mode=""></image>
			</view>
		</view>
		<view class="box margin-t-30 flex">
			<view class="leftbox flex">
				<view class="flex-center">
					<view class="title">
						{{ticketBase.fullname}}
					</view>
				</view>
				<view class="num flex">
					<image class="tip" src="../../static/img/wpicon.png" mode="scaleToFill"></image>
					<text class="chines margin-l-10">
						价格(CNY):
					</text>
					<text class="onStrong margin-r-10">
						{{ticketBase.CurPrice}}
					</text>
					<image class="tip tipr" src="../../static/img/wpicon.png" mode="scaleToFill"></image>
				</view>
			</view>
			<view class="right flex-center">
				<view class="righttext flex-center">
					<view class="rightNumBox">

						<text class="font-size-sm" v-if="ticketBase.CurrentGains>0">+</text>
						<text class="font-size-sm" v-if="ticketBase.CurrentGains<0">-</text>
						{{ticketBase.CurrentGains}}
						<text class="font-size-sm">%</text>
					</view>
				</view>
				<view class="text">
					近24小时涨跌幅
				</view>
			</view>
		</view>
		<!-- #ifdef H5 -->
		<view class="btm">
			<a href="https://beian.miit.gov.cn" class="a-pm">备案编号:浙ICP备2022017146号 </a>
		</view>
		<!-- #endif -->
	</view>
</template>

<script>
	import {
		loadIndexs,
		store_list
	} from '@/api/index.js';
	import {
		getTicket
	} from '@/api/quick.js';
	import {
		mapState,
		mapMutations
	} from 'vuex';
	export default {
		data() {
			return {
				current: 0,
				titleNViewBackground: '',
				swiperCurrent: 0,
				swiperLength: 0,
				carouselList: [], //轮播图列表
				text: ['双模式 双系统  开创第三代新零售'],
				ticketBase: {}
			};
		},
		onShow() {
			this.loadData();
			this.getTicket()
		},
		methods: {
			...mapMutations(['setLat', 'setLon', 'setChoose']),
			getTicket() {
				getTicket()
					.then(
						(res) => {
							console.log(res);
							this.ticketBase = res.data.v;
							this.ticketBase.CurrentGains = +this.ticketBase.CurrentGains
						}
					).catch(
						(err) => {
							console.log(err);
						}
					)
			},
			loadData() {
				loadIndexs({})
					.then(({
						data
					}) => {
						let goods = data.info;
						this.dataList = goods.bastList; //精品推荐
						this.carouselList = data.banner;
					})
					.catch(e => {});
			},
			nav(url) {
				uni.navigateTo({
					url,
					fail() {
						uni.switchTab({
							url
						});
					}
				});
			},
			//轮播图切换修改背景色
			swiperChange(e) {
				const index = e.detail.current;
				this.swiperCurrent = index;
				this.titleNViewBackground = this.carouselList[index].background;
			},
			// 點擊搜索框
			clickSearch() {
				uni.navigateTo({
					url: '/pages/product/search'
				});
			},
		}
	};
</script>

<style lang="scss">
	.box {
		border-radius: 10rpx;
		line-height: 1;
		margin: 0 30rpx;
		background-image: url("../../static/img/indwxWp.png");
		background-size: 100% auto;
		background-repeat: no-repeat;
		position: relative;
		height: 230rpx;
		align-items: stretch;

		.leftbox {
			flex-grow: 1;
			padding: 20rpx 0;
			flex-direction: column;

			.title {
				padding: 6rpx 20rpx;
				border-radius: 50rpx;
				font-size: $font-sm;
				color: #FFF;
				border: 1px solid #FFF;
			}

			.num {
				font-size: $font-lg;
				text-align: center;
				color: $color-red;
				height: 80rpx;
				.onStrong{
					font-size: 36rpx;
				}
				.chines {
					color: #FFF;
				}

				.tip {
					width: 80rpx;
					height: 6rpx;

					&.tipr {
						transform: rotate(180deg);
					}
				}
			}
		}


		.right {
			flex-shrink: 0;
			width: 200rpx;
			flex-direction: column;
			color: #FFF;

			.righttext {
				width: 130rpx;
				height: 130rpx;
				border-radius: 1000rpx;
					border: 1px solid #FFF;
				.rightNumBox {
					font-size: 40rpx;
				}
			}

			.text {
				margin-top: 20rpx;
				font-size: $font-sm;
				text-shadow: 2px 2px 1px red;
			}
		}


	}

	page,
	.center {
		min-height: 100%;
		height: auto;
		background: #ffffff;
	}

	.vheigh {
		height: var(--status-bar-height);
		background-color: $base-color;
	}

	.top {
		position: relative;
		width: 100%;
		height: 360rpx;

		.top-bg {
			position: absolute;
			top: 0;
			left: 0;
			right: 0;
			width: 100%;
			height: 100%;
		}

		.top-main {
			position: relative;
			z-index: 2;
			padding: 30rpx;

			.search-box {
				justify-content: center;
				width: 698rpx;
				height: 60rpx;
				background: rgba(255, 240, 245, 0.4);
				box-shadow: 0px 10rpx 20rpx 0px rgba(4, 114, 69, 0.22);
				border-radius: 30rpx;

				.search {
					width: 34rpx;
					height: 34rpx;
				}

				.search-font {
					margin-left: 14rpx;
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #ffffff;
				}
			}
		}
	}

	.carousel {
		width: 700rpx;
		height: 276rpx;
		/* #ifndef APP-PLUS */
		margin: -240rpx auto 0;
		/* #endif */
		/* #ifdef APP-PLUS */
		margin: -180rpx auto 0;
		/* #endif */
		border-radius: 40rpx;

		image {
			border-radius: 40rpx;
			width: 700rpx;
			height: 276rpx;
		}
	}

	.tongz {
		width: 690rpx;
		height: 70rpx;
		margin: 32rpx auto 0;
		padding: 18rpx 30rpx 18rpx 24rpx;
		align-items: center;
		position: relative;

		.tongz-bg {
			position: absolute;
			top: 0;
			right: 0;
			left: 0;
			width: 690rpx;
			height: 70rpx;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.tongz-left {
			width: 640rpx;

			.image-left {
				width: 28rpx;
				height: 34rpx;
			}

			.tongz-font {
				margin-left: 22rpx;
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #0f253a;
			}
		}

		.tongz-right {
			position: relative;
			z-index: 11;
			width: 12rpx;
			height: 26rpx;

			image {
				width: 100%;
				height: 100%;
			}
		}
	}

	.nav-item {
		width: 698rpx;
		height: 219rpx;
		background: linear-gradient(150deg, #F5BE41 0%, #DF4226 100%);
		border-radius: 14rpx;
		margin: 40rpx auto 0;

		.nav-img {
			width: 100%;
			height: 100%;
			border-radius: 14rpx;
		}
	}

	.btm {
		position: fixed;
		bottom: 0;
		width: 100%;
		height: 50rpx;
		line-height: 50rpx;
		text-align: center;

		.a-pm {
			text-decoration: none;
			width: 100%;
			height: 50rpx;
			line-height: 50rpx;
			color: navigator;
		}
	}
</style>