edit_address.html 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <extend name="Public:base" />
  2. <block name="head_script">
  3. <link href="__CSS__/member.css" rel="stylesheet" type="text/css">
  4. <link href="__PUBLIC__/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
  5. </block>
  6. <block name="content">
  7. <div>
  8. <div class="container">
  9. <div class="row">
  10. <div id="content" class="col-sm-9">
  11. <div class="page-title">
  12. <h1>{$action_title}</h1>
  13. </div>
  14. <fieldset>
  15. <notempty name="Think.get.id">
  16. <input name="address_id" type="hidden" value="{$Think.get.id}" />
  17. </notempty>
  18. <div class="form-group required clearfix">
  19. <label class="col-sm-2 control-label">收货人</label>
  20. <div class="col-sm-10">
  21. <input type="text" value="{$address.name|default=''}" name="name">
  22. </div>
  23. </div>
  24. <div class="form-group required clearfix">
  25. <label class="col-sm-2 control-label">联系电话</label>
  26. <div class="col-sm-10">
  27. <input type="text" value="{$address.telephone|default=''}" name="telephone">
  28. </div>
  29. </div>
  30. <div class="form-group required clearfix">
  31. <label class="col-sm-2 control-label">收货地址</label>
  32. <div class="col-sm-10">
  33. <input type="text" value="{$address.address|default=''}" name="address">
  34. </div>
  35. </div>
  36. <div class="form-group required clearfix">
  37. <label class="col-sm-2 control-label">区域</label>
  38. <div class="col-sm-10">
  39. <p id="area">
  40. <select name="province_id" id="province">
  41. <option value="-1" selected>省份</option>
  42. <volist name="province" id="v">
  43. <option <?php if($address['province_id']==$v['area_id']){echo ' selected="selected"';} ?> value="{$v.area_id}">{$v.area_name}</option>
  44. </volist>
  45. </select>
  46. <select name="city_id" id="city">
  47. <option value="-1">城市</option>
  48. <volist name="city" id="v">
  49. <option <?php if($address['city_id']==$v['area_id']){echo ' selected="selected"';} ?> value="{$v.area_id}">{$v.area_name}</option>
  50. </volist>
  51. </select>
  52. <?php if(isset($country)){ ?>
  53. <select name="country_id" id="country">
  54. <volist name="country" id="v">
  55. <option <?php if($address['country_id']==$v['area_id']){echo ' selected="selected"';} ?> value="{$v.area_id}">{$v.area_name}</option>
  56. </volist>
  57. </select>
  58. <?php } ?>
  59. </p>
  60. </div>
  61. </div>
  62. </fieldset>
  63. <div class="buttons clearfix">
  64. <div class="left" style="margin-left:15px;">
  65. <button class="button continue " id="submit" type="submit">提交</button>
  66. </div>
  67. </div>
  68. </div>
  69. <include file="User/side" />
  70. </div>
  71. </div>
  72. </div>
  73. </block>
  74. <block name="foot_script">
  75. <script type="text/javascript">
  76. $("#province").change(function(){
  77. var ajaxurl='{:U("/c_getarea")}';
  78. var areaId=this.value;
  79. var areaType='city';
  80. $('#country').remove();
  81. if(areaId!=-1){
  82. $.post(ajaxurl,{'areaId':areaId},function(data){
  83. if(areaType==='city'){
  84. $('#'+areaType).html('<option value="-1">城市</option>');
  85. }
  86. if(areaType!=='null'){
  87. $.each(data,function(no,items){
  88. $('#'+areaType).append('<option value="'+items.area_id+'">'+items.area_name+'</option>');
  89. });
  90. }
  91. });
  92. }else{
  93. $('#'+areaType).html('<option value="-1">城市</option>');
  94. }
  95. });
  96. $("#city").change(function(){
  97. var ajaxurl='{:U("/c_getarea")}';
  98. var areaId=this.value;
  99. var areaType='county';
  100. $('#country').remove();
  101. $.post(ajaxurl,{'areaId':areaId},function(data){
  102. if(data!=null){
  103. var html='';
  104. html+=' <select name="country_id" id="country">'
  105. $.each(data,function(no,items){
  106. html+= '<option value="'+items.area_id+'">'+items.area_name+'</option>';
  107. });
  108. html+='</select>';
  109. $('#area').append(html);
  110. }
  111. });
  112. });
  113. //注册
  114. $('#submit').live('click', function() {
  115. $.ajax({
  116. url: '{$action}',
  117. type: 'post',
  118. data: $('input[type=\'text\'],input[type=\'hidden\'], select'),
  119. dataType: 'json',
  120. beforeSend: function() {
  121. $('#submit').attr('disabled', true);
  122. $('#submit').after('<span class="wait">&nbsp;<img src="__IMG__/loading.gif" alt="" /></span>');
  123. },
  124. complete: function() {
  125. $('#submit').attr('disabled', false);
  126. $('.wait').remove();
  127. },
  128. success: function(json) {
  129. $('.warning, .error').remove();
  130. if (json['redirect']) {
  131. location = json['redirect'];
  132. } else if (json['error']) {
  133. if (json['error']['name']) {
  134. $("input[name='name']").after('<span class="error">' + json['error']['name'] + '</span>');
  135. }
  136. if (json['error']['telephone']) {
  137. $("input[name='telephone']").after('<span class="error">' + json['error']['telephone'] + '</span>');
  138. }
  139. if (json['error']['address']) {
  140. $("input[name='address']").after('<span class="error">' + json['error']['address'] + '</span>');
  141. }
  142. if (json['error']['area']) {
  143. $('#area').after('<span class="error">' + json['error']['area'] + '</span>');
  144. }
  145. }
  146. },
  147. error: function(xhr, ajaxOptions, thrownError) {
  148. alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
  149. }
  150. });
  151. });
  152. </script>
  153. </block>