order-block.js
2.58 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/**
* 订单
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2016/2/17
*/
var $ = require('yoho.jquery');
var dialog = require('../common/dialog');
var Dialog = dialog.Dialog;
var Confirm = dialog.Confirm;
var $tpl = $('#cancel-dialog-tpl');
var html = $tpl.html();
var active;
function dialogFactory(id) {
var options = {
mask: false,
btns: [
{
id: 'cancel-sure',
name: '确定并取消订单',
btnClass: ['cancel-sure'],
cb: function() {
var $checked = $('.cancel-dialog :checked');
$.ajax({
type: 'POST',
url: '/home/orders/cancelorder',
data: {
orderCode: id,
reason: $checked.length > 0 ? $checked.val() : ''
}
}).then(function(data) {
if (data.code === 200) {
active.close();
history.go(0);
} else {
$('.cancel-dialog .cancel-tip').html(data.message);
}
});
}
},
{
id: 'cancel-no',
name: '取消',
btnClass: ['cancel-no'],
cb: function() {
active.close();
}
}
],
content: html,
className: 'cancel-dialog'
};
return new Dialog(options);
}
$tpl.remove();
//查看物流
$('.check-logistics').click(function() {
$(this).parent().siblings('.logistics').removeClass('hide');
});
$('.close-logistics').click(function() {
$(this).closest('.logistics').addClass('hide');
});
$('.me-orders').on('click', '.cancel-order', function(e) {
//取消订单
active = dialogFactory($(this).closest('.order').data('id'));
active.show();
}).on('click', '.confirm-received', function(e) {
var id = $(this).closest('.order').data('id');
//确认收货
active = new Confirm({
cb: function() {
$.ajax({
type: 'POST',
url: '/home/orders/confirmorder',
data: {
orderCode: id
}
}).then(function(data) {
if (data.code === 200) {
active.close();
history.go(0);
}
});
},
content: '您确定要确认收货吗?'
});
active.show();
});