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

index.html 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. {layout name="layout1" /}
  2. <style>
  3. .layui-form-label {
  4. width: 120px;
  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" lay-accordion="" style="border:1px dashed #c4c4c4">
  12. <div class="layui-colla-item">
  13. <h2 class="layui-colla-title like-layui-colla-title" style="background-color: #fff">操作提示</h2>
  14. <div class="layui-colla-content layui-show">
  15. <p>*设置分销商品的佣金比例;</p>
  16. </div>
  17. </div>
  18. </div>
  19. </div>
  20. <!--搜索区域-->
  21. <div class="layui-card-body layui-form">
  22. <div class="layui-form-item">
  23. <div class="layui-inline">
  24. <div class="layui-form-label">商品信息</div>
  25. <div class="layui-input-inline">
  26. <input type="text" id="keyword" name="keyword" class="layui-input" />
  27. </div>
  28. </div>
  29. <div class="layui-inline">
  30. <div class="layui-form-label">平台商品分类</div>
  31. <div class="layui-input-inline">
  32. <select name="platform_cate_id" id="platform_cate_id" placeholder="请选择" >
  33. <option value="all">全部</option>
  34. {foreach $cate_list as $val }
  35. <option value="{$val.id}">{$val.html}{$val.name}</option>
  36. {/foreach}
  37. </select>
  38. </div>
  39. </div>
  40. <div class="layui-inline">
  41. <div class="layui-form-label">店铺商品分类</div>
  42. <div class="layui-input-inline">
  43. <select name="shop_cate_id" id="shop_cate_id" placeholder="请选择" >
  44. <option value="all">全部</option>
  45. {foreach $shop_cate_list as $val }
  46. <option value="{$val.id}">{$val.name}</option>
  47. {/foreach}
  48. </select>
  49. </div>
  50. </div>
  51. <div class="layui-inline">
  52. <div class="layui-form-label">分销状态</div>
  53. <div class="layui-input-inline">
  54. <select name="is_distribution" id="is_distribution" placeholder="请选择" >
  55. <option value="all">全部</option>
  56. <option value="0">不参与</option>
  57. <option value="1">参与</option>
  58. </select>
  59. </div>
  60. </div>
  61. <div class="layui-inline">
  62. <button class="layui-btn layui-btn-primary layui-bg-blue" lay-submit lay-filter="search">搜索</button>
  63. <button class="layui-btn layui-btn-primary" lay-submit lay-filter="reset">重置</button>
  64. </div>
  65. </div>
  66. </div>
  67. <div class="layui-card-body">
  68. <!--功能按钮-->
  69. <div class="btns">
  70. <buttion class="layui-btn layui-btn-sm layui-bg-blue" id="join">参与分销</buttion>
  71. <buttion class="layui-btn layui-btn-sm layui-bg-red" id="cancel">取消分销</buttion>
  72. </div>
  73. <!--数据表格-->
  74. <table id="lists" lay-filter="lists"></table>
  75. <!--工具条模板-->
  76. <script type="text/html" id="operate">
  77. <a class="layui-btn layui-btn-xs layui-bg-blue" lay-event="set">设置佣金</a>
  78. {{# if(d.distribution_flag){ }}
  79. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="cancel">取消分销</a>
  80. {{# } else { }}
  81. <a class="layui-btn layui-bg-blue layui-btn-xs" lay-event="join">参与分销</a>
  82. {{# } }}
  83. </script>
  84. <!--自定义模板-->
  85. <script type="text/html" id="goods-info">
  86. <img src="{{d.image}}" style="height:60px;width: 60px" class="image-show">
  87. <div class="layui-input-inline" style="text-align: left;">
  88. <p>商品编号:{{d.code}}</p>
  89. <p style="width: 300px;text-overflow:ellipsis;overflow: hidden">商品名称:{{d.name}}</p>
  90. </div>
  91. </script>
  92. <script type="text/html" id="goods-price">
  93. ¥ {{d.min_price}} - ¥ {{d.max_price}}
  94. </script>
  95. <script type="text/html" id="goods-distribution">
  96. {{# if(d.distribution_flag){ }}
  97. 参与
  98. {{# } else { }}
  99. 不参与
  100. {{# } }}
  101. </script>
  102. </div>
  103. </div>
  104. </div>
  105. <script>
  106. layui.config({
  107. version:"{$front_version}",
  108. base: '/static/lib/'
  109. }).use(['table', 'form'], function () {
  110. let $ = layui.$
  111. , form = layui.form
  112. , table = layui.table;
  113. //监听搜索
  114. form.on('submit(search)', function(data){
  115. var field = data.field;
  116. //执行重载
  117. table.reload('lists', {
  118. where: field,
  119. page: {curr: 1}
  120. });
  121. });
  122. //清空查询
  123. form.on('submit(reset)', function(){
  124. $('#keyword').val('');
  125. $('#platform_cate_id').val('all');
  126. $('#shop_cate_id').val('all');
  127. $('#is_distribution').val('all');
  128. form.render('select');
  129. //刷新列表
  130. table.reload('lists', {
  131. where: [], page: {curr: 1}
  132. });
  133. });
  134. // 数据表格渲染
  135. table.render({
  136. elem: '#lists'
  137. ,url: '{:url("distribution.goods/index")}' //数据接口
  138. ,method: 'post'
  139. ,page: true //开启分页
  140. ,cols: [[ //表头
  141. {type:'checkbox'}
  142. ,{templet: '#goods-info', title: '商品信息', width:500}
  143. ,{templet: '#goods-price', title: '价格', width:300}
  144. ,{templet: '#goods-distribution', title: '分销状态', width: 150}
  145. ,{title: '操作', toolbar: '#operate'}
  146. ]] , text: {none: '暂无数据!'}
  147. , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
  148. return {
  149. "code": res.code,
  150. "msg": res.msg,
  151. "count": res.data.count, //解析数据长度
  152. "data": res.data.lists, //解析数据列表
  153. };
  154. },
  155. response: {
  156. statusCode: 1
  157. }
  158. ,done: function(res, curr, count){
  159. // 解决操作栏因为内容过多换行问题
  160. $(".layui-table-main tr").each(function (index, val) {
  161. $($(".layui-table-fixed-l .layui-table-body tbody tr")[index]).height($(val).height());
  162. $($(".layui-table-fixed-r .layui-table-body tbody tr")[index]).height($(val).height());
  163. });
  164. }
  165. });
  166. // 工具条事件
  167. table.on('tool(lists)', function(obj){
  168. var layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值)
  169. if(layEvent === 'cancel'){ // 取消分销
  170. layer.confirm('确定要取消吗?', function(index){
  171. layer.close(index);
  172. like.ajax({
  173. url: "{:url('distribution.goods/isDistribution')}",
  174. data: {ids: [obj.data.id],is_distribution:0},
  175. type: "post",
  176. success:function(res) {
  177. if(res.code === 1) {
  178. layui.layer.msg(res.msg);
  179. layer.close(index);
  180. table.reload("lists");
  181. }
  182. }
  183. });
  184. });
  185. } else if(layEvent === 'join'){ // 参与分销
  186. layer.confirm('确定要参与吗?', function(index){
  187. layer.close(index);
  188. like.ajax({
  189. url: "{:url('distribution.goods/isDistribution')}",
  190. data: {ids: [obj.data.id],is_distribution:1},
  191. type: "post",
  192. success:function(res) {
  193. if(res.code === 1) {
  194. layui.layer.msg(res.msg);
  195. layer.close(index);
  196. table.reload("lists");
  197. }
  198. }
  199. });
  200. });
  201. } else if(layEvent === 'set'){ // 设置佣金
  202. id = obj.data.id;
  203. // 弹窗显示添加页
  204. layer.open({
  205. type: 2
  206. ,title: "设置佣金"
  207. ,content: "{:url('distribution.goods/set')}?id=" + id
  208. ,area: ["90%", "90%"]
  209. ,btn: ["确定", "取消"]
  210. ,yes: function(index, layero){
  211. var iframeWindow = window["layui-layer-iframe" + index];
  212. var submit = layero.find("iframe").contents().find("#setSubmit");
  213. iframeWindow.layui.form.on("submit(setSubmit)", function(data){
  214. like.ajax({
  215. url: "{:url('distribution.goods/set')}",
  216. data: data.field,
  217. type: "post",
  218. success:function(res) {
  219. if(res.code === 1) {
  220. layui.layer.msg(res.msg);
  221. layer.close(index);
  222. table.reload("lists");
  223. }
  224. }
  225. });
  226. return false;
  227. });
  228. submit.trigger("click");
  229. }
  230. });
  231. }
  232. });
  233. // 功能按钮
  234. $('#cancel').click(function() { // 批量取消分销
  235. var checkStatus = table.checkStatus('lists');
  236. if (checkStatus.data.length == 0) {
  237. layer.msg('请先选择商品');
  238. return false;
  239. }
  240. // 提取选中行id
  241. let ids = [];
  242. checkStatus.data.forEach(function($item) {
  243. ids.push($item['id']);
  244. });
  245. like.ajax({
  246. url: "{:url('distribution.goods/isDistribution')}",
  247. data: {ids: ids,is_distribution:0},
  248. type: "post",
  249. success:function(res) {
  250. if(res.code === 1) {
  251. layui.layer.msg(res.msg);
  252. table.reload("lists");
  253. }
  254. }
  255. });
  256. });
  257. $('#join').click(function() { // 批量参与分销
  258. var checkStatus = table.checkStatus('lists');
  259. if (checkStatus.data.length == 0) {
  260. layer.msg('请先选择商品');
  261. return false;
  262. }
  263. // 提取选中行id
  264. let ids = [];
  265. checkStatus.data.forEach(function($item) {
  266. ids.push($item['id']);
  267. });
  268. like.ajax({
  269. url: "{:url('distribution.goods/isDistribution')}",
  270. data: {ids: ids,is_distribution:1},
  271. type: "post",
  272. success:function(res) {
  273. if(res.code === 1) {
  274. layui.layer.msg(res.msg);
  275. table.reload("lists");
  276. }
  277. }
  278. });
  279. });
  280. });
  281. </script>