offpay_area.index.php 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <?php defined('InShopNC') or exit('Access Invalid!');?>
  2. <link href="<?php echo ADMIN_TEMPLATES_URL;?>/css/font/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
  3. <!--[if IE 7]>
  4. <link rel="stylesheet" href="<?php echo ADMIN_TEMPLATES_URL;?>/css/font/font-awesome/css/font-awesome-ie7.min.css">
  5. <![endif]-->
  6. <div class="page">
  7. <div class="fixed-bar">
  8. <div class="item-title">
  9. <h3>配送地区</h3>
  10. <ul class="tab-base">
  11. <li><a class="current"><span>配送地区</span></a></li>
  12. </ul>
  13. </div>
  14. </div>
  15. <div class="fixed-empty"></div>
  16. <form id="area_form" method="post">
  17. <input type="hidden" name="form_submit" value="ok" />
  18. <input type="hidden" name="act" value="offpay_area" />
  19. <input type="hidden" name="op" value="add" />
  20. <input type="hidden" name="county" id="county" value="" />
  21. <table class="table tb-type2" id="prompt">
  22. <tbody>
  23. <tr class="space odd">
  24. <th colspan="12"><div class="title">
  25. <h5><?php echo $lang['nc_prompts'];?></h5>
  26. <span class="arrow"></span></div></th>
  27. </tr>
  28. <tr>
  29. <td><ul>
  30. <li>此处只能设置平台自营店铺支持货到付款的地区,注意:只有开启货到付款时以下设置的地区才会生效</li>
  31. <li>选择完子地区确认后,系统并未保存,需要点击页面底部的保存按钮系统才会保存设置的地区</li>
  32. </ul></td>
  33. </tr>
  34. </tbody>
  35. </table>
  36. <table id="table_area_box" class="table tb-type2">
  37. <thead>
  38. <tr class="thead">
  39. <th class="w10"></th>
  40. <th class="w120">省</th>
  41. <th>市</th>
  42. </tr>
  43. </thead>
  44. <tbody>
  45. <?php foreach ($output['province_array'] as $pid => $pinfo) {?>
  46. <tr>
  47. <td></td>
  48. <td><label>
  49. <input type="checkbox" <?php if (array_key_exists($pid, $output['province_checked_array'])) echo 'checked';?> value="<?php echo $pid;?>" name="province[]">
  50. <strong><?php echo $pinfo['area_name']?></strong></label></td>
  51. <td><?php if (is_array($pinfo['child'])) {?>
  52. <?php foreach($pinfo['child'] as $city_id => $city_name) {?>
  53. <div class="area-list">
  54. <label>
  55. <input <?php if ($output['city_checked_array'][$city_id]) echo 'checked';?> type="checkbox" nc_province="<?php echo $pid;?>" value="<?php echo $city_id;?>" name="city[]">
  56. <?php echo $city_name;?> </label>
  57. (<span city_id="<?php echo $city_id;?>" title="已选下级地区"><?php echo count($output['city_checked_child_array'][$city_id]);?></span>)<a city_id="<?php echo $city_id;?>" nc_title="<?php echo $city_name;?>" province_id="<?php echo $pid;?>" nc_type="edit" href="javascript:void(0);" title="选择下级地区"><i class="icon-pencil"></i></a> </div>
  58. <?php }?></td>
  59. </tr>
  60. <?php }?>
  61. <?php }?>
  62. </tbody>
  63. <tfoot>
  64. <tr class="tfoot">
  65. <td colspan="15"><a href="JavaScript:void(0);" class="btn" id="submitBtn"><span><?php echo $lang['nc_submit'];?></span></a></td>
  66. </tr>
  67. </tfoot>
  68. </table>
  69. </form>
  70. </div>
  71. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/area_array.js" charset="utf-8"></script>
  72. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/dialog/dialog.js" id="dialog_js" charset="utf-8"></script>
  73. <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/jquery-ui/jquery.ui.js"></script>
  74. <script type="text/javascript">
  75. //将系统已选择的县ID放入JS数组
  76. var CUR_COUNTY = new Array();
  77. <?php if (!empty($output['city_checked_child_array']) && is_array($output['city_checked_child_array'])) { ?>
  78. <?php foreach ($output['city_checked_child_array'] as $city_id => $county_ids) { ?>
  79. CUR_COUNTY[<?php echo $city_id;?>] = new Array();
  80. <?php foreach($county_ids as $k => $v) { ?>
  81. CUR_COUNTY[<?php echo $city_id;?>][<?php echo $v;?>] = true;
  82. <?php } ?>
  83. <?php } ?>
  84. <?php } ?>
  85. $(function(){
  86. //省点击事件
  87. $('input[name="province[]"]').on('click',function(){
  88. if ($(this).attr('checked') == 'checked'){
  89. $('input[nc_province="' + $(this).val() + '"]').each(function(){
  90. $(this).attr('checked','checked');
  91. if (typeof nc_a[$(this).val()] == 'object') {
  92. county_array = nc_a[$(this).val()];
  93. } else {
  94. county_array = new Array();
  95. }
  96. CUR_COUNTY[$(this).val()] = new Array();
  97. for(i = 0; i < county_array.length; i++) {
  98. CUR_COUNTY[$(this).val()][county_array[i][0]] = true;
  99. }
  100. count = county_array.length;
  101. $('span[city_id="'+$(this).val()+'"]').html(count);
  102. });
  103. }else{
  104. $('input[nc_province="' + $(this).val() + '"]').each(function(){
  105. $(this).attr('checked',false);
  106. CUR_COUNTY[$(this).val()] = undefined;
  107. $('span[city_id="'+$(this).val()+'"]').html(0);
  108. });
  109. }
  110. });
  111. //点击编辑事件
  112. $('a[nc_type="edit"]').on('click',function(){
  113. if (typeof CUR_COUNTY[$(this).attr('city_id')] == 'object'){
  114. cur_county = CUR_COUNTY[$(this).attr('city_id')];
  115. }else{
  116. cur_county = new Array();
  117. }
  118. var province_array = nc_a[$(this).attr('city_id')];
  119. if (typeof nc_a[$(this).attr('city_id')] == 'object'){
  120. county_array = nc_a[$(this).attr('city_id')];
  121. }else{
  122. county_array = new Array();
  123. }
  124. if (county_array.length == 0) {
  125. alert('下面没有子地区,无需要编辑');
  126. return;
  127. }
  128. county_html = '<table id="table_area_box_edit" class="table tb-type2"><tbody><tr class="noborder"><td city_id="'+$(this).attr('city_id')+'" province_id="'+$(this).attr('province_id')+'">';
  129. for(i = 0; i < county_array.length; i++){
  130. county_html += '<label><input type="checkbox"';
  131. if (typeof(cur_county[county_array[i][0]]) != 'undefined') {
  132. county_html += ' checked ' ;
  133. }
  134. county_html += (' value="'+county_array[i][0]+'" name="county[]">' + county_array[i][1] + '</label>');
  135. }
  136. county_html += '</td></tr><tr><td class="align-center"><a id="county_submit" class="btn" href="JavaScript:void(0);"><span>确认</span></a></td></tr><tr class="noborder"><td class="align-center" style="color:#f30;">确认后,还需要点击页面底部的保存按钮完成保存操作</td></tr></tbody></table>';
  137. html_form('select_county', '选择 '+ $(this).attr('nc_title') +' 子地区', county_html, 500,1);
  138. });
  139. //选择市级事件
  140. $('input[name="city[]"]').on('click',function(){
  141. if ($(this).attr('checked')) {
  142. if (typeof nc_a[$(this).val()] == 'object') {
  143. county_array = nc_a[$(this).val()];
  144. } else {
  145. county_array = new Array();
  146. }
  147. CUR_COUNTY[$(this).val()] = new Array();
  148. for(i = 0; i < county_array.length; i++) {
  149. CUR_COUNTY[$(this).val()][county_array[i][0]] = true;
  150. }
  151. count = county_array.length;
  152. if ($('input[nc_province="'+$(this).attr('nc_province')+'"]').size() == $('input[nc_province="'+$(this).attr('nc_province')+'"]:checked').size()) {
  153. $('input[value="'+$(this).attr('nc_province')+'"]').attr('checked',true);
  154. } else {
  155. $('input[value="'+$(this).attr('nc_province')+'"]').attr('checked',false);
  156. }
  157. } else {
  158. CUR_COUNTY[$(this).val()] = undefined;
  159. count = 0;
  160. $('input[value="'+$(this).attr('nc_province')+'"]').attr('checked',false);
  161. }
  162. $('span[city_id="'+$(this).val()+'"]').html(count);
  163. });
  164. //弹出县编辑确认事件
  165. $('body').on('click','#county_submit',function(){
  166. cur_td = $('.dialog_content > table > tbody > tr > td');
  167. cur_checkbox = cur_td.find('input[type="checkbox"]');
  168. cur_checkbox.each(function(){
  169. if ($(this).attr('checked')) {
  170. if (typeof CUR_COUNTY[cur_td.attr('city_id')] != 'object') {
  171. CUR_COUNTY[cur_td.attr('city_id')] = new Array();
  172. }
  173. CUR_COUNTY[cur_td.attr('city_id')][$(this).val()] = true;
  174. } else {
  175. if (typeof CUR_COUNTY[cur_td.attr('city_id')] == 'object') {
  176. if (typeof CUR_COUNTY[cur_td.attr('city_id')][$(this).val()] != 'undefined') {
  177. CUR_COUNTY[cur_td.attr('city_id')][$(this).val()] = undefined;
  178. }
  179. }
  180. }
  181. });
  182. cur_new_county = cur_td.find('input[type="checkbox"]:checked').size();
  183. $('span[city_id="'+cur_td.attr('city_id')+'"]').html(cur_new_county);
  184. if (cur_checkbox.size() == cur_new_county) {
  185. v = true;
  186. } else {
  187. v = false;
  188. }
  189. $('input[value="'+cur_td.attr('city_id')+'"]').attr('checked',v);
  190. if ($('input[nc_province="'+cur_td.attr('province_id')+'"]').size() == $('input[nc_province="'+cur_td.attr('province_id')+'"]:checked').size()) {
  191. $('input[value="'+cur_td.attr('province_id')+'"]').attr('checked',true);
  192. } else {
  193. $('input[value="'+cur_td.attr('province_id')+'"]').attr('checked',false);
  194. }
  195. DialogManager.close('select_county');
  196. });
  197. //表单提交事件
  198. $("#submitBtn").click(function(){
  199. var county_id_str = '';
  200. for(var city_id in CUR_COUNTY) {
  201. for(var county_d in CUR_COUNTY[city_id]) {
  202. if (typeof(CUR_COUNTY[city_id][county_d]) != 'undefined') {
  203. county_id_str += county_d + ',';
  204. }
  205. }
  206. }
  207. $("#county").val(county_id_str);
  208. $("#area_form").submit();
  209. });
  210. });
  211. </script>