|
@@ -2,6 +2,8 @@ var dialog = require('../../plugins/dialog'); |
|
@@ -2,6 +2,8 @@ var dialog = require('../../plugins/dialog'); |
2
|
var _dialog = dialog.Dialog;
|
2
|
var _dialog = dialog.Dialog;
|
3
|
var _alert = dialog.Alert;
|
3
|
var _alert = dialog.Alert;
|
4
|
|
4
|
|
|
|
5
|
+var validate = require('../../me/order/validation');
|
|
|
6
|
+
|
5
|
|
7
|
|
6
|
require('../../common/foreach-polyfill');
|
8
|
require('../../common/foreach-polyfill');
|
7
|
|
9
|
|
|
@@ -29,10 +31,26 @@ function getTpl(data) { |
|
@@ -29,10 +31,26 @@ function getTpl(data) { |
29
|
}
|
31
|
}
|
30
|
|
32
|
|
31
|
// 取消订单
|
33
|
// 取消订单
|
32
|
-function cancelOrder(code, onCancel) {
|
34
|
+function cancelOrder(code, onCancel, w) {
|
33
|
var $checked = $('.reason .row .checked');
|
35
|
var $checked = $('.reason .row .checked');
|
34
|
var reason = $checked.next('.reason-text').text();
|
36
|
var reason = $checked.next('.reason-text').text();
|
35
|
var reasonId = $checked.parent().data('value');
|
37
|
var reasonId = $checked.parent().data('value');
|
|
|
38
|
+ var pass = true;
|
|
|
39
|
+
|
|
|
40
|
+ if (reason === '其它' || reason === '其他') {
|
|
|
41
|
+ reason = $checked.siblings('.input').val();
|
|
|
42
|
+
|
|
|
43
|
+ pass = validate.start('#other-reason', {
|
|
|
44
|
+ maxLength: 50,
|
|
|
45
|
+ errMsg: '原因最多50个字符'
|
|
|
46
|
+ });
|
|
|
47
|
+ }
|
|
|
48
|
+
|
|
|
49
|
+ if (!pass) {
|
|
|
50
|
+ return false;
|
|
|
51
|
+ }
|
|
|
52
|
+
|
|
|
53
|
+ w.close();
|
36
|
|
54
|
|
37
|
$.ajax({
|
55
|
$.ajax({
|
38
|
url: '/me/cancelOrder',
|
56
|
url: '/me/cancelOrder',
|
|
@@ -82,8 +100,7 @@ function showDiaglog(tpl, code, onCancel) { |
|
@@ -82,8 +100,7 @@ function showDiaglog(tpl, code, onCancel) { |
82
|
btnClass: ['confirm'],
|
100
|
btnClass: ['confirm'],
|
83
|
name: '确定并取消订单',
|
101
|
name: '确定并取消订单',
|
84
|
cb: function() {
|
102
|
cb: function() {
|
85
|
- cancelOrder(code, onCancel);
|
|
|
86
|
- tip.close();
|
103
|
+ cancelOrder(code, onCancel, tip);
|
87
|
}
|
104
|
}
|
88
|
},
|
105
|
},
|
89
|
{
|
106
|
{
|
|
@@ -104,7 +121,7 @@ function showDiaglog(tpl, code, onCancel) { |
|
@@ -104,7 +121,7 @@ function showDiaglog(tpl, code, onCancel) { |
104
|
var $ele = $(ele);
|
121
|
var $ele = $(ele);
|
105
|
var $input = $('.cancel-dialog .reason input');
|
122
|
var $input = $('.cancel-dialog .reason input');
|
106
|
|
123
|
|
107
|
- if (checked && $ele.parent('.other').length) {
|
124
|
+ if (checked && $ele.hasClass('other')) {
|
108
|
$input.prop('disabled', false);
|
125
|
$input.prop('disabled', false);
|
109
|
$input.focus();
|
126
|
$input.focus();
|
110
|
} else {
|
127
|
} else {
|
|
@@ -131,6 +148,13 @@ function getCancelReason(code, onCancel) { |
|
@@ -131,6 +148,13 @@ function getCancelReason(code, onCancel) { |
131
|
if (idx === 0) {
|
148
|
if (idx === 0) {
|
132
|
d[0].checked = true;
|
149
|
d[0].checked = true;
|
133
|
}
|
150
|
}
|
|
|
151
|
+
|
|
|
152
|
+ d.forEach(function(r) {
|
|
|
153
|
+ if (r.reason === '其他' || r.reason === '其它') {
|
|
|
154
|
+ r.isOther = true;
|
|
|
155
|
+ }
|
|
|
156
|
+ })
|
|
|
157
|
+
|
134
|
reasons.push({
|
158
|
reasons.push({
|
135
|
subReasons: d
|
159
|
subReasons: d
|
136
|
});
|
160
|
});
|