index.php 17 KB

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