index.html 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. {extend name='admin@main'}
  2. {block name="button"}
  3. <a data-dbclick class="layui-btn layui-btn-sm" data-open='{:url("add")}'>添加藏品</a>
  4. {/block}
  5. {block name="content"}
  6. <div class="think-box-shadow">
  7. {include file='goods/index_search'}
  8. <table class="layui-table margin-top-10" lay-skin="line">
  9. {notempty name='list'}
  10. <thead>
  11. <tr>
  12. <th class='text-left nowrap'>商品名称</th>
  13. <th class='text-left nowrap'>封面</th>
  14. <th class='text-left nowrap'>价格</th>
  15. <th class='text-left nowrap'>库存</th>
  16. <th class='text-left nowrap'>剩余库存</th>
  17. <th class='text-left nowrap'>铸造数量<br />(成功数/总数)</th>
  18. <th class="text-left nowrap">开始时间</th>
  19. <th class="text-left nowrap">结束时间</th>
  20. <th class="text-left nowrap">添加时间</th>
  21. <th class="text-left nowrap">状态</th>
  22. <th class="text-right"></th>
  23. </tr>
  24. </thead>
  25. {/notempty}
  26. <tbody>
  27. {foreach $list as $key=>$vo}
  28. <tr>
  29. <td class='text-left nowrap'>{$vo.name|default=''}</td>
  30. <td class='text-left nowrap'>
  31. <img data-tips-image="{$vo.cover|default=''}" src="{$vo.cover|default=''}" width="50px">
  32. </td>
  33. <td class='text-left nowrap'>{$vo.price|default=''}</td>
  34. <td class='text-left nowrap'>{$vo.inventory|default=''}</td>
  35. <td class='text-left nowrap'>{$vo.now_inventory|default=''}</td>
  36. <td class='text-left nowrap'>{$vo.zz|default=''}/{$vo.casting_num|default=''}</td>
  37. <td class='text-left nowrap'>{$vo.sell_time|default=''}</td>
  38. <td class='text-left nowrap'>{$vo.end_time|default=''}</td>
  39. <td class='text-left nowrap'>{$vo.create_at}</td>
  40. <td class='text-left nowrap'>
  41. {if $vo.status eq 0}已下架{else/}
  42. {eq name='vo.sy_state' value='1'}合成中{/eq}
  43. {eq name='vo.sy_state' value='2'}即将开售{/eq}
  44. {eq name='vo.sy_state' value='3'}已结束{/eq}
  45. {eq name='vo.sy_state' value='4'}已售罄{/eq}
  46. {/if}
  47. </td>
  48. <td class='text-right'>
  49. <a data-title="合成材料" class="layui-btn layui-btn-sm" data-open='{:url("material")}?id={$vo.id}'>合成材料</a>
  50. <a data-title="铸造明细" class="layui-btn layui-btn-sm" data-open='{:url("detail")}?id={$vo.id}'>铸造明细</a>
  51. <a data-title="铸造" class="layui-btn layui-btn-sm" data-modal='{:url("hash")}?id={$vo.id}'>铸造</a>
  52. {if $vo.sy_state eq 2}
  53. <a data-title="赠送" class="layui-btn layui-btn-sm" data-modal='{:url("send")}?id={$vo.id}'>赠送</a>
  54. <a class='layui-btn layui-btn-normal layui-btn-sm dr' id="dr" style="background-color:#DC2219;margin-right: 10px;width: 65px " onclick="changename('{$vo.id}')">
  55. 批量赠送
  56. </a>
  57. <a data-title="编辑商品" class="layui-btn layui-btn-sm" data-open='{:url("edit")}?id={$vo.id}'>编 辑</a>
  58. {/if}
  59. <a data-title="收藏记录" class="layui-btn layui-btn-sm" data-open='{:url("/store/collect_info/index")}?goods_id={$vo.id}'>收藏记录</a>
  60. {if $vo.status eq 1}
  61. <span class="layui-btn layui-btn-sm layui-btn-warm" onclick="btn_confirm('下架','down','{$vo.id}');">下 架</span>
  62. {else}
  63. <span class="layui-btn layui-btn-sm layui-btn-warm" onclick="btn_confirm('上架','up','{$vo.id}');">上 架</span>
  64. {/if}
  65. <span data-title="删除商品" class="layui-btn layui-btn-sm layui-btn-danger" onclick="btn_confirm('删除','del','{$vo.id}');" >删 除</span>
  66. </td>
  67. </tr>
  68. {/foreach}
  69. </tbody>
  70. </table>
  71. {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
  72. </div>
  73. <script>
  74. function btn_confirm(msg,fun,id) {
  75. layer.confirm('请确定是否'+msg, {btn: ['确定', '取消'], title: "提示"}, function () {
  76. var url = "/store/goods/"+fun;
  77. layer.closeAll();
  78. $.ajax({
  79. type: "post",
  80. url: url,
  81. data: {id:id},
  82. dataType: "json",
  83. async: false,
  84. success: function (data) {
  85. layer.msg(data.info);
  86. setTimeout(function () {
  87. window.location.reload();
  88. },1000)
  89. }
  90. });
  91. });
  92. }
  93. var co_id = ''
  94. function changename(val){
  95. co_id = val
  96. }
  97. layui.use('upload', function(){
  98. var upload = layui.upload;
  99. //执行实例
  100. var uploadInst = upload.render({
  101. elem: '.dr' //绑定元素
  102. ,url: 'admin/api.plugs/upload'
  103. ,accept: 'file', //普通文件,
  104. // ,data:{
  105. // id:function () {
  106. // return project_id
  107. // }
  108. // },
  109. before: function(obj){ //obj参数包含的信息,跟 choose回调完全一致,可参见上文。
  110. console.log(obj)
  111. // layer.load(); //上传loading
  112. }
  113. ,done: function(res){
  114. console.log(co_id)
  115. console.log(res)
  116. if (res.uploaded == true){
  117. var value = {path:res.key,c_id:co_id,url:res.url}
  118. $.ajax({
  119. url:"/store/goods/import",
  120. type:'get',
  121. data:value
  122. ,success:function(result){
  123. console.log(result);
  124. if (result.code==1){
  125. layer.msg('赠送成功',{time:2000,end:function () {
  126. location.reload();
  127. // $.form.href('{:url("admin/main_project/index")}');
  128. }});
  129. }else if (result.code==2){
  130. layer.msg('成功:'+result.data.success+',失败:'+result.data.error,{icon: 5});
  131. }else if (result.code==3){
  132. layer.msg(result.info,{icon: 5});
  133. }
  134. }
  135. });
  136. }else {
  137. layer.msg(res.error.message,{icon: 5});
  138. }
  139. // layer.closeAll('loading'); //关闭loading
  140. }
  141. ,error: function(){
  142. layer.msg('上传失败');
  143. }
  144. });
  145. });
  146. </script>
  147. {/block}