sMSindex.html 7.79 KB
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<link rel="stylesheet" type="text/css" th:href="@{/static/css/sMSindex.css}" />
	<script type="text/javascript" th:src="@{/static/js/sMSrem.js}" charset="utf-8"></script>
	<script type="text/javascript" th:src="@{/static/js/time.js}"></script>
	<script src="https://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
	<title></title>
</head>

<body>
<div class="layout">
	<div class="bg">
		<h1 th:utext="${activityName}">活动名称</h1>
		<div class="coupon-box">
			<div class="coupon-box-title">专属福利</div>
			<div class="coupon" th:each="coupon:${couponList}">
				<div class="verificationCode" th:utext="${coupon.verificationCode}"></div>
				<div class="left">
					<div th:if="${coupon.discountType == 4}" class="discountType4" >
						实物券
					</div>
					<div th:if="${coupon.discountType != 4}" class="discountType123">
						<div class="unit">
							<span th:if="${coupon.discountType != 2}" style="font-size:0.12rem;">¥</span><span th:utext="${coupon.denomination}" th:if="${coupon.discountType != 2}" style="font-size:0.2rem;">8.8</span>
							<span th:utext="${coupon.denomination}" th:if="${coupon.discountType == 2}">8.8</span><span th:if="${coupon.discountType == 2}">折</span>
						</div>
						<div class="discountName" th:utext="${coupon.discountType == 1 ? '满减券': coupon.discountType == 2 ? '折扣券' :'通用券'}"></div>
					</div>
				</div>
				<div class="right">
					<div class="coupon-name text-ellipsis" th:utext="${coupon.couponName}">优惠卷名称</div>
					<div class="tips text-ellipsis" th:if="${coupon.useBarriers != 1}" th:utext="${'满'+coupon.full+'可用'}">仅限XXXX使用</div>
					<div class="tips" th:if="${coupon.useBarriers == 1}">无限制</div>
					<div class="time text-ellipsis" th:if="${coupon.effectiveType == 1&&coupon.verificationStatus == 2}" th:utext="${'有效期:'+ coupon.receiveTime+'-'+coupon.receiveEndTime}"></div>
					<div class='time text-ellipsis' th:if="${coupon.verificationStatus != 2&&coupon.effectiveType == 1}" th:utext="${'领取后'+ coupon.effectiveDays +'天有效'}"></div>
					<div class="time text-ellipsis f-12" th:if="${coupon.effectiveType == 2}">有效期:<span th:utext="${coupon.effectiveStartTime+'-'+coupon.effectiveEndTime}"></span></div>
				</div>
				<div class="goUse"> 
					去使用
				</div>
			</div>
			<div class="coupon-btn">
				免费领取
			</div>
			<div class='coupon-tips'></div>
		</div>
		<div class="activity-box">
			<div class="activity-title">活动时间</div>
			<div class="activity-time" th:utext="${activityStartTime+'-'+activityEndTime}">2019年3月18日-4月18日</div>
			<div class="activity-title">活动规则</div>
			<!-- <textarea class="textarea" id="textarea" readonly="readonly" th:utext="${activityRule}"></textarea> -->
			<div id='textarea'></div>
			<div class="merchant-box">
				<div class="activity-title">适用门店</div>
				<div class="user">
					<img th:src="@{/static/images/test.png}" th:utext="${merchantName}"/>
				</div>
				<p th:utext="${bussinessAddress}"></p>
				<p>营业时间:<span th:utext="${bussinessHours}"></span></p>
				<p >联系电话:<span th:utext="${bussinessPhone}"></span></p>
			</div>
		</div>
		
	</div>

</div>

<!--领取成功弹框-->
<div class="succeed">
	<img th:src="@{/static/images/succeed.png}" />
	<p>领取成功</p>
