coupon.js 1.17 KB
/**
 * Created by Administrator on 2016/4/13.
 */
var $ = require('jquery');
var $receive = $('.main-right-receive');
var $mask = $('.floor-mask');
var $message = $('.floor-message');
var $tooltip = $('.floor-tooltip');

$receive.on('touchend',function(){
    var curDom=$(this);
    $.ajax({
        url:'/coupon/receiveCoupon',
        dataType:'json',
        success:function(data){
            if (data['noLogin'] === true) {
                var msg=data.msg;
                var status=data.status;
                if(!status){
                    curDom.hide();
                    curDom.next().show();
                    $tooltip.show();
                    setTimeout(function(){
                        $tooltip.hide();
                    },3000);
                }else{
                    $message.find('.coupon-message-content').text(msg);
                    $mask.show();
                    $message.show();
                }
            }else{
                location.href = data['url'];
            }
        },
        error:function(){}
    });
});

$('.coupon-floor a').on('click', function () {
    if($(this).attr('href').length <= 0) {
        return false;
    }
})