7 changed files with 364 additions and 41 deletions
-
1app/Common/ReturnCode.php
-
34app/Http/Controllers/Weixin/AddressController.php
-
12app/Http/Model/UserAddress.php
-
17public/js/weixin/mobile.js
-
2resources/views/weixin/address/index.blade.php
-
68resources/views/weixin/address/userAddressAdd.blade.php
-
269resources/views/weixin/address/userAddressUpdate.blade.php
@ -0,0 +1,269 @@ |
|||||
|
<!DOCTYPE html><html><head><meta http-equiv="content-type" content="text/html;charset=utf-8"/> |
||||
|
<title>收货地址编辑</title><meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"> |
||||
|
<link href="<?php echo env('APP_URL'); ?>/css/weixin/style.css" type="text/css" rel="stylesheet"> |
||||
|
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/jquery.min.js"></script> |
||||
|
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/weixin/mobile.js"></script> |
||||
|
<meta name="keywords" content="关键词"><meta name="description" content="描述"></head><body style="background-color:#f1f1f1;"> |
||||
|
<div class="classreturn loginsignup "> |
||||
|
<div class="ds-in-bl return"><a href="javascript:history.back(-1);"><img src="<?php echo env('APP_URL'); ?>/images/weixin/return.png" alt="返回"></a></div> |
||||
|
<div class="ds-in-bl tit center"><span>收货地址编辑</span></div> |
||||
|
<div class="ds-in-bl nav_menu"><a href="javascript:void(0);"><img src="<?php echo env('APP_URL'); ?>/images/weixin/class1.png" alt="菜单"></a></div> |
||||
|
</div> |
||||
|
<div class="flool tpnavf cl"> |
||||
|
<div class="nav_list"> |
||||
|
<ul> |
||||
|
<a href="index.html"><li><img src="<?php echo env('APP_URL'); ?>/images/weixin/home_icon.png"><p>首页</p></li></a> |
||||
|
<a href="/Weixin/index.php?m=Store&a=index"><li><img src="<?php echo env('APP_URL'); ?>/images/weixin/brand_icon.png"><p>分类</p></li></a> |
||||
|
<a href="/Weixin/index.php?m=Cart&a=index"><li><img src="<?php echo env('APP_URL'); ?>/images/weixin/car_icon.png"><p>购物车</p></li></a> |
||||
|
<a href="/Weixin/index.php?m=User&a=index"><li><img src="<?php echo env('APP_URL'); ?>/images/weixin/center_icon.png"><p>个人中心</p></li></a></ul> |
||||
|
<div class="cl"></div> |
||||
|
</div> |
||||
|
</div> |
||||
|
<style> |
||||
|
.adr_add{margin:0 10px;} |
||||
|
.adr-form-group{margin-top:10px;} |
||||
|
.adr-form-group input[type=text],.adr-form-group textarea{display: block;width: 100%;font-size:16px;padding:10px;color: #777;vertical-align: middle;background-color: #fff;background-image: none;border: 1px solid #ddd;border-radius: 0;box-sizing:border-box;}
|
||||
|
.adr-form-group select{padding:5px;margin-right:10px;} |
||||
|
.bottoma{display:block;font-size:18px;padding:10px;color:white;background-color: #f23030;text-align:center;}
|
||||
|
</style> |
||||
|
<div class="adr_add"> |
||||
|
<div class="adr-form-group"> |
||||
|
<label for="doc-ipt-email-1">收货人</label> |
||||
|
<input name="name" type="text" class="" id="name" placeholder="输入姓名" value="<?php echo $post['name']; ?>"> |
||||
|
</div> |
||||
|
<div class="adr-form-group"> |
||||
|
<label for="doc-ipt-email-1">手机号码</label> |
||||
|
<input type="text" name="mobile" class="" id="mobile" placeholder="输入手机号码" value="<?php echo $post['mobile']; ?>"> |
||||
|
</div> |
||||
|
<div class="adr-form-group"> |
||||
|
地区: <select id='sheng'></select><select id='shi'></select><select id='qu'></select> |
||||
|
<script> |
||||
|
// JavaScript Document
|
||||
|
$(document).ready(function(e) { |
||||
|
//加载省的数据
|
||||
|
LoadSheng(86,<?php echo $post['province']; ?>);
|
||||
|
//加载市的数据
|
||||
|
LoadShi(<?php echo $post['province']; ?>,<?php echo $post['city']; ?>);
|
||||
|
//加载区的数据
|
||||
|
LoadQu(<?php echo $post['city']; ?>,<?php echo $post['district']; ?>);
|
||||
|
|
||||
|
//给省的下拉加点击事件
|
||||
|
$("#sheng").change(function(){ |
||||
|
//重新加载市
|
||||
|
LoadShi(); |
||||
|
//重新加载区
|
||||
|
LoadQu(); |
||||
|
}); |
||||
|
|
||||
|
//给市的下拉加点击事件
|
||||
|
$("#shi").change(function(){ |
||||
|
//重新加载区
|
||||
|
LoadQu(); |
||||
|
}); |
||||
|
}); |
||||
|
|
||||
|
//加载省份的方法
|
||||
|
function LoadSheng(parent_id,select_id) |
||||
|
{ |
||||
|
//省的父级代号
|
||||
|
parent_id = parent_id || '86'; |
||||
|
select_id = select_id || 0; |
||||
|
|
||||
|
$.ajax({ |
||||
|
async:false, |
||||
|
url:'<?php echo env('APP_API_URL')."/region_list"; ?>', |
||||
|
data:{id:parent_id}, |
||||
|
type:"GET", |
||||
|
dataType:"json", |
||||
|
success: function(res){ |
||||
|
var hang = res.data; |
||||
|
var str = ""; |
||||
|
for(var i=0;i<hang.length;i++) |
||||
|
{ |
||||
|
if(select_id != 0 && select_id == hang[i].id) |
||||
|
{ |
||||
|
str = str+"<option selected='selected' value='"+hang[i].id+"'>"+hang[i].name+"</option>"; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
str = str+"<option value='"+hang[i].id+"'>"+hang[i].name+"</option>"; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
$("#sheng").html(str); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
//加载市的方法
|
||||
|
function LoadShi(parent_id,select_id) |
||||
|
{ |
||||
|
//找市的父级代号
|
||||
|
parent_id = parent_id || $("#sheng").val(); |
||||
|
select_id = select_id || 0; |
||||
|
|
||||
|
$.ajax({ |
||||
|
async:false, |
||||
|
url:'<?php echo env('APP_API_URL')."/region_list"; ?>', |
||||
|
data:{id:parent_id}, |
||||
|
type:"GET", |
||||
|
dataType:"json", |
||||
|
success: function(res){ |
||||
|
var hang = res.data; |
||||
|
var str = ""; |
||||
|
for(var i=0;i<hang.length;i++) |
||||
|
{ |
||||
|
if(select_id != 0 && select_id == hang[i].id) |
||||
|
{ |
||||
|
str = str+"<option selected='selected' value='"+hang[i].id+"'>"+hang[i].name+"</option>"; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
str = str+"<option value='"+hang[i].id+"'>"+hang[i].name+"</option>"; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
$("#shi").html(str); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
//加载区的方法
|
||||
|
function LoadQu(parent_id,select_id) |
||||
|
{ |
||||
|
//找区的父级代号
|
||||
|
parent_id = parent_id || $("#shi").val(); |
||||
|
select_id = select_id || 0; |
||||
|
|
||||
|
$.ajax({ |
||||
|
url:'<?php echo env('APP_API_URL')."/region_list"; ?>', |
||||
|
data:{id:parent_id}, |
||||
|
type:"GET", |
||||
|
dataType:"json", |
||||
|
success: function(res){ |
||||
|
var hang = res.data; |
||||
|
var str = ""; |
||||
|
for(var i=0;i<hang.length;i++) |
||||
|
{ |
||||
|
if(select_id != 0 && select_id == hang[i].id) |
||||
|
{ |
||||
|
str = str+"<option selected='selected' value='"+hang[i].id+"'>"+hang[i].name+"</option>"; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
str = str+"<option value='"+hang[i].id+"'>"+hang[i].name+"</option>"; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
$("#qu").html(str); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
</script> |
||||
|
</div> |
||||
|
<div class="adr-form-group"> |
||||
|
<label for="doc-ta-1">详细地址</label> |
||||
|
<textarea name="address" class="" rows="3" id="address"><?php echo $post['address']; ?></textarea>
|
||||
|
</div> |
||||
|
<div class="adr-form-group"> |
||||
|
<label> |
||||
|
<input type="checkbox" name="is_default" id="is_default" <?php if($post['is_default']==1){echo 'checked="checked"';} ?>> 设为默认
|
||||
|
</label> |
||||
|
</div> |
||||
|
</div> |
||||
|
<a style="margin:10px;" class="bottoma" href="javascript:adr_dosubmit();">提交</a> |
||||
|
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/layer/mobile/layer.js"></script> |
||||
|
<script> |
||||
|
function adr_dosubmit() |
||||
|
{ |
||||
|
var access_token = '<?php echo $_SESSION['weixin_user_info']['access_token']; ?>'; |
||||
|
|
||||
|
var url = '<?php echo env('APP_API_URL').'/user_address_add'; ?>'; |
||||
|
var name = $("#name").val(); |
||||
|
var mobile = $("#mobile").val(); |
||||
|
var address = $("#address").val(); |
||||
|
|
||||
|
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) |
||||
|
{ |
||||
|
//提示
|
||||
|
layer.open({ |
||||
|
content: res.msg |
||||
|
,skin: 'msg' |
||||
|
,time: 2 //2秒后自动关闭
|
||||
|
}); |
||||
|
|
||||
|
window.history.back(); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
//提示
|
||||
|
layer.open({ |
||||
|
content: res.msg |
||||
|
,skin: 'msg' |
||||
|
,time: 2 //2秒后自动关闭
|
||||
|
}); |
||||
|
|
||||
|
var url = "http://www.baidu.com"; |
||||
|
location.href = url; |
||||
|
} |
||||
|
},'json'); |
||||
|
} |
||||
|
</script> |
||||
|
</body></html> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue