|
@@ -8,70 +8,16 @@ var $ = require('jquery'), |
|
@@ -8,70 +8,16 @@ var $ = require('jquery'), |
8
|
lazyLoad = require('yoho.lazyload'),
|
8
|
lazyLoad = require('yoho.lazyload'),
|
9
|
Hammer = require('yoho.hammer'),
|
9
|
Hammer = require('yoho.hammer'),
|
10
|
dialog = require('./dialog'),
|
10
|
dialog = require('./dialog'),
|
11
|
- tip = require('../plugin/tip'),
|
|
|
12
|
- orderId = $('#order-detail').data('id'),
|
|
|
13
|
- $countDownHours = $('.hours'),
|
|
|
14
|
- $countdownContainer = $('.count-down'),
|
|
|
15
|
- Swiper = require('yoho.iswiper'),
|
|
|
16
|
- $ownerInfo = $('.owner-info'),
|
|
|
17
|
- $reaMask = $('.reason-mask'),
|
|
|
18
|
- reasonSwiper,
|
|
|
19
|
- optHammer;
|
11
|
+ tip = require('../plugin/tip');
|
|
|
12
|
+
|
|
|
13
|
+var orderId = $('#order-detail').data('id');
|
|
|
14
|
+
|
|
|
15
|
+var optHammer;
|
20
|
|
16
|
|
21
|
lazyLoad({
|
17
|
lazyLoad({
|
22
|
try_again_css: 'order-failure'
|
18
|
try_again_css: 'order-failure'
|
23
|
});
|
19
|
});
|
24
|
|
20
|
|
25
|
-function downCount(options) {
|
|
|
26
|
-
|
|
|
27
|
- var difference = options,// difference of dates
|
|
|
28
|
- interval;
|
|
|
29
|
- /**
|
|
|
30
|
- * Main downCount function that calculates everything
|
|
|
31
|
- */
|
|
|
32
|
- function countdown() {
|
|
|
33
|
-
|
|
|
34
|
- // basic math variables
|
|
|
35
|
- var _second = 1000,
|
|
|
36
|
- _minute = _second * 60,
|
|
|
37
|
- _hour = _minute * 60,
|
|
|
38
|
- _day = _hour * 24,
|
|
|
39
|
- hours,
|
|
|
40
|
- minutes,
|
|
|
41
|
- seconds;
|
|
|
42
|
-
|
|
|
43
|
- // calculate dates
|
|
|
44
|
- hours = Math.floor((difference % _day) / _hour),
|
|
|
45
|
- minutes = Math.floor((difference % _hour) / _minute),
|
|
|
46
|
- seconds = Math.floor((difference % _minute) / _second);
|
|
|
47
|
-
|
|
|
48
|
- // fix dates so that it will show two digets
|
|
|
49
|
- hours = (String(hours).length >= 2) ? hours : '0' + hours;
|
|
|
50
|
- minutes = (String(minutes).length >= 2) ? minutes : '0' + minutes;
|
|
|
51
|
- seconds = (String(seconds).length >= 2) ? seconds : '0' + seconds;
|
|
|
52
|
-
|
|
|
53
|
- // set to DOM
|
|
|
54
|
- $countdownContainer.removeClass('hide');
|
|
|
55
|
- if (hours === '00') {
|
|
|
56
|
- $countDownHours.text('剩余' + minutes + ':' + seconds);
|
|
|
57
|
- } else {
|
|
|
58
|
- $countDownHours.text('剩余' + hours + ':' + minutes + ':' + seconds);
|
|
|
59
|
- }
|
|
|
60
|
-
|
|
|
61
|
- difference -= 1000;
|
|
|
62
|
-
|
|
|
63
|
- if (difference < 0) {
|
|
|
64
|
- clearInterval(interval);// stop timer
|
|
|
65
|
- return;
|
|
|
66
|
- }
|
|
|
67
|
- }
|
|
|
68
|
- if (difference !== '' && difference > 0) {
|
|
|
69
|
- interval = setInterval(countdown, 1000);// start
|
|
|
70
|
- }
|
|
|
71
|
-}
|
|
|
72
|
-
|
|
|
73
|
-downCount($countDownHours.text());
|
|
|
74
|
-
|
|
|
75
|
//订单删除
|
21
|
//订单删除
|
76
|
optHammer = new Hammer(document.getElementsByClassName('opt')[0]);
|
22
|
optHammer = new Hammer(document.getElementsByClassName('opt')[0]);
|
77
|
optHammer.on('tap', function(e) {
|
23
|
optHammer.on('tap', function(e) {
|
|
@@ -109,66 +55,23 @@ optHammer.on('tap', function(e) { |
|
@@ -109,66 +55,23 @@ optHammer.on('tap', function(e) { |
109
|
});
|
55
|
});
|
110
|
});
|
56
|
});
|
111
|
} else if ($cur.hasClass('btn-cancel')) {
|
57
|
} else if ($cur.hasClass('btn-cancel')) {
|
112
|
- $reaMask.css('visibility', 'visible');
|
|
|
113
|
- }
|
|
|
114
|
-});
|
|
|
115
|
|
58
|
|
116
|
-if ($ownerInfo.data('changeable') === true) {
|
|
|
117
|
- $ownerInfo.find('.rest').show();
|
|
|
118
|
- $ownerInfo.on('touchend', function() {
|
|
|
119
|
- location.href = $ownerInfo.data('url');
|
|
|
120
|
- });
|
|
|
121
|
-}
|
|
|
122
|
-
|
|
|
123
|
-$(function() {
|
|
|
124
|
- reasonSwiper = new Swiper('.box-main', {
|
|
|
125
|
- initialSlide: 0,
|
|
|
126
|
- centeredSlides: true,
|
|
|
127
|
- slidesPerView: 5,
|
|
|
128
|
- direction: 'vertical',
|
|
|
129
|
- onSlideChangeStart: function(reasonSwiper) {
|
|
|
130
|
- var activeIndex = reasonSwiper.activeIndex,
|
|
|
131
|
- slides = reasonSwiper.slides,
|
|
|
132
|
- i = 0;
|
|
|
133
|
-
|
|
|
134
|
- if (slides.length !== 1) {
|
|
|
135
|
- if (activeIndex === 0) {
|
|
|
136
|
- for (i = 1; i < slides.length; i++) {
|
|
|
137
|
- $(slides[i]).css('transform', '');
|
|
|
138
|
- }
|
|
|
139
|
- } else if (activeIndex === slides.length - 1) {
|
|
|
140
|
- for (i = 0; i < activeIndex; i++) {
|
|
|
141
|
- $(slides[i]).css('transform', 'rotateX(' + (30 + (activeIndex - i) * 12) + 'deg)');
|
|
|
142
|
- }
|
|
|
143
|
- } else {
|
|
|
144
|
- for (i = 0; i < activeIndex; i++) {
|
|
|
145
|
- $(slides[i]).css('transform', 'rotateX(' + (30 + (activeIndex - i) * 12) + 'deg)');
|
|
|
146
|
- }
|
|
|
147
|
- for (i = activeIndex + 1; i < slides.length; i++) {
|
|
|
148
|
- $(slides[i]).css('transform', '');
|
|
|
149
|
- }
|
|
|
150
|
- }
|
|
|
151
|
- }
|
|
|
152
|
- $(slides[activeIndex]).css('transform', '');
|
59
|
+ //取消订单
|
|
|
60
|
+ dialog.showDialog({
|
|
|
61
|
+ dialogText: '确定取消订单吗?',
|
|
|
62
|
+ hasFooter: {
|
|
|
63
|
+ leftBtnText: '取消',
|
|
|
64
|
+ rightBtnText: '确定'
|
153
|
}
|
65
|
}
|
154
|
- });
|
|
|
155
|
-});
|
|
|
156
|
-
|
|
|
157
|
-$reaMask.find('.box-cmp').on('touchend', function(e) {
|
|
|
158
|
- var selSolid = reasonSwiper.slides[reasonSwiper.activeIndex],
|
|
|
159
|
- reason = $(selSolid).text(),
|
|
|
160
|
- reasonId = $(selSolid).data('reasonId');
|
|
|
161
|
-
|
66
|
+ }, function() {
|
162
|
$.ajax({
|
67
|
$.ajax({
|
163
|
type: 'GET',
|
68
|
type: 'GET',
|
164
|
url: '/home/cancelOrder',
|
69
|
url: '/home/cancelOrder',
|
165
|
data: {
|
70
|
data: {
|
166
|
- id: orderId,
|
|
|
167
|
- reason: reason,
|
|
|
168
|
- reasonId: reasonId
|
71
|
+ id: orderId
|
169
|
}
|
72
|
}
|
170
|
}).then(function(res) {
|
73
|
}).then(function(res) {
|
171
|
- $reaMask.fadeOut();
|
74
|
+ $('#dialog-wrapper').hide();
|
172
|
if ($.type(res) !== 'object') {
|
75
|
if ($.type(res) !== 'object') {
|
173
|
return;
|
76
|
return;
|
174
|
}
|
77
|
}
|
|
@@ -181,13 +84,21 @@ $reaMask.find('.box-cmp').on('touchend', function(e) { |
|
@@ -181,13 +84,21 @@ $reaMask.find('.box-cmp').on('touchend', function(e) { |
181
|
}).fail(function() {
|
84
|
}).fail(function() {
|
182
|
tip.show('网络错误');
|
85
|
tip.show('网络错误');
|
183
|
});
|
86
|
});
|
184
|
-});
|
|
|
185
|
-
|
|
|
186
|
-$reaMask.on('touchend', function(event) {
|
|
|
187
|
- if (event.target.className !== 'reason-mask') {
|
|
|
188
|
- return false;
|
87
|
+ });
|
|
|
88
|
+ } else if ($cur.hasClass('btn-rebuy')) {
|
|
|
89
|
+ $.ajax({
|
|
|
90
|
+ type: 'GET',
|
|
|
91
|
+ url: '/home/readd',
|
|
|
92
|
+ data: {
|
|
|
93
|
+ orderCode: orderId
|
|
|
94
|
+ },
|
|
|
95
|
+ success: function(res) {
|
|
|
96
|
+ tip.show(res.message);
|
|
|
97
|
+ location.href = '/cart/index/index';
|
|
|
98
|
+ },
|
|
|
99
|
+ error: function(res) {
|
|
|
100
|
+ tip.show(res.message);
|
|
|
101
|
+ }
|
|
|
102
|
+ });
|
189
|
}
|
103
|
}
|
190
|
-
|
|
|
191
|
- $reaMask.css('visibility', 'hidden');
|
|
|
192
|
- event.stopPropagation();
|
|
|
193
|
}); |
104
|
}); |