Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop
Showing
12 changed files
with
411 additions
and
301 deletions
framework @ 75bbc3b0
@@ -22,7 +22,7 @@ class HelpData | @@ -22,7 +22,7 @@ class HelpData | ||
22 | $param['method'] = 'app.help.li'; | 22 | $param['method'] = 'app.help.li'; |
23 | $param['client_secret'] = Sign::getSign($param); | 23 | $param['client_secret'] = Sign::getSign($param); |
24 | 24 | ||
25 | - return Yohobuy::post(Yohobuy::API_URL, $param, $param); | 25 | + return Yohobuy::post(Yohobuy::API_URL, $param); |
26 | } | 26 | } |
27 | 27 | ||
28 | 28 |
@@ -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 | +}); |
@@ -100,8 +100,8 @@ function submitOrder() { | @@ -100,8 +100,8 @@ function submitOrder() { | ||
100 | data: { | 100 | data: { |
101 | addressId: orderInfo('addressId'), | 101 | addressId: orderInfo('addressId'), |
102 | cartType: orderInfo('cartType'), | 102 | cartType: orderInfo('cartType'), |
103 | - deliveryId: orderInfo('deliveryId') || 1, | ||
104 | - deliveryTimeId: orderInfo('deliveryTimeId') || 2, | 103 | + deliveryId: orderInfo('deliveryId'), |
104 | + deliveryTimeId: orderInfo('deliveryTimeId'), | ||
105 | invoiceText: $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'), | 105 | invoiceText: $invoice.find('[name="invoice-title"]').val() || orderInfo('invoiceText'), |
106 | invoiceType: $invoice.find('.invoice-type').val() || orderInfo('invoiceType'), | 106 | invoiceType: $invoice.find('.invoice-type').val() || orderInfo('invoiceType'), |
107 | msg: $('#msg').find('input').val() || orderInfo('msg'), | 107 | msg: $('#msg').find('input').val() || orderInfo('msg'), |
@@ -30,6 +30,7 @@ $newCoupon.on('submit', function() { | @@ -30,6 +30,7 @@ $newCoupon.on('submit', function() { | ||
30 | if (res.code === 200) { | 30 | if (res.code === 200) { |
31 | tip.show('优惠券可用'); | 31 | tip.show('优惠券可用'); |
32 | orderInfo('couponCode', res.data.coupon_code); | 32 | orderInfo('couponCode', res.data.coupon_code); |
33 | + orderInfo('couponValue', res.data.coupon_value); | ||
33 | window.location.href = '/shoppingCart/orderEnsure?coupon_code=' + res.data.coupon_code; | 34 | window.location.href = '/shoppingCart/orderEnsure?coupon_code=' + res.data.coupon_code; |
34 | } else { | 35 | } else { |
35 | tip.show(res.message); | 36 | tip.show(res.message); |
@@ -93,7 +93,7 @@ | @@ -93,7 +93,7 @@ | ||
93 | } | 93 | } |
94 | 94 | ||
95 | .coupon-count { | 95 | .coupon-count { |
96 | - padding: 5rem / $pxConvertRem; | 96 | + padding: 5rem / $pxConvertRem 15rem / $pxConvertRem; |
97 | background: #f00; | 97 | background: #f00; |
98 | color: #fff; | 98 | color: #fff; |
99 | @include border-radius(10px); | 99 | @include border-radius(10px); |
@@ -104,6 +104,14 @@ | @@ -104,6 +104,14 @@ | ||
104 | .coin-check { | 104 | .coin-check { |
105 | float: right; | 105 | float: right; |
106 | color: #999; | 106 | color: #999; |
107 | + | ||
108 | + &.used { | ||
109 | + color: #f00; | ||
110 | + } | ||
111 | + | ||
112 | + .iconfont { | ||
113 | + color: #999; | ||
114 | + } | ||
107 | } | 115 | } |
108 | 116 | ||
109 | .coin-check { | 117 | .coin-check { |
@@ -115,6 +123,10 @@ | @@ -115,6 +123,10 @@ | ||
115 | color: #000; | 123 | color: #000; |
116 | } | 124 | } |
117 | 125 | ||
126 | + em { | ||
127 | + color: #f00; | ||
128 | + } | ||
129 | + | ||
118 | } | 130 | } |
119 | 131 | ||
120 | .checkbox.icon-checkbox { | 132 | .checkbox.icon-checkbox { |
@@ -187,6 +199,10 @@ | @@ -187,6 +199,10 @@ | ||
187 | } | 199 | } |
188 | } | 200 | } |
189 | 201 | ||
202 | + .price-cal { | ||
203 | + font-family: monospace; | ||
204 | + } | ||
205 | + | ||
190 | .cost { | 206 | .cost { |
191 | border-top: 1px solid #f7f7f7; | 207 | border-top: 1px solid #f7f7f7; |
192 | line-height: 100rem / $pxConvertRem; | 208 | line-height: 100rem / $pxConvertRem; |
@@ -44,7 +44,6 @@ | @@ -44,7 +44,6 @@ | ||
44 | {{# coupon}} | 44 | {{# coupon}} |
45 | <li class="coupon"> | 45 | <li class="coupon"> |
46 | <a href="/shoppingCart/selectCoupon"> | 46 | <a href="/shoppingCart/selectCoupon"> |
47 | - <!-- <a href="{{url}}"> --> | ||
48 | <span class="title">优惠券</span> | 47 | <span class="title">优惠券</span> |
49 | {{#if count}} | 48 | {{#if count}} |
50 | <span class="coupon-count"> | 49 | <span class="coupon-count"> |
@@ -122,7 +121,7 @@ | @@ -122,7 +121,7 @@ | ||
122 | {{/couponPrice}} | 121 | {{/couponPrice}} |
123 | <li> | 122 | <li> |
124 | <span>YOHO币</span> | 123 | <span>YOHO币</span> |
125 | - - {{yohoCoin}} | 124 | + - ¥{{yohoCoin}} |
126 | </li> | 125 | </li> |
127 | <li class="cost"> | 126 | <li class="cost"> |
128 | 应付金额: <em>¥{{price}}</em> | 127 | 应付金额: <em>¥{{price}}</em> |
@@ -845,7 +845,7 @@ class HomeController extends AbstractAction | @@ -845,7 +845,7 @@ class HomeController extends AbstractAction | ||
845 | 845 | ||
846 | $this->_view->display('order-detail', array( | 846 | $this->_view->display('order-detail', array( |
847 | 'orderDetailPage' => true, | 847 | 'orderDetailPage' => true, |
848 | - 'orderDetail' => OrderModel::orderDetail($orderCode, $this->_uid, $this->_session), | 848 | + 'orderDetail' => OrderModel::orderDetail($orderCode, $this->_uid, $this->_usession), |
849 | )); | 849 | )); |
850 | } | 850 | } |
851 | 851 | ||
@@ -867,7 +867,8 @@ class HomeController extends AbstractAction | @@ -867,7 +867,8 @@ class HomeController extends AbstractAction | ||
867 | /** | 867 | /** |
868 | * 帮助中心列表详细信息 | 868 | * 帮助中心列表详细信息 |
869 | */ | 869 | */ |
870 | - public function helpDetailAction() { | 870 | + public function helpDetailAction() |
871 | + { | ||
871 | $caption = $this->get('caption', '帮助中心'); | 872 | $caption = $this->get('caption', '帮助中心'); |
872 | $code = $this->get('code', 0); | 873 | $code = $this->get('code', 0); |
873 | if (empty($code)) { | 874 | if (empty($code)) { |
@@ -877,9 +878,8 @@ class HomeController extends AbstractAction | @@ -877,9 +878,8 @@ class HomeController extends AbstractAction | ||
877 | $this->setTitle($caption); | 878 | $this->setTitle($caption); |
878 | $this->setNavHeader($caption); | 879 | $this->setNavHeader($caption); |
879 | 880 | ||
880 | - $service = Home\HelpModel::serviceDetail($code); | ||
881 | $this->_view->display('helpDetail', array( | 881 | $this->_view->display('helpDetail', array( |
882 | - 'iHelp' => $service, | 882 | + 'iHelp' => Home\HelpModel::serviceDetail($code), |
883 | )); | 883 | )); |
884 | } | 884 | } |
885 | 885 |
@@ -13,6 +13,7 @@ class ShoppingCartController extends AbstractAction | @@ -13,6 +13,7 @@ class ShoppingCartController extends AbstractAction | ||
13 | /* | 13 | /* |
14 | * 购物车首页 | 14 | * 购物车首页 |
15 | */ | 15 | */ |
16 | + | ||
16 | public function indexAction() | 17 | public function indexAction() |
17 | { | 18 | { |
18 | $this->setTitle('购物车'); | 19 | $this->setTitle('购物车'); |
@@ -29,239 +30,243 @@ class ShoppingCartController extends AbstractAction | @@ -29,239 +30,243 @@ class ShoppingCartController extends AbstractAction | ||
29 | // 渲染模板 | 30 | // 渲染模板 |
30 | $this->_view->display('index', $data); | 31 | $this->_view->display('index', $data); |
31 | } | 32 | } |
33 | + | ||
32 | /* | 34 | /* |
33 | * 异步获取购物车数据 | 35 | * 异步获取购物车数据 |
34 | */ | 36 | */ |
37 | + | ||
35 | public function getCartDataAction() | 38 | public function getCartDataAction() |
36 | { | 39 | { |
37 | - $result = array(); | 40 | + $result = array(); |
41 | + | ||
42 | + if ($this->isAjax()) { | ||
43 | + $shoppingKey = Helpers::getShoppingKeyByCookie(); | ||
44 | + $uid = $this->getUid(true); | ||
45 | + | ||
46 | + $result = CartModel::getCartData($uid, $shoppingKey); | ||
47 | + } | ||
48 | + | ||
49 | + if (empty($result)) { | ||
50 | + echo ' '; | ||
51 | + } else { | ||
52 | + $this->echoJson($result); | ||
53 | + } | ||
54 | + } | ||
55 | + | ||
56 | + /** | ||
57 | + * 购物车商品选择与取消 | ||
58 | + */ | ||
59 | + public function selectAction() | ||
60 | + { | ||
61 | + $result = array(); | ||
62 | + | ||
63 | + if ($this->isAjax()) { | ||
64 | + $productId = $this->post('id', 0); | ||
65 | + $uid = $this->getUid(true); | ||
66 | + $shoppingKey = $this->getSession('shoppingKey'); | ||
67 | + $result = CartModel::selectGoods($uid, $productId, $shoppingKey); | ||
68 | + } | ||
69 | + | ||
70 | + if (empty($result)) { | ||
71 | + echo ' '; | ||
72 | + } else { | ||
73 | + $this->echoJson($result); | ||
74 | + } | ||
75 | + } | ||
76 | + | ||
77 | + /** | ||
78 | + * 移出购物车 | ||
79 | + */ | ||
80 | + public function delAction() | ||
81 | + { | ||
82 | + $result = array(); | ||
83 | + | ||
84 | + if ($this->isAjax()) { | ||
85 | + $productId = $this->post('id', 0); | ||
86 | + $uid = $this->getUid(true); | ||
87 | + $shoppingKey = $this->getSession('shoppingKey'); | ||
88 | + $result = CartModel::removeFromCart($uid, $productId, $shoppingKey); | ||
89 | + } | ||
90 | + | ||
91 | + if (empty($result)) { | ||
92 | + echo ' '; | ||
93 | + } else { | ||
94 | + $this->echoJson($result); | ||
95 | + } | ||
96 | + } | ||
97 | + | ||
98 | + /** | ||
99 | + * 移入收藏夹 | ||
100 | + */ | ||
101 | + public function colAction() | ||
102 | + { | ||
103 | + $result = array(); | ||
104 | + | ||
105 | + if ($this->isAjax()) { | ||
106 | + $productId = $this->post('id', 0); | ||
107 | + $uid = $this->getUid(true); | ||
108 | + $result = CartModel::addToFav($uid, $productId); | ||
109 | + } | ||
110 | + | ||
111 | + if (empty($result)) { | ||
112 | + echo ' '; | ||
113 | + } else { | ||
114 | + $this->echoJson($result); | ||
115 | + } | ||
116 | + } | ||
117 | + | ||
118 | + /* | ||
119 | + * 获取购物车商品数据 | ||
120 | + */ | ||
121 | + | ||
122 | + public function goodinfoAction() | ||
123 | + { | ||
124 | + $result = array(); | ||
125 | + | ||
126 | + if ($this->isAjax()) { | ||
127 | + $num = $this->get('buy_num', 1); | ||
128 | + $skn = $this->get('id', 1); | ||
129 | + $uid = $this->getUid(true); | ||
130 | + $result = CartModel::cartProductData($uid, $skn, $num); // 测试skn的ID为51172055 | ||
131 | + $result['num'] = $num; | ||
132 | + } | ||
133 | + | ||
134 | + if (empty($result)) { | ||
135 | + echo ' '; | ||
136 | + } else { | ||
137 | + $this->echoJson($result); | ||
138 | + } | ||
139 | + } | ||
38 | 140 | ||
39 | - if ($this->isAjax()) { | ||
40 | - $shoppingKey = Helpers::getShoppingKeyByCookie(); | ||
41 | - $uid = $this->getUid(true); | 141 | + /* |
142 | + * 获取购物车加价购商品数据 | ||
143 | + */ | ||
42 | 144 | ||
43 | - $result = CartModel::getCartData($uid, $shoppingKey); | ||
44 | - } | 145 | + public function giftinfoAction() |
146 | + { | ||
147 | + $result = array(); | ||
148 | + | ||
149 | + if ($this->isAjax()) { | ||
150 | + $skn = $this->get('skn', null); | ||
151 | + $promotionId = $this->get('promotionId', null); | ||
152 | + $result = CartModel::giftProductData($skn, $promotionId); | ||
153 | + } | ||
154 | + | ||
155 | + if (empty($result)) { | ||
156 | + echo ' '; | ||
157 | + } else { | ||
158 | + $this->echoJson($result); | ||
159 | + } | ||
160 | + } | ||
45 | 161 | ||
46 | - if (empty($result)) { | ||
47 | - echo ' '; | ||
48 | - } else { | ||
49 | - $this->echoJson($result); | ||
50 | - } | 162 | + /** |
163 | + * 修改购物车商品数据 | ||
164 | + */ | ||
165 | + public function modifyAction() | ||
166 | + { | ||
167 | + $result = array(); | ||
168 | + | ||
169 | + if ($this->isAjax()) { | ||
170 | + $shoppingKey = $this->getSession('shoppingKey'); | ||
171 | + $uid = $this->getUid(true); | ||
172 | + | ||
173 | + $params = array(); | ||
174 | + $params['old_product_sku'] = $this->post('old_product_sku', 0); | ||
175 | + $params['new_product_sku'] = $this->post('new_product_sku', 0); | ||
176 | + $params['buy_number'] = $this->post('buy_number', 0); | ||
177 | + $params['selected'] = $this->post('selected', null); | ||
178 | + $result = CartModel::modifyCartProduct($uid, $params, $shoppingKey); | ||
179 | + } | ||
180 | + | ||
181 | + if (empty($result)) { | ||
182 | + echo ' '; | ||
183 | + } else { | ||
184 | + $this->echoJson($result); | ||
185 | + } | ||
51 | } | 186 | } |
52 | 187 | ||
53 | - /** | ||
54 | - * 购物车商品选择与取消 | ||
55 | - */ | ||
56 | - public function selectAction() | ||
57 | - { | ||
58 | - $result = array(); | ||
59 | - | ||
60 | - if ($this->isAjax()) { | ||
61 | - $productId = $this->post('id', 0); | ||
62 | - $uid = $this->getUid(true); | ||
63 | - $shoppingKey = $this->getSession('shoppingKey'); | ||
64 | - $result = CartModel::selectGoods($uid, $productId, $shoppingKey); | ||
65 | - } | ||
66 | - | ||
67 | - if (empty($result)) { | ||
68 | - echo ' '; | ||
69 | - } else { | ||
70 | - $this->echoJson($result); | ||
71 | - } | ||
72 | - } | ||
73 | - | ||
74 | - /** | ||
75 | - * 移出购物车 | ||
76 | - */ | ||
77 | - public function delAction() | ||
78 | - { | ||
79 | - $result = array(); | ||
80 | - | ||
81 | - if ($this->isAjax()) { | ||
82 | - $productId = $this->post('id', 0); | ||
83 | - $uid = $this->getUid(true); | ||
84 | - $shoppingKey = $this->getSession('shoppingKey'); | ||
85 | - $result = CartModel::removeFromCart($uid, $productId, $shoppingKey); | ||
86 | - } | ||
87 | - | ||
88 | - if (empty($result)) { | ||
89 | - echo ' '; | ||
90 | - } else { | ||
91 | - $this->echoJson($result); | ||
92 | - } | ||
93 | - } | ||
94 | - | ||
95 | - /** | ||
96 | - * 移入收藏夹 | ||
97 | - */ | ||
98 | - public function colAction() | ||
99 | - { | ||
100 | - $result = array(); | ||
101 | - | ||
102 | - if ($this->isAjax()) { | ||
103 | - $productId = $this->post('id', 0); | ||
104 | - $uid = $this->getUid(true); | ||
105 | - $result = CartModel::addToFav($uid, $productId); | ||
106 | - } | ||
107 | - | ||
108 | - if (empty($result)) { | ||
109 | - echo ' '; | ||
110 | - } else { | ||
111 | - $this->echoJson($result); | ||
112 | - } | ||
113 | - } | ||
114 | - | ||
115 | - /* | ||
116 | - * 获取购物车商品数据 | ||
117 | - */ | ||
118 | - public function goodinfoAction() | ||
119 | - { | ||
120 | - $result = array(); | ||
121 | - | ||
122 | - if ($this->isAjax()) { | ||
123 | - $num = $this->get('buy_num', 1); | ||
124 | - $skn = $this->get('id', 1); | ||
125 | - $uid = $this->getUid(true); | ||
126 | - $result = CartModel::cartProductData($uid, $skn, $num); // 测试skn的ID为51172055 | ||
127 | - $result['num'] = $num; | ||
128 | - } | ||
129 | - | ||
130 | - if (empty($result)) { | ||
131 | - echo ' '; | ||
132 | - } else { | ||
133 | - $this->echoJson($result); | ||
134 | - } | ||
135 | - } | ||
136 | - | ||
137 | - /* | ||
138 | - * 获取购物车加价购商品数据 | ||
139 | - */ | ||
140 | - public function giftinfoAction() | ||
141 | - { | ||
142 | - $result = array(); | ||
143 | - | ||
144 | - if ($this->isAjax()) { | ||
145 | - $skn = $this->get('skn', null); | ||
146 | - $promotionId = $this->get('promotionId', null); | ||
147 | - $result = CartModel::giftProductData($skn, $promotionId); | ||
148 | - } | ||
149 | - | ||
150 | - if (empty($result)) { | ||
151 | - echo ' '; | ||
152 | - } else { | ||
153 | - $this->echoJson($result); | ||
154 | - } | ||
155 | - } | ||
156 | - | ||
157 | - /** | ||
158 | - * 修改购物车商品数据 | ||
159 | - */ | ||
160 | - public function modifyAction() | ||
161 | - { | ||
162 | - $result = array(); | ||
163 | - | ||
164 | - if ($this->isAjax()) { | ||
165 | - $shoppingKey = $this->getSession('shoppingKey'); | ||
166 | - $uid = $this->getUid(true); | ||
167 | - | ||
168 | - $params = array(); | ||
169 | - $params['old_product_sku']= $this->post('old_product_sku', 0); | ||
170 | - $params['new_product_sku']= $this->post('new_product_sku', 0); | ||
171 | - $params['buy_number']= $this->post('buy_number', 0); | ||
172 | - $params['selected']= $this->post('selected', null); | ||
173 | - $result = CartModel::modifyCartProduct($uid, $params, $shoppingKey); | ||
174 | - } | ||
175 | - | ||
176 | - if (empty($result)) { | ||
177 | - echo ' '; | ||
178 | - } else { | ||
179 | - $this->echoJson($result); | ||
180 | - } | ||
181 | - } | ||
182 | - | ||
183 | - /** | ||
184 | - * 购物车结算请求 | ||
185 | - */ | ||
186 | - public function orderEnsureAction() | ||
187 | - { | ||
188 | - $this->setTitle('购物车'); | ||
189 | - $this->setNavHeader('购物车'); | ||
190 | - | ||
191 | - $cartType = $this->post('cartType', 'ordinary'); | ||
192 | - $cookieData = $this->getCookie('order-info', null); | ||
193 | - $uid = $this->getUid(true); | ||
194 | - $data = array( | ||
195 | - 'orderEnsurePage' => true, | ||
196 | - 'orderEnsure' => CartModel::cartPay($uid, $cartType, $cookieData) | ||
197 | - ); | 188 | + /** |
189 | + * 购物车结算请求 | ||
190 | + */ | ||
191 | + public function orderEnsureAction() | ||
192 | + { | ||
193 | + $this->setTitle('购物车'); | ||
194 | + $this->setNavHeader('购物车'); | ||
195 | + | ||
196 | + $cartType = $this->post('cartType', 'ordinary'); | ||
197 | + $cookieData = $this->getCookie('order-info', null); | ||
198 | + $uid = $this->getUid(true); | ||
199 | + $data = array( | ||
200 | + 'orderEnsurePage' => true, | ||
201 | + 'orderEnsure' => CartModel::cartPay($uid, $cartType, $cookieData) | ||
202 | + ); | ||
198 | // var_dump($data); | 203 | // var_dump($data); |
199 | - $this->_view->display('order-ensure', $data); | ||
200 | - } | ||
201 | - | ||
202 | - /** | ||
203 | - * 购物车选择改变字段,重新运算订单数据 | ||
204 | - */ | ||
205 | - public function orderComputeAction() | ||
206 | - { | ||
207 | - $result = array(); | ||
208 | - | ||
209 | - if ($this->isAjax()) { | ||
210 | - $cartType = $this->post('cartType', 'ordinary'); | ||
211 | - $deliveryWay = $this->post('deliveryId', 1); | ||
212 | - $paymentType = $this->post('paymentTypeId', 1); | ||
213 | - $couponCode = $this->post('couponCode', null); | ||
214 | - $yohoCoin = $this->post('yohoCoin', null); | ||
215 | - $uid = $this->getUid(true); | ||
216 | - $result = CartModel::orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin); | ||
217 | - } | ||
218 | - | ||
219 | - if (empty($result)) { | ||
220 | - echo ' '; | ||
221 | - } else { | ||
222 | - $this->echoJson($result); | ||
223 | - } | ||
224 | - } | ||
225 | - | ||
226 | - /** | ||
227 | - * 购物车输入优惠券码使用优惠券 | ||
228 | - */ | ||
229 | - public function couponSearchAction() | ||
230 | - { | ||
231 | - $result = array(); | ||
232 | - | ||
233 | - if ($this->isAjax()) { | ||
234 | - $couponCode = $this->get('couponCode', ''); | ||
235 | - $uid = $this->getUid(true); | ||
236 | - $result = CartModel::searchCoupon($uid, $couponCode); | ||
237 | - } | ||
238 | - | ||
239 | - if (empty($result)) { | ||
240 | - echo ' '; | ||
241 | - } else { | ||
242 | - $this->echoJson($result); | ||
243 | - } | ||
244 | - } | ||
245 | - | ||
246 | - /** | ||
247 | - * 购物车结算--获取优惠券列表 | ||
248 | - */ | ||
249 | - public function couponListAction() | ||
250 | - { | ||
251 | - $result = array(); | ||
252 | - | ||
253 | - if ($this->isAjax()) { | ||
254 | - $uid = $this->getUid(true); | ||
255 | - $page = $this->get('page', 1); | ||
256 | - $result = CartModel::getCouponList($uid); | ||
257 | - } | ||
258 | - | ||
259 | - if (empty($result)) { | ||
260 | - echo ' '; | ||
261 | - } else { | ||
262 | - $this->echoJson($result); | ||
263 | - } | ||
264 | - } | 204 | + $this->_view->display('order-ensure', $data); |
205 | + } | ||
206 | + | ||
207 | + /** | ||
208 | + * 购物车选择改变字段,重新运算订单数据 | ||
209 | + */ | ||
210 | + public function orderComputeAction() | ||
211 | + { | ||
212 | + $result = array(); | ||
213 | + | ||
214 | + if ($this->isAjax()) { | ||
215 | + $cartType = $this->post('cartType', 'ordinary'); | ||
216 | + $deliveryWay = $this->post('deliveryId', 1); | ||
217 | + $paymentType = $this->post('paymentTypeId', 1); | ||
218 | + $couponCode = $this->post('couponCode', null); | ||
219 | + $yohoCoin = $this->post('yohoCoin', null); | ||
220 | + $uid = $this->getUid(true); | ||
221 | + $result = CartModel::orderCompute($uid, $cartType, $deliveryWay, $paymentType, $couponCode, $yohoCoin); | ||
222 | + } | ||
223 | + | ||
224 | + if (empty($result)) { | ||
225 | + echo ' '; | ||
226 | + } else { | ||
227 | + $this->echoJson($result); | ||
228 | + } | ||
229 | + } | ||
230 | + | ||
231 | + /** | ||
232 | + * 购物车输入优惠券码使用优惠券 | ||
233 | + */ | ||
234 | + public function couponSearchAction() | ||
235 | + { | ||
236 | + $result = array(); | ||
237 | + | ||
238 | + if ($this->isAjax()) { | ||
239 | + $couponCode = $this->get('couponCode', ''); | ||
240 | + $uid = $this->getUid(true); | ||
241 | + $result = CartModel::searchCoupon($uid, $couponCode); | ||
242 | + } | ||
243 | + | ||
244 | + if (empty($result)) { | ||
245 | + echo ' '; | ||
246 | + } else { | ||
247 | + $this->echoJson($result); | ||
248 | + } | ||
249 | + } | ||
250 | + | ||
251 | + /** | ||
252 | + * 购物车结算--获取优惠券列表 | ||
253 | + */ | ||
254 | + public function couponListAction() | ||
255 | + { | ||
256 | + $result = array(); | ||
257 | + | ||
258 | + if ($this->isAjax()) { | ||
259 | + $uid = $this->getUid(true); | ||
260 | + $page = $this->get('page', 1); | ||
261 | + $result = CartModel::getCouponList($uid); | ||
262 | + } | ||
263 | + | ||
264 | + if (empty($result)) { | ||
265 | + echo ' '; | ||
266 | + } else { | ||
267 | + $this->echoJson($result); | ||
268 | + } | ||
269 | + } | ||
265 | 270 | ||
266 | /** | 271 | /** |
267 | * 下单流程 选择地址 | 272 | * 下单流程 选择地址 |
@@ -272,7 +277,7 @@ class ShoppingCartController extends AbstractAction | @@ -272,7 +277,7 @@ class ShoppingCartController extends AbstractAction | ||
272 | $this->setTitle('选择地址'); | 277 | $this->setTitle('选择地址'); |
273 | $this->setNavHeader('选择地址', Helpers::url('/shoppingCart/orderEnsure')); | 278 | $this->setNavHeader('选择地址', Helpers::url('/shoppingCart/orderEnsure')); |
274 | 279 | ||
275 | - $uid = $this->getUid(true); | 280 | + $uid = $this->getUid(true); |
276 | $address = UserModel::getAddressData($uid); | 281 | $address = UserModel::getAddressData($uid); |
277 | 282 | ||
278 | $this->_view->display('select-address', array( | 283 | $this->_view->display('select-address', array( |
@@ -296,36 +301,72 @@ class ShoppingCartController extends AbstractAction | @@ -296,36 +301,72 @@ class ShoppingCartController extends AbstractAction | ||
296 | )); | 301 | )); |
297 | } | 302 | } |
298 | 303 | ||
299 | - /** | ||
300 | - * 确认结算订单 | ||
301 | - */ | ||
302 | - public function orderSubAction() | ||
303 | - { | ||
304 | - $result = array(); | ||
305 | - | ||
306 | - if ($this->isAjax()) { | ||
307 | - $uid = $this->getUid(true); | ||
308 | - $addressId = $this->post('addressId', null); | ||
309 | - $cartType = $this->post('cartType', 'ordinary'); // 默认普通购物车 | ||
310 | - $deliveryTime = $this->post('deliveryTimeId', 1); // 默认只工作日配送 | ||
311 | - $deliveryWay = $this->post('deliveryId', 1); // 默认普通快递 | ||
312 | - $invoiceTitle = $this->post('invoiceText', null); | ||
313 | - $invoiceId = $this->post('invoiceType', null); | ||
314 | - $paymentId = $this->post('paymentTypeId', 15); | ||
315 | - $paymentType = $this->post('paymentType', 1); // 默认在线支付 | ||
316 | - $remark = $this->post('msg', null); | ||
317 | - $couponCode = $this->post('couponCode', null); | ||
318 | - $yohoCoin = $this->post('yohoCoin', 1); | ||
319 | - $result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin); | ||
320 | - } | ||
321 | - | ||
322 | - if (empty($result)) { | ||
323 | - echo ' '; | ||
324 | - } else { | ||
325 | - // 提交成功清除Cookie | ||
326 | - $this->setCookie('order-info', null); | ||
327 | - | ||
328 | - $this->echoJson($result); | ||
329 | - } | ||
330 | - } | 304 | + /** |
305 | + * 确认结算订单 | ||
306 | + */ | ||
307 | + public function orderSubAction() | ||
308 | + { | ||
309 | + $result = array(); | ||
310 | + | ||
311 | + if ($this->isAjax()) { | ||
312 | + $uid = $this->getUid(true); | ||
313 | + $addressId = $this->post('addressId', null); | ||
314 | + $cartType = $this->post('cartType', 'ordinary'); // 默认普通购物车 | ||
315 | + $deliveryTime = $this->post('deliveryTimeId', 1); // 默认只工作日配送 | ||
316 | + $deliveryWay = $this->post('deliveryId', 1); // 默认普通快递 | ||
317 | + $invoiceTitle = $this->post('invoiceText', null); | ||
318 | + $invoiceId = $this->post('invoiceType', null); | ||
319 | + $paymentId = $this->post('paymentTypeId', 15); | ||
320 | + $paymentType = $this->post('paymentType', 1); // 默认在线支付 | ||
321 | + $remark = $this->post('msg', null); | ||
322 | + $couponCode = $this->post('couponCode', null); | ||
323 | + $yohoCoin = $this->post('yohoCoin', 1); | ||
324 | + $result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin); | ||
325 | + } | ||
326 | + | ||
327 | + if (empty($result)) { | ||
328 | + echo ' '; | ||
329 | + } else { | ||
330 | + // 提交成功清除Cookie | ||
331 | + $this->setCookie('order-info', null); | ||
332 | + | ||
333 | + $this->echoJson($result); | ||
334 | + } | ||
335 | + } | ||
336 | + | ||
337 | + /** | ||
338 | + * 加入购物车 | ||
339 | + * | ||
340 | + * @param string productSku 商品的SKU | ||
341 | + * @param int buyNumber 购买数量 | ||
342 | + * @param int promotionId 促销ID, 加价购有关 | ||
343 | + * @param int goodsType 商品类型,0表示普通商品,1表示加价购商品 | ||
344 | + * @param int isEdit 是否是编辑商品SKU,0表示不是编辑 | ||
345 | + * @return json | ||
346 | + */ | ||
347 | + public function addAction() | ||
348 | + { | ||
349 | + $result = array(); | ||
350 | + | ||
351 | + if ($this->isAjax()) { | ||
352 | + $shoppingKey = Helpers::getShoppingKeyByCookie(); | ||
353 | + $productSku = $this->post('productSku'); | ||
354 | + $buyNumber = $this->post('buyNumber', 1); | ||
355 | + $goodsType = $this->post('goodsType', 0); | ||
356 | + $promotionId = $this->post('promotionId', 0); | ||
357 | + $isEdit = $this->post('isEdit', 0); | ||
358 | + $uid = $this->getUid(true); | ||
359 | + | ||
360 | + // 执行加入购物车操作 | ||
361 | + $result = CartModel::addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid, $shoppingKey); | ||
362 | + | ||
363 | + // 设置加入购物车凭证到客户端浏览器 | ||
364 | + if (isset($result['data']['shopping_key'])) { | ||
365 | + $this->setCookie('_spk', $shoppingKey); | ||
366 | + } | ||
367 | + } | ||
368 | + | ||
369 | + $this->echoJson($result); | ||
370 | + } | ||
371 | + | ||
331 | } | 372 | } |
@@ -8,36 +8,37 @@ use Plugin\Helpers; | @@ -8,36 +8,37 @@ use Plugin\Helpers; | ||
8 | /** | 8 | /** |
9 | * 帮助中心相关数据处理 | 9 | * 帮助中心相关数据处理 |
10 | */ | 10 | */ |
11 | - | ||
12 | -class HelpModel { | 11 | +class HelpModel |
12 | +{ | ||
13 | /* | 13 | /* |
14 | * 获取帮助中心列表 | 14 | * 获取帮助中心列表 |
15 | */ | 15 | */ |
16 | - | ||
17 | - public static function serviceInfo() { | ||
18 | - //调用接口获取数据 | ||
19 | - $res = json_decode(HelpData::serviceInfo(), TRUE); | ||
20 | - $cateInfo = $res['data']; | 16 | + public static function serviceInfo() |
17 | + { | ||
21 | $iHelp = array(); | 18 | $iHelp = array(); |
22 | - $list = array(); | ||
23 | - if ($cateInfo) { | ||
24 | - foreach ($cateInfo as $key => $value) { | 19 | + |
20 | + $cateInfo = HelpData::serviceInfo(); | ||
21 | + if (!empty($cateInfo['data'])) { | ||
22 | + foreach ($cateInfo['data'] as $key => $value) { | ||
25 | $iHelp[$key]['name'] = $value['caption']; | 23 | $iHelp[$key]['name'] = $value['caption']; |
26 | $iHelp[$key]['code'] = $value['code']; | 24 | $iHelp[$key]['code'] = $value['code']; |
27 | - $iHelp[$key]['url'] = Helpers::url('/home/helpDetail', array('code' => $value['code'], 'caption' => $value['caption']) ); | 25 | + $iHelp[$key]['url'] = Helpers::url('/home/helpDetail', array('code' => $value['code'], 'caption' => $value['caption'])); |
28 | } | 26 | } |
29 | } | 27 | } |
28 | + | ||
30 | return $iHelp; | 29 | return $iHelp; |
31 | } | 30 | } |
32 | - | 31 | + |
33 | /* | 32 | /* |
34 | * 获取帮助中心详细内容 | 33 | * 获取帮助中心详细内容 |
35 | */ | 34 | */ |
36 | - public static function serviceDetail($code) { | 35 | + |
36 | + public static function serviceDetail($code) | ||
37 | + { | ||
37 | $res = HelpData::serviceDetail($code); | 38 | $res = HelpData::serviceDetail($code); |
38 | if (!empty($res)) { | 39 | if (!empty($res)) { |
39 | - if (false !== ($part = strstr($res,'<div class="deal_main">'))) { | ||
40 | - $res = strstr($part,'</body>',TRUE); | 40 | + if (false !== ($part = strstr($res, '<body>'))) { |
41 | + $res = strstr($part, '</body>', true); | ||
41 | } | 42 | } |
42 | } | 43 | } |
43 | return $res; | 44 | return $res; |
@@ -160,17 +160,15 @@ class DetailModel | @@ -160,17 +160,15 @@ class DetailModel | ||
160 | $colorGroup = array(); | 160 | $colorGroup = array(); |
161 | $sizeList = array(); | 161 | $sizeList = array(); |
162 | $goodsGroup = array(); | 162 | $goodsGroup = array(); |
163 | - $coverImage = ''; | ||
164 | - $colorStorageNum = 0; // 颜色的库存总数 | 163 | + $thumbImageList = array(); |
164 | + $colorStorageGroup = array(); // 颜色分组的库存总数集合, 多个之间用/分隔 | ||
165 | + $sizeStorageStr = ''; // 尺码库存总数集合, 多个之间用/分隔 | ||
166 | + $colorStorageNum = 0; | ||
165 | $totalStorageNum = 0; // 总库存数 | 167 | $totalStorageNum = 0; // 总库存数 |
166 | - foreach ($baseInfo['goodsList'] as $i => $value) { | 168 | + foreach ($baseInfo['goodsList'] as $value) { |
167 | $sizeList = array(); | 169 | $sizeList = array(); |
168 | $colorStorageNum = 0; | 170 | $colorStorageNum = 0; |
169 | - | ||
170 | - // 获取默认的封面图 | ||
171 | - if ($i === 0) { | ||
172 | - $coverImage = Helpers::getImageUrl($value['colorImage'], 60, 60); | ||
173 | - } | 171 | + $sizeStorageStr = ''; // clear to empty |
174 | 172 | ||
175 | // 商品分组 | 173 | // 商品分组 |
176 | if (isset($value['goodsImagesList'])) { | 174 | if (isset($value['goodsImagesList'])) { |
@@ -189,10 +187,13 @@ class DetailModel | @@ -189,10 +187,13 @@ class DetailModel | ||
189 | 'id' => $size['id'], | 187 | 'id' => $size['id'], |
190 | 'skuId' => $size['goodsSizeSkuId'], | 188 | 'skuId' => $size['goodsSizeSkuId'], |
191 | 'goodsId' => $size['goodsId'], | 189 | 'goodsId' => $size['goodsId'], |
190 | + 'colorId' => $value['colorId'], | ||
192 | 'name' => $size['sizeName'], | 191 | 'name' => $size['sizeName'], |
193 | 'sizeNum' => $size['goodsSizeStorageNum'], | 192 | 'sizeNum' => $size['goodsSizeStorageNum'], |
194 | ); | 193 | ); |
195 | $colorStorageNum += intval($size['goodsSizeStorageNum']); | 194 | $colorStorageNum += intval($size['goodsSizeStorageNum']); |
195 | + $sizeStorageStr .= $size['goodsSizeStorageNum'] . '/'; | ||
196 | + $colorStorageGroup[ $size['sizeName'] ][ $value['colorName'] ] = $size['goodsSizeStorageNum']; | ||
196 | } | 197 | } |
197 | } | 198 | } |
198 | 199 | ||
@@ -202,11 +203,19 @@ class DetailModel | @@ -202,11 +203,19 @@ class DetailModel | ||
202 | 'skcId' => $value['productSkc'], | 203 | 'skcId' => $value['productSkc'], |
203 | 'name' => $value['colorName'], | 204 | 'name' => $value['colorName'], |
204 | 'goodsName' => $value['goodsName'], | 205 | 'goodsName' => $value['goodsName'], |
205 | - 'shortUrl' => Helpers::getImageUrl($value['colorImage'], 60, 60), | ||
206 | 'colorNum' => $colorStorageNum, | 206 | 'colorNum' => $colorStorageNum, |
207 | - 'sizes' => $sizeList, | 207 | + 'sizeNumStr' => rtrim($sizeStorageStr, '/'), |
208 | ); | 208 | ); |
209 | 209 | ||
210 | + // 缩略图 | ||
211 | + $thumbImageList[] = array('img' => Helpers::getImageUrl($value['colorImage'], 60, 60) ); | ||
212 | + | ||
213 | + // 统计每个尺码对应的各个颜色的库存量 | ||
214 | + foreach ($sizeList as &$sizeArr) { | ||
215 | + $sizeArr['colorNumStr'] = implode('/', array_values($colorStorageGroup[ $sizeArr['name'] ]) ); | ||
216 | + } | ||
217 | + | ||
218 | + // 商品库存总数 | ||
210 | $totalStorageNum += $colorStorageNum; | 219 | $totalStorageNum += $colorStorageNum; |
211 | } | 220 | } |
212 | 221 | ||
@@ -238,12 +247,13 @@ class DetailModel | @@ -238,12 +247,13 @@ class DetailModel | ||
238 | if (!$soldOut && !$notForSale) { | 247 | if (!$soldOut && !$notForSale) { |
239 | $result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html'); | 248 | $result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html'); |
240 | $result['cartInfo']['productId'] = $productId; | 249 | $result['cartInfo']['productId'] = $productId; |
241 | - $result['cartInfo']['thumb'] = $coverImage; | 250 | + $result['cartInfo']['thumbs'] = $thumbImageList; |
242 | $result['cartInfo']['name'] = isset($result['goodsName']) ? $result['goodsName'] : ''; | 251 | $result['cartInfo']['name'] = isset($result['goodsName']) ? $result['goodsName'] : ''; |
243 | $result['cartInfo']['price'] = isset($result['goodsPrice']['currentPrice']) ? $result['goodsPrice']['currentPrice'] : ''; | 252 | $result['cartInfo']['price'] = isset($result['goodsPrice']['currentPrice']) ? $result['goodsPrice']['currentPrice'] : ''; |
244 | $result['cartInfo']['salePrice'] = isset($result['goodsPrice']['previousPrice']) ? $result['goodsPrice']['previousPrice'] : ''; | 253 | $result['cartInfo']['salePrice'] = isset($result['goodsPrice']['previousPrice']) ? $result['goodsPrice']['previousPrice'] : ''; |
245 | $result['cartInfo']['totalNum'] = $totalStorageNum; | 254 | $result['cartInfo']['totalNum'] = $totalStorageNum; |
246 | $result['cartInfo']['colors'] = $colorGroup; | 255 | $result['cartInfo']['colors'] = $colorGroup; |
256 | + $result['cartInfo']['sizes'] = $sizeList; | ||
247 | } | 257 | } |
248 | // 非卖品 | 258 | // 非卖品 |
249 | elseif ($notForSale) { | 259 | elseif ($notForSale) { |
@@ -336,7 +346,7 @@ class DetailModel | @@ -336,7 +346,7 @@ class DetailModel | ||
336 | 346 | ||
337 | $referenceList = array(); | 347 | $referenceList = array(); |
338 | // 判断是否显示参考尺码 | 348 | // 判断是否显示参考尺码 |
339 | - $showReference = !empty($sizeInfo['sizeInfoBo']['sizeBoList'][0]['referenceSize']) && ($sizeInfo['sizeInfoBo']['sizeBoList'][0]['referenceSize']['gender'] == $gender || $sizeInfo['sizeInfoBo']['sizeBoList'][0]['referenceSize']['gender'] == 3); | 349 | + $showReference = !empty($sizeInfo['sizeInfoBo']['sizeBoList'][0]['referenceSize']); |
340 | if ($showReference) { | 350 | if ($showReference) { |
341 | $referenceList[0] = array('param' => $referenceName); | 351 | $referenceList[0] = array('param' => $referenceName); |
342 | } | 352 | } |
@@ -351,7 +361,10 @@ class DetailModel | @@ -351,7 +361,10 @@ class DetailModel | ||
351 | foreach ($sizeInfo['sizeInfoBo']['sizeBoList'] as $value) { | 361 | foreach ($sizeInfo['sizeInfoBo']['sizeBoList'] as $value) { |
352 | $item = array(); | 362 | $item = array(); |
353 | $sizeNameList[] = array('param' => $value['sizeName']); | 363 | $sizeNameList[] = array('param' => $value['sizeName']); |
354 | - if (!empty($value['referenceSize']['gender']) && ($value['referenceSize']['gender'] == $gender || $value['referenceSize']['gender'] == 3)) { | 364 | + if (!empty($value['referenceSize']['gender']) && $boyReference && ($value['referenceSize']['gender'] == 1 || $value['referenceSize']['gender'] == 3)) { |
365 | + $referenceList[] = array('param' => empty($value['referenceSize']['referenceName']) ? ' ' : $value['referenceSize']['referenceName']); | ||
366 | + } | ||
367 | + elseif (!empty($value['referenceSize']['gender']) && $girlReference && ($value['referenceSize']['gender'] == 2 || $value['referenceSize']['gender'] == 3)) { | ||
355 | $referenceList[] = array('param' => empty($value['referenceSize']['referenceName']) ? ' ' : $value['referenceSize']['referenceName']); | 368 | $referenceList[] = array('param' => empty($value['referenceSize']['referenceName']) ? ' ' : $value['referenceSize']['referenceName']); |
356 | } | 369 | } |
357 | foreach ($value['sortAttributes'] as $attr) { | 370 | foreach ($value['sortAttributes'] as $attr) { |
-
Please register or login to post a comment