code review by liangzhifeng
Showing
10 changed files
with
83 additions
and
5 deletions
@@ -231,6 +231,23 @@ $('.nav-home').on('touchstart', function() { | @@ -231,6 +231,23 @@ $('.nav-home').on('touchstart', function() { | ||
231 | window.cancelAnimationFrame = cancelAnimationFrame; | 231 | window.cancelAnimationFrame = cancelAnimationFrame; |
232 | }()); | 232 | }()); |
233 | 233 | ||
234 | +// 给jQuery 扩展 queryString函数 | ||
235 | +$.extend({ | ||
236 | + queryString: function() { | ||
237 | + var vars = [], | ||
238 | + hash, | ||
239 | + i; | ||
240 | + var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); | ||
241 | + | ||
242 | + for (i = 0; i < hashes.length; i++) { | ||
243 | + hash = hashes[i].split('='); | ||
244 | + vars.push(hash[0]); | ||
245 | + vars[hash[0]] = hash[1]; | ||
246 | + } | ||
247 | + return vars; | ||
248 | + } | ||
249 | +}); | ||
250 | + | ||
234 | //暴露公共接口 | 251 | //暴露公共接口 |
235 | window.cookie = cookie; | 252 | window.cookie = cookie; |
236 | 253 |
@@ -20,7 +20,8 @@ var $addressForm = $('.edit-address'), | @@ -20,7 +20,8 @@ var $addressForm = $('.edit-address'), | ||
20 | $area = $('.area'), | 20 | $area = $('.area'), |
21 | isSubmiting, | 21 | isSubmiting, |
22 | currentPage = 'edit', | 22 | currentPage = 'edit', |
23 | - newArea = []; | 23 | + newArea = [], |
24 | + queryString = $.queryString(); | ||
24 | 25 | ||
25 | $($editAddressPage, $addressListPage).css('min-height', function() { | 26 | $($editAddressPage, $addressListPage).css('min-height', function() { |
26 | return $(window).height() - $('#yoho-header').height(); | 27 | return $(window).height() - $('#yoho-header').height(); |
@@ -91,8 +92,12 @@ $addressForm.on('submit', function() { | @@ -91,8 +92,12 @@ $addressForm.on('submit', function() { | ||
91 | isSubmiting = false; | 92 | isSubmiting = false; |
92 | loading.hideLoadingMask(); | 93 | loading.hideLoadingMask(); |
93 | } else { | 94 | } else { |
95 | + if (queryString.refer === 'shopping') { | ||
96 | + window.location.href = '/shoppingCart/selectAddress'; | ||
97 | + } else { | ||
94 | window.location.href = '/home/address'; | 98 | window.location.href = '/home/address'; |
95 | } | 99 | } |
100 | + } | ||
96 | }).fail(function() { | 101 | }).fail(function() { |
97 | tip.show('网络出了点问题~'); | 102 | tip.show('网络出了点问题~'); |
98 | isSubmiting = false; | 103 | isSubmiting = false; |
@@ -69,4 +69,5 @@ $addAddress.on('touchend', function() { | @@ -69,4 +69,5 @@ $addAddress.on('touchend', function() { | ||
69 | $action.on('touchend', '.del', function() { | 69 | $action.on('touchend', '.del', function() { |
70 | deleteId = $(this).data('id'); | 70 | deleteId = $(this).data('id'); |
71 | $confim.fadeIn(); | 71 | $confim.fadeIn(); |
72 | + return false; | ||
72 | }); | 73 | }); |
static/js/shopping-cart/select-address.js
0 → 100644
1 | +/** | ||
2 | + * 购物车 地址选择 | ||
3 | + * @author: bikai<kai.bi@yoho.cn> | ||
4 | + * @date: 2015/12/14 | ||
5 | + */ | ||
6 | + | ||
7 | +var $ = require('jquery'), | ||
8 | + orderInfo = require('./order-info'); | ||
9 | + | ||
10 | +$('.address-item').on('touchend', function() { | ||
11 | + orderInfo('addressId', $(this).data('address_id')); | ||
12 | +}).on('touchend', '.edit', function() { | ||
13 | + window.location.href = $(this).data('href'); | ||
14 | + return false; | ||
15 | +}); |
@@ -2,12 +2,36 @@ | @@ -2,12 +2,36 @@ | ||
2 | <div class="my-address-page select-address-page yoho-page"> | 2 | <div class="my-address-page select-address-page yoho-page"> |
3 | <div class="page-wrap"> | 3 | <div class="page-wrap"> |
4 | {{# address}} | 4 | {{# address}} |
5 | - <a class="address-item" href="/shoppingCart/orderEnsure?address_id={{address_id}}"> | 5 | + <a class="address-item" data-address-id="{{address_id}}" href="/shoppingCart/orderEnsure?address_id={{address_id}}"> |
6 | <span class="name">{{consignee}}</span> | 6 | <span class="name">{{consignee}}</span> |
7 | <span class="tel">{{mobile}}</span> | 7 | <span class="tel">{{mobile}}</span> |
8 | <p class="address-info">{{area}} {{address}}</p> | 8 | <p class="address-info">{{area}} {{address}}</p> |
9 | + <div class="action iconfont"> | ||
10 | + <span class="edit" data-href="/home/addressAct?id={{address_id}}&refer=shopping"></span> | ||
11 | + <span class="del" data-id="{{address_id}}"></span> | ||
12 | + </div> | ||
9 | </a> | 13 | </a> |
10 | {{/ address}} | 14 | {{/ address}} |
15 | + | ||
16 | + <a class="add-address" data-href="/home/addressAct?refer=shopping"> | ||
17 | + 添加新地址 | ||
18 | + </a> | ||
19 | + | ||
20 | + <div class="confim-mask hide"> | ||
21 | + <div class="confim-box"> | ||
22 | + <div class="content"> | ||
23 | + 您确定要删除地址? | ||
24 | + </div> | ||
25 | + <div class="action"> | ||
26 | + <span class="cancel"> | ||
27 | + 取消 | ||
28 | + </span> | ||
29 | + <span class="confim"> | ||
30 | + 确认 | ||
31 | + </span> | ||
32 | + </div> | ||
33 | + </div> | ||
34 | + </div> | ||
11 | </div> | 35 | </div> |
12 | </div> | 36 | </div> |
13 | {{> layout/footer}} | 37 | {{> layout/footer}} |
@@ -218,6 +218,12 @@ | @@ -218,6 +218,12 @@ | ||
218 | seajs.use('js/shopping-cart/order-ensure'); | 218 | seajs.use('js/shopping-cart/order-ensure'); |
219 | </script> | 219 | </script> |
220 | {{/if}} | 220 | {{/if}} |
221 | +{{#if selectAddressPage}} | ||
222 | +<script> | ||
223 | + seajs.use('js/me/address'); | ||
224 | + seajs.use('js/shopping-cart/select-address'); | ||
225 | +</script> | ||
226 | +{{/if}} | ||
221 | {{#if selectCouponPage}} | 227 | {{#if selectCouponPage}} |
222 | <script> | 228 | <script> |
223 | seajs.use('js/shopping-cart/select-coupon'); | 229 | seajs.use('js/shopping-cart/select-coupon'); |
@@ -386,7 +386,7 @@ class ShoppingCartController extends AbstractAction | @@ -386,7 +386,7 @@ class ShoppingCartController extends AbstractAction | ||
386 | $this->setTitle('选择地址'); | 386 | $this->setTitle('选择地址'); |
387 | $this->setNavHeader('选择地址', Helpers::url('/shoppingCart/orderEnsure')); | 387 | $this->setNavHeader('选择地址', Helpers::url('/shoppingCart/orderEnsure')); |
388 | 388 | ||
389 | - $uid = $this->_uid; | 389 | + $uid = $this->getUid(true); |
390 | $address = UserModel::getAddressData($uid); | 390 | $address = UserModel::getAddressData($uid); |
391 | 391 | ||
392 | $this->_view->display('select-address', array( | 392 | $this->_view->display('select-address', array( |
@@ -405,7 +405,7 @@ class ShoppingCartController extends AbstractAction | @@ -405,7 +405,7 @@ class ShoppingCartController extends AbstractAction | ||
405 | $this->setTitle('选择优惠券'); | 405 | $this->setTitle('选择优惠券'); |
406 | $this->setNavHeader('选择优惠券', Helpers::url('/shoppingCart/orderEnsure')); | 406 | $this->setNavHeader('选择优惠券', Helpers::url('/shoppingCart/orderEnsure')); |
407 | 407 | ||
408 | - $uid = $this->_uid; | 408 | + $uid = $this->getUid(true); |
409 | $address = UserModel::getAddressData($uid); | 409 | $address = UserModel::getAddressData($uid); |
410 | 410 | ||
411 | $this->_view->display('select-coupon', array( | 411 | $this->_view->display('select-coupon', array( |
-
Please register or login to post a comment