category.html 12 KB

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