用户地址管理

This commit is contained in:
devil_gong 2018-10-12 11:17:37 +08:00
parent 60868e4afe
commit b76c27129c
8 changed files with 192 additions and 19 deletions

View File

@ -2,7 +2,6 @@
namespace Home\Controller;
use Service\BuyService;
use Service\UserService;
/**
@ -39,15 +38,9 @@ class UserAddressController extends CommonController
*/
public function Index()
{
$cart_list = BuyService::CartList(['user'=>$this->user]);
$this->assign('cart_list', $cart_list['data']);
// 用户地址
$this->assign('user_address_list', UserService::UserAddressList(['user'=>$this->user])['data']);
$base = [
'total_price' => empty($cart_list['data']) ? 0 : array_sum(array_column($cart_list['data'], 'total_price')),
'total_stock' => empty($cart_list['data']) ? 0 : array_sum(array_column($cart_list['data'], 'stock')),
'ids' => empty($cart_list['data']) ? '' : implode(',', array_column($cart_list['data'], 'id')),
];
$this->assign('base', $base);
$this->display('Index');
}

View File

@ -57,6 +57,13 @@ return array(
'is_show' => 1,
'icon' => 'am-icon-gear',
),
array(
'control' => 'UserAddress',
'action' => 'Index',
'name' => '我的地址',
'is_show' => 1,
'icon' => 'am-icon-map-marker',
),
array(
'control' => 'Safety',
'action' => 'Index',

View File

@ -21,7 +21,7 @@
<div class="control">
<h3>确认收货地址</h3>
<notempty name="user_address_list">
<button class="am-btn am-btn-primary am-btn-xs address-submit-save" type="button" data-url="{{:U('Home/UserAddress/SaveInfo')}}">使用新地址</button>
<button class="am-btn am-btn-primary am-btn-xs address-submit-save" type="button" data-url="{{:U('Home/UserAddress/SaveInfo')}}" data-popup-title="新增地址">使用新地址</button>
</notempty>
</div>
<notempty name="user_address_list">
@ -30,6 +30,9 @@
<li class="<if condition="isset($address['is_default']) and $address['is_default'] eq 1">address-default</if>" id="data-list-{{$address.id}}" data-value="{{$address.id}}">
<div class="address-left">
<div class="user-base">
<notempty name="address.alias">
<span class="am-badge am-badge-danger am-radius">{{$address.alias}}</span>
</notempty>
<span class="buy-address-detail">
<span class="buy-user">{{$address.name}}</span>
<span class="buy-phone">{{$address.tel}}</span>
@ -37,7 +40,7 @@
</div>
<div>
<span class="buy-line-title buy-line-title-type">收货地址:</span>
<span class="buy--address-detail">
<span class="buy-address-detail">
<span class="province">{{$address.province_name}}</span>
<span class="city">{{$address.city_name}}</span>
<span class="dist">{{$address.county_name}}</span>
@ -54,7 +57,7 @@
<div class="new-addr-btn">
<a href="javascript:;" class="address-default-submit" data-url="{{:U('Home/UserAddress/SetDefault')}}" data-id="{{$address.id}}">设为默认</a>
<span class="new-addr-bar">|</span>
<a href="javascript:;" class="address-submit-save" data-url="{{:U('Home/UserAddress/SaveInfo', ['id'=>$address['id']])}}">编辑</a>
<a href="javascript:;" class="address-submit-save" data-url="{{:U('Home/UserAddress/SaveInfo', ['id'=>$address['id']])}}" data-popup-title="编辑地址">编辑</a>
<span class="new-addr-bar">|</span>
<a href="javascript:;" class="address-submit-delete" data-url="{{:U('Home/UserAddress/Delete')}}" data-id="{{$address.id}}">删除</a>
</div>
@ -66,7 +69,7 @@
<div class="table-no">
<i class="am-icon-warning"></i>
{{:L('buy_user_address_not_data_tips')}}
<button class="am-btn am-btn-secondary am-btn-xs address-submit-save" type="button" data-url="{{:U('Home/UserAddress/SaveInfo')}}">使用新地址</button></div>
<button class="am-btn am-btn-secondary am-btn-xs address-submit-save" type="button" data-url="{{:U('Home/UserAddress/SaveInfo')}}" data-popup-title="新增地址">使用新地址</button></div>
</empty>
</div>

View File

@ -0,0 +1,73 @@
<include file="Public/Header" />
<!-- header top nav -->
<include file="Public/HeaderTopNav" />
<!-- search -->
<include file="Public/NavSearch" />
<!-- header nav -->
<include file="Public/HeaderNav" />
<!-- goods category -->
<include file="Public/GoodsCategory" />
<!-- content -->
<div class="am-container user-main">
<!-- user menu start -->
<include file="Public/UserMenu" />
<!-- user menu end -->
<!-- content start -->
<div class="user-content">
<div class="user-content-body">
<div class="control">
<button class="am-btn am-btn-primary am-btn-xs am-icon-plus address-submit-save" type="button" data-url="{{:U('Home/UserAddress/SaveInfo')}}" data-popup-title="新增地址"> 新增新地址</button>
</div>
<notempty name="user_address_list">
<ul class="address-list">
<foreach name="user_address_list" item="address">
<li class="<if condition="isset($address['is_default']) and $address['is_default'] eq 1">address-default</if>" id="data-list-{{$address.id}}" data-value="{{$address.id}}">
<div class="address-left">
<div class="user-base">
<notempty name="address.alias">
<span class="am-badge am-badge-danger am-radius">{{$address.alias}}</span>
</notempty>
<span class="buy-address-detail">
<span class="buy-user">{{$address.name}}</span>
<span class="buy-phone">{{$address.tel}}</span>
</span>
</div>
<div>
<span class="buy-line-title buy-line-title-type">收货地址:</span>
<span class="buy-address-detail">
<span class="province">{{$address.province_name}}</span>
<span class="city">{{$address.city_name}}</span>
<span class="dist">{{$address.county_name}}</span>
<span class="street">{{$address.address}}</span>
</span>
</div>
<if condition="isset($address['is_default']) and $address['is_default'] eq 1">
<span class="deftip">默认地址</span>
</if>
</div>
<div class="new-addr-btn">
<a href="javascript:;" class="address-default-submit" data-url="{{:U('Home/UserAddress/SetDefault')}}" data-id="{{$address.id}}" data-view="reload">设为默认</a>
<span class="new-addr-bar">|</span>
<a href="javascript:;" class="address-submit-save" data-url="{{:U('Home/UserAddress/SaveInfo', ['id'=>$address['id']])}}" data-popup-title="编辑地址">编辑</a>
<span class="new-addr-bar">|</span>
<a href="javascript:;" class="address-submit-delete" data-url="{{:U('Home/UserAddress/Delete')}}" data-id="{{$address.id}}">删除</a>
</div>
</li>
</foreach>
</ul>
</notempty>
</div>
</div>
<!-- content end -->
</div>
<!-- footer start -->
<include file="Public/Footer" />
<!-- footer end -->

View File

@ -667,7 +667,7 @@ background:url(../Images/ibar_sprites.png) no-repeat;background-position:0px -23
.user-content-body {-webkit-box-flex:1;-webkit-flex:1 0 auto;-ms-flex:1 0 auto;flex:1 0 auto; }
.user-offcanvas-bar { z-index: 900; }
@media only screen and (min-width:640px) {
.user-sidebar {display:block;position:static;background:none; border-top: 5px solid #f78590;}
.user-sidebar {display:block;position:static;background:none; border-top: 5px solid #e94353;}
.user-offcanvas-bar {position:static;width:auto;background:none;-webkit-transform:translate3d(0,0,0);-ms-transform:translate3d(0,0,0);transform:translate3d(0,0,0);overflow-y:hidden;}
.user-offcanvas-bar:after {content:none;}
.user-main { padding: 0 5px; }

View File

@ -1,4 +1,76 @@
.my-content { padding: 15px 10px; }
.region-linkage .chosen-select { display: -webkit-inline-box; width: calc(33.3% - 3px) !important; }
.region-linkage .chosen-select .chosen-single { width: 100%; }
#map { width: 100%; height: 250px; }
/**
* 地址管理
*/
ul.address-list {
overflow: hidden;
margin-top: 10px;
}
ul.address-list li.address-default {
background-image: url(../Images/peraddressbg.png);
}
ul.address-list li {
display: block;
width: calc(50% - 5px);
height: 150px;
float: left;
background-image: url(../Images/peraddbg.png);
background-repeat: no-repeat;
background-size: 100% 100%;
margin: 0 10px 10px 0;
padding: 10px;
position: relative;
}
ul.address-list li .user-base {
font-size: 14px;
font-weight: 700;
}
.new-addr-btn {
position: absolute;
bottom: 10px;
right: 25px;
color: #282828;
text-align: right;
}
ul.address-list li:nth-child(2n) {
margin-right: 0;
}
@media only screen and (min-width: 1025px) {
ul.address-list li {
width: calc(25% - 8px);
}
ul.address-list li:nth-child(2n) {
margin-right: 10px;
}
ul.address-list li:nth-child(4n) {
margin-right: 0;
}
}
/**
* 地址添加/编辑
*/
.my-content {
padding: 15px 10px;
}
.region-linkage .chosen-select {
display: -webkit-inline-box;
width: calc(33.3% - 3px) !important;
}
.region-linkage .chosen-select .chosen-single {
width: 100%;
}
#map {
width: 100%;
height: 250px;
}

View File

@ -93,7 +93,7 @@ $(function()
// 弹出地址选择
$('.address-submit-save').on('click', function(e)
{
ModalLoad($(this).data('url'), '地址管理', 'popup-modal-address', 'common-address-modal');
ModalLoad($(this).data('url'), $(this).data('popup-title'), 'popup-modal-address', 'common-address-modal');
// 阻止事件冒泡
e.stopPropagation();

View File

@ -0,0 +1,25 @@
$(function()
{
// 弹出地址选择
$('.address-submit-save').on('click', function(e)
{
ModalLoad($(this).data('url'), $(this).data('popup-title'), 'popup-modal-address', 'common-address-modal');
// 阻止事件冒泡
e.stopPropagation();
});
// 阻止事件冒泡
$('.address-submit-delete').on('click', function(e)
{
DataDelete($(this));
e.stopPropagation();
});
// 设为默认地址
$('.address-default-submit').on('click', function(e)
{
ConfirmNetworkAjax($(this));
e.stopPropagation();
});
});