|
@@ -7,7 +7,8 @@ |
|
@@ -7,7 +7,8 @@ |
7
|
var $ = require('jquery'),
|
7
|
var $ = require('jquery'),
|
8
|
Hammer = require('yoho.hammer'),
|
8
|
Hammer = require('yoho.hammer'),
|
9
|
lazyLoad = require('yoho.lazyload'),
|
9
|
lazyLoad = require('yoho.lazyload'),
|
10
|
- tip = require('../plugin/tip');
|
10
|
+ tip = require('../plugin/tip'),
|
|
|
11
|
+ Swiper = require('yoho.iswiper');
|
11
|
|
12
|
|
12
|
var $navLi = $('#order-nav > li'),
|
13
|
var $navLi = $('#order-nav > li'),
|
13
|
$orderContainer = $('#order-container');
|
14
|
$orderContainer = $('#order-container');
|
|
@@ -29,7 +30,9 @@ var loading = require('../plugin/loading'); |
|
@@ -29,7 +30,9 @@ var loading = require('../plugin/loading'); |
29
|
|
30
|
|
30
|
var dialog = require('./dialog');
|
31
|
var dialog = require('./dialog');
|
31
|
|
32
|
|
32
|
-var orderHammer;
|
33
|
+var orderHammer,
|
|
|
34
|
+ $reaMask = $('.reason-mask'),
|
|
|
35
|
+ reasonSwiper;
|
33
|
|
36
|
|
34
|
//加载订单
|
37
|
//加载订单
|
35
|
function getOrders(option) {
|
38
|
function getOrders(option) {
|
|
@@ -116,6 +119,8 @@ orderHammer.on('tap', function(e) { |
|
@@ -116,6 +119,8 @@ orderHammer.on('tap', function(e) { |
116
|
$order = $cur.closest('.order');
|
119
|
$order = $cur.closest('.order');
|
117
|
id = $order.data('id');
|
120
|
id = $order.data('id');
|
118
|
|
121
|
|
|
|
122
|
+ $reaMask.data('orderId', id);
|
|
|
123
|
+
|
119
|
if ($cur.closest('.del').length > 0) {
|
124
|
if ($cur.closest('.del').length > 0) {
|
120
|
|
125
|
|
121
|
//Order delete
|
126
|
//Order delete
|
|
@@ -149,38 +154,8 @@ orderHammer.on('tap', function(e) { |
|
@@ -149,38 +154,8 @@ orderHammer.on('tap', function(e) { |
149
|
});
|
154
|
});
|
150
|
});
|
155
|
});
|
151
|
} else if ($cur.closest('.cancel').length > 0) {
|
156
|
} else if ($cur.closest('.cancel').length > 0) {
|
152
|
-
|
|
|
153
|
- //Order cancel
|
|
|
154
|
- dialog.showDialog({
|
|
|
155
|
- dialogText: '确定取消订单吗?',
|
|
|
156
|
- hasFooter: {
|
|
|
157
|
- leftBtnText: '取消',
|
|
|
158
|
- rightBtnText: '确定'
|
|
|
159
|
- }
|
|
|
160
|
- }, function() {
|
|
|
161
|
- $.ajax({
|
|
|
162
|
- type: 'GET',
|
|
|
163
|
- url: '/home/cancelOrder',
|
|
|
164
|
- data: {
|
|
|
165
|
- id: id
|
|
|
166
|
- },
|
|
|
167
|
- success: function(data) {
|
|
|
168
|
- if (data.message) {
|
|
|
169
|
- tip.show(data.message);
|
|
|
170
|
- }
|
|
|
171
|
- if (data.code === 200) {
|
|
|
172
|
-
|
|
|
173
|
- //取消订单页面刷新
|
|
|
174
|
- setTimeout(function() {
|
|
|
175
|
- window.location.reload();
|
|
|
176
|
- }, 2000);
|
|
|
177
|
- }
|
|
|
178
|
- },
|
|
|
179
|
- error: function() {
|
|
|
180
|
- tip.show('取消订单失败');
|
|
|
181
|
- }
|
|
|
182
|
- });
|
|
|
183
|
- });
|
157
|
+ console.log('s');
|
|
|
158
|
+ $reaMask.css('visibility', 'visible');
|
184
|
} else if ($cur.closest('.order-goods').length > 0) {
|
159
|
} else if ($cur.closest('.order-goods').length > 0) {
|
185
|
|
160
|
|
186
|
//Location to order detail
|
161
|
//Location to order detail
|
|
@@ -207,3 +182,42 @@ $(window).scroll(function() { |
|
@@ -207,3 +182,42 @@ $(window).scroll(function() { |
207
|
|
182
|
|
208
|
//初始化请求第一页数据
|
183
|
//初始化请求第一页数据
|
209
|
getOrders();
|
184
|
getOrders();
|
|
|
185
|
+
|
|
|
186
|
+$(function() {
|
|
|
187
|
+ reasonSwiper = new Swiper('.box-main', {
|
|
|
188
|
+ paginationClickable: true,
|
|
|
189
|
+ direction: 'vertical',
|
|
|
190
|
+ slidesPerView: 4,
|
|
|
191
|
+ effect: 'coverflow',
|
|
|
192
|
+ centeredSlides: true
|
|
|
193
|
+ });
|
|
|
194
|
+});
|
|
|
195
|
+
|
|
|
196
|
+$reaMask.find('.box-cmp').on('touchend', function(e) {
|
|
|
197
|
+ var selSolid = reasonSwiper.slides[reasonSwiper.activeIndex],
|
|
|
198
|
+ reason = $(selSolid).text(),
|
|
|
199
|
+ reasonId = $(selSolid).data('reasonId');
|
|
|
200
|
+
|
|
|
201
|
+ $.ajax({
|
|
|
202
|
+ type: 'GET',
|
|
|
203
|
+ url: '/home/cancelOrder',
|
|
|
204
|
+ data: {
|
|
|
205
|
+ id: $reaMask.data('orderId'),
|
|
|
206
|
+ reason: reason,
|
|
|
207
|
+ reasonId: reasonId
|
|
|
208
|
+ }
|
|
|
209
|
+ }).then(function(res) {
|
|
|
210
|
+ $reaMask.fadeOut();
|
|
|
211
|
+ if ($.type(res) !== 'object') {
|
|
|
212
|
+ return;
|
|
|
213
|
+ }
|
|
|
214
|
+ if (res.message) {
|
|
|
215
|
+ tip.show(res.message);
|
|
|
216
|
+ }
|
|
|
217
|
+ setTimeout(function() {
|
|
|
218
|
+ window.location.href = '/home/orders';
|
|
|
219
|
+ }, 2000);
|
|
|
220
|
+ }).fail(function() {
|
|
|
221
|
+ tip.show('网络错误');
|
|
|
222
|
+ });
|
|
|
223
|
+}); |