3cc133a0a2a46bf5f1ff28a633161ab4.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <?php /*a:5:{s:70:"D:\phpstudy_pro\WWW\CRMEB\app\admin\view\store\store_product\index.php";i:1603079624;s:61:"D:\phpstudy_pro\WWW\CRMEB\app\admin\view\public\container.php";i:1595820902;s:62:"D:\phpstudy_pro\WWW\CRMEB\app\admin\view\public\frame_head.php";i:1595820902;s:57:"D:\phpstudy_pro\WWW\CRMEB\app\admin\view\public\style.php";i:1595820902;s:64:"D:\phpstudy_pro\WWW\CRMEB\app\admin\view\public\frame_footer.php";i:1595820902;}*/ ?>
  2. <!DOCTYPE html>
  3. <html lang="zh-CN">
  4. <head>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <?php if(empty($is_layui) || (($is_layui instanceof \think\Collection || $is_layui instanceof \think\Paginator ) && $is_layui->isEmpty())): ?>
  8. <link href="/system/frame/css/bootstrap.min.css?v=3.4.0" rel="stylesheet">
  9. <?php endif; ?>
  10. <link href="/static/plug/layui/css/layui.css" rel="stylesheet">
  11. <link href="/system/css/layui-admin.css" rel="stylesheet">
  12. <link href="/system/frame/css/font-awesome.min.css?v=4.3.0" rel="stylesheet">
  13. <link href="/system/frame/css/animate.min.css" rel="stylesheet">
  14. <link href="/system/frame/css/style.min.css?v=3.0.0" rel="stylesheet">
  15. <script src="/system/frame/js/jquery.min.js"></script>
  16. <script src="/system/frame/js/bootstrap.min.js"></script>
  17. <script src="/static/plug/layui/layui.all.js"></script>
  18. <script>
  19. $eb = parent._mpApi;
  20. window.controlle="<?php echo strtolower(trim(preg_replace("/[A-Z]/", "_\\0", app('request')->controller()), "_"));?>";
  21. window.module="<?php echo app('http')->getName();?>";
  22. </script>
  23. <title></title>
  24. <!--<script type="text/javascript" src="/static/plug/basket.js"></script>-->
  25. <script type="text/javascript" src="/static/plug/requirejs/require.js"></script>
  26. <?php /* <script type="text/javascript" src="/static/plug/requirejs/require-basket-load.js"></script> */ ?>
  27. <script>
  28. var hostname = location.hostname;
  29. if(location.port) hostname += ':' + location.port;
  30. requirejs.config({
  31. map: {
  32. '*': {
  33. 'css': '/static/plug/requirejs/require-css.js'
  34. }
  35. },
  36. shim:{
  37. 'iview':{
  38. deps:['css!iviewcss']
  39. },
  40. 'layer':{
  41. deps:['css!layercss']
  42. }
  43. },
  44. baseUrl:'//'+hostname+'/',
  45. paths: {
  46. 'static':'static',
  47. 'system':'system',
  48. 'vue':'static/plug/vue/dist/vue.min',
  49. 'axios':'static/plug/axios.min',
  50. 'iview':'static/plug/iview/dist/iview.min',
  51. 'iviewcss':'static/plug/iview/dist/styles/iview',
  52. 'lodash':'static/plug/lodash',
  53. 'layer':'static/plug/layer/layer',
  54. 'layercss':'static/plug/layer/theme/default/layer',
  55. 'jquery':'static/plug/jquery/jquery.min',
  56. 'moment':'static/plug/moment',
  57. 'sweetalert':'static/plug/sweetalert2/sweetalert2.all.min',
  58. 'formCreate':'/static/plug/form-create/form-create.min',
  59. },
  60. basket: {
  61. excludes:['system/js/index','system/util/mpVueComponent','system/util/mpVuePackage']
  62. // excludes:['system/util/mpFormBuilder','system/js/index','system/util/mpVueComponent','system/util/mpVuePackage']
  63. }
  64. });
  65. </script>
  66. <script type="text/javascript" src="/system/util/mpFrame.js"></script>
  67. </head>
  68. <body class="gray-bg">
  69. <div class="wrapper wrapper-content">
  70. <div class="layui-fluid" style="background: #fff;margin-top: -10px;">
  71. <div class="layui-tab layui-tab-brief" lay-filter="tab">
  72. <ul class="layui-tab-title">
  73. <li lay-id="list" <?php if($type == '1'): ?>class="layui-this" <?php endif; ?> >
  74. <a href="<?php if($type == '1'): ?>javascript:;<?php else: ?><?php echo Url('index',['type'=>1]); ?><?php endif; ?>">出售中商品(<?php echo htmlentities($onsale); ?>)</a>
  75. </li>
  76. <li lay-id="list" <?php if($type == '2'): ?>class="layui-this" <?php endif; ?>>
  77. <a href="<?php if($type == '2'): ?>javascript:;<?php else: ?><?php echo Url('index',['type'=>2]); ?><?php endif; ?>">仓库中商品(<?php echo htmlentities($forsale); ?>)</a>
  78. </li>
  79. <li lay-id="list" <?php if($type == '4'): ?>class="layui-this" <?php endif; ?>>
  80. <a href="<?php if($type == '4'): ?>javascript:;<?php else: ?><?php echo Url('index',['type'=>4]); ?><?php endif; ?>">已经售馨商品(<?php echo htmlentities($outofstock); ?>)</a>
  81. </li>
  82. <li lay-id="list" <?php if($type == '5'): ?>class="layui-this" <?php endif; ?>>
  83. <a href="<?php if($type == '5'): ?>javascript:;<?php else: ?><?php echo Url('index',['type'=>5]); ?><?php endif; ?>">警戒库存(<?php echo htmlentities($policeforce); ?>)</a>
  84. </li>
  85. <li lay-id="list" <?php if($type == '6'): ?>class="layui-this" <?php endif; ?>>
  86. <a href="<?php if($type == '6'): ?>javascript:;<?php else: ?><?php echo Url('index',['type'=>6]); ?><?php endif; ?>">商品回收站(<?php echo htmlentities($recycle); ?>)</a>
  87. </li>
  88. </ul>
  89. </div>
  90. <div class="layui-row layui-col-space15" id="app">
  91. <div class="layui-col-md12">
  92. <div class="layui-card">
  93. <div class="layui-card-body">
  94. <form class="layui-form layui-form-pane" action="">
  95. <div class="layui-form-item">
  96. <div class="layui-inline">
  97. <label class="layui-form-label">所有分类</label>
  98. <div class="layui-input-block">
  99. <select name="cate_id">
  100. <option value=" ">全部</option>
  101. <?php if(is_array($cate) || $cate instanceof \think\Collection || $cate instanceof \think\Paginator): $i = 0; $__LIST__ = $cate;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
  102. <option value="<?php echo htmlentities($vo['id']); ?>"><?php echo htmlentities($vo['html']); ?><?php echo htmlentities($vo['cate_name']); ?></option>
  103. <?php endforeach; endif; else: echo "" ;endif; ?>
  104. </select>
  105. </div>
  106. </div>
  107. <div class="layui-inline">
  108. <label class="layui-form-label">商品名称</label>
  109. <div class="layui-input-block">
  110. <input type="text" name="store_name" class="layui-input" placeholder="请输入商品名称,关键字,编号">
  111. <input type="hidden" name="type" value="<?php echo htmlentities($type); ?>">
  112. </div>
  113. </div>
  114. <div class="layui-inline">
  115. <div class="layui-input-inline">
  116. <button class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search" lay-filter="search">
  117. <i class="layui-icon layui-icon-search"></i>搜索</button>
  118. <button class="layui-btn layui-btn-primary layui-btn-sm export" lay-submit="export" lay-filter="export">
  119. <i class="fa fa-floppy-o" style="margin-right: 3px;"></i>导出</button>
  120. </div>
  121. </div>
  122. </div>
  123. </form>
  124. </div>
  125. </div>
  126. </div>
  127. <!--商品列表-->
  128. <div class="layui-col-md12">
  129. <div class="layui-card">
  130. <div class="layui-card-body">
  131. <div class="alert alert-info" role="alert">
  132. 列表[虚拟销量],[库存],[排序]可进行快速修改,双击或者单击进入编辑模式,失去焦点可进行自动保存
  133. <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  134. </div>
  135. <div class="layui-btn-container">
  136. <?php switch($type): case "1": ?>
  137. <a class="layui-btn layui-btn-sm" href="<?php echo Url('create'); ?>">添加商品</a>
  138. <button class="layui-btn layui-btn-sm" onclick="$eb.createModalFrame(this.innerText,'<?php echo Url('store.copy_taobao/index'); ?>',{h:700,w:1100});">复制淘宝、天猫、1688、京东</button>
  139. <button class="layui-btn layui-btn-sm" onclick="$eb.createModalFrame(this.innerText,'<?php echo Url('store.copy_taobao/product'); ?>',{h:700,w:1100});">付费采集商品(淘宝、天猫、1688、京东、苏宁)</button>
  140. <?php break; case "2": ?>
  141. <button class="layui-btn layui-btn-sm" data-type="show">批量上架</button>
  142. <?php break; ?>
  143. <?php endswitch; ?>
  144. </div>
  145. <table class="layui-hide" id="List" lay-filter="List"></table>
  146. <!--图片-->
  147. <script type="text/html" id="image">
  148. <img style="cursor: pointer" lay-event="open_image" src="{{d.image}}">
  149. </script>
  150. <!--上架|下架-->
  151. <script type="text/html" id="checkboxstatus">
  152. <input type='checkbox' name='id' lay-skin='switch' value="{{d.id}}" lay-filter='is_show' lay-text='上架|下架' {{ d.is_show == 1 ? 'checked' : '' }}>
  153. </script>
  154. <!--收藏-->
  155. <script type="text/html" id="like">
  156. <span><i class="layui-icon layui-icon-praise"></i> {{d.like}}</span>
  157. </script>
  158. <!--点赞-->
  159. <script type="text/html" id="collect">
  160. <span><i class="layui-icon layui-icon-star"></i> {{d.collect}}</span>
  161. </script>
  162. <!--商品名称-->
  163. <script type="text/html" id="store_name">
  164. <h4>{{d.store_name}}</h4>
  165. <p>价格:<font color="red">{{d.price}}</font> </p>
  166. {{# if(d.cate_name!=''){ }}
  167. <p>分类:{{d.cate_name}}</p>
  168. {{# } }}
  169. </script>
  170. <!--操作-->
  171. <script type="text/html" id="act">
  172. <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" lay-event='edit'>
  173. 编辑
  174. </button>
  175. <button type="button" class="layui-btn layui-btn-xs" onclick="dropdown(this)">操作 <span class="caret"></span></button>
  176. <ul class="layui-nav-child layui-anim layui-anim-upbit">
  177. {{# if(d.is_del){ }}
  178. <li>
  179. <a href="javascript:void(0);" lay-event='delstor'>
  180. <i class="fa fa-trash"></i> 恢复商品
  181. </a>
  182. </li>
  183. {{# }else{ }}
  184. <li>
  185. <a href="javascript:void(0);" lay-event='delstor'>
  186. <i class="fa fa-trash"></i> 移到回收站
  187. </a>
  188. </li>
  189. {{# } }}
  190. <li>
  191. <a href="<?php echo Url('store.storeProductReply/index'); ?>?product_id={{d.id}}">
  192. <i class="fa fa-warning"></i> 评论查看
  193. </a>
  194. </li>
  195. </ul>
  196. </script>
  197. </div>
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. <script src="/system/js/layuiList.js"></script>
  203. <script>
  204. var type=<?=$type?>;
  205. //实例化form
  206. layList.form.render();
  207. //加载列表
  208. layList.tableList('List',"<?php echo Url('product_ist',['type'=>$type]); ?>",function (){
  209. var join=new Array();
  210. switch (parseInt(type)){
  211. case 1:case 3:case 4:case 5:
  212. join=[
  213. {field: 'id', title: 'ID', sort: true,event:'id',width:'6%'},
  214. {field: 'image', title: '商品图片',templet:'#image',width:'10%'},
  215. {field: 'store_name', title: '商品名称',templet:'#store_name'},
  216. {field: 'ficti', title: '虚拟销量',edit:'ficti',width:'8%'},
  217. {field: 'stock', title: '库存',width:'8%'},
  218. {field: 'sort', title: '排序',edit:'sort',width:'6%'},
  219. {field: 'sales', title: '销量',sort: true,event:'sales',width:'8%'},
  220. {field: 'status', title: '状态',templet:"#checkboxstatus",width:'8%'},
  221. {field: 'right', title: '操作',align:'center',toolbar:'#act',width:'14%'},
  222. ];
  223. break;
  224. case 2:
  225. join=[
  226. {type:'checkbox'},
  227. {field: 'id', title: 'ID', sort: true,event:'id',width:'6%'},
  228. {field: 'image', title: '商品图片',templet:'#image',width:'10%'},
  229. {field: 'store_name', title: '商品名称',templet:'#store_name'},
  230. {field: 'price', title: '价格',edit:'price',width:'8%'},
  231. {field: 'ficti', title: '虚拟销量',edit:'ficti',width:'8%'},
  232. {field: 'stock', title: '库存',width:'6%'},
  233. {field: 'sort', title: '排序',edit:'sort',width:'6%'},
  234. {field: 'sales', title: '销量',sort: true,event:'sales',width:'6%'},
  235. {field: 'status', title: '状态',templet:"#checkboxstatus",width:'8%'},
  236. {field: 'right', title: '操作',align:'center',toolbar:'#act',width:'14%'},
  237. ];
  238. break;
  239. case 6:
  240. join=[
  241. {field: 'id', title: '商品ID', sort: true,event:'id'},
  242. {field: 'image', title: '商品图片',templet:'#image'},
  243. {field: 'store_name', title: '商品名称',templet:'#store_name'},
  244. {field: 'price', title: '商品价格',edit:'price'},
  245. {field: 'ficti', title: '虚拟销量',edit:'ficti'},
  246. {field: 'stock', title: '库存'},
  247. {field: 'sort', title: '排序',edit:'sort'},
  248. {field: 'sales', title: '销量',sort: true,event:'sales'},
  249. // {field: 'status', title: '状态',templet:"#checkboxstatus"},
  250. {field: 'right', title: '操作',align:'center',toolbar:'#act',width:'14%'},
  251. ];
  252. break;
  253. }
  254. return join;
  255. })
  256. //excel下载
  257. layList.search('export',function(where){
  258. where.excel = 1;
  259. location.href=layList.U({c:'store.store_product',a:'product_ist',q:where});
  260. })
  261. //下拉框
  262. $(document).click(function (e) {
  263. $('.layui-nav-child').hide();
  264. })
  265. function dropdown(that){
  266. var oEvent = arguments.callee.caller.arguments[0] || event;
  267. oEvent.stopPropagation();
  268. var offset = $(that).offset();
  269. var top=offset.top-$(window).scrollTop();
  270. var index = $(that).parents('tr').data('index');
  271. $('.layui-nav-child').each(function (key) {
  272. if (key != index) {
  273. $(this).hide();
  274. }
  275. })
  276. if($(document).height() < top+$(that).next('ul').height()){
  277. $(that).next('ul').css({
  278. 'padding': 10,
  279. 'top': - ($(that).parent('td').height() / 2 + $(that).height() + $(that).next('ul').height()/2),
  280. 'min-width': 'inherit',
  281. 'position': 'absolute'
  282. }).toggle();
  283. }else{
  284. $(that).next('ul').css({
  285. 'padding': 10,
  286. 'top':$(that).parent('td').height() / 2 + $(that).height(),
  287. 'min-width': 'inherit',
  288. 'position': 'absolute'
  289. }).toggle();
  290. }
  291. }
  292. //快速编辑
  293. layList.edit(function (obj) {
  294. var id=obj.data.id,value=obj.value;
  295. switch (obj.field) {
  296. case 'price':
  297. action.set_product('price',id,value);
  298. break;
  299. case 'stock':
  300. action.set_product('stock',id,value);
  301. break;
  302. case 'sort':
  303. action.set_product('sort',id,value);
  304. break;
  305. case 'ficti':
  306. action.set_product('ficti',id,value);
  307. break;
  308. }
  309. });
  310. //上下加商品
  311. layList.switch('is_show',function (odj,value) {
  312. if(odj.elem.checked==true){
  313. layList.baseGet(layList.Url({c:'store.store_product',a:'set_show',p:{is_show:1,id:value}}),function (res) {
  314. layList.msg(res.msg, function () {
  315. layList.reload();
  316. });
  317. });
  318. }else{
  319. layList.baseGet(layList.Url({c:'store.store_product',a:'set_show',p:{is_show:0,id:value}}),function (res) {
  320. layList.msg(res.msg, function () {
  321. layList.reload();
  322. });
  323. });
  324. }
  325. });
  326. //点击事件绑定
  327. layList.tool(function (event,data,obj) {
  328. switch (event) {
  329. case 'delstor':
  330. var url=layList.U({c:'store.store_product',a:'delete',q:{id:data.id}});
  331. if(data.is_del) var code = {title:"操作提示",text:"确定恢复商品操作吗?",type:'info',confirm:'是的,恢复该商品'};
  332. else var code = {title:"操作提示",text:"确定将该商品移入回收站吗?",type:'info',confirm:'是的,移入回收站'};
  333. $eb.$swal('delete',function(){
  334. $eb.axios.get(url).then(function(res){
  335. if(res.status == 200 && res.data.code == 200) {
  336. $eb.$swal('success',res.data.msg);
  337. obj.del();
  338. location.reload();
  339. }else
  340. return Promise.reject(res.data.msg || '删除失败')
  341. }).catch(function(err){
  342. $eb.$swal('error',err);
  343. });
  344. },code)
  345. break;
  346. case 'open_image':
  347. $eb.openImage(data.image);
  348. break;
  349. case 'edit':
  350. location.href = layList.U({a:'create',q:{id:data.id}});
  351. break;
  352. case 'attr':
  353. $eb.createModalFrame(data.store_name+'-属性',layList.U({a:'attr',q:{id:data.id}}),{h:600,w:800})
  354. break;
  355. }
  356. })
  357. //排序
  358. layList.sort(function (obj) {
  359. var type = obj.type;
  360. switch (obj.field){
  361. case 'id':
  362. layList.reload({order: layList.order(type,'id')},true,null,obj);
  363. break;
  364. case 'sales':
  365. layList.reload({order: layList.order(type,'sales')},true,null,obj);
  366. break;
  367. }
  368. });
  369. //查询
  370. layList.search('search',function(where){
  371. layList.reload(where,true);
  372. });
  373. //自定义方法
  374. var action={
  375. set_product:function(field,id,value){
  376. layList.baseGet(layList.Url({c:'store.store_product',a:'set_product',q:{field:field,id:id,value:value}}),function (res) {
  377. layList.msg(res.msg);
  378. });
  379. },
  380. show:function(){
  381. var ids=layList.getCheckData().getIds('id');
  382. if(ids.length){
  383. layList.basePost(layList.Url({c:'store.store_product',a:'product_show'}),{ids:ids},function (res) {
  384. layList.msg(res.msg);
  385. layList.reload();
  386. });
  387. }else{
  388. layList.msg('请选择要上架的商品');
  389. }
  390. }
  391. };
  392. //多选事件绑定
  393. $('.layui-btn-container').find('button').each(function () {
  394. var type=$(this).data('type');
  395. $(this).on('click',function(){
  396. action[type] && action[type]();
  397. })
  398. });
  399. </script>
  400. </div>
  401. </body>
  402. </html>