| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432 |
- <?php
- use common\services\xhGoodsService;
- use common\components\stringUtil;
- ?>
- <?php
- use backend\widgets\TabWidget;
- echo TabWidget::widget(['list' => $this->context->menuList, 'currentMenu' => $this->context->id]);
- ?>
- <div class="panel panel-default">
- <?php
- use backend\widgets\SubTabWidget;
- echo SubTabWidget::widget(['list' => $this->context->subMenuList, 'currentMenu' => $this->context->action->id]);
- ?>
- <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">
- <a href="/goods/add" class="btn btn-secondary btn-single" style="margin-right:15px;">添加商品</a>
- </div>
- </div>
- </form>
- </div>
- <div name="xhQrTip" style="position:absolute;border-color: #8dc63f;width:110px;height:122px;z-index:9999;display:none;background:white;border:1px solid #ccc;">
- <div style="background:red;">
- <a href="javascript:void(0)" style="color:#68b828;float:right;z-index:9999;" <i="" class="fa-times"></a>
- </div>
- <div></div>
- </div>
- <div class="table-responsive">
- <table class="table table-bordered table-striped table-hover table-condensed">
- <thead>
- <tr class="active">
- <th class="no-sorting hidden-xs"><input type="checkbox"></th>
- <th class="hidden-xs">ID</th>
- <th>封面</th>
- <th>标题</th>
- <th class="hidden-xs">价格</th>
- <?php if (!empty($riseColumn)) { ?>
- <th class="hidden-xs">
- 涨价 <?php echo date("n.j", $goodsSet['startRiseTime']) . '-' . date("n.j", $goodsSet['endRiseTime']); ?>
- </th>
- <?php } ?>
- <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);
- ?>
- <tr>
- <td class="hidden-xs"><input type="checkbox"></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, '…') ?>
- <a data-toggle="tooltip" data-placement="bottom" title="" data-original-title="点击显示二维码链接" data-urlqrcode="<?= $val['urlQrCode'] ?>" data-id="<?= $val['id'] ?>" name="qrShow" href="javascript:void(0)" style="color:#68b828;margin-left:4px;text-decoration:none;"><i class="fa-qrcode"></i></a>
- <a data-toggle="tooltip" data-placement="bottom" title="" data-original-title="显示商品短链接" data-urlqrcode="<?= $val['urlQrCode'] ?>" data-id="<?= $val['id'] ?>" name="showUrl" href="javascript:void(0)" style="color:#68b828;margin-left:4px;text-decoration:none;"><i class="fa-link"></i></a>
- </td>
- <td class="hidden-xs">
- <span id="priceShow<?= $val['id'] ?>"><?php echo $val['price']; ?></span>
- <?php if (!empty($rising)) { ?>
- <a href="javascript:void(0)" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="涨价中…" style="color:#68b828;cursor:pointer;text-decoration:none;"
- <i="" class="fa-long-arrow-up"></a>
- <?php } ?>
- </td>
-
- <?php if (!empty($riseColumn)) { ?>
- <td class="hidden-xs">
- <?php
- if ($goodsSet['riseType'] == $riseType['amount']) {
- echo '¥';
- }
- ?>
- <span><?= $val['riseAmount']; ?></span><input type="text" pre_rise_price="<?= $val['riseAmount']; ?>" name="modifyRisePrice" data-id="<?= $val['id'] ?>" style="width:30px;display:none;border-radius:3px;border:1px solid #ccc;" value=""><?php
- if ($goodsSet['riseType'] == $riseType['percent']) {
- echo '%';
- }
- ?>
- <a href="javascript:void(0)" name="modifyRisePrice" pre_rise_price="<?= $val['riseAmount']; ?>" style="color:#68b828;cursor:pointer;text-decoration:none;"
- <i="" class="fa-pencil"></a>
- </td>
- <?php } ?>
- <td class="hidden-xs"><?php echo stringUtil::calcAdd($val['sold'], $val['actualSold']); ?></td>
- <td class="hidden-xs"><?= $val['viewNum'] ?></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>
- <!-- <a href="javascript:void(0)" name="getGoodsDetail" data-url='/goods/detail-ajax?id=<?= $val['id']; ?>' class="btn btn-secondary btn-sm btn-icon icon-left">查看 </a>-->
- <a href="/goods/edit?id=<?= $val['id']; ?>" class="btn btn-secondary btn-sm btn-icon icon-left">修改 </a>
- <?php if ($val['status'] == 0) { ?>
- <a href="javascript:void(0)" name="dealGoods" data-url="/goods/update-status?id=<?= $val['id']; ?>&status=1" data-msg="下架" class="btn btn-secondary btn-sm btn-icon icon-left">下架 </a>
- <?php } else { ?>
- <a href="javascript:void(0)" name="dealGoods" data-url="/goods/update-status?id=<?= $val['id']; ?>&status=0" data-msg="上架" class="btn btn-secondary btn-sm btn-icon icon-left">上架 </a>
- <?php } ?>
- <!-- <a href="javascript:void(0)" name="dealGoods" data-url="/goods/del-ajax?id=--><?//= $val['id']; ?><!--&status=0" data-msg="删除" class="btn btn-danger btn-sm btn-icon icon-left">删除 </a>-->
- </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="showUrlModal">
- <div class="modal-dialog" style="height:450px;">
- <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 class="row">
- <div class="col-md-6">
- <div class="form-group">
- <label for="field-1" class="control-label">商品链接:</label>
- <input type="tel" class="form-control" placeholder="" name="goodsShortUrl" value="" style="display:inline-block;">
- <input type="hidden" name="showUrlGoodsId"/>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-md-6">
- <div class="form-group">
- <label for="field-1" class="control-label"></label>
- <a href="javascript:void(0)" name="sendUrlToMobile" class="btn btn-secondary btn-sm btn-icon icon-left" style="display:inline-block;">链接发送到手机</a>
- </div>
- </div>
- </div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-info" name="rechargeConfirmButton">确认</button>
- <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
- </div>
- </div>
- </div>
- <script>
- $(function () {
- //显示链接操作
- jQuery("a[name=showUrl]").click(function () {
- var id = $(this).attr('data-id');
- $("input[name=goodsShortUrl]").val('');
- $("input[name=showUrlGoodsId]").val(id);
- $.ajax({
- type: "GET",
- url: '/goods/generate-short-url?goodsId=' + id,
- async: false,
- dataType: 'json',
- success: function (data) {
- if (data.code == 'A0001') {
- $("input[name=goodsShortUrl]").val(data.data.shortUrl);
- jQuery('#showUrlModal').modal('show');
- } else {
- xhPopMsg(data.msg, 1300);
- }
- }
- });
- });
- //确认显示链接
- jQuery("button[name=showUrlConfirmButton]").click(function () {
- var url = $("#rechargeModal .modal-body input[name=requestUrl]").val();
- $.ajax({
- type: "GET",
- url: url + '&rechargeAmount=' + rechargeAmount + '&rechargePassword=' + rechargePassword,
- async: false,
- dataType: 'json',
- success: function (data) {
- if (data.code == 'A0001') {
- setTimeout(function () {
- window.location.reload();
- }, 2000);
- }
- xhPopMsg(data.msg, 1300);
- }
- });
- });
- });
- //发送商品短链接
- $("a[name=sendUrlToMobile]").click(function () {
- var goodsId = $("input[name=showUrlGoodsId]").val();
- $.ajax({
- type: "get",
- url: '/goods/send-url?goodsId=' + goodsId,
- async: true,
- dataType: 'json',
- success: function (data) {
- xhPopMsg(data.msg, 2000);
- }
- });
- });
- </script>
- <!-- modal 确认提醒框 -->
- <div class="modal fade" id="confirmGoodsMention">
- <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');
- $("#confirmGoodsMention .modal-body span").text(msg);
- $("#confirmGoodsMention .modal-body input").val(url);
- jQuery('#confirmGoodsMention').modal('show', {backdrop: 'fade'}).css({
- 'margin-top': function () {
- var modalHeight = jQuery("#confirmGoodsMention").find('.modal-dialog').height();
- return ($(window).height() / 2 - (modalHeight / 2));
- }
- });
- });
- //点击确认操作
- jQuery("button[name=confirmOk]").click(function () {
- var url = $("#confirmGoodsMention .modal-body input").val();
- $.ajax({
- type: "GET", url: url, async: false, dataType: 'json', success: function (data) {
- if (data.code == 'A0001') {
- $('#confirmGoodsMention').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>
- <script type="text/javascript" src="/js/jquery.lazyload.min.js"></script>
- <script>
- $(".lazy").lazyload({effect: "fadeIn"});
- </script>
|