<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>更换刷头提示</title>
		<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">
		<link rel="stylesheet" type="text/css" href="//css.iamberry.com/tooth/css/mui.min.css?v=2017101701" />
		<link rel="stylesheet" type="text/css" href="//css.iamberry.com/tooth/css/iconfont.css?v=2017101701" />
		<link rel="stylesheet" type="text/css" href="//css.iamberry.com/tooth/css/style.css?v=2017101701" />
		<style>
			.yuan{width: 100px;height: 100px;margin: 50px auto;border-radius: 50%;border:3px solid #a6e7fe;line-height: 100px;position: relative;color: #3ba7c9;}
			.yuan:before{content: '';position: absolute;width: 1px;height: 30px;left: 50%;top: -40px;background-color: rgba(0,0,0,.1);}
			.yuan:after{content: '';position: absolute;width: 1px;height: 30px;left: 50%;bottom: -40px;background-color: rgba(0,0,0,.1);}
			.price{position: relative;font-size: 50px;color: #54c0dc;padding-left: 5px;height: 70px;}
			.price:after{content: '¥';position: absolute;left: 0;top:30px;color: #54c0dc;font-size: 16px;}
			.btn-send{width: 70px;height: 70px;position: absolute;right: 18px;top: 50%;-webkit-transform: translateY(-50%);transform: translateY(-50%);border-radius: 50%;color:#54c0dc;background-color: #fff;line-height: 70px;}
			.content1{position: absolute;left: 120px;top: 50%;-webkit-transform: translateY(-50%);transform: translateY(-50%); color: #54c0dc;text-align: left;}
			.couponbox{padding: 0 10px;position: relative;margin: 15px 0;display: none;}
			.mui-popup.mui-popup-in{height: 360px;background: url(http://static.iamberry.com/images/shop/yhq_dlg_bg.png) center top /100% no-repeat;}
			.mui-popup-inner{background-color: transparent;margin-top: 80px;padding: 15px 15px 5px 15px;position: static;}
			.mui-popup-title{font-size: 16px;color: #939393;}
			.mui-popup-title+.mui-popup-text{margin-top: 15px;}
			.mui-popup-text strong{color: #fc5b8b;font-size:20px;}
			.mui-popup-text span{color: #fc5b8b;font-size: 30px;}
			.mui-popup-button{background-color: transparent;}
			.mui-popup-button:after,.mui-popup-inner:after{display: none;}
			.mui-popup-button:last-child{border-radius: 25px;background: #f44f80;height: 38px;line-height: 40px;font-weight: 100;color: #fff;width: 50%;margin: 10px auto;}
			.mui-popup-button:last-child:active{background: #fc5b8b;}
			.mui-popup-button:first-child{border-radius: 25px;background: #fff;height: 38px;line-height: 40px;font-weight: 100;color:#ed376c;width: 50%;margin: 10px auto;border:1px solid #ed376c}
			.mui-popup-button:first-child:active{background: #c9c9c9;}
			.mui-popup-buttons{display: block;}
			.x-close{position: absolute;right:32px;top: 0;width:20px;}
			.mui-popup.mui-popup-out{-webkit-transition-duration: 0ms;transition-duration: 0ms;}
			.no_yhq{text-align: center;position:absolute;left:0;top:50%;width:100%;display: none;-webkit-transform: translateY(-70%);transform: translateY(-70%);}
			.no_yhq img{width:33%;}
		</style>
		<script type="text/javascript">
            // 屏蔽分享
            window.hiddenAllWechatMenu = true;
		</script>
	</head>
	<body style="background: #fff;">
	<div class="loading-bg">
			<div class="mui-loading">
				<div class="mui-spinner">
				</div>
				&nbsp;&nbsp;加载中...
			</div>
	</div>
	<div class="mui-content" style="background: #fff;">
		<div style="height: 200px; background:-webkit-gradient(linear, 0 0, 0 bottom, from(#34a3c5), to(#75cbe8));">
			<div style="width: 100px;margin: 0 auto;padding: 20px 0 15px 0;">
				<img width="100px" src="/tooth/common/shop/images/tx-4.png" />
			</div>
			<div style="color: #fff;text-align: center;">
				亲,您的牙刷刷头已经使用3个月 <br/>定期更换刷头,可有效防止细菌滋生
			</div>
		</div>
		<div class="mui-text-center" style="padding: 10px 0;">
			<h5 id="hintCreateTime">1900-01-01</h5>
			<div>开始使用</div>
			<div class="yuan">
				三个月
			</div>
			<h5 id="hintTime">1900-01-01</h5>
			<div>需要更换</div>
			<div class="couponbox">
				<img width="100%" src="/tooth/common/shop/images/quan-bg3.png" />
				<div style="position: absolute;left: 45px;top: 50%;-webkit-transform: translateY(-50%);"><span class="price">0</span></div>
				<div class="content1">
				<div>仅供购买刷头使用</div>
				<div style="font-size: 12px;">限量100份</div>
				</div>
				<div class="btn-send">立即领取</div>
			</div>
		</div>
	</div>
<script src="//s.iamberry.com/tooth/js/mui.min.js?v=2017101701"></script>
<script src="//s.iamberry.com/tooth/js/jquery-2.1.1.min.js"></script>
<script src="//s.iamberry.com/tooth/js/shop/main.js?v=2017101701"></script>
<!--<script src="//s.iamberry.com/tooth/js/shop/wechat-utils-1.0.js"></script>-->
<script type="text/javascript">
    var hintId=getParam("hintId");
    var couponTypeId='';
	mui.ready(function(){
        mui.ajax(base_path + '/agentTooth/select_order_hint?dates=' + new Date().getTime(), {
            data:{"hintId":hintId},
            dataType: 'json',
            type: 'post',
            timeout: 15000,
            success: function(dt) {
                //console.log(dt)
                if(dt.resultCode=="200") {
                    $("#hintCreateTime").text(formatDate(dt.data.hint.hintCreateTime));
                    $("#hintTime").text(formatDate(dt.data.hint.hintTime));
                    coupon(dt.data.couponTypeId);
                    couponTypeId=dt.data.couponTypeId;
                }else{
                    console.log("获取信息失败!");
				}
            },
            error: function(xhr, type, errorThrown) {
                errorfn(xhr)
            }
        });
		document.querySelector('.loading-bg').style.display='none';
	});
	function coupon(typeId){
        var btnArray = ['否', '是'];
        mui.ajax(base_path + '/coupon/couponTypeList', {
            data: {
                "typeId": typeId
            },
            dataType: 'json',
            type: 'post',
            timeout: 15000,
            success: function(dt) {
                //console.log(dt);
                if(dt.resultCode=="200") {
                    if(dt.data.typeList.length>0){
                    $(".price").text(accDiv(dt.data.typeList[0].couponReduce, 100));
                    /*$(".btn-send").attr("name",dt.data.typeList[0].couponId);*/
                    $(".couponbox").show();
                    }
                }
            },
            error: function(xhr, type, errorThrown) {
                console.log(xhr);
            }
        });
	}
	//领券
    $(document).on('tap','.btn-send',function(){
        if(couponTypeId!=''){
            mui.ajax(base_path + '/coupon/getCoupon', {
                data: {
                    "couponId": couponTypeId
                },
                dataType: 'json',
                type: 'post',
                timeout: 15000,
                success: function(dt) {
                    //console.log(dt);
                    if(dt.status) {
                        var btnArray = ['查看优惠券', '立 即 使 用'];
                        mui.confirm('<span>' + $(".price").text() + '元 </span>优惠券<img class="x-close" src="/tooth/common/shop/images/x.png" />', '恭喜您成功领取一张', btnArray, function(e) {
                            if(e.index == 1) {
                                location.href = base_path + '/wxCart/goProductList'
                            } else {
                                location.href = base_path + '/couponWechat/couponList'
                            }
                        })
                    } else {
                        var r = confirm(dt.message);
                        if(r == true) {
                            location.reload(true)
                        }
                    }
                },
                error: function(xhr, type, errorThrown) {
                    if(xhr.readyState == 4 && xhr.status == 200) {} else {
                        location.href = domanUrl + base_path + "/couponWechat/coupon?dates=" + new Date().getTime()
                    }
                }
            });
		}
	});
	</script>
	</body>
</html>