截流自动化的商城平台
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.

launch.html 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. {layout name="layout1" /}
  2. <style> .layui-table-cell { height: auto; } </style>
  3. <div class="wrapper">
  4. <div class="layui-card">
  5. <!-- 操作提示 -->
  6. {if !$bargain_id}
  7. <div class="layui-card-body">
  8. <div class="layui-collapse like-layui-collapse" style="border:1px dashed #c4c4c4">
  9. <div class="layui-colla-item">
  10. <h2 class="layui-colla-title like-layui-colla-title" style="background-color: #fff">操作提示</h2>
  11. <div class="layui-colla-content layui-show">
  12. <p>*砍价列表,查看帮砍人数,信息,砍价订单等信息;</p>
  13. </div>
  14. </div>
  15. </div>
  16. </div>
  17. {/if}
  18. <!-- 搜索模块 -->
  19. <div class="layui-tab layui-tab-card" lay-filter="tab-all">
  20. <div class="layui-card-body layui-form">
  21. <div class="layui-form-item">
  22. <div class="layui-row">
  23. <div class="layui-inline">
  24. <label for="bargain_sn" class="layui-form-label">砍价编号:</label>
  25. <div class="layui-input-block">
  26. <input type="text" id="bargain_sn" name="bargain_sn" placeholder="请输入" autocomplete="off" class="layui-input">
  27. </div>
  28. </div>
  29. <div class="layui-inline">
  30. <label for="goods_name" class="layui-form-label">商品名称:</label>
  31. <div class="layui-input-block">
  32. <input type="text" id="goods_name" name="goods_name" placeholder="请输入" autocomplete="off" class="layui-input">
  33. </div>
  34. </div>
  35. <div class="layui-inline">
  36. <label for="status" class="layui-form-label">砍价状态:</label>
  37. <div class="layui-input-inline">
  38. <select name="status" id="status" >
  39. <option value="">全部</option>
  40. <option value="0">砍价中</option>
  41. <option value="1">砍价成功</option>
  42. <option value="2">砍价失败</option>
  43. </select>
  44. </div>
  45. </div>
  46. </div>
  47. <div class="layui-row">
  48. <div class="layui-inline">
  49. <label for="keyword_type" class="layui-form-label">发起用户:</label>
  50. <div class="layui-input-block">
  51. <select id="keyword_type" name="keyword_type" >
  52. <option value="">请选择</option>
  53. <option value="sn">会员编号</option>
  54. <option value="nickname">会员昵称</option>
  55. </select>
  56. </div>
  57. </div>
  58. <div class="layui-inline">
  59. <input type="text" id="keyword" name="keyword" placeholder="请输入" autocomplete="off" class="layui-input">
  60. </div>
  61. <div class="layui-row">
  62. <div class="layui-inline">
  63. <label class="layui-form-label">发起时间:</label>
  64. <div class="layui-inline">
  65. <input type="text" id="launch_start_time" name="launch_start_time" placeholder="开始时间" autocomplete="off" class="layui-input">
  66. </div>
  67. <div class="layui-inline"> - </div>
  68. <div class="layui-inline">
  69. <input type="text" id="launch_end_time" name="launch_end_time" placeholder="结束时间" class="layui-input">
  70. </div>
  71. </div>
  72. <div class="layui-inline">
  73. <button class="layui-btn layui-btn-sm layuiadmin-btn-article {$view_theme_color}" lay-submit lay-filter="search">
  74. <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
  75. </button>
  76. <button class="layui-btn layui-btn-sm layui-btn-primary layuiadmin-btn-article }" lay-submit lay-filter="clear-search">重置</button>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. <!-- 数据表格 -->
  84. <div class="layui-tab-item layui-show">
  85. <div class="layui-card">
  86. <div class="layui-card-body">
  87. <table id="table-lists" lay-filter="table-lists"></table>
  88. <script type="text/html" id="table-user">
  89. {{# if((d.user) == null){ }}
  90. 会员信息缺失
  91. {{# } else { }}
  92. <img src="{{d.user.avatar}}" style="height:80px;width: 80px" class="image-show">
  93. <div class="layui-input-inline" style="text-align: left">
  94. <p>会员编号:{{d.user.sn}}</p>
  95. <p>会员昵称:{{d.user.nickname}}</p>
  96. <p>会员等级:{{d.user.level.name ?? '无'}}</p>
  97. </div>
  98. {{# } }}
  99. </script>
  100. <script type="text/html" id="table-goods">
  101. <div>
  102. <img src="{{d.goods_image}}" alt="图片" style="width:60px;height:60px;float:left;" class="image-show">
  103. <div class="layui-inline">
  104. <div >{{d.goods_snap.name}}</div>
  105. <div>{{d.goods_snap.spec_value_str}}&nbsp; ¥{{d.goods_snap.price}}</div>
  106. </div>
  107. </div>
  108. </script>
  109. <script type="text/html" id="table-start_time">
  110. <div style="width:100px;height:60px;white-space:normal;">
  111. {{d.launch_start_time}}
  112. </div>
  113. </script>
  114. <script type="text/html" id="table-end_time">
  115. <div style="width:100px;height:60px;white-space:normal;">
  116. {{d.launch_end_time}}
  117. </div>
  118. </script>
  119. <script type="text/html" id="operation">
  120. <a class="layui-btn layui-btn-normal layui-btn-sm " lay-event="detail">详情</a>
  121. {{# if(d.status != '砍价失败'){ }}
  122. <a class="layui-btn layui-btn-danger layui-btn-sm " lay-event="close">结束砍价</a>
  123. {{# } }}
  124. </script>
  125. </div>
  126. </div>
  127. </div>
  128. </div>
  129. </div>
  130. <script>
  131. layui.config({
  132. base: '/static/plug/layui-admin/dist/layuiadmin/' //静态资源所在路径
  133. }).extend({
  134. index: 'lib/index' //主入口模块
  135. }).use(['index','table','like', 'laydate'], function(){
  136. var $ = layui.$
  137. ,form = layui.form
  138. ,table = layui.table
  139. ,like = layui.like
  140. ,laydate = layui.laydate;
  141. // 渲染数据表格
  142. table.render({
  143. elem: '#table-lists'
  144. ,url: '{:url("bargain.Bargain/launch")}?bargain_id={$bargain_id}'
  145. ,cols: [[
  146. {field: 'id', title: '序号',width:60, align:"center"}
  147. ,{field: 'bargain_sn', title: '砍价编号',width:160, align:"center"}
  148. ,{field: 'user', title: '发起用户',width:300, templet: '#table-user'}
  149. ,{field: 'goods', title: '砍价商品',width:250, templet: '#table-goods'}
  150. ,{field: 'launchStartTime', title: '发起时间', width:120, align: 'center', templet: '#table-start_time'}
  151. ,{field: 'launchEndTime', title: '结束时间', width:120, align: 'center', templet: '#table-end_time'}
  152. ,{field: 'help_number', title: '已砍价次数', width:120, align: 'center'}
  153. ,{field: 'current_price', title: '当前价格', width:120, align: 'center'}
  154. ,{field: 'status', title: '砍价状态', width:100, align: 'center'}
  155. ,{fixed: 'right', title: '操作', align: 'center', toolbar: '#operation',width:200}
  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(res, curr, count){
  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. var active = {
  179. detail: function (obj) {
  180. layer.open({
  181. type: 2
  182. ,title: '砍价详情'
  183. ,content: '{:url("bargain.Bargain/detail")}?id='+obj.data.id
  184. ,area: ['90%','90%']
  185. });
  186. },
  187. close: function(obj) {
  188. layer.confirm('确定要结束砍价吗?结束砍价会设置砍价失败,请谨慎处理', function(index) {
  189. like.ajax({
  190. url: '{:url("bargain.Bargain/close")}',
  191. data: {id:obj.data.id},
  192. type: "post",
  193. success: function (res) {
  194. if (res.code === 1) {
  195. layui.layer.msg(res.msg, {offset: '15px', icon: 1, time: 1000});
  196. layer.close(index);
  197. obj.del();
  198. }
  199. }
  200. });
  201. layer.close(index);
  202. })
  203. }
  204. };
  205. // 监听表格右侧工具条
  206. table.on('tool(table-lists)', function(obj){
  207. var type = obj.event;
  208. active[type] ? active[type].call(this, obj) : '';
  209. });
  210. // 切换状态
  211. form.on('switch(switch-status)',function (obj) {
  212. var id = obj.elem.attributes['data-id'].nodeValue;
  213. var fields = obj.elem.attributes['data-field'].nodeValue;
  214. var status = this.checked ? 1 : 0;
  215. var data = {"id":id, "field":fields, "status":status};
  216. active['switchStatus'] ? active['switchStatus'].call(this, data) : '';
  217. });
  218. // 绑定点击按钮事件
  219. $('.layui-btn.layuiadmin-btn').on('click', function(){
  220. var type = $(this).data('type');
  221. active[type] ? active[type].call(this) : '';
  222. });
  223. //图片放大
  224. $(document).on('click', '.image-show', function () {
  225. var src = $(this).attr('src');
  226. like.showImg(src);
  227. });
  228. // 开始时间
  229. laydate.render({
  230. type: 'datetime'
  231. ,elem: '#launch_start_time'
  232. ,trigger: 'click'
  233. ,done: function (value, date, endDate) {
  234. var startDate = new Date(value).getTime();
  235. var endTime = new Date($('#launch_end_time').val()).getTime();
  236. if (endTime < startDate) {
  237. layer.msg('结束时间不能小于开始时间');
  238. $('#launch_start_time').val($('#launch_end_time').val());
  239. }
  240. }
  241. });
  242. laydate.render({
  243. type: 'datetime'
  244. ,elem: '#launch_end_time'
  245. ,trigger: 'click'
  246. ,done: function (value, date, endDate) {
  247. var startDate = new Date($('#launch_start_time').val()).getTime();
  248. var endTime = new Date(value).getTime();
  249. if (endTime < startDate) {
  250. layer.msg('结束时间不能小于开始时间');
  251. $('#launch_end_time').val($('#launch_start_time').val());
  252. }
  253. }
  254. });
  255. //监听搜索
  256. form.on('submit(search)', function(data){
  257. var field = data.field;
  258. table.reload('table-lists', {
  259. where: field,
  260. page: { curr: 1 }
  261. });
  262. });
  263. // 监听重置搜素
  264. form.on('submit(clear-search)', function(){
  265. $('#bargain_sn').val('');
  266. $('#goods_name').val('');
  267. $('#status').val('');
  268. $('#keyword_type').val('');
  269. $('#keyword').val('');
  270. $('#launch_start_time').val('');
  271. $('#launch_end_time').val('');
  272. form.render('select');
  273. table.reload('table-lists', { where: [] });
  274. });
  275. $(document).on('click', '.day', function () {
  276. var value = parseInt($(this).attr('day'));
  277. var toDay = Times.getDay(value, false);
  278. var curDay = Times.getDay(0);
  279. $("#launch_start_time").val(toDay + ' 00:00:00');
  280. $("#launch_end_time").val(curDay + ' 00:00:00');
  281. })
  282. });
  283. </script>