Authored by htoooth

update status code

... ... @@ -122,7 +122,6 @@ module.exports = class extends global.yoho.BaseModel {
id: pid
}
}).then(result => {
if (result.code !== 200) {
return {
error: Error('出错了')
... ... @@ -130,11 +129,12 @@ module.exports = class extends global.yoho.BaseModel {
}
return {
status: uid ? result.data.status : 0,
status: result.data.status,
imageUrl: result.data.image,
content: result.data.content,
contentTitle: result.data.title,
url: result.data.url
url: result.data.url,
id: result.data.id
};
});
}
... ...
... ... @@ -8,24 +8,20 @@
<div class="promo-desc__content">{{{content}}}</div>
</div>
<div class="promo-status {{#isEqualOr status 0 1}} promo-status_submit {{else}} promo-status_over {{/isEqualOr}}js-submit" data-url="{{url}}" data-pid="{{id}}" data-status="{{status}}">
{{#isEqualOr status 0 1}}
点击确认参加活动
<div class="promo-status {{#isEqualOr status 2 3}} promo-status_submit {{else}} promo-status_over {{/isEqualOr}} js-submit" data-url="{{url}}" data-pid="{{id}}" data-status="{{status}}">
{{#isEqualOr status 1}}
活动未开始
{{/isEqualOr}}
{{#isEqualOr status 2}}
报名成功,去分享活动商品
点击确认参加活动
{{/isEqualOr}}
{{#isEqualOr status 3}}
不满足参加活动条件
报名成功,去分享活动商品
{{/isEqualOr}}
{{#isEqualOr status 4}}
活动未开始
{{/isEqualOr}}
{{#isEqualOr status 5}}
活动已结束,请关注其他活动
{{/isEqualOr}}
</div>
... ...
{{#isEqualOr status 0 1}}
点击确认参加活动
{{/isEqualOr}}
{{#isEqualOr status 2}}
报名成功,去分享活动商品
{{/isEqualOr}}
{{#isEqualOr status 3}}
不满足参加活动条件
{{/isEqualOr}}
{{#isEqualOr status 4}}
活动未开始
{{/isEqualOr}}
{{#isEqualOr status 5}}
活动已结束,请关注其他活动
{{/isEqualOr}}
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;
}
}
});
... ...