<template>
	<view class="cotainer">
		<!-- #ifdef MP-WEIXIN -->
		<privacy-popup ref="privacyComponent" @agree-privacy="onAgreePrivacy"
			@reject-privacy="onRejectPrivacy"></privacy-popup>
		<!-- #endif -->

		<view>
			<view class="myswiper">
				<u-swiper mode="none" border-radius="0" :list="list" height="440"></u-swiper>
			</view>
			<view class="tags">
				<view v-for="item in tags">
					<image src="../../static/index_tag.png" alt="" />
					<text>{{item}}</text>
				</view>
			</view>
			<view class="menu">
				<view class="menu-left">
					<view @click="toUrl(1)">
						<image src="../../static/index_icon4.png"></image>
						<view>
							<view>进入兑换</view>
							<view>JIN RU DUI HUAN</view>
						</view>
						<view class="menu-btn">
							<view>GO</view>
							<u-icon name="arrow-right" size="18"></u-icon>
						</view>
					</view>

				</view>
				<view class="menu-right">
					<view class="menu-right-top">
						<view>
							<image src="../../static/index_icon5.png"></image>
						</view>
						<view>
							<view>
								<view>商城入口</view>
								<view>SHANG CHENG RU KOU</view>
							</view>
							<view class="menu-btn">
								<view>GO</view>
								<u-icon name="arrow-right" size="18"></u-icon>
							</view>
						</view>
					</view>
					<view class="menu-right-bottom">
						<view @click="toUrl(2)">
							<view>
								<image src="../../static/index_icon6.png" mode=""></image>
							</view>
							<view>更改预约</view>
						</view>
						<view @click="toUrl(3)">
							<view>
								<image src="../../static/index_icon7.png" mode=""></image>
							</view>
							<view>物流查询</view>
						</view>
					</view>
				</view>
				<!-- <view>进入兑换</view>
				<view >更改预约</view>
				<view class="width100" >物流查询</view>
				<view @click="toUrl(4)">线下商品</view>
				<view @click="toUrl(5)">生鲜商品</view> -->
			</view>
			<view class="contact"  @click="toUrl(4)">
				<image src="../../static/index_icon8.png"></image>
				<view>
					<view>蟹太太官方旗舰店</view>
					<view>
						<view>点击咨询领百元新人券</view>
						<image src="../../static/index_icon9.png" mode=""></image>
					</view>
					<view class="contact-btn">
						<view>
							专属管家
							<u-icon name="arrow-right" size="23"></u-icon>
						</view>
					</view>
				</view>
			</view>
			<view class="ad">
				<image src="../../static/index_title.png"></image>
				<view class="ad-wrap">
					<view>
						<image class="img1" src="../../static/index_img1.png" mode=""></image>
					</view>
					<view>
						<image class="img2" src="../../static/index_img2.png" mode=""></image>
						<image class="img3" src="../../static/index_img3.png" mode=""></image>
					</view>
				</view>
			</view>
		</view>
		<tabbar :currentPage="0"></tabbar>
	</view>
</template>

<script>
	import PrivacyPopup from '@/components/privacy-popup/privacy-popup.vue';
	import tabbar from '@/components/tabbar/tabbar.vue';
	import {
		isNull
	} from '@/common/util.js'
	export default {
		components: {
			PrivacyPopup,
			tabbar
		},
		data() {
			return {
				list: [{
					image: require("@/static/index_banner.png")
				}],
				tags: ['品牌自营', '品质保障', '顺丰包邮', '售后无忧']

			}
		},
		onShareAppMessage() {
			// return shareInfo
		},
		onShareTimeline() {
			// return shareInfo
		},
		onLoad(option) {
			if (isNull(this.vuex_token)) {
				this.getToken()
			}
		},
		onShow() {

		},
		onHide() {

		},
		methods: {
			onAgreePrivacy() {
				// 用户同意隐私政策
				// 在这里添加您想要执行的代码
				console.log('User agreed to the privacy policy');
				// this.getToken()
			},
			onRejectPrivacy() {
				// 用户拒绝隐私政策
				// 在这里添加您想要执行的代码
				console.log('User rejected the privacy policy');
			},
			async getToken() {
				await uni.login({
					provider: 'weixin',
					success: (res) => {
						this.$u.api.login({
							code: res.code
						}).then(res => {
							this.$u.vuex('vuex_token', res.token)
							this.$u.api.user().then(res => {
								this.$u.vuex('vuex_user', res)
							})
						}).catch(err => {
							console.log('login-error:', JSON.stringify(err))
						})
					},
					fail: (res) => {
						console.log("errtoken", JSON.stringify(res))
					}
				});
			},
			toUrl(index) {
				var url = ''
				console.log("index",index)
				if (index == 1) {
					url = '/pages/change/change'
				} else if (index == 2) {
					url = '/packages/card/index'
				} else if (index == 3) {
					url = '/packages/myorder/myorder'
				} else if (index == 4) {
					url = '/packages/product/public'
				} else if (index == 5) {
					url = '/packages/product/fresh'
				}
				
				if (!isNull(url)) {
					uni.navigateTo({
						url: url
					})
				}

			},

		}
	}
