<template>
	<view class="container">
		<view class="top">
			<!-- <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-h.png" mode=""></image>
					<view class="search-font">输入关键词搜索</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 class="img" :src="item.pic" mode="scaleToFill" />
				</swiper-item>
			</swiper>
		</view>
		<view class="box">
			<view class="box-title">
				<view class="left">
					艺绘
				</view>
				<view class="right" @click="navTo('/pages/index/cangp')">
					查看更多 >
				</view>
			</view>
			<view class="box-content" v-for="(item,index) in list" @click="buy(item)">
				<view class="img">
					<image :src="item.image" mode=""></image>
				</view>
				<view class="content-title">
					<view class="title">
						{{item.store_name}}
					</view>
					<view class="text">
						黑道研究会 发行
					</view>
					<view class="text">
						发行数量: {{item.stock}}份
					</view>
					<view class="text">
						开售时间: {{item.cmy_pay_time}}
					</view>
				</view>
			</view>
			<!-- <view class="box-content">
				<view class="img">
					<image src="../../static/index/nvwang.png" mode=""></image>
				</view>
				<view class="content-title">
					<view class="">
						黑道女王
					</view>
					<view class="text">
						黑道研究会 发行
					</view>
					<view class="text">
						发行数量: 14521份
					</view>
				</view>
			</view> -->
		</view>
		<view class="btm" style="height: 44px;"></view>
		<!-- 客服 -->
		<!-- <uni-popup ref="popupkf" type="center">
			<view class="popup-box">
				<view class="img"><image src="../../static/img/img009.png" mode=""></image></view>
				<view class="mian">
					<view class="delivery">
						<view class="title">已经为您定制专属客服</view>
						<image src="../../static/img/img010.png" mode=""></image>
					</view>
					<view class="nocancel">客服VX:{{ text }}</view>
					<view class="comfirm-box">
						<view class="cancel" @click="kfClose()">取消</view>
						<view class="comfirm" @click="comfirm(text)">复制微信</view>
					</view>
				</view>
			</view>
		</uni-popup> -->

	</view>
</template>

<script>
	import {
		getBargainList,
		getProducts
	} from '@/api/product.js';
	// import {mapState} from 'vuex'
	import {
		loadIndexs
	} from '@/api/index.js'
	import {
		mapState,
		mapMutations
	} from 'vuex';
	// #ifdef H5
	import {
		weixindata,
		shareLoad
	} from '@/utils/wxAuthorized';
	// #endif
	export default {
		data() {
			return {
				isSc: 2,
				text: '',
				checkid: 0,
				titleNViewBackground: '',
				longitude: 0, //经度
				latitude: 0, //纬度
				swiperCurrent: 0,
				swiperLength: 0,
				carouselList: [], //轮播列表
				bastList: [], //会员礼包
				integralList: [], //兑换专区
				list: [], //卡片信息
				page: 1,
				limit: 10,
				loadType: 'more',
				text: [],
				article: []
			};
		},
		computed: {
			...mapState(['loginInterceptor', 'baseURL']),
			...mapState('user', ['hasLogin', 'userInfo'])
		},
		onLoad: function(option) {
				this.loadIndex()
				this.getProduct()
		},
		onShow: function() {
			if (this.hasLogin) {
				this.loadIndex()
				this.getProduct()
			}
		},
		// onReachBottom() {
		// 	this.getproducts();
		// },
		methods: {
			...mapMutations(['setLat', 'setLon']),
			loadIndex() {
				let obj = this
				loadIndexs().then(res => {
					// console.log(res, 'res');
					obj.carouselList = res.data.banner
					// console.log(res,'res');
					// obj.list = res.data.info.fastList

				})
			},
			getProduct() {
				let obj = this
				getProducts().then(res => {
					// obj.carouselList = res.data.banner
					// console.log(res, 'res');
					obj.list = res.data.map((e) => {
						let time = new Date(e.sell_time * 1000);
						e.cmy_pay_time = time.getFullYear() + '年' + (time.getMonth() + 1) + '月' + time
							.getDate() + '日' + time.getHours() + '时' + time.getMinutes() + '分' + time
							.getSeconds() + '秒'
						return e
					})

				})
			},
			buy(item) {
				console.log(item, 'res');
				uni.navigateTo({
					url: '/pages/product/product?id=' + item.id + '&isSc=' + this.isSc
				})
			},
			navTo(url) {
				uni.switchTab({
					url
				})
			},
			// 點擊搜索框
			clickSearch() {
				uni.navigateTo({
					url: '/pages/product/search'
				});
			},
			swiperChange() {}



		}
	};
</script>

<style lang="scss">
	page {
		width: 750rpx;
		height: 100%;
		background: #111111;
	}
	.carousel {
		width: 750rpx;
		height: 375rpx;
		.carousel-item {
			height:100%;
			width:100%;
			.img{
				height:100%;
				width:100%;
			}
		}
	}

	.top {
		position: relative;
		width: 100%;

		.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: #191919;

				// 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: #a4a4a4;
				}
			}
		}
	}

	.box {
		padding: 30rpx;

		.box-title {
			margin-top: 20rpx;
			display: flex;
			justify-content: space-between;

			.left {
				font-size: 38rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #FFFFFF;
				line-height: 120rpx;
			}

			.right {

				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				line-height: 120rpx;
			}

		}

		.box-content {
			margin: 50rpx 0;

			.img {
				width: 690rpx;
				height: 690rpx;

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

			.content-title {
				margin-top: -10rpx;
				padding: 30rpx 20rpx;

				border-bottom-left-radius: 10rpx;
				border-bottom-right-radius: 10rpx;
				border: 2rpx solid #533A6A;
				// box-shadow: 0px 0px 20rpx 0px rgba(79,59,103,0.0600);

				.title {
					font-size: 39rpx;
					font-weight: bold;
					color: #FFFFFF;
					margin-bottom: 20rpx;

				}

				.text {
					margin: 10rpx 0;
					color: #FFFFFF;
					font-size: 28rpx;
				}
			}
		}
	}

	.popup-box {
		width: 522rpx;
		height: 605rpx;
		background-color: #ffffff;
		border-radius: 20rpx;
		position: relative;

		.img {
			position: relative;
			top: -56rpx;
			left: 0;
			width: 522rpx;
			height: 132rpx;
			display: flex;
			justify-content: center;

			image {
				border-radius: 20rpx 20rpx 0 0;
				width: 450rpx;
				height: 132rpx;
			}
		}

		.mian {
			margin-top: -44rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			// padding: 32rpx 32rpx;
			background-color: #ffffff;
			border-radius: 0 0 20rpx 20rpx;
			text-align: center;

			.delivery {
				font-size: 40rpx;
				color: #333333;
				display: flex;
				align-items: center;
				flex-direction: column;

				.title {}

				image {
					margin-top: 48rpx;
					width: 172rpx;
					height: 160rpx;
				}
			}

			.nocancel {
				font-size: 32rpx;
				color: #333333;
				margin-top: 14rpx;
			}

			.comfirm-box {
				margin-top: 52rpx;
				display: flex;
				// margin-bottom: 32rpx;

				// justify-content: space-around;
				.cancel {
					display: flex;
					align-items: center;
					justify-content: center;
					width: 197rpx;
					height: 74rpx;
					border: 1px solid #dcc786;
					border-radius: 38rpx;

					font-size: 32rpx;
					color: #605128;
				}

				.comfirm {
					margin-left: 32rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					width: 197rpx;
					height: 74rpx;
					background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
					border-radius: 38px;
					font-size: 32rpx;
					color: #605128;
				}
			}
		}
	}

	.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%;
			}
		}
	}
</style>
