<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">$(function(){
    // ä¼˜æƒ&nbsp;åˆ¸
    $('.coupon-name').on('click',function(e){
        $('.coupon-down').show();
        // $('.coupon-down&gt;span').css({'right':'auto','left':'50px'});
    })
    $('.coupon-a').on('click',function(e){
        $('.coupon-down').show();
        // $('.coupon-down&gt;span').css({'right':'70px','left':'auto'});
    })
    $('.get-coupon-use').on('click',function(e){
        $('.coupon-down').show();
    })
    $('.close-coupon').on('click',function(e){
        $('.coupon-down').hide();
    })
    $('.couponList').find('.couponLi').each(function(i){
        var that=$(this);
        var type=$('.bottom_cou').eq(i).attr('data-type');
        var start_at=$('.bottom_cou').eq(i).attr('data-start');
        var end_at=$('.bottom_cou').eq(i).attr('data-end');
        var time=$('.bottom_cou').eq(i).attr('data-time');
        var show_time='';
        if(type==1){
            show_time=start_at.split(' ')[0]+' PT ~ '+end_at.split(' ')[0]+' PT';
        }else if(type==2){
            show_time=`Will expire in ${time} days`
        }else{
            // show_time='Valid forever';
            show_time='';
        }
        $('.bottom_cou').eq(i).text(show_time);
    });
    $('.couponLi-btn').on('click',function(e){
        var that=$(this);
        var id=that.attr('data-id');
        if(that.hasClass('get_btn')){//é¢†å–
            if(!$.cookie('Authorization')) {
                window.location.href = `/login?redirect=${window.location.pathname}`;
            }else{
                $.ajax({
                    type: "post",
                    data:{id:id},
                    url: window.Xdcommon.url+'/interface/coupon/get_coupon',
                    success: function(res) {
                        if(res.code == '200') {
                            var data=res.data;
                            // window.location.href = window.Xdcommon.url+window.location.pathname;
                            if(data.is_receive==0){
                                if(data.status==0){
                                    that.removeClass('get_btn');
                                    that.addClass('get_btn');
                                    that.text('Get');
                                    that.parents('.couponLi').find('img').attr('src','web/image/coupon/getted.png');
                                }else{
                                    that.removeClass('get_btn');
                                    that.addClass('get_no_btn');
                                    that.text('Get');
                                    that.parents('.couponLi').find('img').attr('src','web/image/coupon/used.png');
                                }
                            }else{
                                if(data.status==0){
                                    that.removeClass('get_btn');
                                    that.addClass('use_btn');
                                    that.text('Use');
                                    that.parents('.couponLi').find('img').attr('src','web/image/coupon/getted.png');
                                }else{
                                    that.removeClass('get_btn');
                                    that.addClass('get_no_btn');
                                    that.text('Use');
                                    that.parents('.couponLi').find('img').attr('src','web/image/coupon/used.png');
                                }
                            }
                            layer.msg('Received successfully', {time: 3000, icon:1});
                        }
                        else if(res.code == '401') {
                            window.location.href = `/login?redirect=${window.location.pathname}`
                        }
                        else {
                            layer.msg(res.message, {time: 3000, icon:2});
                        }
                    }
                });
            }
        }else if(that.hasClass('use_btn')){//ä½¿ç”¨
            location.href = '/';
        }else{
            layer.msg('Has been collected!', {time: 3000, icon:2});
        }
    })
});</pre></body></html>