sold.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. <?php
  2. use common\services\xhGoodsService;
  3. use common\components\stringUtil;
  4. ?>
  5. <?php
  6. use backend\widgets\TabWidget;
  7. echo TabWidget::widget(['list' => $this->context->menuList, 'currentMenu' => $this->context->id]);
  8. ?>
  9. <div class="panel panel-default">
  10. <?php
  11. use backend\widgets\SubTabWidget;
  12. echo SubTabWidget::widget(['list' => $this->context->subMenuList, 'currentMenu' => $this->context->action->id]);
  13. ?>
  14. <div class="panel-body">
  15. <div class="dataTables_wrapper form-inline dt-bootstrap no-footer">
  16. <div class="row">
  17. <form action="" method="GET">
  18. <div class="col-xs-6" style="width:90%;">
  19. <div class="dataTables_length">
  20. <a href="/goods/add" class="btn btn-secondary btn-single" style="margin-right:15px;">添加商品</a>
  21. </div>
  22. </div>
  23. </form>
  24. </div>
  25. <div name="xhQrTip" style="position:absolute;border-color: #8dc63f;width:110px;height:122px;z-index:9999;display:none;background:white;border:1px solid #ccc;">
  26. <div style="background:red;">
  27. <a href="javascript:void(0)" style="color:#68b828;float:right;z-index:9999;"
  28. <i="" class="fa-times"></a>
  29. </div>
  30. <div></div>
  31. </div>
  32. <div class="table-responsive">
  33. <table class="table table-bordered table-striped table-hover">
  34. <thead>
  35. <tr class="active">
  36. <th class="no-sorting hidden-xs"><input type="checkbox"></th>
  37. <th class="hidden-xs">ID</th>
  38. <th>封面</th>
  39. <th>标题</th>
  40. <th class="hidden-xs">价格</th>
  41. <?php if (!empty($riseColumn)) { ?>
  42. <th class="hidden-xs">
  43. 涨价 <?php echo date("n.j", $goodsSet['startRiseTime']) . '-' . date("n.j", $goodsSet['endRiseTime']); ?>
  44. </th>
  45. <?php } ?>
  46. <th class="hidden-xs">销量</th>
  47. <th class="hidden-xs">状态</th>
  48. <th class="hidden-xs">创建时间</th>
  49. <th>操作</th>
  50. </tr>
  51. </thead>
  52. <tbody class="middle-align">
  53. <?php
  54. foreach ($models as $key => $info) {
  55. $id = $info['id'];
  56. $val = xhGoodsService::getById($id);
  57. ?>
  58. <tr>
  59. <td class="hidden-xs"><input type="checkbox"></td>
  60. <td class="hidden-xs"><?php echo $val['id']; ?></td>
  61. <td>
  62. <?php
  63. $coverLargeImg = $val['cover'];
  64. $coverList = xhGoodsService::getGoodsImgList($coverLargeImg);
  65. ?>
  66. <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"/>
  67. </td>
  68. <td>
  69. <?= stringUtil::subStringUtf8($val['goodsName'], 8, '…') ?>
  70. <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>
  71. <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>
  72. </td>
  73. <td class="hidden-xs">
  74. <span id="priceShow<?= $val['id'] ?>"><?php echo $val['price']; ?></span>
  75. <?php if (!empty($rising)) { ?>
  76. <a href="javascript:void(0)" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="涨价中…" style="color:#68b828;cursor:pointer;text-decoration:none;"
  77. <i="" class="fa-long-arrow-up"></a>
  78. <?php } ?>
  79. </td>
  80. <?php if (!empty($riseColumn)) { ?>
  81. <td class="hidden-xs">
  82. <?php
  83. if ($goodsSet['riseType'] == $riseType['amount']) {
  84. echo '¥';
  85. }
  86. ?>
  87. <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
  88. if ($goodsSet['riseType'] == $riseType['percent']) {
  89. echo '%';
  90. }
  91. ?>
  92. <a href="javascript:void(0)" name="modifyRisePrice" pre_rise_price="<?= $val['riseAmount']; ?>" style="color:#68b828;cursor:pointer;text-decoration:none;"
  93. <i="" class="fa-pencil"></a>
  94. </td>
  95. <?php } ?>
  96. <td class="hidden-xs"><?php echo stringUtil::calcAdd($val['sold'], $val['actualSold']); ?></td>
  97. <td class="hidden-xs"><?php if ($val['status'] == 0) echo '上架'; else echo '下架'; ?></td>
  98. <td class="hidden-xs"><?= date("Y-m-d", strtotime($val['createTime'])); ?></td>
  99. <td>
  100. <!-- <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>-->
  101. <a href="/goods/edit?id=<?= $val['id']; ?>" class="btn btn-secondary btn-sm btn-icon icon-left">修改 </a>
  102. <?php if ($val['status'] == 0) { ?>
  103. <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>
  104. <?php } else { ?>
  105. <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>
  106. <?php } ?>
  107. <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>
  108. </td>
  109. </tr>
  110. <?php } ?>
  111. </tbody>
  112. </table>
  113. </div>
  114. <div class="row">
  115. <div>
  116. <!--
  117. <div style="display:inline-block;margin-left:15px;">
  118. <label><select name="example-1_length"
  119. aria-controls="example-1" class="form-control">
  120. <option value="0">批量操作</option>
  121. <option value="1">批量下架</option>
  122. <option value="2">批量删除</option>
  123. </select>
  124. </label>
  125. <input class="btn btn-secondary btn-single" type="submit" name="" value="确认" />
  126. </div>
  127. -->
  128. <div class="dataTables_paginate paging_simple_numbers" style="float:right;padding-top:0px;margin-right:15px;">
  129. <?= $paging ?>
  130. </div>
  131. </div>
  132. </div>
  133. </div>
  134. </div>
  135. </div>
  136. <!-- footer -->
  137. <?php
  138. use backend\widgets\FooterWidget;
  139. ?>
  140. <?= FooterWidget::widget() ?>
  141. <!-- footer -->
  142. <!-- modal 显示链接 -->
  143. <div class="modal fade" id="showUrlModal">
  144. <div class="modal-dialog" style="height:450px;">
  145. <div class="modal-content">
  146. <div class="modal-header">
  147. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  148. <h4 class="modal-title">提示</h4>
  149. </div>
  150. <div class="modal-body">
  151. <div class="row">
  152. <div class="col-md-6">
  153. <div class="form-group">
  154. <label for="field-1" class="control-label">商品链接:</label>
  155. <input type="tel" class="form-control" placeholder="" name="goodsShortUrl" value="" style="display:inline-block;">
  156. <input type="hidden" name="showUrlGoodsId"/>
  157. </div>
  158. </div>
  159. </div>
  160. <div class="row">
  161. <div class="col-md-6">
  162. <div class="form-group">
  163. <label for="field-1" class="control-label"></label>
  164. <a href="javascript:void(0)" name="sendUrlToMobile" class="btn btn-secondary btn-sm btn-icon icon-left" style="display:inline-block;">链接发送到手机</a>
  165. </div>
  166. </div>
  167. </div>
  168. </div>
  169. <div class="modal-footer">
  170. <button type="button" class="btn btn-info" name="rechargeConfirmButton">确认</button>
  171. <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
  172. </div>
  173. </div>
  174. </div>
  175. </div>
  176. <script>
  177. $(function () {
  178. //显示链接操作
  179. jQuery("a[name=showUrl]").click(function () {
  180. var id = $(this).attr('data-id');
  181. $("input[name=goodsShortUrl]").val('');
  182. $("input[name=showUrlGoodsId]").val(id);
  183. $.ajax({
  184. type: "GET",
  185. url: '/goods/generate-short-url?goodsId=' + id,
  186. async: false,
  187. dataType: 'json',
  188. success: function (data) {
  189. if (data.code == 'A0001') {
  190. $("input[name=goodsShortUrl]").val(data.data.shortUrl);
  191. jQuery('#showUrlModal').modal('show');
  192. } else {
  193. xhPopMsg(data.msg, 1300);
  194. }
  195. }
  196. });
  197. });
  198. //确认显示链接
  199. jQuery("button[name=showUrlConfirmButton]").click(function () {
  200. var url = $("#rechargeModal .modal-body input[name=requestUrl]").val();
  201. $.ajax({
  202. type: "GET",
  203. url: url + '&rechargeAmount=' + rechargeAmount + '&rechargePassword=' + rechargePassword,
  204. async: false,
  205. dataType: 'json',
  206. success: function (data) {
  207. if (data.code == 'A0001') {
  208. setTimeout(function () {
  209. window.location.reload();
  210. }, 2000);
  211. }
  212. xhPopMsg(data.msg, 1300);
  213. }
  214. });
  215. });
  216. });
  217. //发送商品短链接
  218. $("a[name=sendUrlToMobile]").click(function () {
  219. var goodsId = $("input[name=showUrlGoodsId]").val();
  220. $.ajax({
  221. type: "get",
  222. url: '/goods/send-url?goodsId=' + goodsId,
  223. async: true,
  224. dataType: 'json',
  225. success: function (data) {
  226. xhPopMsg(data.msg, 2000);
  227. }
  228. });
  229. });
  230. </script>
  231. <!-- modal 确认提醒框 -->
  232. <div class="modal fade" id="confirmMention">
  233. <div class="modal-dialog" style="height:300px;">
  234. <div class="modal-content">
  235. <div class="modal-header">
  236. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  237. <h4 class="modal-title">消息提示</h4>
  238. </div>
  239. <div class="modal-body">
  240. 确认<span></span>?<input type="hidden" name="requestUrl" value=""/>
  241. </div>
  242. <div class="modal-footer">
  243. <button type="button" class="btn btn-info" name="confirmOk">确认</button>
  244. <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
  245. </div>
  246. </div>
  247. </div>
  248. </div>
  249. <!-- Modal 查看商品-->
  250. <div class="modal fade" id="modal-goodsDetail">
  251. <div class="modal-dialog">
  252. <div class="modal-content">
  253. <div class="modal-header">
  254. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  255. <h4 class="modal-title">商品详细</h4>
  256. </div>
  257. <div class="modal-body">
  258. </div>
  259. <div class="modal-footer">
  260. <button type="button" class="btn btn-info" data-dismiss="modal">确认</button>
  261. </div>
  262. </div>
  263. </div>
  264. </div>
  265. <script>
  266. //确认提醒操作
  267. $(function () {
  268. jQuery("a[name=dealGoods]").click(function () {
  269. var url = $(this).attr('data-url');
  270. var msg = $(this).attr('data-msg');
  271. $("#confirmMention .modal-body span").text(msg);
  272. $("#confirmMention .modal-body input").val(url);
  273. jQuery('#confirmMention').modal('show', {backdrop: 'fade'}).css({
  274. 'margin-top': function () {
  275. var modalHeight = jQuery("#confirmMention").find('.modal-dialog').height();
  276. return ($(window).height() / 2 - (modalHeight / 2));
  277. }
  278. });
  279. });
  280. //点击确认操作
  281. jQuery("button[name=confirmOk]").click(function () {
  282. var url = $("#confirmMention .modal-body input").val();
  283. $.ajax({
  284. type: "GET", url: url, async: false, dataType: 'json', success: function (data) {
  285. if (data.code == 'A0001') {
  286. $('#confirmMention').modal('hide');
  287. window.location.reload();
  288. }
  289. }
  290. });
  291. });
  292. });
  293. //推荐商品
  294. $(function () {
  295. jQuery("a[name=recommendGoods]").click(function () {
  296. var url = $(this).attr('data-url');
  297. $.ajax({
  298. type: "GET", url: url, async: false, dataType: 'json', success: function (data) {
  299. if (data.code == 'A0001') {
  300. xhPopMsg(data.msg, 1200);//调用定时浮层 XXX毫秒后消失
  301. } else {
  302. xhPopMsg(data.msg, 2000);//调用定时浮层 XXX毫秒后消失
  303. }
  304. }
  305. });
  306. });
  307. });
  308. $("a[name=qrShow]").click(function () {
  309. var left = $(this).position().left;
  310. var top = $(this).position().top;
  311. var id = $(this).attr('data-id');
  312. var urlqrcode = $(this).attr('data-urlqrcode');
  313. var object = $(this);
  314. $("div[name=xhQrTip]").children('div').eq(1).html('<img src="/images/loading.gif" style="margin:47px 0 0 47px;" />');
  315. $("div[name=xhQrTip]").css('left', left).css('top', top - 110).css('display', 'block');
  316. if (urlqrcode.length > 0) {
  317. $("div[name=xhQrTip]").children('div').eq(1).html('<img width="105" src="<?= Yii::$app->params['imgUrl'] ?>' + urlqrcode + '" />');
  318. $("div[name=xhQrTip]").css('left', left).css('top', top - 110).css("padding", "2px").fadeIn();
  319. } else {
  320. $.ajax({
  321. type: "get",
  322. url: '/goods/show-goods-qrcode?id=' + id,
  323. async: true,
  324. dataType: 'json',
  325. success: function (data) {
  326. if (data.code == 'A0001') {
  327. var imgUrl = data.data.url;
  328. object.attr('data-urlqrcode', imgUrl);
  329. $("div[name=xhQrTip]").children('div').eq(1).html('<img width="105" src="<?= Yii::$app->params['imgUrl'] ?>' + imgUrl + '" />');
  330. $("div[name=xhQrTip]").css('left', left).css('top', top - 110).css("padding", "2px").fadeIn();
  331. }
  332. }
  333. });
  334. }
  335. });
  336. $("div[name=xhQrTip]").click(function () {
  337. $(this).css("display", "none");
  338. });
  339. //发送模板消息类型的商品链接
  340. $("a[name=sendGoodsUrlToMobile]").click(function () {
  341. var goodsId = $(this).attr('data-id');
  342. $.ajax({
  343. type: "get",
  344. url: '/goods/send-goods-url?goodsId=' + goodsId,
  345. async: true,
  346. dataType: 'json',
  347. success: function (data) {
  348. xhPopMsg(data.msg, 2000);
  349. }
  350. });
  351. });
  352. <?php if(!empty($riseColumn)){ ?>
  353. //修改要涨的价格
  354. $("a[name=modifyRisePrice]").click(function () {
  355. var pre_rise_price = $(this).attr('pre_rise_price');
  356. $(this).css("display", "none").siblings('span').css('display', 'none').siblings('input').css('display', 'inline-block').focus().val(pre_rise_price);
  357. });
  358. $("input[name=modifyRisePrice]").blur(function () {
  359. var that = $(this);
  360. var newRiseAmount = $(this).val();
  361. var pre_rise_price = $(this).attr('pre_rise_price');
  362. var id = $(this).attr('data-id');
  363. if (isNaN(newRiseAmount)) {
  364. xhPopMsg('填写有误');
  365. that.focus().val(pre_rise_price);
  366. return;
  367. }
  368. if (newRiseAmount <= 0) {
  369. xhPopMsg('填写有误');
  370. that.focus().val(pre_rise_price);
  371. return;
  372. }
  373. if (newRiseAmount.indexOf('.') > 0) {
  374. if (newRiseAmount.toString().split(".")[1].length > 2) {
  375. xhPopMsg('价格填写有误');
  376. that.focus().val(pre_rise_price);
  377. return;
  378. }
  379. }
  380. if (newRiseAmount == pre_rise_price) {
  381. that.css('display', 'none').attr("pre_rise_price", newRiseAmount);
  382. that.siblings('a').css("display", "inline-block").attr("pre_rise_price", newRiseAmount);
  383. that.siblings('span').css("display", "inline-block").html(newRiseAmount);
  384. return;
  385. }
  386. $.ajax({
  387. type: "GET",
  388. url: '/goods/modify-rise-price?id=' + id + '&riseAmount=' + newRiseAmount,
  389. async: false,
  390. dataType: 'json',
  391. success: function (data) {
  392. if (data.code == 'A0001') {
  393. that.css('display', 'none').attr("pre_rise_price", newRiseAmount);
  394. that.siblings('a').css("display", "inline-block").attr("pre_rise_price", newRiseAmount);
  395. that.siblings('span').css("display", "inline-block").html(newRiseAmount);
  396. $("#priceShow" + id).text(data.data.price);
  397. }
  398. xhPopMsg(data.msg);
  399. }
  400. });
  401. });
  402. <?php } ?>
  403. </script>