</script>

<style lang="scss">
	.cotainer {
		background-color: #f0efed;
		height: 100vh;
		width: 100vw;
		overflow: scroll;
		padding-bottom:160rpx;
		.myswiper {
			// padding: 40rpx;
		}

		.tags {
			display: flex;
			align-items: center;
			justify-content: space-around;
			padding: 20rpx 0;

			>view {
				width: 25%;
				display: flex;
				align-items: center;
				justify-content: center;

				image {
					width: 30rpx;
					height: 30rpx;
					margin-right: 8rpx;
				}

				text {
					color: #323232;
					font-size: 25rpx;
				}
			}
		}

		.menu {
			// padding: 30rpx;
			display: flex;
			flex-wrap: wrap;
			align-items: center;
			background-color: #fff;
			width: 100%;
			height: 380rpx;
			box-shadow: inset 0px 15px 15px -15px #dddddd, inset 0px -15px 15px -15px #dddddd;

			padding: 20rpx 35rpx;
			padding-left: 0;

			>view {
				height: 330rpx;
			}

			&-left {
				width: 45%;
				display: flex;
				align-items: center;
				flex-wrap: wrap;
				border-right: 1px solid #7a7a7a;
				padding: 0 35rpx;

				image {
					width: 81rpx;
					height: 80rpx;
				}

				>view {
					width: 100%;
					text-align: center;

					>view {
						margin-top: 20rpx;
						font-size: 28rpx;
						color: #323232;

						:last-child {
							font-size: 17rpx;
						}
					}

				}
			}

			&-right {
				width: calc(55% - 35rpx);
				margin-left: 35rpx;

				>view {
					height: 50%;
				}

				&-top {
					display: flex;
					align-items: center;
					border-bottom: 1px solid #7a7a7a;

					>view {
						width: 55%;
						text-align: center;
						font-size: 28rpx;

						image {
							width: 82rpx;
							height: 81rpx;
						}

						>view {
							:last-child {
								font-size: 17rpx;
							}
						}
					}

					>view {
						&:first-child {
							width: 45%;
						}
					}

				}

				&-bottom {
					display: flex;
					align-items: center;
					justify-content: space-between;
					font-size: 28rpx;
					color: #323232;
					margin-top: 20rpx;
					height: calc(50% - 20rpx) !important;

					>view {
						width: 50%;
						height: 100%;
						text-align: center;
						display: flex;
						flex-wrap: wrap;
						align-items: center;

						>view {
							width: 100%;
							text-align: center;


							&:first-child {
								height: 71rpx;
								line-height: 71rpx;
								margin-bottom: -20rpx;
							}
						}

						&:first-child {
							border-right: 1px solid #7a7a7a;

							image {
								width: 77rpx;
								height: 71rpx;
							}
						}

						&:last-child {
							image {
								width: 78rpx;
								height: 59rpx;
								vertical-align: middle;
							}
						}
					}
				}
			}

			&-btn {
				background-color: #000;
				color: #fff !important;
				border-radius: 20rpx;
				display: inline-block;
				padding: 0 10rpx;
				// line-height: 40rpx;
				// height: 40rpx;
				text-align: center;
				margin-top: 20rpx;
				font-size: 0 !important;

				view {
					font-size: 20rpx;
					display: inline-block;
				}
			}
		}

		.contact {
			width: 100%;
			position: relative;
			font-size: 30rpx;
			color: #f6d9b6;
			height: 242rpx;

			>image {
				width: 708rpx;
				height: 223rpx;
				// margin:20rpx auto;
				position: absolute;
				top: 21rpx;
				left: 21rpx;
			}

			>view {
				position: absolute;
				z-index: 9;
				top: 50rpx;
				left: 60rpx;

				>view {
					display: flex;
					align-items: center;
					margin-bottom: 15rpx;

					&:first-child {
						color: #fff;
						font-size: 20rpx;
					}
				}

				image {
					width: 35rpx;
					height: 26rpx;
					margin-left: 10rpx;
				}

			}

			&-btn {
				font-size: 24rpx;
				border: 1px solid #f6d9b6;
				border-radius: 50rpx;
				width: 50%;
				text-align: center;
				/* justify-content: space-around; */
				padding: 10rpx;
				justify-content: center;
			}

		}

		.ad {
			padding: 0 35rpx;

			>image {
				width: 212rpx;
				height: 81rpx;
				margin-bottom: 10rpx;
			}

			&-wrap {
				display: flex;
				justify-content: space-between;

				view {
					&:last-child {
						width: 261rpx;
					}
				}
			}

			.img1 {
				width: 407rpx;
				height: 271rpx;
			}

			.img2 {
				width: 261rpx;
				height: 132rpx;
			}

			.img3 {
				width: 261rpx;
				height: 132rpx;
			}
		}
	}
</style>