index.php 16 KB

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