index.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. {extend name="public/container"}
  2. {block name="content"}
  3. <div class="layui-fluid">
  4. <div class="layui-row layui-col-space15" id="app">
  5. <div class="layui-col-md12">
  6. <div class="layui-card">
  7. <div class="layui-card-header">
  8. <div style="font-weight: bold;">专栏专题</div>
  9. </div>
  10. <div class="layui-card-body">
  11. <div class="layui-row layui-col-space15">
  12. <div class="layui-col-md12">
  13. <form class="layui-form layui-form-pane" action="">
  14. <div class="layui-form-item">
  15. <div class="layui-inline">
  16. <label class="layui-form-label">专题搜索</label>
  17. <div class="layui-input-inline">
  18. <input type="text" name="store_name" class="layui-input" placeholder="请输入专栏名称,简介,短语,编号">
  19. <input type="hidden" name="activity_type" value="{$activity_type}">
  20. <input type="hidden" name="subject_id" value="{$subject_id}">
  21. </div>
  22. </div>
  23. <div class="layui-inline">
  24. <label class="layui-form-label">专题分类</label>
  25. <div class="layui-input-inline">
  26. <select name="subject_id" lay-search="">
  27. <option value="0">全部</option>
  28. {volist name='subject_list' id='vo'}
  29. <optgroup label="{$vo.name}">{$vo.name}
  30. {volist name='$vo.special_subject' id='vc'}
  31. <option value="{$vc.id}">|----{$vc.name}</option>
  32. {/volist}
  33. </optgroup>
  34. {/volist}
  35. </select>
  36. </div>
  37. </div>
  38. <div class="layui-inline">
  39. <label class="layui-form-label">显示状态</label>
  40. <div class="layui-input-inline">
  41. <select name="is_show">
  42. <option value="">全部</option>
  43. <option value="1">显示</option>
  44. <option value="0">隐藏</option>
  45. </select>
  46. </div>
  47. </div>
  48. <div class="layui-inline">
  49. <label class="layui-form-label">时间范围</label>
  50. <div class="layui-input-inline" style="width: 260px;">
  51. <input type="text" name="datetime" class="layui-input" id="datetime" placeholder="时间范围">
  52. </div>
  53. </div>
  54. <div class="layui-inline">
  55. <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search" lay-filter="search">
  56. <i class="layui-icon">&#xe615;</i> 搜索
  57. </button>
  58. </div>
  59. </div>
  60. </form>
  61. </div>
  62. <!--产品列表-->
  63. <div class="layui-col-md12">
  64. <div class="layui-btn-group">
  65. <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" onclick="action.open_add('{:Url('add',['special_type' =>$special_type])}','添加{$special_title}')"><i class="layui-icon">&#xe608;</i> 添加{$special_title}</button> <button class="layui-btn layui-btn-normal layui-btn-sm" onclick="window.location.reload()"><i class="layui-icon">&#xe669;</i> 刷新</button>
  66. </div>
  67. <table class="layui-hide" id="List" lay-filter="List"></table>
  68. <script type="text/html" id="recommend">
  69. {{# layui.each(d.recommend, function(index, item){ }}
  70. <span class="layui-badge layui-bg-blue recom-item" data-id="{{index}}" data-pid="{{d.id}}" style="margin-bottom: 5px;">{{item}}</span>
  71. {{# }); }}
  72. </script>
  73. <script type="text/html" id="is_pink">
  74. {{# if(d.is_pink){ }}
  75. <span class="layui-badge layui-bg-blue">开启</span>
  76. {{# }else{ }}
  77. <span class="layui-badge">关闭</span>
  78. {{# } }}
  79. </script>
  80. <script type="text/html" id="is_live_goods">
  81. <input type='checkbox' name='is_live_goods' lay-skin='switch' value="{{d.id}}" lay-filter='is_live_goods' lay-text='是|否' {{ d.is_live_goods == 1 ? 'checked' : '' }}>
  82. </script>
  83. <script type="text/html" id="is_show">
  84. <input type='checkbox' name='id' lay-skin='switch' value="{{d.id}}" lay-filter='is_show' lay-text='上架|下架' {{ d.is_show == 1 ? 'checked' : '' }}>
  85. </script>
  86. <script type="text/html" id="image">
  87. <img style="cursor: pointer;width: 100px;" lay-event='open_image' src="{{d.image}}">
  88. </script>
  89. <script type="text/html" id="act">
  90. <button type="button" class="layui-btn layui-btn-normal layui-btn-xs" onclick="dropdown(this)"><i class="layui-icon">&#xe625;</i> 操作</button>
  91. <ul class="layui-nav-child layui-anim layui-anim-upbit">
  92. <li>
  93. <a href="javascript:void(0)" onclick="action.open_add('{:Url('add')}?id={{d.id}}&special_type={$special_type}','编辑专题')" >
  94. <i class="fa fa-paste"></i> 编辑专题
  95. </a>
  96. </li>
  97. <li>
  98. <a href="{:Url('ump.store_combination/combina_list')}?cid={{d.id}}&special_type={$special_type}" >
  99. <i class="fa fa-street-view"></i> 查看拼团
  100. </a>
  101. </li>
  102. <li>
  103. <a href="javascript:void(0)" onclick="$eb.createModalFrame('{{d.title}}-推荐管理','{:Url('recommend')}?special_id={{d.id}}',{h:300,w:400})">
  104. <i class="fa fa-check-circle"></i> 推荐至首页
  105. </a>
  106. </li>
  107. <li>
  108. <a href="javascript:void(0)" onclick="$eb.createModalFrame('{{d.title}}-拼团管理','{:Url('pink')}?special_id={{d.id}}',{h:500})">
  109. <i class="fa fa-users"></i> 拼团设置
  110. </a>
  111. </li>
  112. <li>
  113. <a lay-event='delect' href="javascript:void(0)">
  114. <i class="fa fa-trash"></i> 删除专题
  115. </a>
  116. </li>
  117. </ul>
  118. </script>
  119. </div>
  120. </div>
  121. </div>
  122. </div>
  123. </div>
  124. </div>
  125. </div>
  126. <script src="{__ADMIN_PATH}js/layuiList.js"></script>
  127. {/block}
  128. {block name="script"}
  129. <script>
  130. var special_type = {$special_type} ? {$special_type} : 6;
  131. //实例化form
  132. layList.form.render();
  133. layList.date({
  134. elem: '#datetime',
  135. theme: '#0092DC',
  136. type: 'datetime',
  137. range: '~'
  138. });
  139. //加载列表
  140. layList.tableList({o:'List', done:function () {}},"{:Url('list',['subject_id'=>$subject_id, 'special_type'=>$special_type])}",function (){
  141. return [
  142. {field: 'id', title: '编号',width:60,align: 'center'},
  143. {field: 'title', title: '名称',align: 'center'},
  144. {field: 'subject_name', title: '分类',align: 'center',width:80},
  145. {field: 'image', title: '封面',templet:'#image',align: 'center'},
  146. {field: 'recommend', title: '推荐',templet:'#recommend',align: 'center'},
  147. {field: 'money', title: '价格',align: 'center',width:70},
  148. {field: 'member_money', title: '会员价',align: 'center',width:70},
  149. {field: 'pink_money', title: '拼团价',align: 'center',width:70},
  150. {field: 'task_count', title: '专题数量',align: 'center',width:70},
  151. {field: 'sales', title: '销量',align: 'center',width:70},
  152. {field: 'is_pink', title: '拼团状态',templet:'#is_pink',align: 'center',width:70},
  153. {field: 'sort', title: '排序',sort: true,event:'sort',edit:'sort',align: 'center',width:60},
  154. {field: 'is_show', title: '状态',templet:'#is_show',align: 'center',width:80},
  155. {field: 'right', title: '操作',align:'center',toolbar:'#act',width:70},
  156. ];
  157. });
  158. //下拉框
  159. $(document).click(function (e) {
  160. $('.layui-nav-child').hide();
  161. })
  162. $(function () {
  163. $(document).on('mouseover', '.recom-item', function () {
  164. var that = this;
  165. layui.use('layer', function () {
  166. var layer = layui.layer;
  167. layer.tips('点击即可取消此推荐', that, {
  168. tips: [1, '#0093dd']
  169. });
  170. });
  171. });
  172. $(document).on('mouseout', '.recom-item', function () {
  173. var that = this;
  174. layui.use('layer', function () {
  175. var layer = layui.layer;
  176. layer.closeAll();
  177. });
  178. });
  179. $(document).on('click', '.recom-item', function () {
  180. var that = this;
  181. var url = layList.U({ a: 'cancel_recommendation', q: { id: that.dataset.id, special_id: that.dataset.pid } });
  182. $eb.$swal(
  183. 'delete',
  184. function () {
  185. $eb.axios
  186. .get(url)
  187. .then(function (res) {
  188. if (res.data.code == 200) {
  189. $eb.$swal('success', res.data.msg);
  190. window.location.reload();
  191. } else {
  192. return Promise.reject(res.data.msg || '删除失败');
  193. }
  194. })
  195. .catch(function (err) {
  196. $eb.$swal('error', err);
  197. });
  198. },
  199. {
  200. title: '确定取消此推荐?',
  201. text: '取消后无法撤销,请谨慎操作!',
  202. confirm: '确定取消'
  203. }
  204. );
  205. });
  206. });
  207. function dropdown(that){
  208. var oEvent = arguments.callee.caller.arguments[0] || event;
  209. oEvent.stopPropagation();
  210. var offset = $(that).offset();
  211. var top=offset.top-$(window).scrollTop();
  212. var index = $(that).parents('tr').data('index');
  213. $('.layui-nav-child').each(function (key) {
  214. if (key != index) {
  215. $(this).hide();
  216. }
  217. })
  218. if($(document).height() < top+$(that).next('ul').height()){
  219. $(that).next('ul').css({
  220. 'padding': 10,
  221. 'top': - ($(that).parent('td').height() / 2 + $(that).height() + $(that).next('ul').height()/2),
  222. 'min-width': 'inherit',
  223. 'position': 'absolute'
  224. }).toggle();
  225. }else{
  226. $(that).next('ul').css({
  227. 'padding': 10,
  228. 'top':$(that).parent('td').height() / 2 + $(that).height(),
  229. 'min-width': 'inherit',
  230. 'position': 'absolute'
  231. }).toggle();
  232. }
  233. }
  234. //自定义方法
  235. var action= {
  236. set_value: function (field, id, value, model_type) {
  237. layList.baseGet(layList.Url({
  238. a: 'set_value',
  239. q: {field: field, id: id, value: value, model_type:model_type}
  240. }), function (res) {
  241. layList.msg(res.msg);
  242. });
  243. },
  244. //打开新添加页面
  245. open_add: function (url,title) {
  246. layer.open({
  247. type: 2 //Page层类型
  248. ,area: ['100%', '100%']
  249. ,title: title
  250. ,shade: 0.6 //遮罩透明度
  251. ,maxmin: true //允许全屏最小化
  252. ,anim: 1 //0-6的动画形式,-1不开启
  253. ,content: url
  254. ,end:function() {
  255. location.reload();
  256. }
  257. });
  258. }
  259. }
  260. //查询
  261. layList.search('search',function(where){
  262. var arr_time = [];
  263. var start_time = '';
  264. var end_time = '';
  265. if (where.datetime) {
  266. arr_time = where.datetime.split('~');
  267. start_time = arr_time[0].trim();
  268. end_time = arr_time[1].trim();
  269. }
  270. layList.reload({
  271. activity_type: where.activity_type,
  272. subject_id: where.subject_id,
  273. is_show: where.is_show,
  274. start_time: start_time,
  275. end_time: end_time,
  276. store_name: where.store_name
  277. },true);
  278. });
  279. layList.switch('is_show',function (odj,value) {
  280. var is_show_value = 0
  281. if(odj.elem.checked==true){
  282. var is_show_value = 1
  283. }
  284. action.set_value('is_show',value,is_show_value,'special');
  285. });
  286. //快速编辑
  287. layList.edit(function (obj) {
  288. var id=obj.data.id,value=obj.value;
  289. switch (obj.field) {
  290. case 'title':
  291. action.set_value('title',id,value,'special');
  292. break;
  293. case 'sort':
  294. if(value < 0) return layList.msg('排序不能小于0');
  295. action.set_value('sort',id,value,'special');
  296. break;
  297. case 'fake_sales':
  298. action.set_value('fake_sales',id,value,'special');
  299. break;
  300. }
  301. });
  302. //监听并执行排序
  303. layList.sort(['id','sort'],true);
  304. //点击事件绑定
  305. layList.tool(function (event,data,obj) {
  306. switch (event) {
  307. case 'delect':
  308. var url=layList.U({a:'delete',q:{id:data.id, model_type:'special'}});
  309. $eb.$swal('delete',function(){
  310. $eb.axios.get(url).then(function(res){
  311. if(res.status == 200 && res.data.code == 200) {
  312. $eb.$swal('success',res.data.msg);
  313. obj.del();
  314. }else
  315. return Promise.reject(res.data.msg || '删除失败')
  316. }).catch(function(err){
  317. $eb.$swal('error',err);
  318. });
  319. })
  320. break;
  321. case 'open_image':
  322. $eb.openImage(data.image);
  323. break;
  324. }
  325. })
  326. </script>
  327. {/block}