<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telphone=no, email=no" />
		<title>Aiberle爱贝源</title>
		<link rel="stylesheet" type="text/css" href="css/mui.min.css" />
		<link rel="stylesheet" type="text/css" href="css/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="css/main.css" />
		<style>
			.back{background: url(images/ia_air_purifier_back.jpg);background-size: 100%; background-repeat:no-repeat;}
		</style>
	</head>
	
	<body>
		<!-- <div class="back" style="width: 100%; height: 100%;">
			<div style="height: 107px;"></div>
			<div class="receive"><img src="images/ia_air_receive.png" alt="" style="width: 66%;display: block;margin-left: 19%;margin-top: 20px;margin-bottom: 35px;"></div>
			<div class="product_to"><img src="images/ia_air_purifier_product.jpg" alt="" style="width: 66%;display: block;margin-left: 18%;    margin-bottom: 85px;"></div>
		</div> -->
		
		<script src="js/mui.min.js"></script>
		<script src="js/jquery-2.1.1.min.js"></script>
		<script src="js/jquery.autocompleter.js"></script>
		<script src="js/main.js"></script>
	</body>
	<script>
		mui.ready(function() {
			$.ajax(base_path + '/wechat/getUserInfo?dates=' + new Date().getTime(), {
				dataType: 'json',
				type: 'post',
				timeout: 15000,
				xhrFields: {
					withCredentials: true
				},
				crossDomain: true,
				success: function(dt) {
					if(dt.isRedirect) {
						location.href = dt.redirectURL;
					} else {
						receiveCoupon();
						console.log("用户信息刷新成功或今日已经刷新");
					}
				},
				error: function(xhr, type, errorThrown) {
					console.log(xhr)
				}
			});
		});
		
		function receiveCoupon(){
			$.ajax(base_path + '/wechat/coupon/receive_coupon_end?dates=' + new Date().getTime(), {
				data: {
					"couponId": 50001
				},
				dataType: 'json',
				xhrFields: {
					withCredentials: true
				},
				crossDomain: true,
				type: 'post',
				timeout: 15000,
				success: function(dt) {
					if(dt.isRedirect) {
						location.href = dt.redirectURL;
					} else {
						// if(dt.status) {
						// 	mui.toast(dt.message);
						// } else {
						// 	mui.toast(dt.message);
						// }
						mui.openWindow({
							url: 'pro-details.html?productId=53'
						});
						// mui.alert(dt.message, function() {
						// });
					}
				},
				error: function(xhr, type, errorThrown) {
					console.log(xhr);
					mui.alert("领取失败!网络出小差了", function() {
					});
				}
			});
		}
		
		$(document).on('tap', '.product_to', function() {
			mui.openWindow({
				url: 'pro-details.html?productId=53'
			});
		});
	</script>

</html>