|
|
|
|
|
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');
|
|
|
|
|
|
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');
|
|
|
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
$.yAlert(result.data.message);
|
|
|
changeStatus(result.data.result);
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
...
|
...
|
|