作者 anyv
1 个管道 的构建 通过 耗费 0 秒

5

... ... @@ -153,6 +153,8 @@ class PersonalcenterController extends WeChatBaseController{
public function add_shop_address(){
if($this -> request -> isPost()){
$uid = cmf_get_current_user_id();
$_POST['uid'] = $uid;
$add = Db::name('address') -> insert($_POST);
if($add){
return true;
... ... @@ -163,11 +165,37 @@ class PersonalcenterController extends WeChatBaseController{
return $this -> fetch();
}
}
/**
* 设置默认地址
*/
public function set_default_address(){
$uid = cmf_get_current_user_id();
Db::name('address') -> where('uid',$uid) -> update(['default_address'=>1]);
$data = Db::name('address') -> where('id',$_POST['id']) -> update(['default_address'=>1]);
if($data){
return true;
}else{
return false;
}
}
/**
* 删除默认地址
*/
public function address_del(){
$data = Db::name('address') -> delete($_POST['id']);
if($data){
return true;
}else{
return false;
}
}
... ...
... ... @@ -37,8 +37,8 @@
</div>
<p class="ad_conAddress">收货地址:{$vo.region}{$vo.detailed}</p>
<div class="ad_MoRemove">
<div class="ad_mo">设为默认</div>
<div class="ad_move">删除</div>
<div class="ad_mo" onclick="set_default({$vo.id})">设为默认</div>
<div class="ad_move" onclick="address_del({$vo.id})">删除</div>
</div>
</li>
</volist>
... ... @@ -48,6 +48,31 @@
<script src="__TMPL__/public/assets/js/base.js"></script>
<script src="__TMPL__/public/assets/js/address.js"></script>
<script src="__TMPL__/public/assets/js/jquery.js"></script>
<script>
/**
*点击设置默认
*/
function set_default(id){
$.post("{:url('Personalcenter/set_default_address')}",{id:id},function(data){
if(data){
}else{
alert('设置失败!');
}
});
}
/**
* 点击删除地址
*/
function address_del(id){
$.post("{:url('Personalcenter/address_del')}",{id:id},function(data){
if($data){
}else{
alert('删除失败!');
}
});
}
</script>
</body>
</html>
\ No newline at end of file
... ...