截流自动化的商城平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

activity.html 17KB

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