```javascript=
{
key: 'grabCoupon',
value: function grabCoupon(tag) {
var self = this;
$('.J_couponArea').on('click', function(e) {
e.preventDefault();
var $this = $(this);
var $btnCoupon = $this.find('.J_couponBtn');
var couponId = $this.attr('data-coupon-id');
if ($this.attr('disabled')) {
return false;
}
if (gIsLoginMi()) {
$.ajax({
url: self.dataUrl.getCoupon,
type: 'GET',
xhrFields: {
withCredentials: true
},
data: {
tag: self.tag,
present_id: couponId
},
success: function success(res) {
if (res.code == 0 && (res.data. == 1 || res.data.present_type == 6) && res.data.present_id == couponId) {
$this.attr('disabled', 'disabled');
window.location.reload();
} else if (res.code == -2) {
gLogin(window.location.href);
} else if (res.code == 10027) {
// 認為沒有券了.
$this.attr('disabled', 'disabled');
$btnCoupon.text(_couponText['couponAllGone']);
} else {
// 認為沒有券了.
$this.attr('disabled', 'disabled');
$btnCoupon.text(_couponText['couponAllGone']);
if (GLOBAL_CONFIG.clientType == 'pc') {
alert(_couponText['couponFail']);
} else {
winTips({
msg: _couponText['couponFail']
});
}
}
}
});
} else {
gLogin(window.location.href);
}
});
}
```