zero-buy.page.js
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
require('admin/activity.page.css');
const $alert = $('#alert-modal');
const $confirm = $('#confirm-modal');
// $('#alert-modal').modal('show')
function bindEvent() {
const editStatusFn = function(id, status) {
return $.ajax({
method: 'post',
url: '/admin/activity/zerobuy/editStatus',
data: {
id,
status
}
});
};
const editFn = function() {
window.open('/admin/activity/zerobuy/edit?id=' +
$(this).parent().data('id'), '_blank');
};
const switchFn = function() {
let $this = $(this);
let status = $this.hasClass('btn-switch-open') ? 1 : 0;
editStatusFn($this.data('id'), status).then(res => {
if (res.code === 200) {
location.reload();
} else {
$alert.find('.modal-text').text(res.message);
$alert.modal('show');
}
});
};
const exportFn = function() {
};
let publishId;
const publishFn = function() {
editStatusFn(publishId, 2).then(res => {
if (res.code === 200) {
location.reload();
} else {
$alert.find('.modal-text').text(res.message);
$alert.modal('show');
}
});
};
$('.btn-edit').on('click', editFn);
$('.btn-switch-open').on('click', switchFn);
$('.btn-switch-close').on('click', switchFn);
$('.btn-export').on('click', exportFn);
$('.btn-publish').on('click', function() {
publishId = $(this).data('id');
$confirm.modal('show');
});
$('.sure-publish-btn').on('click', publishFn);
}
bindEvent();