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.

260 lines
7.8 KiB

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