Authored by liangxs

订单列表取消原因

@@ -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 +});
1 .order-page { 1 .order-page {
2 background: #f0f0f0; 2 background: #f0f0f0;
3 3
  4 + .reason-mask {
  5 + position: fixed;
  6 + width: 100%;
  7 + height: 100%;
  8 + left: 0;
  9 + top: 0;
  10 + background: rgba(0, 0, 0, .5);
  11 + z-index: 5;
  12 + visibility: hidden;
  13 +
  14 + .reason-box {
  15 + border-bottom: solid 1px #CCCCCC;
  16 + font: inherit;
  17 + vertical-align: baseline;
  18 + position: absolute;
  19 + left: 50%;
  20 + top: 50%;
  21 + margin-left: -270px;
  22 + margin-top: -290px;
  23 + width: 540px;
  24 + height:580px;
  25 + color: #444;
  26 + background: #fff;
  27 + border-radius: 10px;
  28 +
  29 + .box-head {
  30 + height: 60px;
  31 + line-height: 60px;
  32 + text-align: right;
  33 + font-size: 36px;
  34 + background: rgb(240, 240, 240);
  35 + padding-right: 30px;
  36 + }
  37 +
  38 + .box-main {
  39 + background: #FFFFFF;
  40 + padding: 20px;
  41 + height:480px;
  42 + margin-top: 40px;
  43 + }
  44 +
  45 + li {
  46 + text-align: center;
  47 + height: 36px;
  48 + font-size: 24px;
  49 + line-height: 36px;
  50 + background: #FFF;
  51 + color: rgba(0, 0, 0, .5);
  52 + }
  53 +
  54 + .swiper-slide-active {
  55 + font-size: 36px;
  56 + color: rgb(0,0,0);
  57 + height: 48px;
  58 + line-height: 96px;
  59 + }
  60 + }
  61 + }
  62 +
4 .order { 63 .order {
5 position: relative; 64 position: relative;
6 display: block; 65 display: block;