|
|
|
|
|
import 'scss/activity/have-gain-promodetail.page.scss';
|
|
|
import $ from 'yoho-jquery';
|
|
|
import statusTpl from 'hbs/activity/have-gain/status.hbs';
|
|
|
require('js/plugin/modal.alert');
|
|
|
|
|
|
const $promoStatus = $('.promo-status.js-submit');
|
...
|
...
|
@@ -10,35 +9,52 @@ function joinActivity(id) { |
|
|
return $.post(`/activity/have-gain/promo/${id}`);
|
|
|
}
|
|
|
|
|
|
function changeStatus(status) {
|
|
|
$promoStatus.removeClass('promo-status_over').addClass('promo-status_submit')
|
|
|
.html(statusTpl({status}));
|
|
|
}
|
|
|
|
|
|
$promoStatus.on('click', function() {
|
|
|
const $this = $(this);
|
|
|
const url = $this.data('url');
|
|
|
const pid = $this.data('pid');
|
|
|
const status = parseInt($this.data('status'));
|
|
|
|
|
|
if ($this.hasClass('promo-status_over')) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (url) {
|
|
|
window.location.href = url;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (pid) {
|
|
|
joinActivity(pid).then(result => {
|
|
|
if (result.code !== 200) {
|
|
|
$.yAlert(result.data.message);
|
|
|
return;
|
|
|
switch (status) {
|
|
|
case 2: {
|
|
|
if (pid) {
|
|
|
joinActivity(pid).then(result => {
|
|
|
if (result.code == 400) {
|
|
|
window.location.href = result.redirect;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (result.code !== 200) {
|
|
|
$.yAlert(result.data.message);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (result.data.result === 1) {
|
|
|
$promoStatus
|
|
|
.text('报名成功,去分享活动商品')
|
|
|
.data('status', 3);
|
|
|
$.yAlert(result.data.message);
|
|
|
} else if (result.data.result === 3) {
|
|
|
$promoStatus
|
|
|
.text('不符合条件')
|
|
|
.removeClass('promo-status_submit')
|
|
|
.addClass('promo-status_over');
|
|
|
$.yAlert(result.data.message);
|
|
|
} else {
|
|
|
$.yAlert(result.data.message);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
$.yAlert(result.data.message);
|
|
|
changeStatus(result.data.result);
|
|
|
});
|
|
|
break;
|
|
|
}
|
|
|
case 3: {
|
|
|
window.location.href = url;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
...
|
...
|
|