diff --git a/app/Common/ReturnCode.php b/app/Common/ReturnCode.php index 5557175..0e04eb4 100644 --- a/app/Common/ReturnCode.php +++ b/app/Common/ReturnCode.php @@ -6,5 +6,6 @@ class ReturnCode //通用 const SUCCESS = '操作成功'; //操作成功 const FAIL = '操作失败'; //操作失败 - const SUCCESS_CODE = 0; + const NO_FOUND = '您访问的页面不存在'; + const SUCCESS_CODE = 0; } \ No newline at end of file diff --git a/app/Http/Controllers/Weixin/AddressController.php b/app/Http/Controllers/Weixin/AddressController.php index 6fc6184..31ca714 100644 --- a/app/Http/Controllers/Weixin/AddressController.php +++ b/app/Http/Controllers/Weixin/AddressController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers\Weixin; use App\Http\Controllers\Weixin\CommonController; use Illuminate\Http\Request; +use App\Common\ReturnCode; class AddressController extends CommonController { @@ -48,7 +49,7 @@ class AddressController extends CommonController $html .= '

'.$v['mobile'].'

'; } - $html .= '

'.$v['province'].$v['city'].$v['district'].' '.$v['address'].'

'; + $html .= '

'.$v['province_name'].$v['city_name'].$v['district_name'].' '.$v['address'].'

'; $html .= '
编辑删除
'; $html .= ''; } @@ -63,25 +64,24 @@ class AddressController extends CommonController //收货地址添加 public function userAddressAdd(Request $request) { - if($request->input('typeid', '') != ''){$data['typeid'] = $request->input('typeid');} - if($request->input('tuijian', '') != ''){$data['tuijian'] = $request->input('tuijian');} - if($request->input('keyword', '') != ''){$data['keyword'] = $request->input('keyword');} - if($request->input('status', '') != ''){$data['status'] = $request->input('status');} - if($request->input('is_promote', '') != ''){$data['is_promote'] = $request->input('is_promote');} - if($request->input('orderby', '') != ''){$data['orderby'] = $request->input('orderby');} - if($request->input('max_price', '') != ''){$data['max_price'] = $request->input('max_price');}else{$data['max_price'] = 99999;} - if($request->input('min_price', '') != ''){$data['min_price'] = $request->input('min_price');}else{$data['min_price'] = 0;} + return view('weixin.address.userAddressAdd'); + } + + //收货地址修改 + public function userAddressUpdate(Request $request) + { + $id = $request->input('id',''); + + if($id == ''){$this->error_jump(ReturnCode::NO_FOUND,route('weixin'),3);} - //商品列表 $postdata = array( - 'access_token' => $_SESSION['weixin_user_info']['access_token'], - 'limit' => 10, - 'offset' => 0 + 'id' => $_REQUEST['id'], + 'access_token' => $_SESSION['weixin_user_info']['access_token'] ); - $url = env('APP_API_URL')."/user_address_list"; - $goods_list = curl_request($url,$postdata,'GET'); - $data['user_address_list'] = $goods_list['data']['list']; + $url = env('APP_API_URL')."/user_address_detail"; + $res = curl_request($url,$postdata,'GET'); + $data['post'] = $res['data']; - return view('weixin.address.userAddressAdd', $data); + return view('weixin.address.userAddressUpdate',$data); } } \ No newline at end of file diff --git a/app/Http/Model/UserAddress.php b/app/Http/Model/UserAddress.php index c998ab6..9263302 100644 --- a/app/Http/Model/UserAddress.php +++ b/app/Http/Model/UserAddress.php @@ -36,13 +36,13 @@ class UserAddress extends BaseModel if($res['list']) { - /* foreach($res['list'] as $k=>$v) + foreach($res['list'] as $k=>$v) { $res['list'][$k]['country_name'] = Region::getRegionName($v['country']); $res['list'][$k]['province_name'] = Region::getRegionName($v['province']); $res['list'][$k]['city_name'] = Region::getRegionName($v['city']); $res['list'][$k]['district_name'] = Region::getRegionName($v['district']); - } */ + } } } else @@ -62,13 +62,13 @@ class UserAddress extends BaseModel { $arr = self::where('id',$address_id)->first(); - /* if($arr) + if($arr) { $arr->country_name = Region::getRegionName($arr->country); $arr->province_name = Region::getRegionName($arr->province); $arr->city_name = Region::getRegionName($arr->city); $arr->district_name = Region::getRegionName($arr->district); - } */ + } return $arr; } @@ -80,13 +80,13 @@ class UserAddress extends BaseModel ->where('user.id',$user_id)->select('user_address.id','user_address.name','country','province','city','district','address','user_address.mobile','zipcode') ->first(); - /* if($arr) + if($arr) { $arr->country_name = Region::getRegionName($arr->country); $arr->province_name = Region::getRegionName($arr->province); $arr->city_name = Region::getRegionName($arr->city); $arr->district_name = Region::getRegionName($arr->district); - } */ + } } return $arr; diff --git a/public/js/weixin/mobile.js b/public/js/weixin/mobile.js index 8f4ce0f..f6a7ff3 100644 --- a/public/js/weixin/mobile.js +++ b/public/js/weixin/mobile.js @@ -24,4 +24,21 @@ function delconfirm(url,des) layer.close(index); } }); +} + +//手机号验证 +function validatemobile(mobile) +{ + if(mobile.length == 0 || mobile.length != 11) + { + return false; + } + + var reg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/; + if(!reg.test(mobile)) + { + return false; + } + + return true; } \ No newline at end of file diff --git a/resources/views/weixin/address/index.blade.php b/resources/views/weixin/address/index.blade.php index 32a9486..a7654ef 100644 --- a/resources/views/weixin/address/index.blade.php +++ b/resources/views/weixin/address/index.blade.php @@ -37,7 +37,7 @@ $v){ ?>

