goods.blade.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. @extends('layouts.base')
  2. @section('content')
  3. @section('title', trans('商品详情'))
  4. <script type="text/javascript">
  5. window.type = "{{$goods['type']}}";
  6. window.virtual = "{{$goods['virtual']}}";
  7. $(function () {
  8. $(':radio[name=type]').click(function () {
  9. window.type = $("input[name='type']:checked").val();
  10. window.virtual = $("#virtual").val();
  11. if (window.type == '1') {
  12. $('#dispatch_info').show();
  13. } else {
  14. $('#dispatch_info').hide();
  15. }
  16. if (window.type == '3') {
  17. if ($('#virtual').val() == '0') {
  18. $('.choosetemp').show();
  19. }
  20. }
  21. })
  22. $("input[name='back']").click(function () {
  23. location.href = "{!! yzWebUrl('goods.goods.index') !!}";
  24. });
  25. })
  26. window.optionchanged = false;
  27. require(['bootstrap'], function () {
  28. $('#myTab a').click(function (e) {
  29. e.preventDefault();
  30. $(this).tab('show');
  31. })
  32. });
  33. require(['util'], function (u) {
  34. $('#cp').each(function () {
  35. u.clip(this, $(this).text());
  36. });
  37. });
  38. function formcheck() {
  39. window.type = $("input[name='goods[type]']:checked").val();
  40. window.virtual = $("#virtual").val();
  41. var reg = /(^[-+]?[1-9]\d*(\.\d{1,2})?$)|(^[-+]?[0]{1}(\.\d{1,2})?$)/; //金额字段验证,后两位小数
  42. var numerictype = /^(0|[1-9]\d*)$/; //整数验证
  43. var thumb = /\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/;
  44. var datetime = /(\d{2}|\d{4})(?:\-)?([0]{1}\d{1}|[1]{1}[0-2]{1})(?:\-)?([0-2]{1}\d{1}|[3]{1}[0-1]{1})(?:\s)?([0-1]{1}\d{1}|[2]{1}[0-3]{1})(?::)?([0-5]{1}\d{1})(?::)?([0-5]{1}\d{1})/;
  45. @section('widget_js')
  46. if (!numerictype.test($(':input[name="widgets[sale][max_point_deduct]"]').val().replace("%","")) && $(':input[name="widgets[sale][max_point_deduct]"]').val() != '') {
  47. $('#myTab a[href="#tab_sale"]').tab('show');
  48. Tip.focus(':input[name="widgets[sale][max_point_deduct]"]', '最大积分抵扣格式错误,只能为非负整数或空.');
  49. return false;
  50. }
  51. if (!numerictype.test($(':input[name="widgets[sale][min_point_deduct]"]').val().replace("%","")) && $(':input[name="widgets[sale][min_point_deduct]"]').val() != '') {
  52. $('#myTab a[href="#tab_sale"]').tab('show');
  53. Tip.focus(':input[name="widgets[sale][min_point_deduct]"]', '最小积分抵扣格式错误,只能为非负整数或空.');
  54. return false;
  55. }
  56. if ($(':input[name="widgets[sale][ed_full]"]').val() != '' && !reg.test($(':input[name="widgets[sale][ed_full]"]').val())) {
  57. $('#myTab a[href="#tab_sale"]').tab('show');
  58. Tip.focus(':input[name="widgets[sale][ed_full]"]', '满额立减金额格式错误,最多两位小数.');
  59. return false;
  60. }
  61. if ($(':input[name="widgets[sale][ed_reduction]"]').val() != '' && !reg.test($(':input[name="widgets[sale][ed_reduction]"]').val())) {
  62. $('#myTab a[href="#tab_sale"]').tab('show');
  63. Tip.focus(':input[name="widgets[sale][ed_reduction]"]', '满额立减金额格式错误,最多两位小数.');
  64. return false;
  65. }
  66. if ($(':input[name="widgets[sale][point]"]').val() != '') {
  67. if (!$(':input[name="widgets[sale][point]"]').val().match('\%')) {
  68. if (!numerictype.test($(':input[name="widgets[sale][point]"]').val())) {
  69. $('#myTab a[href="#tab_sale"]').tab('show');
  70. Tip.focus(':input[name="widgets[sale][point]"]', '赠送积分格式错误,只能为非负整数.');
  71. return false;
  72. }
  73. }
  74. }
  75. if ($.trim($(':input[name="widgets[share][share_thumb]"]').val()) != '' && !thumb.test($.trim($(':input[name="widgets[share][share_thumb]"]').val()))) {
  76. $('#myTab a[href="#tab_share"]').tab('show');
  77. Tip.focus(':input[name="widgets[share][share_thumb]"]', '图片类型必须是.gif,jpeg,jpg,png中的一种.');
  78. return false;
  79. }
  80. if ($(':input[name="widgets[privilege][once_buy_limit]"]').val() == '') {
  81. $('#myTab a[href="#tab_privilege"]').tab('show');
  82. Tip.focus(':input[name="widgets[privilege][once_buy_limit]"]', "请输入每次限购数量!");
  83. return false;
  84. } else {
  85. if (!numerictype.test($(':input[name="widgets[privilege][once_buy_limit]"]').val())) {
  86. $('#myTab a[href="#tab_privilege"]').tab('show');
  87. Tip.focus(':input[name="widgets[privilege][once_buy_limit]"]', '每次限购数量格式错误,只能为非负整数.');
  88. return false;
  89. }
  90. }
  91. if ($(':input[name="widgets[privilege][total_buy_limit]"]').val() == '') {
  92. $('#myTab a[href="#tab_privilege"]').tab('show');
  93. Tip.focus(':input[name="widgets[privilege][total_buy_limit]"]', "请输入会员限购总数!");
  94. return false;
  95. } else {
  96. if (!numerictype.test($(':input[name="widgets[privilege][total_buy_limit]"]').val())) {
  97. $('#myTab a[href="#tab_privilege"]').tab('show');
  98. Tip.focus(':input[name="widgets[privilege][total_buy_limit]"]', '会员限购总数格式错误,只能为非负整数.');
  99. return false;
  100. }
  101. }
  102. if ($(':input[name="widgets[privilege][day_buy_limit]"]').val() == '') {
  103. $('#myTab a[href="#tab_privilege"]').tab('show');
  104. Tip.focus(':input[name="widgets[privilege][day_buy_limit]"]', "请输入会员每天限购数量!");
  105. return false;
  106. } else {
  107. if (!numerictype.test($(':input[name="widgets[privilege][day_buy_limit]"]').val())) {
  108. $('#myTab a[href="#tab_privilege"]').tab('show');
  109. Tip.focus(':input[name="widgets[privilege][day_buy_limit]"]', '会员每天限购数量格式错误,只能为非负整数.');
  110. return false;
  111. }
  112. }
  113. if ($(':input[name="widgets[privilege][week_buy_limit]"]').val() == '') {
  114. $('#myTab a[href="#tab_privilege"]').tab('show');
  115. Tip.focus(':input[name="widgets[privilege][week_buy_limit]"]', "请输入会员每周限购数量!");
  116. return false;
  117. } else {
  118. if (!numerictype.test($(':input[name="widgets[privilege][week_buy_limit]"]').val())) {
  119. $('#myTab a[href="#tab_privilege"]').tab('show');
  120. Tip.focus(':input[name="widgets[privilege][week_buy_limit]"]', '会员每周限购数量格式错误,只能为非负整数.');
  121. return false;
  122. }
  123. }
  124. if ($(':input[name="widgets[privilege][month_buy_limit]"]').val() == '') {
  125. $('#myTab a[href="#tab_privilege"]').tab('show');
  126. Tip.focus(':input[name="widgets[privilege][month_buy_limit]"]', "请输入会员每月限购总数!");
  127. return false;
  128. } else {
  129. if (!numerictype.test($(':input[name="widgets[privilege][month_buy_limit]"]').val())) {
  130. $('#myTab a[href="#tab_privilege"]').tab('show');
  131. Tip.focus(':input[name="widgets[privilege][month_buy_limit]"]', '会员每月限购总数格式错误,只能为非负整数.');
  132. return false;
  133. }
  134. }
  135. if ($('.discounts_value').val()) {
  136. if (!reg.test($('.discounts_value').val())) {
  137. $('#myTab a[href="#tab_discount"]').tab('show');
  138. Tip.focus('.discounts_value', '折扣或固定金额数值格式错误,最多两位小数.');
  139. return false;
  140. }
  141. }
  142. @show
  143. if ($(':input[name="widgets[dispatch][dispatch_price]"]').val() == '') {
  144. $('#myTab a[href="#tab_dispatch"]').tab('show');
  145. Tip.focus(':input[name="widgets[dispatch][dispatch_price]"]', "请输入统一邮费金额!");
  146. return false;
  147. } else {
  148. if (!reg.test($(':input[name="widgets[dispatch][dispatch_price]"]').val())) {
  149. $('#myTab a[href="#tab_dispatch"]').tab('show');
  150. Tip.focus(':input[name="widgets[dispatch][dispatch_price]"]', '统一邮费金额数值格式错误,最多两位小数.');
  151. return false;
  152. }
  153. }
  154. if ($(':input[name="widgets[area_dividend][has_dividend]"]').get(0) != undefined && $(':input[name="widgets[area_dividend][has_dividend]"]').get(0).checked) {
  155. if ($(':input[name="widgets[area_dividend][has_dividend_price]"]').val() == '') {
  156. $('#myTab a[href="#tab_area_dividend"]').tab('show');
  157. Tip.focus(':input[name="widgets[area_dividend][has_dividend_price]"]', "独立分红金额!");
  158. return false;
  159. }
  160. }
  161. var full = true;
  162. if (window.type == '3') {
  163. if (window.virtual != '0') { //如果单规格,不能有规格
  164. if ($('#hasoption').get(0).checked) {
  165. $('#myTab a[href="#tab_option"]').tab('show');
  166. util.message('您的商品类型为:虚拟物品(卡密)的单规格形式,需要关闭商品规格!');
  167. return false;
  168. }
  169. }
  170. else {
  171. var has = false;
  172. $('.spec_item_virtual').each(function () {
  173. has = true;
  174. if ($(this).val() == '' || $(this).val() == '0') {
  175. $('#myTab a[href="#tab_option"]').tab('show');
  176. Tip.focus($(this).next(), '请选择虚拟物品模板!');
  177. full = false;
  178. return false;
  179. }
  180. });
  181. if (!has) {
  182. $('#myTab a[href="#tab_option"]').tab('show');
  183. util.message('您的商品类型为:虚拟物品(卡密)的多规格形式,请添加规格!');
  184. return false;
  185. }
  186. }
  187. }
  188. if (!full) {
  189. return false;
  190. }
  191. full = checkoption();
  192. if (!full) {
  193. return false;
  194. }
  195. if (optionchanged) {
  196. $('#myTab a[href="#tab_option"]').tab('show');
  197. alert('规格数据有变动,请重新点击 [刷新规格项目表] 按钮!');
  198. return false;
  199. }
  200. var discountway = $('input:radio[name=discountway]:checked').val();
  201. var discounttype = $('input:radio[name=discounttype]:checked').val();
  202. var returntype = $('input:radio[name=returntype]:checked').val();
  203. var marketprice = $('input:text[name=marketprice]').val();
  204. var isreturn = false;
  205. if (discountway == 1) {
  206. if (discounttype == 1) {
  207. $(".discounts").each(function () {
  208. if (parseFloat($(this).val()) <= 0 || parseFloat($(this).val()) >= 10) {
  209. $(this).val('');
  210. isreturn = true;
  211. alert('请输入正确折扣!');
  212. return false;
  213. }
  214. });
  215. } else {
  216. $(".discounts2").each(function () {
  217. if (parseFloat($(this).val()) <= 0 || parseFloat($(this).val()) >= 10) {
  218. $(this).val('');
  219. isreturn = true;
  220. alert('请输入正确折扣!');
  221. return false;
  222. }
  223. });
  224. }
  225. } else {
  226. if (discounttype == 1) {
  227. $(".discounts").each(function () {
  228. if (parseFloat($(this).val()) < 0 || parseFloat($(this).val()) >= parseFloat(marketprice)) {
  229. $(this).val('');
  230. isreturn = true;
  231. alert('请输入正确折扣金额!');
  232. return false;
  233. }
  234. });
  235. } else {
  236. $(".discounts2").each(function () {
  237. if (parseFloat($(this).val()) < 0 || parseFloat($(this).val()) >= parseFloat(marketprice)) {
  238. $(this).val('');
  239. isreturn = true;
  240. alert('请输入正确折扣金额!');
  241. return false;
  242. }
  243. });
  244. }
  245. }
  246. if (returntype == 1) {
  247. $(".returns").each(function () {
  248. if (parseFloat($(this).val()) < 0 || parseFloat($(this).val()) >= parseFloat(marketprice)) {
  249. $(this).val('');
  250. isreturn = true;
  251. alert('请输入正确返现金额!');
  252. return false;
  253. }
  254. });
  255. } else {
  256. $(".returns2").each(function () {
  257. if (parseFloat($(this).val()) < 0 || parseFloat($(this).val()) >= parseFloat(marketprice)) {
  258. $(this).val('');
  259. isreturn = true;
  260. alert('请输入正确返现金额!');
  261. return false;
  262. }
  263. });
  264. }
  265. if (isreturn) {
  266. return false;
  267. }
  268. return true;
  269. }
  270. function checkoption() {
  271. var full = true;
  272. if ($("#hasoption").get(0).checked) {
  273. $(".spec_title").each(function (i) {
  274. if ($(this).val() == '') {
  275. $('#myTab a[href="#tab_option"]').tab('show');
  276. Tip.focus(".spec_title:eq(" + i + ")", "请输入规格名称!", "top");
  277. full = false;
  278. return false;
  279. }
  280. });
  281. $(".spec_item_title").each(function (i) {
  282. if ($(this).val() == '') {
  283. $('#myTab a[href="#tab_option"]').tab('show');
  284. Tip.focus(".spec_item_title:eq(" + i + ")", "请输入规格项名称!", "top");
  285. full = false;
  286. return false;
  287. }
  288. });
  289. }
  290. if (!full) {
  291. return false;
  292. }
  293. return full;
  294. }
  295. </script>
  296. <script type="text/javascript">
  297. //鼠标划过显示商品链接二维码
  298. $('.umphp').hover(function () {
  299. var url = $(this).attr('data-url');
  300. var goodsid = $(this).attr('data-goodsid');
  301. $.post("{!! yzWebUrl('shop.goods') !!}"
  302. , {'op': 'goods_qrcode', id: goodsid, url: url}
  303. , function (qr) {
  304. if (qr.img) {
  305. var goodsqr = qr.img;
  306. var element = document.getElementById(goodsid);
  307. element.src = goodsqr;
  308. }
  309. }
  310. , "json"
  311. );
  312. $(this).addClass("selected");
  313. },
  314. function () {
  315. $(this).removeClass("selected");
  316. })
  317. function fastChange(id, type, value) {
  318. $.ajax({
  319. url: "{!! yzWebUrl('shop.goods') !!}",
  320. type: "post",
  321. data: {op: 'change', id: id, type: type, value: value},
  322. cache: false,
  323. success: function () {
  324. location.reload();
  325. }
  326. })
  327. }
  328. $(function () {
  329. $("form").keypress(function (e) {
  330. if (e.which == 13) {
  331. return false;
  332. }
  333. });
  334. $('.tdedit input').keydown(function (event) {
  335. if (event.keyCode == 13) {
  336. var group = $(this).closest('.input-group');
  337. var type = group.find('button').data('type');
  338. var goodsid = group.find('button').data('goodsid');
  339. var val = $.trim($(this).val());
  340. if (type == 'title' && val == '') {
  341. return;
  342. }
  343. group.prev().show().find('span').html(val);
  344. group.hide();
  345. fastChange(goodsid, type, val);
  346. }
  347. })
  348. $('.tdedit').mouseover(function () {
  349. $(this).find('.fa-pencil').show();
  350. }).mouseout(function () {
  351. $(this).find('.fa-pencil').hide();
  352. });
  353. $('.fa-edit-item').click(function () {
  354. var group = $(this).closest('span').hide().next();
  355. group.show().find('button').unbind('click').click(function () {
  356. var type = $(this).data('type');
  357. var goodsid = $(this).data('goodsid');
  358. var val = $.trim(group.find(':input').val());
  359. if (type == 'title' && val == '') {
  360. Tip.show(group.find(':input'), '请输入名称!');
  361. return;
  362. }
  363. group.prev().show().find('span').html(val);
  364. group.hide();
  365. fastChange(goodsid, type, val);
  366. });
  367. })
  368. })
  369. </script>
  370. <link rel="stylesheet" type="text/css" href="{{static_url('css/font-awesome.min.css')}}">
  371. <div class="right-titpos">
  372. <ul class="add-snav">
  373. <li class="active"><a href="#"><i class="fa fa-circle-o" style="color: #33b5d2;"></i>商品编辑</a></li>
  374. </ul>
  375. </div>
  376. <form id="goods-edit" action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
  377. <div class="panel-default panel-center">
  378. <div class="top">
  379. <ul class="add-shopnav" id="myTab">
  380. @section('goods_widget_title')
  381. @foreach(\app\common\modules\widget\Widget::current()->getItem('goods') as $key => $value)
  382. <li><a href="#{{$key}}">{{$value['title']}}</a></li>
  383. @endforeach
  384. @show
  385. </ul>
  386. </div>
  387. <div class="info">
  388. <div class="panel-body">
  389. <div class="tab-content">
  390. @section('goods_widget_view')
  391. @foreach(\app\common\modules\widget\Widget::current()->getItem('goods') as $key => $value)
  392. <div class="tab-pane"
  393. id="{{$key}}">{!! widget($value['class'], ['goods_id'=> $goods->id])!!}</div>
  394. @endforeach
  395. @show
  396. </div>
  397. <div class="form-group col-sm-12 mrleft40 border-t">
  398. <input type="submit" name="submit" value="{{$lang['shopsubmit']}}" class="btn btn-success"
  399. onclick="return formcheck()"/>
  400. <input type="hidden" name="token" value="{{$var['token']}}"/>
  401. @section('back')
  402. <input type="button" name="back" value="返回列表" class="btn btn-default back"/>
  403. @show
  404. </div>
  405. </div>
  406. </div>
  407. </div>
  408. </form>
  409. {{--</div>--}}
  410. @endsection('content')