list.php 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <?php
  2. use common\services\xhMerchantService;
  3. use common\services\xhGoodsService;
  4. use common\components\stringUtil;
  5. ?>
  6. <div class="page-title">
  7. <div class="title-env">
  8. <h1 class="title">商品管理</h1>
  9. </div>
  10. <div class="breadcrumb-env">
  11. <ol class="breadcrumb bc-1">
  12. <li>
  13. <a href="/"><i class="fa-home"></i>Home</a>
  14. </li>
  15. <li>
  16. <a href="javascript:void(0)">商城管理</a>
  17. </li>
  18. <li class="active">
  19. <strong>商品管理</strong>
  20. </li>
  21. </ol>
  22. </div>
  23. </div>
  24. <div class="panel panel-default">
  25. <div class="panel-body">
  26. <div class="dataTables_wrapper form-inline dt-bootstrap no-footer">
  27. <div class="row">
  28. <form action="" method="GET">
  29. <div class="col-xs-6" style="width:90%;">
  30. <div class="dataTables_length">
  31. <label>状态: <select name="status" aria-controls="example-1" class="form-control">
  32. <option <?php if($status == -1) echo 'selected="selected"';?> value="-1">全部</option>
  33. <option <?php if($status == 0) echo 'selected="selected"';?> value="0">上架</option>
  34. <option <?php if($status == 1) echo 'selected="selected"';?> value="1">下架</option>
  35. </select>
  36. </label>
  37. <label>标题:<input type="search" class="form-control" name="goodsName" value="<?php if(isset($_GET['goodsName'])) echo $_GET['goodsName']; ?>"
  38. placeholder="" aria-controls="example-1"></label>
  39. <input class="btn btn-secondary btn-single" type="submit" name="submit" value="搜索" />
  40. </div>
  41. </div>
  42. </form>
  43. </div>
  44. <div class="table-responsive">
  45. <table class="table table-bordered table-striped table-hover" >
  46. <thead>
  47. <tr class="active">
  48. <th class="no-sorting hidden-xs"><input type="checkbox"></th>
  49. <th class="hidden-xs">商家</th>
  50. <th class="hidden-xs">ID</th>
  51. <th>封面</th>
  52. <th>标题</th>
  53. <th class="hidden-xs">价格</th>
  54. <th class="hidden-xs">销量</th>
  55. <th class="hidden-xs">状态</th>
  56. <th class="hidden-xs">创建时间</th>
  57. <th>操作</th>
  58. </tr>
  59. </thead>
  60. <tbody class="middle-align">
  61. <?php
  62. foreach($models as $key => $info){
  63. $id = $info['id'];
  64. $val = xhGoodsService::getById($id);
  65. $merchantId = $info['merchantId'];
  66. $merchant = xhMerchantService::getById($merchantId);
  67. ?>
  68. <tr>
  69. <td class="hidden-xs"><input type="checkbox"></td>
  70. <td class="hidden-xs"><?php echo $merchant['merchantName'];?></td>
  71. <td class="hidden-xs"><?php echo $val['id'];?></td>
  72. <td>
  73. <?php
  74. $coverLargeImg = $val['cover'];
  75. $coverList = xhGoodsService::getGoodsImgList($coverLargeImg);
  76. ?>
  77. <img src="/images/newGrey.gif" class="lazy" data-original="<?php echo Yii::$app->params['imgUrl'].$coverList['small'];?>" onerror="javascript:this.src='/images/invalid.png';" width="20" />
  78. </td>
  79. <td><?= stringUtil::subStringUtf8($val['goodsName'],8,'…')?></td>
  80. <td class="hidden-xs"><span id="priceShow<?= $val['id'] ?>"><?php echo $val['price'];?></span>
  81. </td>
  82. <td class="hidden-xs"><?php echo stringUtil::calcAdd($val['sold'], $val['actualSold']);?></td>
  83. <td class="hidden-xs"><?php if($val['status'] == 0) echo '上架'; else echo '下架'; ?></td>
  84. <td class="hidden-xs"><?= date("Y-m-d",strtotime($val['createTime']));?></td>
  85. <td></td>
  86. </tr>
  87. <?php } ?>
  88. </tbody>
  89. </table>
  90. </div>
  91. <div class="row">
  92. <div>
  93. <!--
  94. <div style="display:inline-block;margin-left:15px;">
  95. <label><select name="example-1_length"
  96. aria-controls="example-1" class="form-control">
  97. <option value="0">批量操作</option>
  98. <option value="1">批量下架</option>
  99. <option value="2">批量删除</option>
  100. </select>
  101. </label>
  102. <input class="btn btn-secondary btn-single" type="submit" name="" value="确认" />
  103. </div>
  104. -->
  105. <div class="dataTables_paginate paging_simple_numbers" style="float:right;padding-top:0px;margin-right:15px;">
  106. <?= $paging ?>
  107. </div>
  108. </div>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. <!-- footer -->
  114. <?php
  115. use backend\widgets\FooterWidget;
  116. ?>
  117. <?= FooterWidget::widget()?>
  118. <!-- footer -->
  119. <!-- modal 确认提醒框 -->
  120. <div class="modal fade" id="confirmMention">
  121. <div class="modal-dialog" style="height:300px;">
  122. <div class="modal-content">
  123. <div class="modal-header">
  124. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  125. <h4 class="modal-title">消息提示</h4>
  126. </div>
  127. <div class="modal-body">
  128. 确认<span></span>?<input type="hidden" name="requestUrl" value="" />
  129. </div>
  130. <div class="modal-footer">
  131. <button type="button" class="btn btn-info" name="confirmOk" >确认</button>
  132. <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
  133. </div>
  134. </div>
  135. </div>
  136. </div>
  137. <!-- Modal 查看商品-->
  138. <div class="modal fade" id="modal-goodsDetail">
  139. <div class="modal-dialog">
  140. <div class="modal-content">
  141. <div class="modal-header">
  142. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  143. <h4 class="modal-title">商品详细</h4>
  144. </div>
  145. <div class="modal-body">
  146. </div>
  147. <div class="modal-footer">
  148. <button type="button" class="btn btn-info" data-dismiss="modal">确认</button>
  149. </div>
  150. </div>
  151. </div>
  152. </div>
  153. <script>
  154. //确认提醒操作
  155. $(function(){
  156. jQuery("a[name=dealGoods]").click(function(){
  157. var url = $(this).attr('data-url');
  158. var msg = $(this).attr('data-msg');
  159. $("#confirmMention .modal-body span").text(msg);
  160. $("#confirmMention .modal-body input").val(url);
  161. jQuery('#confirmMention').modal('show', {backdrop: 'fade'}).css({
  162. 'margin-top': function () {
  163. var modalHeight = jQuery("#confirmMention").find('.modal-dialog').height();
  164. return ($(window).height() / 2 - (modalHeight / 2));
  165. }
  166. });
  167. });
  168. //点击确认操作
  169. jQuery("button[name=confirmOk]").click(function(){
  170. var url = $("#confirmMention .modal-body input").val();
  171. $.ajax({type:"GET",url:url,async:false,dataType:'json',success:function(data){
  172. if(data.code == 'A0001'){
  173. $('#confirmMention').modal('hide');
  174. window.location.reload();
  175. }
  176. }});
  177. });
  178. });
  179. //推荐商品
  180. $(function(){
  181. jQuery("a[name=recommendGoods]").click(function(){
  182. var url = $(this).attr('data-url');
  183. $.ajax({type:"GET",url:url,async:false,dataType:'json',success:function(data){
  184. if(data.code == 'A0001'){
  185. xhPopMsg(data.msg,1200);//调用定时浮层 XXX毫秒后消失
  186. }else{
  187. xhPopMsg(data.msg,2000);//调用定时浮层 XXX毫秒后消失
  188. }
  189. }});
  190. });
  191. });
  192. $("a[name=qrShow]").click(function(){
  193. var left = $(this).position().left;
  194. var top = $(this).position().top;
  195. var id = $(this).attr('data-id');
  196. var urlqrcode = $(this).attr('data-urlqrcode');
  197. var object = $(this);
  198. $("div[name=xhQrTip]").children('div').eq(1).html('<img src="/images/loading.gif" style="margin:47px 0 0 47px;" />');
  199. $("div[name=xhQrTip]").css('left',left).css('top',top - 110).css('display','block');
  200. if(urlqrcode.length > 0){
  201. $("div[name=xhQrTip]").children('div').eq(1).html('<img width="105" src="<?= Yii::$app->params['imgUrl'] ?>'+urlqrcode+'" />');
  202. $("div[name=xhQrTip]").css('left',left).css('top',top - 110).css("padding","2px").fadeIn();
  203. }else{
  204. $.ajax({type:"get",url:'/goods/show-goods-qrcode?id='+id,async:true,dataType:'json',success:function(data){
  205. if(data.code == 'A0001'){
  206. var imgUrl = data.data.url;
  207. object.attr('data-urlqrcode',imgUrl);
  208. $("div[name=xhQrTip]").children('div').eq(1).html('<img width="105" src="<?= Yii::$app->params['imgUrl'] ?>'+imgUrl+'" />');
  209. $("div[name=xhQrTip]").css('left',left).css('top',top - 110).css("padding","2px").fadeIn();
  210. }
  211. }});
  212. }
  213. });
  214. $("div[name=xhQrTip]").click(function(){
  215. $(this).css("display","none");
  216. });
  217. $("a[name=sendGoodsUrlToMobile]").click(function(){
  218. var goodsId = $(this).attr('data-id');
  219. $.ajax({type:"get",url:'/goods/send-goods-url?goodsId='+goodsId,async:true,dataType:'json',success:function(data){
  220. xhPopMsg(data.msg,2000);
  221. }});
  222. });
  223. <?php if(!empty($riseColumn)){ ?>
  224. //修改要涨的价格
  225. $("a[name=modifyRisePrice]").click(function(){
  226. var pre_rise_price = $(this).attr('pre_rise_price');
  227. $(this).css("display","none").siblings('span').css('display','none').siblings('input').css('display','inline-block').focus().val(pre_rise_price);
  228. });
  229. $("input[name=modifyRisePrice]").blur(function(){
  230. var that = $(this);
  231. var newRiseAmount = $(this).val();
  232. var pre_rise_price = $(this).attr('pre_rise_price');
  233. var id = $(this).attr('data-id');
  234. if(isNaN(newRiseAmount)){
  235. xhPopMsg('填写有误');
  236. that.focus().val(pre_rise_price);
  237. return;
  238. }
  239. if(newRiseAmount <= 0){
  240. xhPopMsg('填写有误');
  241. that.focus().val(pre_rise_price);
  242. return;
  243. }
  244. if(newRiseAmount.indexOf('.') > 0){
  245. if(newRiseAmount.toString().split(".")[1].length > 2){
  246. xhPopMsg('价格填写有误');
  247. that.focus().val(pre_rise_price);
  248. return;
  249. }
  250. }
  251. if(newRiseAmount == pre_rise_price){
  252. that.css('display','none').attr("pre_rise_price",newRiseAmount);
  253. that.siblings('a').css("display","inline-block").attr("pre_rise_price",newRiseAmount);
  254. that.siblings('span').css("display","inline-block").html(newRiseAmount);
  255. return;
  256. }
  257. $.ajax({type:"GET",url:'/goods/modify-rise-price?id='+id+'&riseAmount='+newRiseAmount,async:false,dataType:'json',success:function(data){
  258. if(data.code == 'A0001'){
  259. that.css('display','none').attr("pre_rise_price",newRiseAmount);
  260. that.siblings('a').css("display","inline-block").attr("pre_rise_price",newRiseAmount);
  261. that.siblings('span').css("display","inline-block").html(newRiseAmount);
  262. $("#priceShow"+id).text(data.data.price);
  263. }
  264. xhPopMsg(data.msg);
  265. }});
  266. });
  267. <?php } ?>
  268. </script>