index.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <div class="row-content am-cf">
  2. <div class="row">
  3. <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
  4. <div class="widget am-cf">
  5. <div class="widget-head am-cf">
  6. <div class="widget-title am-cf">拼团商品列表</div>
  7. </div>
  8. <div class="widget-body am-fr">
  9. <!-- 工具栏 -->
  10. <div class="page_toolbar am-margin-bottom-xs am-cf">
  11. <form class="toolbar-form" action="">
  12. <input type="hidden" name="s" value="/<?= $request->pathinfo() ?>">
  13. <div class="am-u-sm-12 am-u-md-3">
  14. <div class="am-form-group">
  15. <?php if (checkPrivilege('apps.sharing.goods/add')): ?>
  16. <div class="am-btn-group am-btn-group-xs">
  17. <a class="am-btn am-btn-default am-btn-success"
  18. href="<?= url('apps.sharing.goods/add') ?>">
  19. <span class="am-icon-plus"></span> 新增商品
  20. </a>
  21. </div>
  22. <?php endif; ?>
  23. <?php if (checkPrivilege('apps.sharing.goods/copy_master')): ?>
  24. <div class="am-btn-group am-btn-group-xs">
  25. <a class="j-copyAdd am-btn am-btn-default am-btn-secondary"
  26. href="javascript:void(0);">
  27. <span class="am-icon-plus"></span> 复制主商城商品
  28. </a>
  29. </div>
  30. <?php endif; ?>
  31. </div>
  32. </div>
  33. <div class="am-u-sm-12 am-u-md-9">
  34. <div class="am fr">
  35. <div class="am-form-group am-fl">
  36. <?php $category_id = $request->get('category_id') ?: null; ?>
  37. <select name="category_id"
  38. data-am-selected="{searchBox: 1, btnSize: 'sm', placeholder: '商品分类', maxHeight: 400}">
  39. <option value=""></option>
  40. <?php if (isset($catgory)): foreach ($catgory as $first): ?>
  41. <option value="<?= $first['category_id'] ?>"
  42. <?= $category_id == $first['category_id'] ? 'selected' : '' ?>>
  43. <?= $first['name'] ?></option>
  44. <?php if (isset($first['child'])): foreach ($first['child'] as $two): ?>
  45. <option value="<?= $two['category_id'] ?>"
  46. <?= $category_id == $two['category_id'] ? 'selected' : '' ?>>
  47.   <?= $two['name'] ?></option>
  48. <?php if (isset($two['child'])): foreach ($two['child'] as $three): ?>
  49. <option value="<?= $three['category_id'] ?>"
  50. <?= $category_id == $three['category_id'] ? 'selected' : '' ?>>
  51.    <?= $three['name'] ?></option>
  52. <?php endforeach; endif; ?>
  53. <?php endforeach; endif; ?>
  54. <?php endforeach; endif; ?>
  55. </select>
  56. </div>
  57. <div class="am-form-group am-fl">
  58. <?php $goods_status = $request->get('goods_status') ?: null; ?>
  59. <select name="goods_status"
  60. data-am-selected="{btnSize: 'sm', placeholder: '商品状态'}">
  61. <option value=""></option>
  62. <option value="10"
  63. <?= $goods_status == 10 ? 'selected' : '' ?>>上架
  64. </option>
  65. <option value="20"
  66. <?= $goods_status == 20 ? 'selected' : '' ?>>下架
  67. </option>
  68. </select>
  69. </div>
  70. <div class="am-form-group am-fl">
  71. <div class="am-input-group am-input-group-sm tpl-form-border-form">
  72. <input type="text" class="am-form-field" name="goods_name"
  73. placeholder="请输入商品名称"
  74. value="<?= $request->get('goods_name') ?>">
  75. <div class="am-input-group-btn">
  76. <button class="am-btn am-btn-default am-icon-search"
  77. type="submit"></button>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. </form>
  84. </div>
  85. <div class="am-scrollable-horizontal am-u-sm-12">
  86. <table width="100%" class="am-table am-table-compact am-table-striped
  87. tpl-table-black am-text-nowrap">
  88. <thead>
  89. <tr>
  90. <th>商品ID</th>
  91. <th>商品图片</th>
  92. <th>商品名称</th>
  93. <th>商品分类</th>
  94. <th>成团人数</th>
  95. <th>成团有效时长</th>
  96. <th>实际销量</th>
  97. <th>商品排序</th>
  98. <th>商品状态</th>
  99. <th>添加时间</th>
  100. <th>操作</th>
  101. </tr>
  102. </thead>
  103. <tbody>
  104. <?php if (!$list->isEmpty()): foreach ($list as $item): ?>
  105. <tr>
  106. <td class="am-text-middle"><?= $item['goods_id'] ?></td>
  107. <td class="am-text-middle">
  108. <a href="<?= $item['image'][0]['file_path'] ?>"
  109. title="点击查看大图" target="_blank">
  110. <img src="<?= $item['image'][0]['file_path'] ?>"
  111. width="50" height="50" alt="商品图片">
  112. </a>
  113. </td>
  114. <td class="am-text-middle">
  115. <p class="item-title"><?= $item['goods_name'] ?></p>
  116. </td>
  117. <td class="am-text-middle"><?= $item['category']['name'] ?></td>
  118. <td class="am-text-middle"><?= $item['people'] ?></td>
  119. <td class="am-text-middle"><?= $item['group_time'] ?>小时</td>
  120. <td class="am-text-middle"><?= $item['sales_actual'] ?></td>
  121. <td class="am-text-middle"><?= $item['goods_sort'] ?></td>
  122. <td class="am-text-middle">
  123. <span class="j-state am-badge x-cur-p
  124. am-badge-<?= $item['goods_status']['value'] == 10 ? 'success' : 'warning' ?>"
  125. data-id="<?= $item['goods_id'] ?>"
  126. data-state="<?= $item['goods_status']['value'] ?>">
  127. <?= $item['goods_status']['text'] ?>
  128. </span>
  129. </td>
  130. <td class="am-text-middle"><?= $item['create_time'] ?></td>
  131. <td class="am-text-middle">
  132. <div class="tpl-table-black-operation">
  133. <?php if (checkPrivilege('apps.sharing.goods/edit')): ?>
  134. <a href="<?= url('apps.sharing.goods/edit',
  135. ['goods_id' => $item['goods_id']]) ?>">
  136. <i class="am-icon-pencil"></i> 编辑
  137. </a>
  138. <?php endif; ?>
  139. <?php if (checkPrivilege('apps.sharing.goods/delete')): ?>
  140. <a href="javascript:;" class="item-delete tpl-table-black-operation-del"
  141. data-id="<?= $item['goods_id'] ?>">
  142. <i class="am-icon-trash"></i> 删除
  143. </a>
  144. <?php endif; ?>
  145. <?php if (checkPrivilege('apps.sharing.goods/copy')): ?>
  146. <a class="tpl-table-black-operation-green"
  147. href="<?= url('apps.sharing.goods/copy',
  148. ['goods_id' => $item['goods_id']]) ?>">
  149. 一键复制
  150. </a>
  151. <?php endif; ?>
  152. </div>
  153. </td>
  154. </tr>
  155. <?php endforeach; else: ?>
  156. <tr>
  157. <td colspan="11" class="am-text-center">暂无记录</td>
  158. </tr>
  159. <?php endif; ?>
  160. </tbody>
  161. </table>
  162. </div>
  163. <div class="am-u-lg-12 am-cf">
  164. <div class="am-fr"><?= $list->render() ?> </div>
  165. <div class="am-fr pagination-total am-margin-right">
  166. <div class="am-vertical-align-middle">总记录:<?= $list->total() ?></div>
  167. </div>
  168. </div>
  169. </div>
  170. </div>
  171. </div>
  172. </div>
  173. </div>
  174. <script id="tpl-copyForm" type="text/template">
  175. <div class="am-padding-top-sm">
  176. <form class="j-copyForm am-form tpl-form-line-form">
  177. <div class="am-form-group">
  178. <label class="am-u-sm-3 am-form-label"> 商品ID </label>
  179. <div class="am-u-sm-8 am-u-end">
  180. <input type="number" class="j-goods_id tpl-form-input" name="goods_id" required>
  181. <small>可在 <a href="<?= url('goods/index') ?>" target="_blank">商品管理 - 商品列表</a> 中查看
  182. </small>
  183. </div>
  184. </div>
  185. </form>
  186. </div>
  187. </script>
  188. <script>
  189. $(function () {
  190. /**
  191. * 复制主商城商品
  192. */
  193. $('.j-copyAdd').click(function () {
  194. var $copyForm = $('#tpl-copyForm');
  195. var URL = "<?= url('apps.sharing.goods/copy_master')?>";
  196. layer.open({
  197. type: 1
  198. , title: '复制主商城商品'
  199. , area: '340px'
  200. , offset: 'auto'
  201. , anim: 1
  202. , closeBtn: 1
  203. , shade: 0.3
  204. , btn: ['确定', '取消']
  205. , content: $copyForm.html()
  206. , success: function (layero) {
  207. }
  208. , yes: function (index, layero) {
  209. var goodsId = layero.find('.j-goods_id').val();
  210. if (goodsId > 0) {
  211. window.location = URL + '&goods_id=' + goodsId;
  212. }
  213. layer.close(index);
  214. }
  215. });
  216. });
  217. // 商品状态
  218. $('.j-state').click(function () {
  219. // 验证权限
  220. if (!"<?= checkPrivilege('apps.sharing.goods/state')?>") {
  221. return false;
  222. }
  223. var data = $(this).data();
  224. layer.confirm('确定要' + (parseInt(data.state) === 10 ? '下架' : '上架') + '该商品吗?'
  225. , {title: '友情提示'}
  226. , function (index) {
  227. $.post("<?= url('apps.sharing.goods/state') ?>"
  228. , {
  229. goods_id: data.id,
  230. state: Number(!(parseInt(data.state) === 10))
  231. }
  232. , function (result) {
  233. result.code === 1 ? $.show_success(result.msg, result.url)
  234. : $.show_error(result.msg);
  235. });
  236. layer.close(index);
  237. });
  238. });
  239. // 删除元素
  240. var url = "<?= url('apps.sharing.goods/delete') ?>";
  241. $('.item-delete').delete('goods_id', url);
  242. });
  243. </script>