Authored by 毕凯

code review by liangzhifeng

... ... @@ -231,6 +231,23 @@ $('.nav-home').on('touchstart', function() {
window.cancelAnimationFrame = cancelAnimationFrame;
}());
// 给jQuery 扩展 queryString函数
$.extend({
queryString: function() {
var vars = [],
hash,
i;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
});
//暴露公共接口
window.cookie = cookie;
... ...
... ... @@ -20,7 +20,8 @@ var $addressForm = $('.edit-address'),
$area = $('.area'),
isSubmiting,
currentPage = 'edit',
newArea = [];
newArea = [],
queryString = $.queryString();
$($editAddressPage, $addressListPage).css('min-height', function() {
return $(window).height() - $('#yoho-header').height();
... ... @@ -91,7 +92,11 @@ $addressForm.on('submit', function() {
isSubmiting = false;
loading.hideLoadingMask();
} else {
window.location.href = '/home/address';
if (queryString.refer === 'shopping') {
window.location.href = '/shoppingCart/selectAddress';
} else {
window.location.href = '/home/address';
}
}
}).fail(function() {
tip.show('网络出了点问题~');
... ...
... ... @@ -69,4 +69,5 @@ $addAddress.on('touchend', function() {
$action.on('touchend', '.del', function() {
deleteId = $(this).data('id');
$confim.fadeIn();
return false;
});
... ...
... ... @@ -6,4 +6,6 @@
require('./cart');
require('./gift-advance');
require('./order-ensure');
\ No newline at end of file
require('./order-ensure');
require('./select-coupon');
require('./select-address');
... ...
/**
* 购物车 地址选择
* @author: bikai<kai.bi@yoho.cn>
* @date: 2015/12/14
*/
var $ = require('jquery'),
orderInfo = require('./order-info');
$('.address-item').on('touchend', function() {
orderInfo('addressId', $(this).data('address_id'));
}).on('touchend', '.edit', function() {
window.location.href = $(this).data('href');
return false;
});
... ...
@import "good", "chose-panel", "gift-advance-good", "order-ensure", "select-coupon";
@import "good", "chose-panel", "gift-advance-good", "order-ensure", "select-coupon", "select-address";
.icon-checkbox:before { content: "\e61c"; }
... ...
.select-address-page {
padding-bottom: pxToRem(20px);
.add-address {
margin-bottom: 0;
}
}
... ...
... ... @@ -2,12 +2,36 @@
<div class="my-address-page select-address-page yoho-page">
<div class="page-wrap">
{{# address}}
<a class="address-item" href="/shoppingCart/orderEnsure?address_id={{address_id}}">
<a class="address-item" data-address-id="{{address_id}}" href="/shoppingCart/orderEnsure?address_id={{address_id}}">
<span class="name">{{consignee}}</span>
<span class="tel">{{mobile}}</span>
<p class="address-info">{{area}} {{address}}</p>
<div class="action iconfont">
<span class="edit" data-href="/home/addressAct?id={{address_id}}&refer=shopping">&#xe61e;</span>
<span class="del" data-id="{{address_id}}">&#xe621;</span>
</div>
</a>
{{/ address}}
<a class="add-address" data-href="/home/addressAct?refer=shopping">
添加新地址
</a>
<div class="confim-mask hide">
<div class="confim-box">
<div class="content">
您确定要删除地址?
</div>
<div class="action">
<span class="cancel">
取消
</span>
<span class="confim">
确认
</span>
</div>
</div>
</div>
</div>
</div>
{{> layout/footer}}
... ...
... ... @@ -218,6 +218,12 @@
seajs.use('js/shopping-cart/order-ensure');
</script>
{{/if}}
{{#if selectAddressPage}}
<script>
seajs.use('js/me/address');
seajs.use('js/shopping-cart/select-address');
</script>
{{/if}}
{{#if selectCouponPage}}
<script>
seajs.use('js/shopping-cart/select-coupon');
... ...
... ... @@ -386,7 +386,7 @@ class ShoppingCartController extends AbstractAction
$this->setTitle('选择地址');
$this->setNavHeader('选择地址', Helpers::url('/shoppingCart/orderEnsure'));
$uid = $this->_uid;
$uid = $this->getUid(true);
$address = UserModel::getAddressData($uid);
$this->_view->display('select-address', array(
... ... @@ -405,7 +405,7 @@ class ShoppingCartController extends AbstractAction
$this->setTitle('选择优惠券');
$this->setNavHeader('选择优惠券', Helpers::url('/shoppingCart/orderEnsure'));
$uid = $this->_uid;
$uid = $this->getUid(true);
$address = UserModel::getAddressData($uid);
$this->_view->display('select-coupon', array(
... ...