message-content.js 693 Bytes
/**
 * 我的信息
 * @author: yyqing<yanqing.yang@yoho.cn>
 * @date: 2016/3/25
 */
var $ = require('yoho.jquery');

var $pickBtn = $('.pick-coupon-btn');

var pickBusy = false;

$pickBtn.click(function() {
    var data = $(this).data();

    if (pickBusy) {
        return;
    }
    pickBusy = true;
    $.ajax({
        type: 'GET',
        url: '/home/message/pickCoupon',
        data: data
    }).then(function(jsonData) {
        var msg = jsonData.message;

        if (jsonData.code === 200) {
            msg = '领取成功';
            $(this).removeClass('pick-coupon-btn');
        }

        pickBusy = false;

        alert(msg);
    });
});