| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- <?php
- use common\services\xhMerchantService;
- use common\services\xhGoodsService;
- use common\components\stringUtil;
- ?>
- <div class="page-title">
- <div class="title-env">
- <h1 class="title">商品管理</h1>
- </div>
- <div class="breadcrumb-env">
- <ol class="breadcrumb bc-1">
- <li>
- <a href="/"><i class="fa-home"></i>Home</a>
- </li>
- <li>
- <a href="javascript:void(0)">商城管理</a>
- </li>
- <li class="active">
- <strong>商品管理</strong>
- </li>
- </ol>
- </div>
- </div>
- <div class="panel panel-default">
- <div class="panel-body">
- <div class="dataTables_wrapper form-inline dt-bootstrap no-footer">
- <div class="row">
- <form action="" method="GET">
- <div class="col-xs-6" style="width:90%;">
- <div class="dataTables_length">
- <label>状态: <select name="status" aria-controls="example-1" class="form-control">
- <option <?php if($status == -1) echo 'selected="selected"';?> value="-1">全部</option>
- <option <?php if($status == 0) echo 'selected="selected"';?> value="0">上架</option>
- <option <?php if($status == 1) echo 'selected="selected"';?> value="1">下架</option>
- </select>
- </label>
- <label>标题:<input type="search" class="form-control" name="goodsName" value="<?php if(isset($_GET['goodsName'])) echo $_GET['goodsName']; ?>"
- placeholder="" aria-controls="example-1"></label>
- <input class="btn btn-secondary btn-single" type="submit" name="submit" value="搜索" />
- </div>
- </div>
- </form>
- </div>
- <div class="table-responsive">
- <table class="table table-bordered table-striped table-hover" >
- <thead>
- <tr class="active">
- <th class="no-sorting hidden-xs"><input type="checkbox"></th>
- <th class="hidden-xs">商家</th>
- <th class="hidden-xs">ID</th>
- <th>封面</th>
- <th>标题</th>
- <th class="hidden-xs">价格</th>
- <th class="hidden-xs">销量</th>
- <th class="hidden-xs">状态</th>
- <th class="hidden-xs">创建时间</th>
- <th>操作</th>
- </tr>
- </thead>
- <tbody class="middle-align">
- <?php
- foreach($models as $key => $info){
- $id = $info['id'];
- $val = xhGoodsService::getById($id);
- $merchantId = $info['merchantId'];
- $merchant = xhMerchantService::getById($merchantId);
- ?>
- <tr>
- <td class="hidden-xs"><input type="checkbox"></td>
- <td class="hidden-xs"><?php echo $merchant['merchantName'];?></td>
- <td class="hidden-xs"><?php echo $val['id'];?></td>
- <td>
- <?php
- $coverLargeImg = $val['cover'];
- $coverList = xhGoodsService::getGoodsImgList($coverLargeImg);
- ?>
- <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" />
- </td>
- <td><?= stringUtil::subStringUtf8($val['goodsName'],8,'…')?></td>
- <td class="hidden-xs"><span id="priceShow<?= $val['id'] ?>"><?php echo $val['price'];?></span>
- </td>
- <td class="hidden-xs"><?php echo stringUtil::calcAdd($val['sold'], $val['actualSold']);?></td>
- <td class="hidden-xs"><?php if($val['status'] == 0) echo '上架'; else echo '下架'; ?></td>
- <td class="hidden-xs"><?= date("Y-m-d",strtotime($val['createTime']));?></td>
- <td></td>
- </tr>
- <?php } ?>
- </tbody>
- </table>
- </div>
- <div class="row">
- <div>
- <!--
- <div style="display:inline-block;margin-left:15px;">
- <label><select name="example-1_length"
- aria-controls="example-1" class="form-control">
- <option value="0">批量操作</option>
- <option value="1">批量下架</option>
- <option value="2">批量删除</option>
- </select>
- </label>
- <input class="btn btn-secondary btn-single" type="submit" name="" value="确认" />
- </div>
- -->
- <div class="dataTables_paginate paging_simple_numbers" style="float:right;padding-top:0px;margin-right:15px;">
- <?= $paging ?>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- footer -->
- <?php
- use backend\widgets\FooterWidget;
- ?>
- <?= FooterWidget::widget()?>
- <!-- footer -->
- <!-- modal 确认提醒框 -->
- <div class="modal fade" id="confirmMention">
- <div class="modal-dialog" style="height:300px;">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <h4 class="modal-title">消息提示</h4>
- </div>
-
- <div class="modal-body">
- 确认<span></span>?<input type="hidden" name="requestUrl" value="" />
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-info" name="confirmOk" >确认</button>
- <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
- </div>
- </div>
- </div>
- </div>
- <!-- Modal 查看商品-->
- <div class="modal fade" id="modal-goodsDetail">
- <div class="modal-dialog">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <h4 class="modal-title">商品详细</h4>
- </div>
- <div class="modal-body">
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-info" data-dismiss="modal">确认</button>
- </div>
- </div>
- </div>
- </div>
- <script>
- //确认提醒操作
- $(function(){
- jQuery("a[name=dealGoods]").click(function(){
- var url = $(this).attr('data-url');
- var msg = $(this).attr('data-msg');
- $("#confirmMention .modal-body span").text(msg);
- $("#confirmMention .modal-body input").val(url);
- jQuery('#confirmMention').modal('show', {backdrop: 'fade'}).css({
- 'margin-top': function () {
- var modalHeight = jQuery("#confirmMention").find('.modal-dialog').height();
- return ($(window).height() / 2 - (modalHeight / 2));
- }
- });
- });
- //点击确认操作
- jQuery("button[name=confirmOk]").click(function(){
- var url = $("#confirmMention .modal-body input").val();
- $.ajax({type:"GET",url:url,async:false,dataType:'json',success:function(data){
- if(data.code == 'A0001'){
- $('#confirmMention').modal('hide');
- window.location.reload();
- }
- }});
- });
- });
- //推荐商品
- $(function(){
- jQuery("a[name=recommendGoods]").click(function(){
- var url = $(this).attr('data-url');
- $.ajax({type:"GET",url:url,async:false,dataType:'json',success:function(data){
- if(data.code == 'A0001'){
- xhPopMsg(data.msg,1200);//调用定时浮层 XXX毫秒后消失
- }else{
- xhPopMsg(data.msg,2000);//调用定时浮层 XXX毫秒后消失
- }
- }});
- });
- });
- $("a[name=qrShow]").click(function(){
- var left = $(this).position().left;
- var top = $(this).position().top;
- var id = $(this).attr('data-id');
- var urlqrcode = $(this).attr('data-urlqrcode');
- var object = $(this);
- $("div[name=xhQrTip]").children('div').eq(1).html('<img src="/images/loading.gif" style="margin:47px 0 0 47px;" />');
- $("div[name=xhQrTip]").css('left',left).css('top',top - 110).css('display','block');
- if(urlqrcode.length > 0){
- $("div[name=xhQrTip]").children('div').eq(1).html('<img width="105" src="<?= Yii::$app->params['imgUrl'] ?>'+urlqrcode+'" />');
- $("div[name=xhQrTip]").css('left',left).css('top',top - 110).css("padding","2px").fadeIn();
- }else{
- $.ajax({type:"get",url:'/goods/show-goods-qrcode?id='+id,async:true,dataType:'json',success:function(data){
- if(data.code == 'A0001'){
- var imgUrl = data.data.url;
- object.attr('data-urlqrcode',imgUrl);
- $("div[name=xhQrTip]").children('div').eq(1).html('<img width="105" src="<?= Yii::$app->params['imgUrl'] ?>'+imgUrl+'" />');
- $("div[name=xhQrTip]").css('left',left).css('top',top - 110).css("padding","2px").fadeIn();
- }
- }});
- }
- });
- $("div[name=xhQrTip]").click(function(){
- $(this).css("display","none");
- });
- $("a[name=sendGoodsUrlToMobile]").click(function(){
- var goodsId = $(this).attr('data-id');
- $.ajax({type:"get",url:'/goods/send-goods-url?goodsId='+goodsId,async:true,dataType:'json',success:function(data){
- xhPopMsg(data.msg,2000);
- }});
- });
- <?php if(!empty($riseColumn)){ ?>
- //修改要涨的价格
- $("a[name=modifyRisePrice]").click(function(){
- var pre_rise_price = $(this).attr('pre_rise_price');
- $(this).css("display","none").siblings('span').css('display','none').siblings('input').css('display','inline-block').focus().val(pre_rise_price);
- });
- $("input[name=modifyRisePrice]").blur(function(){
- var that = $(this);
- var newRiseAmount = $(this).val();
- var pre_rise_price = $(this).attr('pre_rise_price');
- var id = $(this).attr('data-id');
- if(isNaN(newRiseAmount)){
- xhPopMsg('填写有误');
- that.focus().val(pre_rise_price);
- return;
- }
- if(newRiseAmount <= 0){
- xhPopMsg('填写有误');
- that.focus().val(pre_rise_price);
- return;
- }
- if(newRiseAmount.indexOf('.') > 0){
- if(newRiseAmount.toString().split(".")[1].length > 2){
- xhPopMsg('价格填写有误');
- that.focus().val(pre_rise_price);
- return;
- }
- }
- if(newRiseAmount == pre_rise_price){
- that.css('display','none').attr("pre_rise_price",newRiseAmount);
- that.siblings('a').css("display","inline-block").attr("pre_rise_price",newRiseAmount);
- that.siblings('span').css("display","inline-block").html(newRiseAmount);
- return;
- }
- $.ajax({type:"GET",url:'/goods/modify-rise-price?id='+id+'&riseAmount='+newRiseAmount,async:false,dataType:'json',success:function(data){
- if(data.code == 'A0001'){
- that.css('display','none').attr("pre_rise_price",newRiseAmount);
- that.siblings('a').css("display","inline-block").attr("pre_rise_price",newRiseAmount);
- that.siblings('span').css("display","inline-block").html(newRiseAmount);
- $("#priceShow"+id).text(data.data.price);
- }
- xhPopMsg(data.msg);
- }});
- });
- <?php } ?>
- </script>
|