message-detail.js 923 Bytes
var $ = require('jquery'),
    dialog = require('./dialog');

var $page = $('.massage-page');

var pickBusy = false;


// 领取生日券
$page.on('touchstart', '.pick-coupon-btn', function() {
    if (pickBusy) {
        return;
    }
    pickBusy = true;

    var $id = $(this).data('id');

    $.ajax({
        type: 'POST',
        url: '/home/pickCoupon',
        data: {
            id: $id
        },
        success: function(data) {
            if (data.code === 200) {
                dialog.showDialog({
                    dialogText: '领取成功',
                    autoHide: 2000,
                    fast: true
                });
                $(this).removeClass('pick-coupon-btn');
            }

            pickBusy = false;

            dialog.showDialog({
                dialogText: data.message,
                autoHide: 2000,
                fast: true
            });
        }
    });
});