<template>
	<view class="body">
		<uniSwiperDot :info="info" :current="current" field="content" mode="default" :dots-styles=dotsStyles>
			<swiper autoplay="true" circular="true" interval="4000" duration="500" class="swiper-box">
				<swiper-item v-for="(item ,index) in info" :key="index" @click="clickItem(item)">
					<image class="imagestyle" :src="item.cover.url" mode=""></image>
				</swiper-item>
			</swiper>
		</uniSwiperDot>
		<view class="content">
			<view class="RedCar" @click="buyCar">
				<p
					style="width: 46vw; text-align: center; color: red; line-height: 10vw; margin-top: 8vw; font-weight: 550;">
					买车</p>
				<p style="width: 46vw; text-align: center; color: #e0e0e0e0;"> <span>BUY</span>
					<sapn>CAR</sapn>
				</p>
		<!-- 		<p>
					<image style="width: 50vw; height: 50vw; margin-top: -7vw; " src="../../static/redcar.png"></image>
				</p> -->
			</view>
			<view class="whiteCar" @click="sellCar">
				<p style="width: 46vw; text-align: center;  color: blue; margin-top: 10vw; font-weight: 550;">卖车</p>
				<p style="width: 46vw; text-align: center;  color: #e0e0e0e0; margin-top: 2vw;"> <span>BUY</span>
					<sapn>CAR</sapn>
				</p>
				<!-- <p>
					<image style="width: 40vw; height: 40vw; margin-top: -3vw; margin-left: 5vw; "
						src="../../static/whiteCar.png"></image>
				</p> -->
			</view>
		</view>
		<view class="floot">
			<view class="model" v-for="(item,index) in NewCarList" :key="index" @click="newDetial(item)">
				<view style="margin-left: 2vw; margin-top: 2vw;">
					<image style="width: 15vw; height: 15vw;" :src="item.img.url"></image>
				</view>
				<view style="margin-top: 5vw; margin-left: 3vw;">
					<p
						style="width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.75rem; ">
						{{item.name}}
					</p>
					<p> <span style="font-size: 0.75rem;">指导价:</span> <span
							style="font-size: 0.75rem; color: red;">{{Number(item.min_price/10000)}}万起</span>
					</p>
				</view>
				<view
					style="width: 20vw; margin-left: 2vw; margin-top: 6vw; height: 8vw; background-color: #fff5f5; color: red;  text-align: center; font-size: 0.75rem; line-height: 8vw; border-radius: 4vw;">
					<p>{{item.brand_name}} </p>
				</view>
			</view>
		</view>
	</view>

</template>

<script>
	import uniSwiperDot from '../../uni_modules/uni-swiper-dot/components/uni-swiper-dot/uni-swiper-dot.vue'
	export default {
		components: {
			uniSwiperDot
		},
		data() {
			return {
				dotsStyles: {
					backgroundColor: 'rgba(83, 200, 249,0.3)',
					border: '1px rgba(83, 200, 249,0.3) solid',
					color: '#fff',
					bottom: 2,
					selectedBackgroundColor: 'white',
					selectedBorder: '1px rgba(83, 200, 249,0.9) solid'
				},
				info: [],
				NewCarList: []
			}
		},
		onLoad() {
			this.getNewCarList(1, '')
			this.Swiper()
		},
		methods: {
			newDetial(item) {
				uni.navigateTo({
					url: '/pages/index/newCarDetial?DetialInfo=' + encodeURIComponent(JSON.stringify(item))
				})
			},
			// 热门车系
			getNewCarList(is_hot, name) {
				this.$api.getNewCar(is_hot, name, res => {
					if (res.code == 0) {
						this.NewCarList = res.data
					}
				})
			},
			clickItem(item) {
				console.log(item)
				uni.navigateTo({
					url: '/pages/index/active?id=' + item.id
				})
			},
			Swiper() {
				this.$api.getSwiper(res => {
					if (res.code == 0) {
						this.info = res.data
					}
				})
			},
			buyCar() {
				uni.navigateTo({
					url: "/pages/index/buyCar"
				})
			},
			sellCar() {
				uni.navigateTo({
					url: "/pages/index/sellCar"
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.body {
		width: 100vw;
		height: 100vh;

		.content {
			width: 92vw;
			height: 20vh;
			margin-left: 4vw;
			box-sizing: border-box;
			border-top: 0.5px solid #f6f6f6;
			border-bottom: 0.5px solid #f6f6f6;
			display: flex;
			margin-top: 2vw;

			.RedCar {
				width: 46vw;
				border-right: 0.5px solid #f6f6f6;
			}

			.whiteCar {
				width: 46vw;
			}

		}

		.floot {
			width: 100vw;
			height: 40vh;
			overflow-y: auto;
			box-sizing: border-box;
			padding:0 4vw ;
			.model {
				width: 92vw;
				height: 20vw;
				display: flex;
				margin-top: 2vw;
				background-color: #f8f8f8;
			}
		}

		.imagestyle {
			margin-top: 0vw;
			width: 100%;
			height: 100%;
		}

		.swiper-box {
			height: 60vw;
		}

		// .swiper-box {
		// 	height: 40vw;
		// }
		// .imagestyle {
		// 	margin-top: 0vw;
		// 	width: 100%;
		// 	height: 100%
		// }
	}
</style>