test.phtml 1.18 KB
{{> layout/header}}
{{# floor}}
{{#if isCoupon}}
{{# list}}
{{#if isGet}}
<div>{{status}}</div>
{{/if}}
{{#if isZero}}
<div>{{status}}</div>
{{/if}}
{{#if isGeted}}
<div>{{status}}</div>
{{/if}}
{{/list}}
{{/if}}
{{#if isCarouselBanner}}
{{# list}}
<div>isCarouselBanner</div>
{{/list}}
{{/if}}
{{/ floor}}

<input type="hidden" id="couponId"/>
<button onclick="receiveCoupon()">领券</button>
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="application/javascript">
    function receiveCoupon() {
        // 获取当前 URL
        var referrer = window.location.pathname;
        $.ajax({
            method: 'GET',
            url: 'http://m.dev.yohobuy.com/coupon/receiveCoupon',
            data: {
                couponID: 2516
            },
            dataType: 'json',
            success: function (returnData) {
                if (returnData['noLogin'] === true) {
                    window.location.href = returnData['url'];
                } else {
                    alert(returnData);
                }
            },
            error: function (e) {
                alert(e);
            }
        });
    }
</script>
{{> layout/footer}}