index.html 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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='goods1/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">发行时间</th>
  18. <th class="text-left nowrap">添加时间</th>
  19. <th class="text-left nowrap">状态</th>
  20. <th class="text-left nowrap">操作</th>
  21. </tr>
  22. </thead>
  23. {/notempty}
  24. <tbody>
  25. {foreach $list as $key=>$vo}
  26. <tr>
  27. <td class='text-left nowrap'>{$vo.name|default=''}</td>
  28. <td class='text-left nowrap'>
  29. <img data-tips-image="{$vo.cover|default=''}" src="{$vo.cover|default=''}" width="50px">
  30. </td>
  31. <td class='text-left nowrap'>{$vo.price|default=''}</td>
  32. <td class='text-left nowrap'>{$vo.inventory|default=''}</td>
  33. <td class='text-left nowrap'>{$vo.now_inventory|default=''}</td>
  34. <td class='text-left nowrap'>{$vo.sell_time|default=''}</td>
  35. <td class='text-left nowrap'>{$vo.create_at}</td>
  36. <td class='text-left nowrap'>
  37. {if $vo.status eq 0}已下架{else/}
  38. {eq name='vo.state' value='1'}抢购中{/eq}
  39. {eq name='vo.state' value='2'}即将开售{/eq}
  40. {eq name='vo.state' value='3'}已售罄{/eq}
  41. {/if}
  42. </td>
  43. <td class='text-left nowrap'>
  44. <a data-title="编辑盲盒" class="layui-btn layui-btn-sm" data-open='{:url("edit")}?id={$vo.id}'>编 辑</a>
  45. <a data-title="收藏记录" class="layui-btn layui-btn-sm" data-open='{:url("/store/collect_info/index")}?goods_id={$vo.id}'>收藏记录</a>
  46. {if $vo.status eq 1}
  47. <span class="layui-btn layui-btn-sm layui-btn-warm" onclick="btn_confirm('下架','down','{$vo.id}');">下 架</span>
  48. {else}
  49. <span class="layui-btn layui-btn-sm layui-btn-warm" onclick="btn_confirm('上架','up','{$vo.id}');">上 架</span>
  50. {/if}
  51. <a data-title="赠送" class="layui-btn layui-btn-sm" data-modal='{:url("send")}?id={$vo.id}'>赠送</a>
  52. <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}')">
  53. 批量赠送
  54. </a>
  55. {if $vo.status eq 0}
  56. <span data-title="删除盲盒" class="layui-btn layui-btn-sm layui-btn-danger" onclick="btn_confirm('删除','del','{$vo.id}');" >删 除</span>
  57. {/if}
  58. <a data-title="藏品管理" class="layui-btn layui-btn-sm" data-open='{:url("store/blind_box/index")}?coll_id={$vo.id}'>藏品管理</a>
  59. </td>
  60. </tr>
  61. {/foreach}
  62. </tbody>
  63. </table>
  64. {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
  65. </div>
  66. <script>
  67. function btn_confirm(msg,fun,id) {
  68. layer.confirm('请确定是否'+msg, {btn: ['确定', '取消'], title: "提示"}, function () {
  69. var url = "/store/goods1/"+fun;
  70. layer.closeAll();
  71. $.ajax({
  72. type: "post",
  73. url: url,
  74. data: {id:id},
  75. dataType: "json",
  76. async: false,
  77. success: function (data) {
  78. layer.msg(data.info);
  79. setTimeout(function () {
  80. window.location.reload();
  81. },1000)
  82. }
  83. });
  84. });
  85. }
  86. var co_id = ''
  87. function changename(val){
  88. co_id = val
  89. }
  90. layui.use('upload', function(){
  91. var upload = layui.upload;
  92. //执行实例
  93. var uploadInst = upload.render({
  94. elem: '.dr' //绑定元素
  95. ,url: 'admin/api.plugs/upload'
  96. ,accept: 'file', //普通文件,
  97. before: function(obj){ //obj参数包含的信息,跟 choose回调完全一致,可参见上文。
  98. console.log(obj)
  99. }
  100. ,done: function(res){
  101. console.log(co_id)
  102. console.log(res)
  103. if (res.uploaded == true){
  104. var value = {path:res.key,c_id:co_id,url:res.url}
  105. $.ajax({
  106. url:"/store/goods1/import",
  107. type:'get',
  108. data:value
  109. ,success:function(result){
  110. console.log(result);
  111. if (result.code==1){
  112. layer.msg('赠送成功',{time:2000,end:function () {
  113. location.reload();
  114. }});
  115. }else if (result.code==2){
  116. layer.open({
  117. type:1,
  118. area:['500px', '500px'],
  119. content:'成功:'+result.data.success+',失败:'+result.data.error+'<br />'+
  120. '错误号码:<br />'+result.data.phone_error,
  121. btn:['导出错误号码'],
  122. yes:function (index) {
  123. var url = '/store/goods1/get_excl';
  124. var params = {'phone': result.data.phone_error};
  125. jsSubmit(url, params);
  126. }
  127. });
  128. }else if (result.code==3){
  129. layer.msg(result.info,{icon: 5});
  130. }
  131. }
  132. });
  133. }else {
  134. layer.msg(res.error.message,{icon: 5});
  135. }
  136. }
  137. ,error: function(){
  138. layer.msg('上传失败');
  139. }
  140. });
  141. });
  142. function jsSubmit(url, params, method = "get")
  143. {
  144. var form = $("<form></form>");
  145. form.attr({"method": method, "action": url});
  146. params = JSON.stringify(params.phone)
  147. var input = $("<input type='hidden'>");
  148. input.attr("name", 'phone');
  149. input.val(params);
  150. form.append(input);
  151. $("html").append(form);
  152. form.submit();
  153. }
  154. </script>
  155. {/block}