address.htm 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. ##tlayout("www/layout.htm"){
  2. <nav class="my-nav">
  3. <ul class="container list-unstyled nav-list clearfix">
  4. <li><a href="/user">个人中心</a></li>
  5. <li><a href="/user/orders">我的订单</a></li>
  6. <li><a href="/user/diy">我的定制</a></li>
  7. <li class="active"><a href="/user/address">收货地址</a></li>
  8. </ul>
  9. </nav>
  10. <section class="container">
  11. <div class="row my-account">
  12. <div class="col-sm-2">
  13. <ul class="list-unstyled account-list">
  14. <li class="active">
  15. <a href="/user/address">收货地址</a>
  16. </li>
  17. </ul>
  18. </div>
  19. <div class="col-sm-10">
  20. <div class="account-form">
  21. <h3 class="account-title">收货地址</h3>
  22. <form class="order-form" action="/user/updateAddress" method="post" id="submit_form">
  23. <div class="row">
  24. <div class="form-group col-sm-6">
  25. <label><span style="color: red;">*</span>收件人</label>
  26. <input type="text" class="form-control" name="take_name" placeholder="请输入收件人" value="${user.take_name!}" />
  27. </div>
  28. </div>
  29. <div class="row">
  30. <div class="form-group col-sm-6">
  31. <label><span style="color: red;">*</span>手机号</label>
  32. <input type="text" class="form-control" name="take_phone" placeholder="请输入手机号" value="${user.take_phone!}" />
  33. </div>
  34. </div>
  35. <div class="row">
  36. <div class="form-group col-sm-6">
  37. <label>邮编</label>
  38. <input type="text" class="form-control" name="take_post_code" placeholder="请输入邮编" value="${user.take_post_code!}" />
  39. </div>
  40. </div>
  41. <div class="row" id="area_list">
  42. <div class="form-group col-sm-3">
  43. <label for="city"><span style="color: red;">*</span>地区</label>
  44. <select class="form-control" onchange="changeArea(this)" name="take_area_id" id="area_list_1">
  45. <option value="">--请选择--</option>
  46. ##for(_item in area_list!){
  47. <option value="${_item.id!}">${_item.name!}</option>
  48. ##}
  49. </select>
  50. </div>
  51. </div>
  52. <div class="row">
  53. <div class="form-group col-sm-6">
  54. <label><span style="color: red;">*</span>详细地址</label>
  55. <textarea class="form-control" rows="3" name="take_address" placeholder="请输入详细地址">${user.take_address!}</textarea>
  56. </div>
  57. </div>
  58. <div class="row">
  59. <div class="col-sm-3">
  60. <button type="button" onclick="submitForm()" class="btn btn-lightblue btn-block">提交</button>
  61. </div>
  62. </div>
  63. </form>
  64. </div>
  65. </div>
  66. </div>
  67. </section>
  68. <script>
  69. $(document).ready(function(){
  70. ##if(exist("area") && area!=null){
  71. ##if(area.level==1){
  72. $("#area_list_1").val("${area_1!}");
  73. ##}else if(area.level==2){
  74. $("#area_list_1").val("${area_1!}");
  75. $.post("/shop/getArea",{id:"${area_1!}"},function(data){
  76. if(data.success){
  77. if(data.area_list!=null && data.area_list.length!=0){
  78. $("#area_list_1").removeAttr("name");
  79. var html="";
  80. html+="<div class='form-group col-sm-3'>";
  81. html+="<label>&nbsp;&nbsp;</label>";
  82. html+="<select class='form-control' onchange='changeArea(this)' name='take_area_id' id='area_list_2'>";
  83. html+="<option value=''>--请选择--</option>";
  84. $.each(data.area_list,function(index, array){
  85. html+="<option value=" + array["id"] + ">" + array["name"] + "</option>";
  86. });
  87. html+="</select>";
  88. html+="</div>";
  89. $("#area_list").append(html);
  90. $("#area_list_2").val("${area_2!}");
  91. }else{
  92. $("#area_list_1").attr("name", "take_area_id");
  93. }
  94. }else{
  95. alert(data.msg);
  96. }
  97. });
  98. ##}else{
  99. $("#area_list_1").val("${area_1!}");
  100. $.post("/shop/getArea",{id:"${area_1!}"},function(data){
  101. if(data.success){
  102. if(data.area_list!=null && data.area_list.length!=0){
  103. $("#area_list_1").removeAttr("name");
  104. var html="";
  105. html+="<div class='form-group col-sm-3'>";
  106. html+="<label>&nbsp;&nbsp;</label>";
  107. html+="<select class='form-control' onchange='changeArea(this)' name='take_area_id' id='area_list_2'>";
  108. html+="<option value=''>--请选择--</option>";
  109. $.each(data.area_list,function(index, array){
  110. html+="<option value=" + array["id"] + ">" + array["name"] + "</option>";
  111. });
  112. html+="</select>";
  113. html+="</div>";
  114. $("#area_list").append(html);
  115. $("#area_list_2").val("${area_2!}");
  116. $.post("/shop/getArea",{id:"${area_2!}"},function(data_1){
  117. if(data_1.success){
  118. if(data_1.area_list!=null && data_1.area_list.length!=0){
  119. $("#area_list_2").removeAttr("name");
  120. var html="";
  121. html+="<div class='form-group col-sm-3'>";
  122. html+="<label>&nbsp;&nbsp;</label>";
  123. html+="<select class='form-control' onchange='changeArea(this)' name='take_area_id' id='area_list_3'>";
  124. html+="<option value=''>--请选择--</option>";
  125. $.each(data_1.area_list,function(index, array){
  126. html+="<option value=" + array["id"] + ">" + array["name"] + "</option>";
  127. });
  128. html+="</select>";
  129. html+="</div>";
  130. $("#area_list").append(html);
  131. $("#area_list_3").val("${area_3!}");
  132. }else{
  133. $("#area_list_2").attr("name", "take_area_id");
  134. }
  135. }else{
  136. alert(data.msg);
  137. }
  138. });
  139. }else{
  140. $("#area_list_1").attr("name", "take_area_id");
  141. }
  142. }else{
  143. alert(data.msg);
  144. }
  145. });
  146. ##}
  147. ##}
  148. });
  149. function changeArea(object){
  150. $(object).parent().nextAll().remove();
  151. if($(object).val()!=null && $(object).val()!=""){
  152. $.post("/shop/getArea",{id:$(object).val()},function(data){
  153. if(data.success){
  154. if(data.area_list!=null && data.area_list.length!=0){
  155. $(object).removeAttr("name");
  156. var html="";
  157. html+="<div class='form-group col-sm-3'>";
  158. html+="<label>&nbsp;&nbsp;</label>";
  159. html+="<select class='form-control' onchange='changeArea(this)' name='take_area_id' id='area_list_" + ($("#area_list").find("select").length + 1) + "'>";
  160. html+="<option value=''>--请选择--</option>";
  161. $.each(data.area_list,function(index, array){
  162. html+="<option value=" + array["id"] + ">" + array["name"] + "</option>";
  163. });
  164. html+="</select>";
  165. html+="</div>";
  166. $("#area_list").append(html);
  167. }else{
  168. $(object).attr("name", "take_area_id");
  169. }
  170. }else{
  171. alert(data.msg);
  172. }
  173. });
  174. }
  175. }
  176. function submitForm(){
  177. $('#submit_form').ajaxSubmit({
  178. success: function(data){
  179. alert(data.msg);
  180. if(data.success){
  181. location.reload();
  182. }
  183. }
  184. });
  185. }
  186. </script>
  187. ##}