</div>
</body>
<script th:inline="javascript">
    $(function() {
        rem(window, {
            designWidth: 750,
            designHeight: 667,
            designFontSize: 200
        });
				var couponList = [[${couponList}]];
				var bgId = [[${bgmUrl}]]
				var activityRule = [[${activityRule}]]
        var receiveCode = [[${couponList.get(0).receiveCode}]];
				var saleStatus = [[${saleStatus}]]
				var activityTimeOut = [[${activityTimeOut}]]
				var receiveStatus = [[${receiveStatus}]]
				console.log(saleStatus,activityTimeOut)
				
				var bgUrl = ['default', 'spring', 'summer', 'autumn', 'winter']
				$('html').addClass(bgUrl[bgId - 1])
				if(bgId == 2){
					$('h1').attr('style', 'color:#169D2E');
				}else if(bgId == 3){
					$('h1').attr('style', 'color:#FF691C');
				}else if(bgId == 4){
					$('h1').attr('style', 'color:#CC6800');
				}else{
					$('h1').attr('style', 'color:#FFFFFF');
				}
				// 点击之后返回优惠券信息
				$('.coupon-btn').click(function(){
            $('.succeed').show();
            $(this).hide();
						var tempRes;
						$('.coupon').addClass('receive')
						$('.goUse').show()
						$('.goUse').click(function(){
							showVerificationCode($(this))
						})
           $.ajax({
                type:"GET",
                data:{code: receiveCode},
                url:"code",
                success:function(res){
                    console.log(res);
                    tempRes = res;
                    for(var i in res){
                    	console.log(res[i]);
                    	 var text = "有效期:" + res[i].effectiveStartTime + '-' + res[i].effectiveEndTime;
                        $("#sID1"+res[i].id).text(text);
                        $("#sID2"+res[i].id).text(text);
                        $("#codeIDS"+res[i].id).text(res.verificationCode); 
                    }
                }
            });
            setTimeout(function(){
                $('.succeed').hide();
                for(var i in tempRes){
                	$('#succeed1'+tempRes[i].id).show();
                }
            },1500)
        });
				if(saleStatus ==  'f' || activityTimeOut == '1') {
					$('.coupon-btn').hide()
					var text =  activityTimeOut == '1'? '活动已过期' : '活动已下架'
					$('.coupon-tips').text(text).show()
					$('.coupon').addClass('lose')
				} else {
					if(receiveStatus != '1'){
						for(var i = 0; i < couponList.length; i++) {
							$('.coupon-btn').hide()
							$('.coupon').addClass('receive')
							$('.goUse').show()
							$('.goUse').click(function(){
								showVerificationCode($(this))
							})
						}
					}
				}
				
				
        // 设置textarea 自适应高度
        function makeExpandingArea(el) {
            var timer = null;
            //由于ie8有溢出堆栈问题,故调整了这里
            var setStyle = function(el, auto) {
                if (auto) el.style.height = 'auto';
                el.style.height = el.scrollHeight + 'px';
            }
            var delayedResize = function(el) {
                if (timer) {
                    clearTimeout(timer);
                    timer = null;
                }
                timer = setTimeout(function() {
                    setStyle(el)
                }, 200);
            }
            if (el.addEventListener) {
                el.addEventListener('input', function() {
                    setStyle(el, 1);
                }, false);
                setStyle(el)
            } else if (el.attachEvent) {
                el.attachEvent('onpropertychange', function() {
                    setStyle(el)
                })
                setStyle(el)
            }
            if (window.VBArray && window.addEventListener) { //IE9
                el.attachEvent("onkeydown", function() {
                    var key = window.event.keyCode;
                    if (key == 8 || key == 46) delayedResize(el);

                });
                el.attachEvent("oncut", function() {
                    delayedResize(el);
                }); //处理粘贴
            }
				}
				function showVerificationCode(that){
					that.siblings('.verificationCode').show()
				}
				var text = [[${activityRule}]]
				var arr = text.split('\n')
				for(var i = 0; i < arr.length; i++){
					$('#textarea').append('<div>'+ arr[i] +'<div>')
				}
    })
</script>
</html>