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

$receive.on('touchend',function(){console.log('s');
    $.ajax({
        url:'/coupon/receiveCoupon',
        dataType:'json',
        success:function(data){
            if (data['noLogin'] === true) {
                var msg=data.msg;
                var status=data.status;
                if(!status){
                    $tooltip.show();
                    $right.css({"background":"url('http://static.dev.yohobuy.com/img/test/received.png')","background-repeat:":"no-repeat","background-size":"100%"});
                    setTimeout(function(){
                        $tooltip.hide();
                    },3000);
                }else{
                    $message.find('.coupon-message-content').text(msg);
                    $mask.show();
                    $message.show();
                }
            }else{
                location.href = data['url'];
            }
        },
        error:function(){}
    });
});