截流自动化的商城平台
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

activity.html 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. {layout name="layout1" /}
  2. <style> .layui-table-cell { height: auto; }
  3. p{
  4. float: left;
  5. }
  6. </style>
  7. <div class="wrapper">
  8. <div class="layui-card">
  9. <!-- 操作提示 -->
  10. <div class="layui-card-body">
  11. <div class="layui-collapse like-layui-collapse" style="border:1px dashed #c4c4c4">
  12. <div class="layui-colla-item">
  13. <div class="layui-inline">
  14. <h2 class="layui-colla-title like-layui-colla-title" style="background-color: #fff">操作提示</h2>
  15. <div class="layui-colla-content layui-show">
  16. <p>*设置参与砍价活动的商品。</p>
  17. <p>*生效的砍价活动商品需要满足两个条件,一是开启活动,二是在活动有效期内。</p>
  18. </div>
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. <!-- 搜索模块 -->
  24. <div class="layui-form layui-card-header layuiadmin-card-header-auto" style="margin-top: 30px;">
  25. <div class="layui-form-item">
  26. <div class="layui-inline">
  27. <label for="goods_name" class="layui-form-label">商品名称:</label>
  28. <div class="layui-input-block">
  29. <input type="text" id="goods_name" name="goods_name" placeholder="请输入" autocomplete="off" class="layui-input">
  30. </div>
  31. </div>
  32. <div class="layui-inline">
  33. <label for="status" class="layui-form-label">砍价状态:</label>
  34. <div class="layui-input-inline">
  35. <select name="status" id="status" >
  36. <option value="">全部</option>
  37. <option value="1">已开启</option>
  38. <option value="0">已关闭</option>
  39. </select>
  40. </div>
  41. </div>
  42. <div class="layui-inline">
  43. <button class="layui-btn layui-btn-sm layuiadmin-btn-article {$view_theme_color}" lay-submit lay-filter="list-search">
  44. <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
  45. </button>
  46. <button class="layui-btn layui-btn-sm layui-btn-primary layuiadmin-btn-article }" lay-submit lay-filter="list-clear-search">重置</button>
  47. </div>
  48. </div>
  49. </div>
  50. <!-- 数据表格 -->
  51. <div class="layui-card-body">
  52. <div style="padding-bottom: 10px;">
  53. <button class="layui-btn layui-btn-sm layuiadmin-btn {$view_theme_color}" data-type="add">新增砍价商品</button>
  54. </div>
  55. <div class="layui-tab" lay-filter="lists-tab">
  56. <ul class="layui-tab-title">
  57. <li class="layui-this" data-type="1">砍价商品({$num.audit_pass})</li>
  58. <li data-type="0">待审核商品({$num.unaudit})</li>
  59. <li data-type="2">审核拒绝商品({$num.audit_refund})</li>
  60. </ul>
  61. </div>
  62. <table id="table-lists" lay-filter="table-lists"></table>
  63. <script type="text/html" id="table-goods">
  64. <div>
  65. <img src="{{d.goods.image}}" alt="图片" style="width:60px;height:60px;float:left;" class="image-show">
  66. <div style="margin-left:5px; width:150px;height:60px;white-space:normal;float: left;">{{d.goods.name}}</div>
  67. </div>
  68. </script>
  69. <script type="text/html" id="table-cost_price">
  70. ¥{{d.goods.min_price}} ~ ¥{{d.goods.max_price}}
  71. </script>
  72. <script type="text/html" id="table-floor_price">
  73. ¥{{d.bargain_min_price}} ~ ¥{{d.bargain_max_price}}
  74. </script>
  75. <script type="text/html" id="info">
  76. <p>发起砍价:{{d.info.launch_people_number_count}}</p>
  77. <p>砍价成功人数:{{d.info.success_knife_people_number_count}}</p>
  78. <p>帮砍人数:{{d.info.knife_people_number_count}}</p>
  79. </script>
  80. <script type="text/html" id="table-activity_time">
  81. {{d.activity_start_time}} ~ {{d.activity_end_time}}
  82. </script>
  83. <script type="text/html" id="operation">
  84. {{# if(d.status == 1){ }}
  85. <a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="stop"><i class="layui-icon"></i>停止活动</a>
  86. {{# } }}
  87. {{# if(d.status == 0){ }}
  88. <a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="start"><i class="layui-icon"></i>开启活动</a>
  89. {{# } }}
  90. <a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="detail"><i class="layui-icon"></i>详情</a>
  91. <a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="edit">编辑</a>
  92. <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del">移除商品</a>
  93. {{# if(d.audit_status == 1){ }}
  94. <a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="lists">砍价记录</a>
  95. {{# } }}
  96. </script>
  97. </div>
  98. </div>
  99. </div>
  100. <script>
  101. layui.config({
  102. base: '/static/plug/layui-admin/dist/layuiadmin/'
  103. }).extend({
  104. index: 'lib/index'
  105. }).use(['index', 'table', 'like'], function(){
  106. var $ = layui.$
  107. ,form = layui.form
  108. ,table = layui.table
  109. ,like = layui.like
  110. ,element = layui.element;
  111. //监听搜索
  112. form.on('submit(list-search)', function(data){
  113. var field = data.field;
  114. //执行重载
  115. table.reload('table-lists', {
  116. where: field
  117. });
  118. });
  119. //清空查询
  120. form.on('submit(list-clear-search)', function () {
  121. $('#status').val('');
  122. $('#goods_name').val('');
  123. form.render('select');
  124. //刷新列表
  125. table.reload('table-lists', {
  126. where: [],
  127. page: {
  128. curr: 1
  129. },
  130. });
  131. });
  132. //获取列表
  133. getList('');
  134. //切换列表
  135. element.on('tab(lists-tab)', function (data) {
  136. $('#goods_name').val('');
  137. $('#status').val('');
  138. form.render('select');
  139. var type = $(this).attr('data-type');
  140. getList(type);
  141. });
  142. // 渲染数据表格
  143. function getList(type) {
  144. table.render({
  145. elem: '#table-lists'
  146. ,url: '{:url("bargain.Bargain/activity")}?type=' + type
  147. ,cols: [[
  148. {field: 'id', title: 'ID',width:60, align:"center"}
  149. ,{field: 'goods', title: '商品',width:160, templet: '#table-goods'}
  150. ,{field: 'cost_price', title: '原价',width:160, align: 'center', templet: '#table-cost_price'}
  151. ,{field: 'floor_price', title: '底价',width:160, align: 'center', templet: '#table-floor_price'}
  152. ,{field: 'info', title: '砍价信息', width:130, align: 'center',templet: '#info'}
  153. ,{field: 'activity_time', title: '活动有效期', width:300, align: 'center', templet: '#table-activity_time'}
  154. ,{field: 'status_text', title: '状态', width:100, align: 'center'}
  155. ,{fixed: 'right', title: '操作', width:450, align: 'center', toolbar: '#operation'}
  156. ]]
  157. ,page:true
  158. ,text: {none: '暂无数据!'}
  159. ,response: {
  160. statusCode: 1
  161. }
  162. ,parseData: function(res){
  163. return {
  164. "code":res.code,
  165. "msg":res.msg,
  166. "count": res.data.count,
  167. "data": res.data.lists
  168. };
  169. }
  170. ,done: function(){
  171. $(".layui-table-main tr").each(function (index, val) {
  172. $($(".layui-table-fixed-l .layui-table-body tbody tr")[index]).height($(val).height());
  173. $($(".layui-table-fixed-r .layui-table-body tbody tr")[index]).height($(val).height());
  174. });
  175. }
  176. });
  177. }
  178. // 事件
  179. var active = {
  180. add: function (obj) {
  181. layer.open({
  182. type: 2
  183. ,title: '新增砍价商品'
  184. ,content: '{:url("bargain.Bargain/add")}'
  185. ,area: ['90%','90%']
  186. ,btn: ['确定', '取消']
  187. ,yes: function(index, layero){
  188. var iframeWindow = window['layui-layer-iframe'+ index];
  189. var submitID = 'addSubmit';
  190. var submit = layero.find('iframe').contents().find('#'+ submitID);
  191. //监听提交
  192. iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
  193. var field = data.field;
  194. like.ajax({
  195. url:'{:url("bargain.Bargain/add")}',
  196. data:field,
  197. type:"post",
  198. success:function(res) {
  199. if(res.code === 1) {
  200. layui.layer.msg(res.msg, { offset:'15px', icon:1, time:1000 });
  201. layer.close(index);
  202. window.location.reload();
  203. }
  204. }
  205. });
  206. });
  207. submit.trigger('click');
  208. }
  209. });
  210. },
  211. edit: function (obj) {
  212. layer.open({
  213. type: 2
  214. ,title: '编辑砍价商品'
  215. ,content: '{:url("bargain.Bargain/edit")}?id=' + obj.data.id
  216. ,area: ['90%','90%']
  217. ,btn: ['确定', '取消']
  218. ,yes: function(index, layero){
  219. var iframeWindow = window['layui-layer-iframe'+ index];
  220. var submitID = 'addSubmit';
  221. var submit = layero.find('iframe').contents().find('#'+ submitID);
  222. //监听提交
  223. iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
  224. var field = data.field;
  225. like.ajax({
  226. url:'{:url("bargain.Bargain/edit")}',
  227. data:field,
  228. type:"post",
  229. success:function(res) {
  230. if(res.code === 1) {
  231. layui.layer.msg(res.msg, { offset:'15px', icon:1, time:1000 });
  232. layer.close(index);
  233. table.reload('table-lists');
  234. }
  235. }
  236. });
  237. });
  238. submit.trigger('click');
  239. }
  240. });
  241. },
  242. del: function(obj) {
  243. if (obj.data.del !== 0 || obj.data.status !== 0) {
  244. layui.layer.msg('活动进行中,禁止删除,请先结束活动!', { time:1000 });
  245. return false;
  246. }
  247. layer.confirm('确定要删除该活动吗? ', function(index) {
  248. like.ajax({
  249. url: '{:url("bargain.Bargain/del")}',
  250. data: {id:obj.data.id},
  251. type: "post",
  252. success: function (res) {
  253. if (res.code === 1) {
  254. layui.layer.msg(res.msg, {offset: '15px', icon: 1, time: 1000});
  255. layer.close(index);
  256. obj.del();
  257. window.location.reload();
  258. }
  259. }
  260. });
  261. layer.close(index);
  262. })
  263. },
  264. lists: function (obj) {
  265. layer.open({
  266. type: 2
  267. ,title: '砍价列表'
  268. ,content: '{:url("bargain.Bargain/launch")}?bargain_id='+obj.data.id
  269. ,area: ['90%','90%']
  270. });
  271. },
  272. detail: function (obj) {
  273. var id = obj.data.id;
  274. layer.open({
  275. type: 2
  276. ,title: '砍价活动商品详情'
  277. ,content: '{:url("bargain.bargain/bargain_detail")}?id='+id
  278. ,area: ['90%', '90%']
  279. ,btn: ['确定', '取消']
  280. ,yes: function(index, layero){
  281. var iframeWindow = window['layui-layer-iframe'+ index]
  282. ,submitID = 'edit-submit'
  283. ,submit = layero.find('iframe').contents().find('#'+ submitID);
  284. submit.trigger('click');
  285. }
  286. })
  287. },
  288. start: function (obj) {
  289. layer.confirm('确定要开启该活动吗? ', function(index) {
  290. like.ajax({
  291. url: '{:url("bargain.Bargain/start")}',
  292. data: {id:obj.data.id},
  293. type: "post",
  294. success: function (res) {
  295. if (res.code === 1) {
  296. layui.layer.msg(res.msg, {offset: '15px', icon: 1, time: 1000});
  297. layer.close(index);
  298. obj.del();
  299. }
  300. }
  301. });
  302. table.reload('table-lists');
  303. })
  304. },
  305. stop: function (obj) {
  306. layer.confirm('确定要停止活动:'+ obj.data.goods.name + '<br>'+'停止活动会将砍价中的砍价记录设置为砍价失败,请谨慎处理。', function(index) {
  307. like.ajax({
  308. url: '{:url("bargain.Bargain/stop")}',
  309. data: {id:obj.data.id},
  310. type: "post",
  311. success: function (res) {
  312. if (res.code === 1) {
  313. layui.layer.msg(res.msg, {offset: '15px', icon: 1, time: 1000});
  314. layer.close(index);
  315. obj.del();
  316. }
  317. }
  318. });
  319. table.reload('table-lists');
  320. })
  321. },
  322. // 切换状态
  323. switchStatus: function (obj) {
  324. if (obj.status) {
  325. var endTime = Date.parse(new Date(obj.endTime)) / 1000;
  326. var curTime = Date.parse(new Date()) / 1000;
  327. if (endTime <= curTime) {
  328. layui.layer.msg('砍价时间已过,请重新修改活动时间后再开启!', {time: 1000});
  329. table.reload('table-lists', {where: []});
  330. return false;
  331. }
  332. like.ajax({
  333. url:'{:url("bargain.Bargain/switchStatus")}',
  334. data:obj,
  335. type:"post",
  336. success:function(res) {
  337. if(res.code === 1) {
  338. layui.layer.msg(res.msg, { offset:'15px', icon:1, time:1000 });
  339. table.reload('table-lists', { where: [] });
  340. }
  341. }
  342. });
  343. } else {
  344. layer.confirm('您确定要关闭该砍价活动吗?', {
  345. btn: ['确定','取消']
  346. }, function(){
  347. like.ajax({
  348. url:'{:url("bargain.Bargain/switchStatus")}',
  349. data:obj,
  350. type:"post",
  351. success:function(res) {
  352. if(res.code === 1) {
  353. layui.layer.msg(res.msg, { offset:'15px', icon:1, time:1000 });
  354. table.reload('table-lists', { where: [] });
  355. }
  356. }
  357. });
  358. }, function(){
  359. table.reload('table-lists', {where: []});
  360. });
  361. }
  362. }
  363. };
  364. // 监听表格右侧工具条
  365. table.on('tool(table-lists)', function(obj){
  366. var type = obj.event;
  367. active[type] ? active[type].call(this, obj) : '';
  368. });
  369. // 切换状态
  370. form.on('switch(switch-status)',function (obj) {
  371. var id = obj.elem.attributes['data-id'].nodeValue;
  372. var fields = obj.elem.attributes['data-field'].nodeValue;
  373. var status = this.checked ? 1 : 0;
  374. var endTime = obj.elem.attributes['data-end-time'].nodeValue;
  375. var data = {"id":id, "field":fields, "status":status, endTime:endTime};
  376. active['switchStatus'] ? active['switchStatus'].call(this, data) : '';
  377. });
  378. // 绑定点击按钮事件
  379. $('.layui-btn.layuiadmin-btn').on('click', function(){
  380. var type = $(this).data('type');
  381. active[type] ? active[type].call(this) : '';
  382. });
  383. //监听搜索
  384. form.on('submit(search)', function(data){
  385. var field = data.field;
  386. table.reload('table-lists', {
  387. where: field,
  388. page: { curr: 1 }
  389. });
  390. });
  391. // 监听重置搜素
  392. form.on('submit(clear-search)', function(){
  393. $('#goods_name').val('');
  394. $('#status').val('');
  395. form.render('select');
  396. table.reload('table-lists', { where: [] });
  397. });
  398. // 图片放大
  399. $(document).on('click', '.image-show', function () {
  400. var src = $(this).attr('src');
  401. like.showImg(src);
  402. });
  403. });
  404. </script>