688451932cb401120021c9d38538ecec.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <?php if (!defined('THINK_PATH')) exit();?><!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': '<?php echo ($_W['uniacid']); ?>',<?php } ?>
  22. <?php if( !empty($_W['acid']) ){ ?>'acid': '<?php echo ($_W['acid']); ?>',<?php } ?>
  23. <?php if (!empty($_W['openid']) ) { ?>'openid': '<?php echo ($_W['openid']); ?>',<?php } ?>
  24. <?php if( !empty($_W['uid']) ) { ?>'uid': '<?php echo ($_W['uid']); ?>',<?php } ?>
  25. 'isfounder': <?php if (!empty($_W['isfounder']) ) { ?>1<?php }else{ ?>0<?php } ?>,
  26. 'siteroot': '<?php echo ($_W['siteroot']); ?>',
  27. 'siteurl': '<?php echo ($_W['siteurl']); ?>',
  28. 'attachurl': '<?php echo ($_W['attachurl']); ?>',
  29. 'attachurl_local': '<?php echo ($_W['attachurl_local']); ?>',
  30. 'attachurl_remote': '<?php echo ($_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' : <?php echo 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. <script type="text/javascript" src="{php echo SNAILFISH_LOCAL}/static/js/dist/jquery/nestable/jquery.nestable.js"></script>
  45. <link href="/static/js/dist/jquery/nestable/nestable.css" rel="stylesheet">
  46. <style type='text/css'>
  47. .dd-handle { height: 40px; line-height: 30px}
  48. .dd-list { width:860px;}
  49. .dd-handle span {
  50. font-weight: normal;
  51. }
  52. .cate_sort{width: 35px;height: 20px;text-align:center;
  53. border:1px solid #ebebeb;}
  54. </style>
  55. </head>
  56. <body layadmin-themealias="default">
  57. <div class="layui-fluid">
  58. <div class="layui-card">
  59. <div class="layui-card-header layui-elem-quote">当前位置:<span class="line-text">商品分类</span></div>
  60. <div class="layui-card-body" style="padding:15px;">
  61. <div class="page-table-header">
  62. <span class="pull-right">
  63. <a href="<?php echo U('group/addcategory', array('ok' => 1));?>" class="layui-btn layui-btn-sm"><i class="fa fa-plus"></i> 添加分类</a>
  64. </span>
  65. <div style="clear:both;"></div>
  66. </div>
  67. <form action="" method="post" class="layui-form" lay-filter="component-layui-form-item" enctype="multipart/form-data" >
  68. <div class="dd" id="div_nestable">
  69. <ol class="dd-list">
  70. <?php foreach( $category as $row ){ ?>
  71. <?php if( empty($row['pid'])){ ?>
  72. <li class="dd-item full" data-id="<?php echo ($row['id']); ?>">
  73. <div class="dd-handle" >
  74. [<input type="text" class="cate_sort" name="cate_sort" id="cate_sort_<?php echo ($row['id']); ?>" cate_id="<?php echo ($row['id']); ?>" value="<?php echo ($row['sort_order']); ?>" onchange="updateSort(this)"/>] <?php echo ($row['name']); ?>
  75. <span class="pull-right">
  76. <input type="checkbox" name="" lay-filter="enabledwsitch" data-href="<?php echo U('group/category_enabled',array('id'=>$row['id']));?>" <?php if( $row['is_show']==1){ ?>checked<?php }else{ } ?> lay-skin="switch" lay-text="显示|隐藏">
  77. <a class='btn btn-default btn-sm btn-operation btn-op' data-toggle="ajaxModal" href="<?php echo U('group/addcategory', array('pid' => $row['id'], 'ok' => 1));?>" title='' >
  78. <span data-toggle="tooltip" data-placement="top" title="" data-original-title="添加子分类">
  79. 添加子分类
  80. </span>
  81. </a>
  82. <a class='btn btn-default btn-sm btn-operation btn-op' data-toggle="ajaxModal" href="<?php echo U('group/addcategory', array('id' => $row['id'] , 'ok' => 1));?>" >
  83. <span data-toggle="tooltip" data-placement="top" data-original-title="修改">
  84. 修改
  85. </span>
  86. </a>
  87. <a class='btn btn-default btn-sm btn-operation btn-op deldom' href="javascript:;" data-href="<?php echo U('group/category_delete', array('id' => $row['id']));?>" data-confirm='确认删除此分类吗?'>删除</a>
  88. </span>
  89. </div>
  90. <?php if( count($children[$row['id']])>0){ ?>
  91. <ol class="dd-list">
  92. <?php foreach( $children[$row['id']] as $child ){ ?>
  93. <li class="dd-item full" data-id="<?php echo ($child['id']); ?>">
  94. <div class="dd-handle" style="width:100%;">
  95. <img src="<?php echo tomedia($child['thumb']);;?>" width='30' height="30" onerror="$(this).remove()" style='padding:1px;border: 1px solid #ccc;float:left;' /> &nbsp;
  96. [<input type="text" class="cate_sort" name="cate_sort" id="cate_sort_<?php echo ($child['id']); ?>" cate_id="<?php echo ($child['id']); ?>" value="<?php echo ($child['sort_order']); ?>" onchange="updateSort(this)"/>] <?php echo ($child['name']); ?>
  97. <span class="pull-right">
  98. <input type="checkbox" name="" lay-filter="enabledwsitch" data-href="<?php echo U('group/category_enabled',array('id'=>$child['id']));?>" <?php if( $child['is_show']==1){ ?>checked<?php }else{ } ?> lay-skin="switch" lay-text="显示|隐藏">
  99. <a class='btn btn-default btn-sm btn-operation btn-op' data-toggle="ajaxModal" href="<?php echo U('group/addcategory', array('pid' => $child['id']));?>" title='添加子分类' >
  100. <span data-toggle="tooltip" data-placement="top" title="" data-original-title="添加子分类">
  101. 添加子分类
  102. </span>
  103. </a>
  104. <a class='btn btn-default btn-sm btn-operation btn-op' data-toggle="ajaxModal" href="<?php echo U('group/addcategory', array('id' => $child['id']));?>" title="修改" >
  105. <span data-toggle="tooltip" data-placement="top" title="" data-original-title="修改">
  106. 修改
  107. </span>
  108. </a>
  109. <a class='btn btn-default btn-sm btn-operation btn-op deldom' href="javascript:;" data-href="<?php echo U('group/category_delete', array('id' => $child['id']));?>" data-confirm="确认删除此分类吗?">
  110. <span data-toggle="tooltip" data-placement="top" data-original-title="删除">
  111. 删除
  112. </span>
  113. </a>
  114. </span>
  115. </div>
  116. <?php if( count($children[$child['id']])>0 ){ ?>
  117. <ol class="dd-list" style='width:100%;'>
  118. <?php foreach( $children[$child['id']] as $third ){ ?>
  119. <li class="dd-item" data-id="<?php echo ($third['id']); ?>">
  120. <div class="dd-handle">
  121. <img src="<?php echo tomedia($third['thumb']);;?>" width='30' height="30" onerror="$(this).remove()" style='padding:1px;border: 1px solid #ccc;float:left;' /> &nbsp;
  122. [<input type="text" class="cate_sort" name="cate_sort" id="cate_sort_<?php echo ($third['id']); ?>" cate_id="<?php echo ($third['id']); ?>" value="<?php echo ($third['sort_order']); ?>" onchange="updateSort(this)"/>] <?php echo ($third['name']); ?>
  123. <span class="pull-right">
  124. <input type="checkbox" name="" lay-filter="enabledwsitch" data-href="<?php echo U('group/category_enabled',array('id'=>$third['id']));?>" <?php if( $third['is_show']==1){ ?>checked<?php }else{ } ?> lay-skin="switch" lay-text="显示|隐藏">
  125. <a class='btn btn-default btn-sm btn-operation btn-op' href="<?php echo U('group/addcategory', array('id' => $third['id']));?>" title="修改" >
  126. <span data-toggle="tooltip" data-placement="top" title="" data-original-title="修改">
  127. <i class="icow icow-bianji2"></i>修改
  128. </span>
  129. </a>
  130. <a class='btn btn-default btn-sm btn-operation btn-op deldom' href="javascript:;" data-href="<?php echo U('group/category_delete', array('id' => $third['id']));?>" data-confirm="确认删除此分类吗?">
  131. 删除
  132. </a>
  133. </span>
  134. </div>
  135. </li>
  136. <?php } ?>
  137. </ol>
  138. <?php } ?>
  139. </li>
  140. <?php } ?>
  141. </ol>
  142. <?php } ?>
  143. </li>
  144. <?php } ?>
  145. <?php } ?>
  146. </ol>
  147. <!--
  148. <table class='table'>
  149. <tr>
  150. <td>
  151. <input id="save_category" type="submit" class="btn btn-primary" value="保存">
  152. <input type="hidden" name="token" value="<?php echo ($_W['token']); ?>" />
  153. <input type="hidden" name="datas" value="" />
  154. </td>
  155. </tr>
  156. </tbody>
  157. </table> -->
  158. </div>
  159. </form>
  160. </div>
  161. </div>
  162. </div>
  163. <script src="/layuiadmin/layui/layui.js"></script>
  164. <script>
  165. layui.config({
  166. base: '/layuiadmin/' //静态资源所在路径
  167. }).extend({
  168. index: 'lib/index' //主入口模块
  169. }).use('index');
  170. </script>
  171. <script>
  172. //由于模块都一次性加载,因此不用执行 layui.use() 来加载对应模块,直接使用即可:
  173. var layer = layui.layer;
  174. var $;
  175. var cur_open_div;
  176. layui.use(['jquery', 'layer','form'], function(){
  177. $ = layui.$;
  178. var form = layui.form;
  179. form.on('radio(linktype)', function(data){
  180. if (data.value == 2) {
  181. $('#typeGroup').show();
  182. } else {
  183. $('#typeGroup').hide();
  184. }
  185. });
  186. form.on('switch(enabledwsitch)', function(data){
  187. var s_url = $(this).attr('data-href')
  188. var s_value = 1;
  189. if(data.elem.checked)
  190. {
  191. s_value = 1;
  192. }else{
  193. s_value = 0;
  194. }
  195. $.ajax({
  196. url:s_url,
  197. type:'post',
  198. dataType:'json',
  199. data:{enabled:s_value},
  200. success:function(info){
  201. if(info.status == 0)
  202. {
  203. layer.msg(info.result.message,{icon: 1,time: 2000});
  204. }else if(info.status == 1){
  205. var go_url = location.href;
  206. if( info.result.hasOwnProperty("url") )
  207. {
  208. go_url = info.result.url;
  209. }
  210. layer.msg('操作成功',{time: 1000,
  211. end:function(){
  212. location.href = info.result.url;
  213. }
  214. });
  215. }
  216. }
  217. })
  218. });
  219. $('.deldom').click(function(){
  220. var s_url = $(this).attr('data-href');
  221. layer.confirm($(this).attr('data-confirm'), function(index){
  222. $.ajax({
  223. url:s_url,
  224. type:'post',
  225. dataType:'json',
  226. success:function(info){
  227. if(info.status == 0)
  228. {
  229. layer.msg(info.result.message,{icon: 1,time: 2000});
  230. }else if(info.status == 1){
  231. var go_url = location.href;
  232. if( info.result.hasOwnProperty("url") )
  233. {
  234. go_url = info.result.url;
  235. }
  236. layer.msg('操作成功',{time: 1000,
  237. end:function(){
  238. location.href = info.result.url;
  239. }
  240. });
  241. }
  242. }
  243. })
  244. });
  245. })
  246. $('#chose_link').click(function(){
  247. cur_open_div = $(this).attr('data-input');
  248. $.post("<?php echo U('util.selecturl', array('ok' => 1));?>", {}, function(shtml){
  249. layer.open({
  250. type: 1,
  251. area: '930px',
  252. content: shtml //注意,如果str是object,那么需要字符拼接。
  253. });
  254. });
  255. })
  256. //监听提交
  257. form.on('submit(formDemo)', function(data){
  258. $.ajax({
  259. url: data.form.action,
  260. type: data.form.method,
  261. data: data.field,
  262. dataType:'json',
  263. success: function (info) {
  264. if(info.status == 0)
  265. {
  266. layer.msg(info.result.message,{icon: 1,time: 2000});
  267. }else if(info.status == 1){
  268. var go_url = location.href;
  269. if( info.result.hasOwnProperty("url") )
  270. {
  271. go_url = info.result.url;
  272. }
  273. layer.msg('操作成功',{time: 1000,
  274. end:function(){
  275. location.href = info.result.url;
  276. }
  277. });
  278. }
  279. }
  280. });
  281. return false;
  282. });
  283. })
  284. </script>
  285. <script language='javascript'>
  286. $(function () {
  287. $('#btnExpand').click(function () {
  288. var action = $(this).data('action');
  289. if (action === 'expand') {
  290. $('#div_nestable').nestable('collapseAll');
  291. $(this).data('action', 'collapse').html('<i class="fa fa-angle-up"></i> 展开所有');
  292. } else {
  293. $('#div_nestable').nestable('expandAll');
  294. $(this).data('action', 'expand').html('<i class="fa fa-angle-down"></i> 折叠所有');
  295. }
  296. })
  297. var depth = <?php echo intval($_W['shopset']['category']['level']);?>;
  298. if (depth <= 0) {
  299. depth = 3;
  300. }
  301. $('.dd-item').addClass('full');
  302. $(".dd-handle a,.dd-handle div").mousedown(function (e) {
  303. e.stopPropagation();
  304. });
  305. var $expand = false;
  306. $('#nestableMenu').on('click', function (e)
  307. {
  308. if ($expand) {
  309. $expand = false;
  310. $('.dd').nestable('expandAll');
  311. } else {
  312. $expand = true;
  313. $('.dd').nestable('collapseAll');
  314. }
  315. });
  316. $('form').submit(function(){
  317. var json = window.JSON.stringify($('#div_nestable').nestable("serialize"));
  318. $(':input[name=datas]').val(json);
  319. });
  320. })
  321. function updateSort(obj){
  322. var cate_id = $(obj).attr('cate_id');
  323. var sort_order = $(obj).val();
  324. $.ajax({
  325. url: "<?php echo U('group/update_catesort');?>",
  326. type: "post",
  327. data: {cate_id:cate_id,sort_order:sort_order},
  328. dataType:'json',
  329. success: function (info) {
  330. if(info.status == 1){
  331. var go_url = location.href;
  332. if( info.result.hasOwnProperty("url") )
  333. {
  334. go_url = info.result.url;
  335. }
  336. location.href = info.result.url;
  337. }else {
  338. layer.msg(info.result.message,{icon: 1,time: 2000});
  339. }
  340. }
  341. });
  342. }
  343. </script>
  344. </body>