默认

-

+

编辑删除
diff --git a/resources/views/weixin/address/userAddressAdd.blade.php b/resources/views/weixin/address/userAddressAdd.blade.php index e7277d7..fba6aa3 100644 --- a/resources/views/weixin/address/userAddressAdd.blade.php +++ b/resources/views/weixin/address/userAddressAdd.blade.php @@ -22,22 +22,10 @@ -
@@ -195,13 +183,61 @@ function adr_dosubmit() var mobile = $("#mobile").val(); var address = $("#address").val(); - var province = '福建'; - var city = '厦门'; - var district = '湖里'; + var province = $("#sheng").val(); + var city = $("#shi").val(); + var district = $("#qu").val(); var is_default = 0; if(document.getElementById("is_default").checked){is_default = 1;} + if(name == '') + { + //提示 + layer.open({ + content: '姓名不能为空' + ,skin: 'msg' + ,time: 2 //2秒后自动关闭 + }); + + return false; + } + + if(mobile == '') + { + //提示 + layer.open({ + content: '手机号不能为空' + ,skin: 'msg' + ,time: 2 //2秒后自动关闭 + }); + + return false; + } + + if(validatemobile(mobile) == false) + { + //提示 + layer.open({ + content: '手机号格式不正确' + ,skin: 'msg' + ,time: 2 //2秒后自动关闭 + }); + + return false; + } + + if(address == '') + { + //提示 + layer.open({ + content: '地址不能为空' + ,skin: 'msg' + ,time: 2 //2秒后自动关闭 + }); + + return false; + } + $.post(url,{access_token:access_token,name:name,mobile:mobile,address:address,province:province,city:city,district:district,is_default:is_default},function(res) { if(res.code==0) diff --git a/resources/views/weixin/address/userAddressUpdate.blade.php b/resources/views/weixin/address/userAddressUpdate.blade.php new file mode 100644 index 0000000..986f8da --- /dev/null +++ b/resources/views/weixin/address/userAddressUpdate.blade.php @@ -0,0 +1,269 @@ + +收货地址编辑 + + + + +
+
返回
+
收货地址编辑
+ +
+
+ +
+ +
+
+ + +
+
+ + +
+
+地区: + +
+
+ + +
+
+ +
+
+提交 + + + \ No newline at end of file