Authored by hf

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

@@ -82,4 +82,3 @@ exports.showDialog = function(data, callback) { @@ -82,4 +82,3 @@ exports.showDialog = function(data, callback) {
82 } 82 }
83 }); 83 });
84 }; 84 };
85 -  
@@ -6,7 +6,9 @@ @@ -6,7 +6,9 @@
6 6
7 var $ = require('jquery'), 7 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'),
  11 + tip = require('../plugin/tip');
10 12
11 var orderId = $('#order-detail').data('id'); 13 var orderId = $('#order-detail').data('id');
12 14
@@ -24,26 +26,64 @@ optHammer.on('tap', function(e) { @@ -24,26 +26,64 @@ optHammer.on('tap', function(e) {
24 if ($cur.hasClass('btn-del')) { 26 if ($cur.hasClass('btn-del')) {
25 27
26 //删除订单 28 //删除订单
27 - if (confirm('确定删除订单吗?')) { 29 + dialog.showDialog({
  30 + dialogText: '确定删除订单吗?',
  31 + hasFooter: {
  32 + leftBtnText: '取消',
  33 + rightBtnText: '确定'
  34 + }
  35 + }, function() {
28 $.ajax({ 36 $.ajax({
29 type: 'GET', 37 type: 'GET',
30 url: '/home/delOrder', 38 url: '/home/delOrder',
31 data: { 39 data: {
32 id: orderId 40 id: orderId
33 } 41 }
  42 + }).then(function(res) {
  43 + $('#dialog-wrapper').hide();
  44 + if (!res) {
  45 + tip.show('网络错误');
  46 + }
  47 + if (res.code === 200) {
  48 + tip.show('删除成功');
  49 + } else {
  50 + tip.show(res.message || '网络错误');
  51 + }
  52 + window.location.href = '/home/orders';
  53 + }).fail(function() {
  54 + tip.show('网络错误');
34 }); 55 });
35 - } 56 + });
36 } else if ($cur.hasClass('btn-cancel')) { 57 } else if ($cur.hasClass('btn-cancel')) {
37 58
38 //取消订单 59 //取消订单
39 - if (confirm('确定取消订单吗?')) { 60 + dialog.showDialog({
  61 + dialogText: '确定取消订单吗?',
  62 + hasFooter: {
  63 + leftBtnText: '取消',
  64 + rightBtnText: '确定'
  65 + }
  66 + }, function() {
40 $.ajax({ 67 $.ajax({
41 type: 'GET', 68 type: 'GET',
42 url: '/home/cancelOrder', 69 url: '/home/cancelOrder',
43 data: { 70 data: {
44 id: orderId 71 id: orderId
45 } 72 }
  73 + }).then(function(res) {
  74 + $('#dialog-wrapper').hide();
  75 + if (!res) {
  76 + tip.show('网络错误');
  77 + }
  78 + if (res.code === 200) {
  79 + tip.show('取消成功');
  80 + } else {
  81 + tip.show(res.message || '网络错误');
  82 + }
  83 + window.location.reload();
  84 + }).fail(function() {
  85 + tip.show('网络错误');
46 }); 86 });
47 - } 87 + });
48 } 88 }
49 -});  
  89 +});