You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

263 lines
8.3 KiB

7 years ago
7 years ago
7 years ago
7 years ago
  1. <!DOCTYPE html><html><head><meta http-equiv="content-type" content="text/html;charset=utf-8"/>
  2. <title>收货地址编辑</title><meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport">
  3. <link href="<?php echo env('APP_URL'); ?>/css/weixin/style.css" type="text/css" rel="stylesheet">
  4. <script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/jquery.min.js"></script>
  5. <script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/weixin/mobile.js"></script>
  6. <meta name="keywords" content="关键词"><meta name="description" content="描述"></head><body style="background-color:#f1f1f1;">
  7. <div class="classreturn loginsignup ">
  8. <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>
  9. <div class="ds-in-bl tit center"><span>收货地址编辑</span></div>
  10. <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>
  11. </div>
  12. @include('weixin.common.headerNav')
  13. <style>
  14. .adr_add{margin:0 10px;}
  15. .adr-form-group{margin-top:10px;}
  16. .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;}
  17. .adr-form-group select{padding:5px;margin-right:10px;}
  18. .bottoma{display:block;font-size:18px;padding:10px;color:white;background-color: #f23030;text-align:center;}
  19. </style>
  20. <input name="id" type="hidden" class="" id="id" value="<?php echo $post['id']; ?>">
  21. <div class="adr_add">
  22. <div class="adr-form-group">
  23. <label for="doc-ipt-email-1">收货人</label>
  24. <input name="name" type="text" class="" id="name" placeholder="输入姓名" value="<?php echo $post['name']; ?>">
  25. </div>
  26. <div class="adr-form-group">
  27. <label for="doc-ipt-email-1">手机号码</label>
  28. <input type="text" name="mobile" class="" id="mobile" placeholder="输入手机号码" value="<?php echo $post['mobile']; ?>">
  29. </div>
  30. <div class="adr-form-group">
  31. 地区: <select id='sheng'></select><select id='shi'></select><select id='qu'></select>
  32. <script>
  33. // JavaScript Document
  34. $(document).ready(function(e) {
  35. //加载省的数据
  36. LoadSheng(86,<?php echo $post['province']; ?>);
  37. //加载市的数据
  38. LoadShi(<?php echo $post['province']; ?>,<?php echo $post['city']; ?>);
  39. //加载区的数据
  40. LoadQu(<?php echo $post['city']; ?>,<?php echo $post['district']; ?>);
  41. //给省的下拉加点击事件
  42. $("#sheng").change(function(){
  43. //重新加载市
  44. LoadShi();
  45. //重新加载区
  46. LoadQu();
  47. });
  48. //给市的下拉加点击事件
  49. $("#shi").change(function(){
  50. //重新加载区
  51. LoadQu();
  52. });
  53. });
  54. //加载省份的方法
  55. function LoadSheng(parent_id,select_id)
  56. {
  57. //省的父级代号
  58. parent_id = parent_id || '86';
  59. select_id = select_id || 0;
  60. $.ajax({
  61. async:false,
  62. url:'<?php echo env('APP_API_URL')."/region_list"; ?>',
  63. data:{id:parent_id},
  64. type:"GET",
  65. dataType:"json",
  66. success: function(res){
  67. var hang = res.data;
  68. var str = "";
  69. for(var i=0;i<hang.length;i++)
  70. {
  71. if(select_id != 0 && select_id == hang[i].id)
  72. {
  73. str = str+"<option selected='selected' value='"+hang[i].id+"'>"+hang[i].name+"</option>";
  74. }
  75. else
  76. {
  77. str = str+"<option value='"+hang[i].id+"'>"+hang[i].name+"</option>";
  78. }
  79. }
  80. $("#sheng").html(str);
  81. }
  82. });
  83. }
  84. //加载市的方法
  85. function LoadShi(parent_id,select_id)
  86. {
  87. //找市的父级代号
  88. parent_id = parent_id || $("#sheng").val();
  89. select_id = select_id || 0;
  90. $.ajax({
  91. async:false,
  92. url:'<?php echo env('APP_API_URL')."/region_list"; ?>',
  93. data:{id:parent_id},
  94. type:"GET",
  95. dataType:"json",
  96. success: function(res){
  97. var hang = res.data;
  98. var str = "";
  99. for(var i=0;i<hang.length;i++)
  100. {
  101. if(select_id != 0 && select_id == hang[i].id)
  102. {
  103. str = str+"<option selected='selected' value='"+hang[i].id+"'>"+hang[i].name+"</option>";
  104. }
  105. else
  106. {
  107. str = str+"<option value='"+hang[i].id+"'>"+hang[i].name+"</option>";
  108. }
  109. }
  110. $("#shi").html(str);
  111. }
  112. });
  113. }
  114. //加载区的方法
  115. function LoadQu(parent_id,select_id)
  116. {
  117. //找区的父级代号
  118. parent_id = parent_id || $("#shi").val();
  119. select_id = select_id || 0;
  120. $.ajax({
  121. url:'<?php echo env('APP_API_URL')."/region_list"; ?>',
  122. data:{id:parent_id},
  123. type:"GET",
  124. dataType:"json",
  125. success: function(res){
  126. var hang = res.data;
  127. var str = "";
  128. for(var i=0;i<hang.length;i++)
  129. {
  130. if(select_id != 0 && select_id == hang[i].id)
  131. {
  132. str = str+"<option selected='selected' value='"+hang[i].id+"'>"+hang[i].name+"</option>";
  133. }
  134. else
  135. {
  136. str = str+"<option value='"+hang[i].id+"'>"+hang[i].name+"</option>";
  137. }
  138. }
  139. $("#qu").html(str);
  140. }
  141. });
  142. }
  143. </script>
  144. </div>
  145. <div class="adr-form-group">
  146. <label for="doc-ta-1">详细地址</label>
  147. <textarea name="address" class="" rows="3" id="address"><?php echo $post['address']; ?></textarea>
  148. </div>
  149. <div class="adr-form-group">
  150. <label>
  151. <input type="checkbox" name="is_default" id="is_default" <?php if($post['is_default']==1){echo 'checked="checked"';} ?>> 设为默认
  152. </label>
  153. </div>
  154. </div>
  155. <a style="margin:10px;" class="bottoma" href="javascript:adr_dosubmit();">提交</a>
  156. <script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/layer/mobile/layer.js"></script>
  157. <script>
  158. function adr_dosubmit()
  159. {
  160. var access_token = '<?php echo $_SESSION['weixin_user_info']['access_token']; ?>';
  161. var url = '<?php echo env('APP_API_URL').'/user_address_update'; ?>';
  162. var id = $("#id").val();
  163. var name = $("#name").val();
  164. var mobile = $("#mobile").val();
  165. var address = $("#address").val();
  166. var province = $("#sheng").val();
  167. var city = $("#shi").val();
  168. var district = $("#qu").val();
  169. var is_default = 0;
  170. if(document.getElementById("is_default").checked){is_default = 1;}
  171. if(name == '')
  172. {
  173. //提示
  174. layer.open({
  175. content: '姓名不能为空'
  176. ,skin: 'msg'
  177. ,time: 2 //2秒后自动关闭
  178. });
  179. return false;
  180. }
  181. if(mobile == '')
  182. {
  183. //提示
  184. layer.open({
  185. content: '手机号不能为空'
  186. ,skin: 'msg'
  187. ,time: 2 //2秒后自动关闭
  188. });
  189. return false;
  190. }
  191. if(validatemobile(mobile) == false)
  192. {
  193. //提示
  194. layer.open({
  195. content: '手机号格式不正确'
  196. ,skin: 'msg'
  197. ,time: 2 //2秒后自动关闭
  198. });
  199. return false;
  200. }
  201. if(address == '')
  202. {
  203. //提示
  204. layer.open({
  205. content: '地址不能为空'
  206. ,skin: 'msg'
  207. ,time: 2 //2秒后自动关闭
  208. });
  209. return false;
  210. }
  211. $.post(url,{access_token:access_token,id:id,name:name,mobile:mobile,address:address,province:province,city:city,district:district,is_default:is_default},function(res)
  212. {
  213. if(res.code==0)
  214. {
  215. //提示
  216. layer.open({
  217. content: res.msg
  218. ,skin: 'msg'
  219. ,time: 2 //2秒后自动关闭
  220. });
  221. window.history.back();
  222. }
  223. else
  224. {
  225. //提示
  226. layer.open({
  227. content: res.msg
  228. ,skin: 'msg'
  229. ,time: 2 //2秒后自动关闭
  230. });
  231. var url = "http://www.baidu.com";
  232. location.href = url;
  233. }
  234. },'json');
  235. }
  236. </script>
  237. </body></html>