addshipping.html 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <?php $shoname_name = D('Home/Front')->get_config_by_name('shoname'); ?>
  6. <title><?php echo $shoname; ?></title>
  7. <link rel="shortcut icon" href="" />
  8. <meta name="renderer" content="webkit">
  9. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  11. <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
  12. <!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
  13. <!--[if lt IE 9]>
  14. <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  15. <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  16. <![endif]-->
  17. <link href="./resource/css/bootstrap.min.css?v=201903260001" rel="stylesheet">
  18. <link href="./resource/css/common.css?v=201903260001" rel="stylesheet">
  19. <script type="text/javascript">
  20. window.sysinfo = {
  21. <?php if (!empty($_W['uniacid']) ){ ?>'uniacid': '{$_W['uniacid']}',<?php } ?>
  22. <?php if( !empty($_W['acid']) ){ ?>'acid': '{$_W['acid']}',<?php } ?>
  23. <?php if (!empty($_W['openid']) ) { ?>'openid': '{$_W['openid']}',<?php } ?>
  24. <?php if( !empty($_W['uid']) ) { ?>'uid': '{$_W['uid']}',<?php } ?>
  25. 'isfounder': <?php if (!empty($_W['isfounder']) ) { ?>1<?php }else{ ?>0<?php } ?>,
  26. 'siteroot': '{$_W['siteroot']}',
  27. 'siteurl': '{$_W['siteurl']}',
  28. 'attachurl': '{$_W['attachurl']}',
  29. 'attachurl_local': '{$_W['attachurl_local']}',
  30. 'attachurl_remote': '{$_W['attachurl_remote']}',
  31. 'module' : {'url' : '<?php if( defined('MODULE_URL') ) { ?>{MODULE_URL}<?php } ?>', 'name' : '<?php if (defined('IN_MODULE') ) { ?>{IN_MODULE}<?php } ?>'},
  32. 'cookie' : {'pre': ''},
  33. 'account' : {:json_encode($_W['account'])},
  34. };
  35. </script>
  36. <script type="text/javascript" src="./resource/js/lib/jquery-1.11.1.min.js"></script>
  37. <script type="text/javascript" src="./resource/js/lib/bootstrap.min.js"></script>
  38. <script type="text/javascript" src="./resource/js/app/util.js?v=201903260001"></script>
  39. <script type="text/javascript" src="./resource/js/app/common.min.js?v=201903260001"></script>
  40. <script type="text/javascript" src="./resource/js/require.js?v=201903260001"></script>
  41. <script type="text/javascript" src="./resource/js/lib/jquery.nice-select.js?v=201903260001"></script>
  42. <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
  43. <link href="/static/css/snailfish.css" rel="stylesheet">
  44. </head>
  45. <body layadmin-themealias="default">
  46. <style>
  47. .mb-3 {
  48. margin-bottom: 1rem!important;
  49. }
  50. .card {
  51. position: relative;
  52. display: -webkit-box;
  53. display: -webkit-flex;
  54. display: -ms-flexbox;
  55. display: flex;
  56. -webkit-box-orient: vertical;
  57. -webkit-box-direction: normal;
  58. -webkit-flex-direction: column;
  59. -ms-flex-direction: column;
  60. flex-direction: column;
  61. background-color: #fff;
  62. border: 1px solid rgba(0,0,0,.125);
  63. border-radius: .25rem;
  64. }
  65. .card-block {
  66. -webkit-box-flex: 1;
  67. -webkit-flex: 1 1 auto;
  68. -ms-flex: 1 1 auto;
  69. flex: 1 1 auto;
  70. padding: 1.25rem;
  71. }
  72. .del-rules-btn{
  73. color:#44abf7 !important;
  74. }
  75. </style>
  76. <div class="layui-fluid">
  77. <div class="layui-card">
  78. <div class="layui-card-header layui-elem-quote">当前位置:<span class="line-text"><?php if( !empty($item['id'])){ ?>编辑<?php }else{ ?>添加<?php } ?>运费模板 <small><?php if( !empty($item['id'])){ ?>修改【{$item['name']}】<?php } ?></span></div>
  79. <div class="layui-card-body" style="padding:15px;">
  80. <form action="" method="post" class="layui-form" lay-filter="component-layui-form-item" enctype="multipart/form-data" >
  81. <input type="hidden" name="data[id]" value="{$item['id']}" />
  82. <div class="layui-form-item">
  83. <label class="layui-form-label must">配送方式名称</label>
  84. <div class="layui-input-block">
  85. <input type="text" name="data[name]" class="form-control" value="{$item['name']}" lay-verify="required" />
  86. </div>
  87. </div>
  88. <div class="layui-form-item">
  89. <label class="layui-form-label">排序</label>
  90. <div class="layui-input-block">
  91. <input type="text" name="sort_order" class="form-control" lay-verify="required" value="{$item['sort_order']}" />
  92. </div>
  93. </div>
  94. <div class="layui-form-item">
  95. <label class="layui-form-label ">是否默认</label>
  96. <div class="layui-input-block">
  97. <label class='radio-inline'><input type='radio' title="是" name='isdefault' id="isdefault1" value='1' <?php if( $item['isdefault']==1){ ?>checked<?php } ?> /> </label>
  98. <label class='radio-inline'><input type='radio' title="否" name='isdefault' id="isdefault0" value='0' <?php if( $item['isdefault']==0){ ?>checked<?php } ?> /> </label>
  99. </div>
  100. </div>
  101. <div class="layui-form-item">
  102. <label class="layui-form-label ">计费方式</label>
  103. <div class="layui-input-block">
  104. <label class='radio-inline'><input type='radio' title="按重量计费" name='type' value='1' <?php if( empty($item) || $item['type']==1){ ?>checked<?php } ?> /> </label>
  105. <label class='radio-inline'><input type='radio' title="按件计费" name='type' value='2' <?php if( $item['type']==2){ ?>checked<?php } ?> /> </label>
  106. </div>
  107. </div>
  108. <div class="layui-form-item">
  109. <label class="layui-form-label " style="padding-top: 11px">全局规则</label>
  110. <div class="layui-input-block">
  111. <table style='width:100%;'>
  112. <thead>
  113. <tr>
  114. <th style="height:40px;width:400px;">运送到</th>
  115. <th class="show_h" style="width:110px;">首重(克)</th>
  116. <th class="show_h" style="width:110px;">首费(元)</th>
  117. <th class="show_h" style="width:110px;">续重(克)</th>
  118. <th class="show_h" style="width:110px;">续费(元)</th>
  119. <th class="show_n" style="width:110px;display:none;">首件(个)</th>
  120. <th class="show_n" style="width:110px;display:none;">运费(元)</th>
  121. <th class="show_n" style="width:110px;display:none;">续件(个)</th>
  122. <th class="show_n" style="width:110px;display:none;">续费(元)</th>
  123. </tr>
  124. </thead>
  125. <tbody id='tbody-areas'>
  126. <tr>
  127. <td style="padding:10px;">全国 [默认运费]</td>
  128. <td class="show_h text-center">
  129. <input type="text" value="{$item['firstweight']}" class="form-control" name="default_firstweight" style="width:80px;"></td>
  130. <td class="show_h text-center">
  131. <input type="text" value="{$item['firstprice']}" class="form-control" name="default_firstprice" style="width:80px;"></td>
  132. <td class="show_h text-center">
  133. <input type="text" value="<?php echo empty($item['secondweight'])?1000:$item['secondweight'];?>" class="form-control" name="default_secondweight" style="width:80px;">
  134. </td>
  135. <td class="show_h text-center">
  136. <input type="text" value="{$item['secondprice']}" class="form-control" name="default_secondprice" style="width:80px;">
  137. </td>
  138. <td class="show_n text-center">
  139. <input type="text" value="<?php echo empty($item['firstnum'])?1:$item['firstnum'];?>" class="form-control" name="default_firstnum" style="width:80px;">
  140. </td>
  141. <td class="show_n text-center">
  142. <input type="text" value="{$item['firstnumprice']}" class="form-control" name="default_firstnumprice" style="width:80px;">
  143. </td>
  144. <td class="show_n text-center">
  145. <input type="text" value="<?php echo empty($item['secondnum'])?1:$item['secondnum'];?>" class="form-control" name="default_secondnum" style="width:80px;">
  146. </td>
  147. <td class="show_n text-center">
  148. <input type="text" value="{$item['secondnumprice']}" class="form-control" name="default_secondnumprice" style="width:80px;">
  149. </td>
  150. </tr>
  151. </tbody>
  152. </table>
  153. </div>
  154. </div>
  155. <div class="layui-form-item row">
  156. <label class="layui-form-label ">运费规则</label>
  157. <div class="layui-input-block" id="card_table">
  158. <a class='btn btn-default' href="javascript:;" onclick='addArea(this)'><span class="fa fa-plus"></span> 新增配送区域</a>
  159. <span class='help-block show_h' <?php if( $item['type']==1){ ?>style='display:none'<?php } ?>>根据重量来计算运费,当物品不足《首重重量》时,按照《首重费用》计算,超过部分按照《续重重量》和《续重费用》乘积来计算</span>
  160. <span class='help-block show_n' <?php if( $item['type']==0){ ?>style='display:none'<?php } ?>>根据件数来计算运费,当物品不足《首件数量》时,按照《首件费用》计算,超过部分按照《续件重量》和《续件费用》乘积来计算</span>
  161. <?php foreach( $dispatch_areas as $row ){ ?>
  162. <?php $random = random(16); ?>
  163. <!--tpl begin-->
  164. <div class="card mb-3 {$random}">
  165. <div class="card-block">
  166. <div class="mb-3">
  167. <span class="show-first-div{$random}"><span class="show-frist"> 首重/件(克/个):</span>{$row['frist']}</span>
  168. <span class="show-price-div{$random}"><span class="show-frist-price">首费(元) :</span>{$row['frist_price']}</span>
  169. <span class="show-second-div{$random}"><span class="show-second">续重/件(克/个) :</span>{$row['second']}</span>
  170. <span class="show-xufei-div{$random}"><span>续费(元) :</span>{$row['second_price']}</span>
  171. <a href="javascript:" data-index="{$random}" onclick="$(this).parent().parent().parent().remove()" class="del-rules-btn float-right">[-删除条目]</a>
  172. </div>
  173. <input type="hidden" name="random[]" value="{$random}" />
  174. <input type="hidden" class='citys' name="citys[{$random}]" value="{$row['citys']}" />
  175. <input type="hidden" class='citys_code' name="citys_code[{$random}]" value="{$row['citys_code']}" />
  176. <input type="hidden" value="{$row['firstweight']}" name="firstweight[{$random}]" />
  177. <input type="hidden" value="{$row['firstprice']}" name="firstprice[{$random}]" />
  178. <input type="hidden" value="<?php echo empty($row['secondweight'])?1000:$row['secondweight'];?>" name="secondweight[{$random}]" />
  179. <input type="hidden" value="{$row['secondprice']}" name="secondprice[{$random}]" />
  180. <input type="hidden" value="<?php echo empty($row['firstnum'])?1:$row['firstnum'];?>" name="firstnum[{$random}]" />
  181. <input type="hidden" value="{$row['firstnumprice']}" name="firstnumprice[{$random}]" />
  182. <input type="hidden" value="<?php echo empty($row['secondnum'])?1:$row['secondnum'];?>" name="secondnum[{$random}]" />
  183. <input type="hidden" value="{$row['secondnumprice']}" name="secondnumprice[{$random}]"/>
  184. <input type="hidden" value="{$row['freeprice']}" name="freeprice[{$random}]" />
  185. <input type="hidden" class="{$random}frist" name="detail[{$random}][frist]" value="{$row['frist']}">
  186. <input type="hidden" class="{$random}frist_price" name="detail[{$random}][frist_price]" value="{$row['frist_price']}">
  187. <input type="hidden" class="{$random}second" name="detail[{$random}][second]" value="{$row['second']}">
  188. <input type="hidden" class="{$random}second_price" name="detail[{$random}][second_price]" value="{$row['second_price']}">
  189. <div>
  190. <span>省份:</span>
  191. <span class="cityshtml">
  192. {$row['citys']}
  193. </span>
  194. </div>
  195. </div>
  196. </div>
  197. <!--tpl end-->
  198. <?php } ?>
  199. </div>
  200. </div>
  201. <div class="layui-form-item">
  202. <label class="layui-form-label"> </label>
  203. <div class="layui-input-block">
  204. <input type="submit" value="提交" lay-submit lay-filter="formDemo" class="btn btn-primary" />
  205. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  206. <a class="btn btn-default" style='margin-left:10px;' href="{:U('shipping/templates',array('ok'=>'1'))}">返回列表</a>
  207. </div>
  208. </div>
  209. </form>
  210. </div>
  211. </div>
  212. </div>
  213. <!--地区开始-->
  214. <style type='text/css'>
  215. .province { float:left; position:relative;width:170px; height:35px; line-height:35px;border:1px solid #fff;padding-top: -10px}
  216. .province:hover { border:1px solid #a6d2fe;border-bottom:1px solid #a6d2fe; background:#edf6ff;}
  217. .province .cityall { margin-top:10px;}
  218. .province ul { list-style: outside none none;position:absolute;padding:0;background:#edf6ff;border:1px solid #a6d2fe;display:none;
  219. width:auto; width:250px; z-index:999999;left:-1px;top:32px;}
  220. .province ul li { float:left;min-width:60px;margin-left:20px; height:30px;line-height:30px; }
  221. .checkbox-inline{
  222. margin: 0;
  223. }
  224. </style>
  225. <div id="modal-areas" class="modal fade" tabindex="-1">
  226. <div class="modal-dialog" style='width: 900px;'>
  227. <div class="modal-content">
  228. <div class="modal-header"><button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button><h3>选择区域</h3></div>
  229. <div class="modal-body" style='' >
  230. <div class="row show_type_1">
  231. <div class="col-sm-6 col-xs-12">
  232. <b class="frist-title help-block">首重(克) :</b>
  233. <input name="frist" id = "frist1" placeholder=" " value="1" step="1" type="number" class="form-control mb-3 frist">
  234. </div>
  235. <div class="col-sm-6 col-xs-12">
  236. <b class="frist-price-title help-block">首费(元) :</b>
  237. <input name="frist_price" id = "frist_price1" placeholder=" " value="0" step="1" type="number" class="form-control mb-3 frist_price">
  238. </div>
  239. </div>
  240. <div class="row show_type_1">
  241. <div class="col-sm-6 col-xs-12">
  242. <b class="second-title help-block">续重(克) :</b>
  243. <input name="second" id = "second1" placeholder=" " value="1" step="1" type="number" class="form-control mb-3 second">
  244. </div>
  245. <div class="col-sm-6 col-xs-12">
  246. <b class="second-price-title help-block">续费(元):</b>
  247. <input name="second_price" id = "second_price1" placeholder=" " value="0" step="1" type="number" class="form-control mb-3 second_price">
  248. </div>
  249. </div>
  250. <div class="row show_type_2" style="display:none;">
  251. <div class="col-sm-6 col-xs-12">
  252. <b class="frist-title">首件(个) :</b>
  253. <input name="frist" id = "frist2" value="1" placeholder=" " step="1" type="number" class="form-control mb-3 frist" >
  254. </div>
  255. <div class="col-sm-6 col-xs-12">
  256. <b class="frist-price-title">运费(元) :</b>
  257. <input name="frist_price" id = "frist_price2" placeholder=" " value="0" step="1" type="number" class="form-control mb-3 frist_price">
  258. </div>
  259. </div>
  260. <div class="row show_type_2" style="display:none;">
  261. <div class="col-sm-6 col-xs-12">
  262. <b class="second-title">续件(个) :</b>
  263. <input name="second" id = "second2" placeholder=" " value="1" step="1" type="number" class="form-control mb-3 second">
  264. </div>
  265. <div class="col-sm-6 col-xs-12">
  266. <b class="second-price-title">续费(元):</b>
  267. <input name="second_price" id = "second_price2" placeholder=" " value="0" step="1" type="number" class="form-control mb-3 second_price">
  268. </div>
  269. </div>
  270. <?php foreach( $areas['province'] as $value ){ ?>
  271. <?php if( $value['@attributes']['name']=='请选择省份'){ continue; } ?>
  272. <?php if( $value['@attributes']['name']=='' || $value['@attributes']['name']=='undefined' || $value['@attributes']['name']=='选择地址'){ continue; } ?>
  273. <div class='province'>
  274. <label class='checkbox-inline' style='margin-left:20px;padding: 0 0 5px 24px;'>
  275. <input type='checkbox' class='cityall' style="" /> {$value['@attributes']['name']}
  276. <span class="citycount" style='color:#ff6600'></span>
  277. </label>
  278. <?php if( count($value['city'])>0){ ?>
  279. <ul style="padding-bottom: 15px;">
  280. <?php foreach( $value['city'] as $c ){ ?>
  281. <li>
  282. <label class='checkbox-inline' >
  283. <input type='checkbox' class='city' style='' code="{$c['@attributes']['code']}" city="{$c['@attributes']['name']}" /> {$c['@attributes']['name']}
  284. </label>
  285. </li>
  286. <?php } ?>
  287. </ul>
  288. <?php } ?>
  289. </div>
  290. <?php } ?>
  291. <div style="clear:both;"></div>
  292. </div>
  293. <div class="modal-footer" style="padding:0px;">
  294. <a href="javascript:;" id='btnSubmitArea' class="btn btn-primary" data-dismiss="modal" aria-hidden="true">确定</a>
  295. <a href="javascript:;" class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</a>
  296. </div>
  297. </div>
  298. </div>
  299. </div>
  300. <script src="/layuiadmin/layui/layui.js"></script>
  301. <script>
  302. layui.config({
  303. base: '/layuiadmin/' //静态资源所在路径
  304. }).extend({
  305. index: 'lib/index' //主入口模块
  306. }).use('index');
  307. </script>
  308. <script>
  309. //由于模块都一次性加载,因此不用执行 layui.use() 来加载对应模块,直接使用即可:
  310. var layer = layui.layer;
  311. var $;
  312. var cur_open_div;
  313. layui.use(['jquery', 'layer','form'], function(){
  314. $ = layui.$;
  315. var form = layui.form;
  316. form.on('radio(linktype)', function(data){
  317. if (data.value == 2) {
  318. $('#typeGroup').show();
  319. } else {
  320. $('#typeGroup').hide();
  321. }
  322. });
  323. $('#chose_link').click(function(){
  324. cur_open_div = $(this).attr('data-input');
  325. $.post("{:U('util.selecturl', array('ok' => 1))}", {}, function(shtml){
  326. layer.open({
  327. type: 1,
  328. area: '930px',
  329. content: shtml //注意,如果str是object,那么需要字符拼接。
  330. });
  331. });
  332. })
  333. //监听提交
  334. form.on('submit(formDemo)', function(data){
  335. $.ajax({
  336. url: data.form.action,
  337. type: data.form.method,
  338. data: data.field,
  339. dataType:'json',
  340. success: function (info) {
  341. if(info.status == 0)
  342. {
  343. layer.msg(info.result.message,{icon: 1,time: 2000});
  344. }else if(info.status == 1){
  345. var go_url = location.href;
  346. if( info.result.hasOwnProperty("url") )
  347. {
  348. go_url = info.result.url;
  349. }
  350. layer.msg('操作成功',{time: 1000,
  351. end:function(){
  352. location.href = info.result.url;
  353. }
  354. });
  355. }
  356. }
  357. });
  358. return false;
  359. });
  360. })
  361. </script>
  362. <script>
  363. $(function(){
  364. $('.province').mouseenter(function(){
  365. $(this).find('ul').show();
  366. }).mouseleave(function(){
  367. $(this).find('ul').hide();
  368. });
  369. $('.cityall').click(function(){
  370. var checked = $(this).get(0).checked;
  371. var citys = $(this).parent().parent().find('.city');
  372. citys.each(function(){
  373. $(this).get(0).checked = checked;
  374. });
  375. var count = 0;
  376. if(checked){
  377. count = $(this).parent().parent().find('.city:checked').length;
  378. }
  379. if(count>0){
  380. $(this).next().html("(" + count + ")") ;
  381. }
  382. else{
  383. $(this).next().html("");
  384. }
  385. });
  386. $('.city').click(function(){
  387. var checked = $(this).get(0).checked;
  388. var cityall = $(this).parent().parent().parent().parent().find('.cityall');
  389. if(checked){
  390. cityall.get(0).checked = true;
  391. }
  392. var count = cityall.parent().parent().find('.city:checked').length;
  393. if(count>0){
  394. cityall.next().html("(" + count + ")") ;
  395. }
  396. else{
  397. cityall.next().html("");
  398. }
  399. });
  400. });
  401. function clearSelects(){
  402. $('.city').attr('checked',false).removeAttr('disabled');
  403. $('.cityall').attr('checked',false).removeAttr('disabled');
  404. $('.citycount').html('');
  405. }
  406. function editArea(btn){
  407. current = $(btn).attr('random');
  408. clearSelects();
  409. var old_citys = $(btn).prev().val().split(';');
  410. $('.city').each(function(){
  411. var parentcheck = false;
  412. for(var i in old_citys){
  413. if(old_citys[i]==$(this).attr('city')){
  414. parentcheck = true;
  415. $(this).get(0).checked = true;
  416. break;
  417. }
  418. }
  419. if(parentcheck){
  420. $(this).parent().parent().parent().parent().find('.cityall').get(0).checked= true;
  421. }
  422. });
  423. $("#modal-areas").modal();
  424. var citystrs = '';
  425. $('#btnSubmitArea').unbind('click').click(function(){
  426. var s_frist = $('.frist').val();
  427. if(s_frist =='' || s_frist == 0)
  428. {
  429. layer.msg('请填写首重');
  430. return false;
  431. }
  432. var s_frist_price = $('.frist_price').val();
  433. if(s_frist_price =='' || s_frist_price == 0)
  434. {
  435. layer.msg('请填写首费');
  436. return false;
  437. }
  438. var s_second = $('.second').val();
  439. if(s_second =='' || s_second == 0)
  440. {
  441. layer.msg('请填写续重');
  442. return false;
  443. }
  444. $('.city:checked').each(function(){
  445. citystrs+= $(this).attr('city') +";";
  446. });
  447. $('.' + current + ' .cityshtml').html(citystrs);
  448. $('.' + current + ' .citys').val(citystrs);
  449. console.log(2);
  450. })
  451. var currents = getCurrents(current);
  452. currents = currents.split(';');
  453. var citys = "";
  454. $('.city').each(function(){
  455. var parentdisabled =false;
  456. for(var i in currents){
  457. if(currents[i]!='' && currents[i]==$(this).attr('city')){
  458. $(this).attr('disabled',true);
  459. $(this).parent().parent().parent().parent().find('.cityall').attr('disabled',true);
  460. }
  461. }
  462. });
  463. }
  464. function selectAreas(){
  465. clearSelects();
  466. var old_citys = $('#areas').html().split(';');
  467. $('.city').each(function(){
  468. var parentcheck = false;
  469. for(var i in old_citys){
  470. if(old_citys[i]==$(this).attr('city')){
  471. parentcheck = true;
  472. $(this).get(0).checked = true;
  473. break;
  474. }
  475. }
  476. if(parentcheck){
  477. $(this).parent().parent().parent().parent().find('.cityall').get(0).checked= true;
  478. }
  479. });
  480. $("#modal-areas").modal();
  481. var citystrs = '';
  482. $('#btnSubmitArea').unbind('click').click(function(){
  483. var s_frist = $('.frist').val();
  484. if(s_frist =='' || s_frist == 0)
  485. {
  486. layer.msg('请填写首重');
  487. return false;
  488. }
  489. var s_frist_price = $('.frist_price').val();
  490. if(s_frist_price =='' || s_frist_price == 0)
  491. {
  492. layer.msg('请填写首费');
  493. return false;
  494. }
  495. var s_second = $('.second').val();
  496. if(s_second =='' || s_second == 0)
  497. {
  498. layer.msg('请填写续重');
  499. return false;
  500. }
  501. $('.city:checked').each(function(){
  502. citystrs+= $(this).attr('city') +";";
  503. });
  504. $('#areas').html(citystrs);
  505. $("#selectedareas").val(citystrs);
  506. })
  507. }
  508. function show_type(flag){
  509. if (flag == 2) {
  510. $('.show_h').hide();
  511. $('.show_n').show();
  512. } else {
  513. $('.show_h').show();
  514. $('.show_n').hide();
  515. }
  516. }
  517. $(function(){
  518. show_type({$item['type']});
  519. $(':radio[name=type]').click(function(){
  520. var val = $(this).val();
  521. $('#card_table .card').remove();
  522. show_type(val);
  523. })
  524. $(':radio[name=isdispatcharea]').click(function(){
  525. var val = $(this).val();
  526. var name = '不';
  527. if(val == 1) {
  528. name = '只';
  529. }
  530. $("#dispatcharea_name").html(name);
  531. })
  532. <?php if( empty($new_area)){ ?>
  533. $('.province').mouseenter(function(){
  534. $(this).find('ul').show();
  535. }).mouseleave(function(){
  536. $(this).find('ul').hide();
  537. });
  538. $('.cityall').click(function(){
  539. var checked = $(this).get(0).checked;
  540. var citys = $(this).parent().parent().find('.city');
  541. citys.each(function(){
  542. $(this).get(0).checked = checked;
  543. });
  544. var count = 0;
  545. if (checked){
  546. count = $(this).parent().parent().find('.city:checked').length;
  547. }
  548. if (count > 0){
  549. $(this).next().html("(" + count + ")");
  550. }
  551. else{
  552. $(this).next().html("");
  553. }
  554. });
  555. $('.city').click(function(){
  556. var checked = $(this).get(0).checked;
  557. var cityall = $(this).parent().parent().parent().parent().find('.cityall');
  558. if (checked){
  559. cityall.get(0).checked = true;
  560. }
  561. var count = cityall.parent().parent().find('.city:checked').length;
  562. if (count > 0){
  563. cityall.next().html("(" + count + ")");
  564. }
  565. else{
  566. cityall.next().html("");
  567. }
  568. });
  569. <?php } ?>
  570. });
  571. function getCurrents(withOutRandom){
  572. var citys = "";
  573. $('.citys').each(function(){
  574. var crandom = $(this).prev().val();
  575. if (withOutRandom && crandom == withOutRandom){
  576. return true;
  577. }
  578. citys += $(this).val();
  579. });
  580. return citys;
  581. }
  582. function getCurrentsCode(withOutRandom){
  583. var citys = "";
  584. $('.citys_code').each(function(){
  585. var crandom = $(this).prev().prev().prev().val();
  586. if (withOutRandom && crandom == withOutRandom){
  587. return true;
  588. }
  589. citys += $(this).val();
  590. });
  591. return citys;
  592. }
  593. var current = '';
  594. function addArea(btn){
  595. $(btn).button('loading');
  596. $.ajax({
  597. url:"{:U('shipping/tpl')}",
  598. dataType:'json',
  599. success:function(json){
  600. $(btn).button('reset');
  601. current = json.random;
  602. var s_type = $('input[name="type"]:checked ').val();
  603. if(s_type == 1)
  604. {
  605. $('.show_type_2').hide();
  606. $('.show_type_1').show();
  607. } else{
  608. $('.show_type_1').hide();
  609. $('.show_type_2').show();
  610. }
  611. $('#card_table').append(json.html);
  612. $('#card_table .card').last().hide();
  613. clearSelects();
  614. $("#modal-areas").modal();
  615. var citystrs = "";
  616. var citystrs_codes = "";
  617. <?php if( empty($new_area)){ ?>
  618. var currents = getCurrents();
  619. currents = currents.split(';');
  620. $('.city').each(function(){
  621. var parentdisabled = false;
  622. for (var i in currents){
  623. if (currents[i] != '' && currents[i] == $(this).attr('city')){
  624. $(this).attr('disabled', true);
  625. $(this).parent().parent().parent().parent().find('.cityall').attr('disabled', true);
  626. }
  627. }
  628. });
  629. $('#btnSubmitArea').unbind('click').click(function(){
  630. //按重计费
  631. var frist1 = $('#frist1').val();
  632. if(frist1 =='' || frist1 == 0)
  633. {
  634. layer.msg('请填写首重');
  635. return false;
  636. }
  637. var re = /^[1-9]+[0-9]*]*$/; //判断字符串是否为数字 /^[0-9]+.?[0-9]*$/ //判断正整数 /^[1-9]+[0-9]*]*$/
  638. if(!re.test(frist1)){
  639. layer.msg('首重请填写大于0整数');
  640. return false;
  641. }
  642. var frist_price1 = $('#frist_price1').val();
  643. var re = /^[0-9]+.?[0-9]*$/; //判断字符串是否为数字 /^[0-9]+.?[0-9]*$/ //判断正整数 /^[1-9]+[0-9]*]*$/
  644. if(!re.test(frist_price1)){
  645. layer.msg('运费请填写非负数字');
  646. return false;
  647. }
  648. var second1 = $('#second1').val();
  649. if(second1 =='' || second1 == 0)
  650. {
  651. layer.msg('请填写续重');
  652. return false;
  653. }
  654. var re = /^[1-9]+[0-9]*]*$/; //判断字符串是否为数字 /^[0-9]+.?[0-9]*$/ //判断正整数 /^[1-9]+[0-9]*]*$/
  655. if(!re.test(second1)){
  656. layer.msg('续重请填写大于0整数');
  657. return false;
  658. }
  659. var second_price1 = $('#second_price1').val();
  660. var re = /^[0-9]+.?[0-9]*$/; //判断字符串是否为数字 /^[0-9]+.?[0-9]*$/ //判断正整数 /^[1-9]+[0-9]*]*$/
  661. if(!re.test(second_price1)){
  662. layer.msg('续费请填写非负数字');
  663. return false;
  664. }
  665. //按件计费
  666. var frist2 = $('#frist2').val();
  667. if(frist2 =='' || frist2 == 0)
  668. {
  669. layer.msg('请填写首件');
  670. return false;
  671. }
  672. var re = /^[1-9]+[0-9]*]*$/; //判断字符串是否为数字 /^[0-9]+.?[0-9]*$/ //判断正整数 /^[1-9]+[0-9]*]*$/
  673. if(!re.test(frist2)){
  674. layer.msg('首件请填写大于0整数');
  675. return false;
  676. }
  677. var frist_price2 = $('#frist_price2').val();
  678. var re = /^[0-9]+.?[0-9]*$/; //判断字符串是否为数字 /^[0-9]+.?[0-9]*$/ //判断正整数 /^[1-9]+[0-9]*]*$/
  679. if(!re.test(frist_price2)){
  680. layer.msg('运费请填写非负数字');
  681. return false;
  682. }
  683. var second2 = $('#second2').val();
  684. if(second2 =='' || second2 == 0)
  685. {
  686. layer.msg('请填写续件');
  687. return false;
  688. }
  689. var re = /^[1-9]+[0-9]*]*$/; //判断字符串是否为数字 /^[0-9]+.?[0-9]*$/ //判断正整数 /^[1-9]+[0-9]*]*$/
  690. if(!re.test(second2)){
  691. layer.msg('续件请填写大于0整数');
  692. return false;
  693. }
  694. var second_price2 = $('#second_price2').val();
  695. var re = /^[0-9]+.?[0-9]*$/; //判断字符串是否为数字 /^[0-9]+.?[0-9]*$/ //判断正整数 /^[1-9]+[0-9]*]*$/
  696. if(!re.test(second_price2)){
  697. layer.msg('续费请填写非负数字');
  698. return false;
  699. }
  700. $('.city:checked').each(function(){
  701. citystrs += $(this).attr('city') + ";";
  702. citystrs_codes += $(this).attr('code') + ";";
  703. });
  704. var s_frist = $('.frist').val();
  705. var s_frist_price = $('.frist_price').val();
  706. var s_second = $('.second').val();
  707. $('.' + current + ' .cityshtml').html(citystrs);
  708. $('.' + current + ' .citys').val(citystrs);
  709. $('.' + current + ' .citys_code').val(citystrs_codes);
  710. if(s_type == 1)
  711. {
  712. var s_first = $('.show_type_1 input[name="frist"]').val();
  713. var s_first_price = $('.show_type_1 input[name="frist_price"]').val();
  714. var s_second = $('.show_type_1 input[name="second"]').val();
  715. var s_second_price = $('.show_type_1 input[name="second_price"]').val();
  716. $('.show-first-div'+current).html('<span class="show-frist"> 首重/件(克/个):</span>'+s_first);
  717. $('.show-price-div'+current).html('<span class="show-frist-price">首费(元) :</span>'+s_first_price);
  718. $('.show-second-div'+current).html('<span class="show-second">续重/件(克/个) :</span>'+s_second);
  719. $('.show-xufei-div'+current).html('<span>续费(元) :</span>'+s_second_price);
  720. $('.' + current + 'frist').val(s_first);
  721. $('.' + current + 'frist_price').val(s_first_price);
  722. $('.' + current + 'second').val(s_second);
  723. $('.' + current + 'second_price').val(s_second_price);
  724. } else{
  725. var s_first = $('.show_type_2 input[name="frist"]').val();
  726. var s_first_price = $('.show_type_2 input[name="frist_price"]').val();
  727. var s_second = $('.show_type_2 input[name="second"]').val();
  728. var s_second_price = $('.show_type_2 input[name="second_price"]').val();
  729. $('.show-first-div'+current).html('<span class="show-frist"> 首重/件(克/个):</span>'+s_first);
  730. $('.show-price-div'+current).html('<span class="show-frist-price">首费(元) :</span>'+s_first_price);
  731. $('.show-second-div'+current).html('<span class="show-second">续重/件(克/个) :</span>'+s_second);
  732. $('.show-xufei-div'+current).html('<span>续费(元) :</span>'+s_second_price);
  733. $('.' + current + 'frist').val(s_first);
  734. $('.' + current + 'frist_price').val(s_first_price);
  735. $('.' + current + 'second').val(s_second);
  736. $('.' + current + 'second_price').val(s_second_price);
  737. }
  738. $('#card_table .card').last().show();
  739. console.log(3);
  740. })
  741. <?php }else{ ?>
  742. var currents = getCurrentsCode();
  743. currents = currents.split(';');
  744. var parentdisabled = false;
  745. for (var i in currents){
  746. var area_info = currents[i].split(' ');
  747. if(area_info[0]) {
  748. $('#ch_pcode'+area_info[0]).prop("disabled",true);
  749. }
  750. if(area_info[1]) {
  751. $('#ch_ccode'+area_info[1]).prop("disabled",true);
  752. }
  753. if(area_info[2]) {
  754. $('#ch_acode'+area_info[2]).prop("disabled",true);
  755. }
  756. }
  757. $('#btnSubmitArea').unbind('click').click(function(){
  758. update_area();
  759. var city_html = $('#city_info').html();
  760. var area_html = $('#area_info').html();
  761. var s_frist = $('.frist').val();
  762. if(s_frist =='' || s_frist == 0)
  763. {
  764. //layer.msg('请填写首重');
  765. //return false;
  766. }
  767. var s_frist_price = $('.frist_price').val();
  768. if(s_frist_price =='' || s_frist_price == 0)
  769. {
  770. //layer.msg('请填写首费');
  771. //return false;
  772. }
  773. var s_second = $('.second').val();
  774. if(s_second =='' || s_second == 0)
  775. {
  776. //layer.msg('请填写续重');
  777. //return false;
  778. }
  779. if (city_html && area_html) {
  780. $('.' + current + ' .cityshtml').html(city_html);
  781. $('.' + current + ' .citys').val(city_html);
  782. $('.' + current + ' .citys_code').val(area_html);
  783. $('#card_table .card').last().show();
  784. }
  785. })
  786. <?php } ?>
  787. var calculatetype1 = $('input[name="type"]:checked ').val();
  788. show_type(calculatetype1);
  789. }
  790. })
  791. }
  792. </script>
  793. </body>