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

58

... ... @@ -209,13 +209,22 @@ class PersonalcenterController extends WeChatBaseController{
*/
public function address_edit(){
$id = $this -> request -> param();
$data = Db::name('address') -> where('id',$id['id']) -> find();
$detailed = explode(',',$data['detailed']);
$data['detailed0'] = $detailed[0];
$data['detailed1'] = $detailed[1];
$this -> assign('data',$data);
return $this -> fetch();
if($this -> request -> isPost()){
$data_update = Db::name('address') -> update($_POST);
if($data_update){
return true;
}else{
return false;
}
}else{
$id = $this -> request -> param();
$data = Db::name('address') -> where('id',$id['id']) -> find();
$detailed = explode(',',$data['detailed']);
$data['detailed0'] = $detailed[0];
$data['detailed1'] = $detailed[1];
$this -> assign('data',$data);
return $this -> fetch();
}
}
... ...
... ... @@ -44,6 +44,7 @@
<div class="add_city" id="city_text" type="text" placeholder="">{$data.region}</div>
<img src="__TMPL__/public/assets/images/29.png" alt="">
</li>
<input type="hidden" name="id" value="{$data.id}" id="id">
<li>
<label for="">详细地址</label>
<input type="text" placeholder="街道、小区、门牌号码" id="address_content" value="{$data.detailed0}">
... ... @@ -73,13 +74,14 @@
}else if($('#address_content').val() == ''){
alert('详细地址不能为空');
}else{
id = $('#id').val();
name = $('#name').val();
phone = $('#phone').val();
region = $('#city_text').text();
address_content = $('#address_content').val();
address_content_con = $('#address_content_con').val();
detailed = address_content+address_content_con;
$.post("{:url('Personalcenter/add_shop_address')}",{name:name,phone:phone,region:region,detailed:detailed},function(data){
detailed = address_content+','+address_content_con;
$.post("{:url('Personalcenter/address_edit')}",{id:id,name:name,phone:phone,region:region,detailed:detailed},function(data){
if(data){
window.location.href = "{:url('Personalcenter/shop_address')}";
}else{
... ...