goods.blade.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  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. // var plugin_id=$('input:radio[name="goods[type2]"]:checked').val();
  40. // var p_id = $('#plugin_id').val();
  41. // if(plugin_id == '2') {
  42. // var txt=$("<input type='hidden' name='goods[plugin_id]' value='"+p_id+"'>"); // 使用 jQuery 创建元素
  43. // $('input:radio[name="goods[type2]"]').after(txt); // 在图片后添加文本
  44. // }
  45. window.type = $("input[name='goods[type]']:checked").val();
  46. window.virtual = $("#virtual").val();
  47. var reg = /(^[-+]?[1-9]\d*(\.\d{1,2})?$)|(^[-+]?[0]{1}(\.\d{1,2})?$)/; //金额字段验证,后两位小数
  48. var numerictype = /^(0|[1-9]\d*)$/; //整数验证
  49. var thumb = /\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/;
  50. 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})/;
  51. /*
  52. *update date 2017/12/20 16:44
  53. *添加排序的验证
  54. */
  55. if (!numerictype.test($(':input[name="goods[display_order]"]').val())) {
  56. $('#myTab a[href="#tab_basic"]').tab('show');
  57. Tip.focus("#displayorder", "排序必须是整数!");
  58. return false;
  59. }
  60. if ($(':input[name="goods[title]"]').val() == '') {
  61. $('#myTab a[href="#tab_basic"]').tab('show');
  62. Tip.focus("#goodsname", "请输入商品名称!");
  63. return false;
  64. }
  65. if ($(':input[name="goods[title]"]').val().length >= '300') {
  66. $('#myTab a[href="#tab_basic"]').tab('show');
  67. Tip.focus("#goodsname", "商品名称不能超过300个字符!");
  68. return false;
  69. }
  70. if ($(':input[name="category[parentid][]"]').val() == 0) {
  71. $('#myTab a[href="#tab_basic"]').tab('show');
  72. Tip.focus(':input[name="category[parentid][]"]', "请选择一级分类!");
  73. return false;
  74. }
  75. if ($(':input[name="category[childid][]"]').val() == 0) {
  76. $('#myTab a[href="#tab_basic"]').tab('show');
  77. Tip.focus(':input[name="category[childid][]"]', "请选择二级分类!");
  78. return false;
  79. }
  80. @if($shopset['cat_level'] == 3)
  81. if ($(':input[name="category[thirdid][]"]').val() == 0) {
  82. $('#myTab a[href="#tab_basic"]').tab('show');
  83. Tip.focus(':input[name="category[thirdid][]"]', "请选择三级分类!");
  84. return false;
  85. }
  86. @endif
  87. if ($(':input[name="goods[sku]"]').val() == '') {
  88. $('#myTab a[href="#tab_basic"]').tab('show');
  89. Tip.focus(':input[name="goods[sku]"]', "请输入商品单位!");
  90. return false;
  91. }
  92. @if (empty($id))
  93. if ($.trim($(':input[name="goods[thumb]"]').val()) == '') {
  94. $('#myTab a[href="#tab_basic"]').tab('show');
  95. Tip.focus(':input[name="goods[thumb]"]', '请上传缩略图.');
  96. return false;
  97. }
  98. //供应链图片不一定是以这些类型结尾
  99. // else {
  100. // if (!thumb.test($.trim($(':input[name="goods[thumb]"]').val()))) {
  101. // $('#myTab a[href="#tab_basic"]').tab('show');
  102. // Tip.focus(':input[name="goods[thumb]"]', '图片类型必须是.gif,jpeg,jpg,png中的一种.');
  103. // return false;
  104. // }
  105. // }
  106. @endif
  107. // if ($.trim($(':input[name="goods[price]"]').val()) == '') {
  108. // $('#myTab a[href="#tab_basic"]').tab('show');
  109. // Tip.focus(':input[name="goods[price]"]', '请填写价格.');
  110. // return false;
  111. // } else {
  112. // if (!reg.test($(':input[name="goods[price]"]').val())) {
  113. // $('#myTab a[href="#tab_basic"]').tab('show');
  114. // Tip.focus(':input[name="goods[price]"]', '价格格式错误,最多两位小数.');
  115. // return false;
  116. // }
  117. // }
  118. // if ($.trim($(':input[name="goods[market_price]"]').val()) == '') {
  119. // $('#myTab a[href="#tab_basic"]').tab('show');
  120. // Tip.focus(':input[name="goods[market_price]"]', '请填写价格.');
  121. // return false;
  122. // } else {
  123. // if (!reg.test($(':input[name="goods[market_price]"]').val())) {
  124. // $('#myTab a[href="#tab_basic"]').tab('show');
  125. // Tip.focus(':input[name="goods[market_price]"]', '价格格式错误,最多两位小数.');
  126. // return false;
  127. // }
  128. // }
  129. // if ($.trim($(':input[name="goods[cost_price]"]').val()) == '') {
  130. // $('#myTab a[href="#tab_basic"]').tab('show');
  131. // Tip.focus(':input[name="goods[cost_price]"]', '请填写价格.');
  132. // return false;
  133. // } else {
  134. // if (!reg.test($(':input[name="goods[cost_price]"]').val())) {
  135. // $('#myTab a[href="#tab_basic"]').tab('show');
  136. // Tip.focus(':input[name="goods[cost_price]"]', '价格格式错误,最多两位小数.');
  137. // return false;
  138. // }
  139. // }
  140. if ($(':input[name="goods[stock]"]').val() == '') {
  141. $('#myTab a[href="#tab_basic"]').tab('show');
  142. Tip.focus(':input[name="goods[stock]"]', "请输入库存!");
  143. return false;
  144. } else {
  145. if (!numerictype.test($(':input[name="goods[stock]"]').val())) {
  146. $('#myTab a[href="#tab_basic"]').tab('show');
  147. Tip.focus(':input[name="goods[stock]"]', '库存格式错误,只能为非负整数.');
  148. return false;
  149. }
  150. }
  151. @section('widget_js')
  152. if (!numerictype.test($(':input[name="widgets[sale][max_point_deduct]"]').val().replace("%","")) && $(':input[name="widgets[sale][max_point_deduct]"]').val() != '') {
  153. $('#myTab a[href="#tab_sale"]').tab('show');
  154. Tip.focus(':input[name="widgets[sale][max_point_deduct]"]', '最大积分抵扣格式错误,只能为非负整数或空.');
  155. return false;
  156. }
  157. if (!numerictype.test($(':input[name="widgets[sale][min_point_deduct]"]').val().replace("%","")) && $(':input[name="widgets[sale][min_point_deduct]"]').val() != '') {
  158. $('#myTab a[href="#tab_sale"]').tab('show');
  159. Tip.focus(':input[name="widgets[sale][min_point_deduct]"]', '最小积分抵扣格式错误,只能为非负整数或空.');
  160. return false;
  161. }
  162. /*if ($(':input[name="widgets[sale][max_point_deduct]"]').val() == '') {
  163. $('#myTab a[href="#tab_sale"]').tab('show');
  164. Tip.focus(':input[name="widgets[sale][max_point_deduct]"]', "请输入积分抵扣!");
  165. return false;
  166. } else {
  167. if (!numerictype.test($(':input[name="widgets[sale][max_point_deduct]"]').val())) {
  168. $('#myTab a[href="#tab_sale"]').tab('show');
  169. Tip.focus(':input[name="widgets[sale][max_point_deduct]"]', '积分抵扣格式错误,只能为非负整数.');
  170. return false;
  171. }
  172. }*/
  173. /*if ($(':input[name="widgets[sale][max_balance_deduct]"]').val() == '') {
  174. $('#myTab a[href="#tab_sale"]').tab('show');
  175. Tip.focus(':input[name="widgets[sale][max_balance_deduct]"]', "请输入余额抵扣!");
  176. return false;
  177. } else {
  178. if (!reg.test($(':input[name="widgets[sale][max_balance_deduct]"]').val())) {
  179. $('#myTab a[href="#tab_sale"]').tab('show');
  180. Tip.focus(':input[name="widgets[sale][max_balance_deduct]"]', '余额抵扣格式错误,最多两位小数.');
  181. return false;
  182. }
  183. }*/
  184. if ($(':input[name="widgets[sale][ed_full]"]').val() != '' && !reg.test($(':input[name="widgets[sale][ed_full]"]').val())) {
  185. $('#myTab a[href="#tab_sale"]').tab('show');
  186. Tip.focus(':input[name="widgets[sale][ed_full]"]', '满额立减金额格式错误,最多两位小数.');
  187. return false;
  188. }
  189. if ($(':input[name="widgets[sale][ed_reduction]"]').val() != '' && !reg.test($(':input[name="widgets[sale][ed_reduction]"]').val())) {
  190. $('#myTab a[href="#tab_sale"]').tab('show');
  191. Tip.focus(':input[name="widgets[sale][ed_reduction]"]', '满额立减金额格式错误,最多两位小数.');
  192. return false;
  193. }
  194. /*
  195. if ($.trim($(':input[name="widgets[sale][max_point_deduct]"]').val()) != ''
  196. && parseInt($(':input[name="widgets[sale][max_point_deduct]"]').val()) != 0
  197. && $.trim($(':input[name="goods[price]"]').val()) != ''
  198. && parseFloat($(':input[name="widgets[sale][max_point_deduct]"]').val())
  199. > parseFloat($(':input[name="goods[price]"]').val())) {
  200. $('#myTab a[href="#tab_sale"]').tab('show');
  201. Tip.focus(':input[name="widgets[sale][max_point_deduct]"]', "积分抵扣金额不能大于商品现价!");
  202. return false;
  203. }
  204. */
  205. if ($(':input[name="widgets[sale][point]"]').val() != '') {
  206. if (!$(':input[name="widgets[sale][point]"]').val().match('\%')) {
  207. if (!numerictype.test($(':input[name="widgets[sale][point]"]').val())) {
  208. $('#myTab a[href="#tab_sale"]').tab('show');
  209. Tip.focus(':input[name="widgets[sale][point]"]', '赠送积分格式错误,只能为非负整数.');
  210. return false;
  211. }
  212. }
  213. }
  214. /*if ($(':input[name="widgets[sale][bonus]"]').val() == '') {
  215. $('#myTab a[href="#tab_sale"]').tab('show');
  216. Tip.focus(':input[name="widgets[sale][bonus]"]', "请输入红包金额!");
  217. return false;
  218. } else {
  219. if (!reg.test($(':input[name="widgets[sale][bonus]"]').val())) {
  220. $('#myTab a[href="#tab_sale"]').tab('show');
  221. Tip.focus(':input[name="widgets[sale][bonus]"]', '红包金额格式错误,最多两位小数.');
  222. return false;
  223. }
  224. }*/
  225. if ($.trim($(':input[name="widgets[share][share_thumb]"]').val()) != '' && !thumb.test($.trim($(':input[name="widgets[share][share_thumb]"]').val()))) {
  226. $('#myTab a[href="#tab_share"]').tab('show');
  227. Tip.focus(':input[name="widgets[share][share_thumb]"]', '图片类型必须是.gif,jpeg,jpg,png中的一种.');
  228. return false;
  229. }
  230. if ($(':input[name="widgets[privilege][once_buy_limit]"]').val() == '') {
  231. $('#myTab a[href="#tab_privilege"]').tab('show');
  232. Tip.focus(':input[name="widgets[privilege][once_buy_limit]"]', "请输入每次限购数量!");
  233. return false;
  234. } else {
  235. if (!numerictype.test($(':input[name="widgets[privilege][once_buy_limit]"]').val())) {
  236. $('#myTab a[href="#tab_privilege"]').tab('show');
  237. Tip.focus(':input[name="widgets[privilege][once_buy_limit]"]', '每次限购数量格式错误,只能为非负整数.');
  238. return false;
  239. }
  240. }
  241. if ($(':input[name="widgets[privilege][total_buy_limit]"]').val() == '') {
  242. $('#myTab a[href="#tab_privilege"]').tab('show');
  243. Tip.focus(':input[name="widgets[privilege][total_buy_limit]"]', "请输入会员限购总数!");
  244. return false;
  245. } else {
  246. if (!numerictype.test($(':input[name="widgets[privilege][total_buy_limit]"]').val())) {
  247. $('#myTab a[href="#tab_privilege"]').tab('show');
  248. Tip.focus(':input[name="widgets[privilege][total_buy_limit]"]', '会员限购总数格式错误,只能为非负整数.');
  249. return false;
  250. }
  251. }
  252. if ($(':input[name="widgets[privilege][day_buy_limit]"]').val() == '') {
  253. $('#myTab a[href="#tab_privilege"]').tab('show');
  254. Tip.focus(':input[name="widgets[privilege][day_buy_limit]"]', "请输入会员每天限购数量!");
  255. return false;
  256. } else {
  257. if (!numerictype.test($(':input[name="widgets[privilege][day_buy_limit]"]').val())) {
  258. $('#myTab a[href="#tab_privilege"]').tab('show');
  259. Tip.focus(':input[name="widgets[privilege][day_buy_limit]"]', '会员每天限购数量格式错误,只能为非负整数.');
  260. return false;
  261. }
  262. }
  263. if ($(':input[name="widgets[privilege][week_buy_limit]"]').val() == '') {
  264. $('#myTab a[href="#tab_privilege"]').tab('show');
  265. Tip.focus(':input[name="widgets[privilege][week_buy_limit]"]', "请输入会员每周限购数量!");
  266. return false;
  267. } else {
  268. if (!numerictype.test($(':input[name="widgets[privilege][week_buy_limit]"]').val())) {
  269. $('#myTab a[href="#tab_privilege"]').tab('show');
  270. Tip.focus(':input[name="widgets[privilege][week_buy_limit]"]', '会员每周限购数量格式错误,只能为非负整数.');
  271. return false;
  272. }
  273. }
  274. if ($(':input[name="widgets[privilege][month_buy_limit]"]').val() == '') {
  275. $('#myTab a[href="#tab_privilege"]').tab('show');
  276. Tip.focus(':input[name="widgets[privilege][month_buy_limit]"]', "请输入会员每月限购总数!");
  277. return false;
  278. } else {
  279. if (!numerictype.test($(':input[name="widgets[privilege][month_buy_limit]"]').val())) {
  280. $('#myTab a[href="#tab_privilege"]').tab('show');
  281. Tip.focus(':input[name="widgets[privilege][month_buy_limit]"]', '会员每月限购总数格式错误,只能为非负整数.');
  282. return false;
  283. }
  284. }
  285. /*if ($(':input[name="widgets[privilege][time_begin_limit]"]').val() == '') {
  286. $('#myTab a[href="#tab_privilege"]').tab('show');
  287. Tip.focus(':input[name="widgets[privilege][time_begin_limit]"]', "请输入限购起始时间!");
  288. return false;
  289. } else {
  290. if (!datetime.test($(':input[name="widgets[privilege][time_begin_limit]"]').val())) {
  291. $('#myTab a[href="#tab_privilege"]').tab('show');
  292. Tip.focus(':input[name="widgets[privilege][time_begin_limit]"]', '限购起始时间格式错误,只能0000-00-00 00:00:00格式.');
  293. return false;
  294. }
  295. }*/
  296. /*if ($(':input[name="widgets[privilege][time_end_limit]"]').val() == '') {
  297. $('#myTab a[href="#tab_privilege"]').tab('show');
  298. Tip.focus(':input[name="widgets[privilege][time_end_limit]"]', "请输入限购结束时间!");
  299. return false;
  300. } else {
  301. if (!datetime.test($(':input[name="widgets[privilege][time_end_limit]"]').val())) {
  302. $('#myTab a[href="#tab_privilege"]').tab('show');
  303. Tip.focus(':input[name="widgets[privilege][time_end_limit]"]', '限购结束时间格式错误,只能0000-00-00 00:00:00格式.');
  304. return false;
  305. }
  306. }*/
  307. if ($('.discounts_value').val()) {
  308. if (!reg.test($('.discounts_value').val())) {
  309. $('#myTab a[href="#tab_discount"]').tab('show');
  310. Tip.focus('.discounts_value', '折扣或固定金额数值格式错误,最多两位小数.');
  311. return false;
  312. }
  313. }
  314. // if ($(':input[name="widgets[single_return][return_rate]"]').val() == '') {
  315. // $('#myTab a[href="#tab_single_return"]').tab('show');
  316. // Tip.focus(':input[name="widgets[single_return][return_rate]"]', "请输返现比例!");
  317. // return false;
  318. // }
  319. @show
  320. if ($(':input[name="widgets[dispatch][dispatch_price]"]').val() == '') {
  321. $('#myTab a[href="#tab_dispatch"]').tab('show');
  322. Tip.focus(':input[name="widgets[dispatch][dispatch_price]"]', "请输入统一邮费金额!");
  323. return false;
  324. } else {
  325. if (!reg.test($(':input[name="widgets[dispatch][dispatch_price]"]').val())) {
  326. $('#myTab a[href="#tab_dispatch"]').tab('show');
  327. Tip.focus(':input[name="widgets[dispatch][dispatch_price]"]', '统一邮费金额数值格式错误,最多两位小数.');
  328. return false;
  329. }
  330. }
  331. if ($(':input[name="widgets[area_dividend][has_dividend]"]').get(0) != undefined && $(':input[name="widgets[area_dividend][has_dividend]"]').get(0).checked) {
  332. if ($(':input[name="widgets[area_dividend][has_dividend_price]"]').val() == '') {
  333. $('#myTab a[href="#tab_area_dividend"]').tab('show');
  334. Tip.focus(':input[name="widgets[area_dividend][has_dividend_price]"]', "独立分红金额!");
  335. return false;
  336. }
  337. }
  338. var full = true;
  339. if (window.type == '3') {
  340. if (window.virtual != '0') { //如果单规格,不能有规格
  341. if ($('#hasoption').get(0).checked) {
  342. $('#myTab a[href="#tab_option"]').tab('show');
  343. util.message('您的商品类型为:虚拟物品(卡密)的单规格形式,需要关闭商品规格!');
  344. return false;
  345. }
  346. }
  347. else {
  348. var has = false;
  349. $('.spec_item_virtual').each(function () {
  350. has = true;
  351. if ($(this).val() == '' || $(this).val() == '0') {
  352. $('#myTab a[href="#tab_option"]').tab('show');
  353. Tip.focus($(this).next(), '请选择虚拟物品模板!');
  354. full = false;
  355. return false;
  356. }
  357. });
  358. if (!has) {
  359. $('#myTab a[href="#tab_option"]').tab('show');
  360. util.message('您的商品类型为:虚拟物品(卡密)的多规格形式,请添加规格!');
  361. return false;
  362. }
  363. }
  364. }
  365. if (!full) {
  366. return false;
  367. }
  368. full = checkoption();
  369. if (!full) {
  370. return false;
  371. }
  372. if (optionchanged) {
  373. $('#myTab a[href="#tab_option"]').tab('show');
  374. alert('规格数据有变动,请重新点击 [刷新规格项目表] 按钮!');
  375. return false;
  376. }
  377. var discountway = $('input:radio[name=discountway]:checked').val();
  378. var discounttype = $('input:radio[name=discounttype]:checked').val();
  379. var returntype = $('input:radio[name=returntype]:checked').val();
  380. var marketprice = $('input:text[name=marketprice]').val();
  381. var isreturn = false;
  382. // Tip.focus("#goodsname", "请输入商品名称!");
  383. // return false;
  384. if (discountway == 1) {
  385. if (discounttype == 1) {
  386. $(".discounts").each(function () {
  387. if (parseFloat($(this).val()) <= 0 || parseFloat($(this).val()) >= 10) {
  388. $(this).val('');
  389. isreturn = true;
  390. alert('请输入正确折扣!');
  391. return false;
  392. }
  393. });
  394. } else {
  395. $(".discounts2").each(function () {
  396. if (parseFloat($(this).val()) <= 0 || parseFloat($(this).val()) >= 10) {
  397. $(this).val('');
  398. isreturn = true;
  399. alert('请输入正确折扣!');
  400. return false;
  401. }
  402. });
  403. }
  404. } else {
  405. if (discounttype == 1) {
  406. $(".discounts").each(function () {
  407. if (parseFloat($(this).val()) < 0 || parseFloat($(this).val()) >= parseFloat(marketprice)) {
  408. $(this).val('');
  409. isreturn = true;
  410. alert('请输入正确折扣金额!');
  411. return false;
  412. }
  413. });
  414. } else {
  415. $(".discounts2").each(function () {
  416. if (parseFloat($(this).val()) < 0 || parseFloat($(this).val()) >= parseFloat(marketprice)) {
  417. $(this).val('');
  418. isreturn = true;
  419. alert('请输入正确折扣金额!');
  420. return false;
  421. }
  422. });
  423. }
  424. }
  425. if (returntype == 1) {
  426. $(".returns").each(function () {
  427. if (parseFloat($(this).val()) < 0 || parseFloat($(this).val()) >= parseFloat(marketprice)) {
  428. $(this).val('');
  429. isreturn = true;
  430. alert('请输入正确返现金额!');
  431. return false;
  432. }
  433. });
  434. } else {
  435. $(".returns2").each(function () {
  436. if (parseFloat($(this).val()) < 0 || parseFloat($(this).val()) >= parseFloat(marketprice)) {
  437. $(this).val('');
  438. isreturn = true;
  439. alert('请输入正确返现金额!');
  440. return false;
  441. }
  442. });
  443. }
  444. if (isreturn) {
  445. return false;
  446. }
  447. return true;
  448. }
  449. function checkoption() {
  450. var full = true;
  451. if ($("#hasoption").get(0).checked) {
  452. $(".spec_title").each(function (i) {
  453. if ($(this).val() == '') {
  454. $('#myTab a[href="#tab_option"]').tab('show');
  455. Tip.focus(".spec_title:eq(" + i + ")", "请输入规格名称!", "top");
  456. full = false;
  457. return false;
  458. }
  459. });
  460. $(".spec_item_title").each(function (i) {
  461. if ($(this).val() == '') {
  462. $('#myTab a[href="#tab_option"]').tab('show');
  463. Tip.focus(".spec_item_title:eq(" + i + ")", "请输入规格项名称!", "top");
  464. full = false;
  465. return false;
  466. }
  467. });
  468. }
  469. if (!full) {
  470. return false;
  471. }
  472. return full;
  473. }
  474. </script>
  475. <script type="text/javascript">
  476. //鼠标划过显示商品链接二维码
  477. $('.umphp').hover(function () {
  478. var url = $(this).attr('data-url');
  479. var goodsid = $(this).attr('data-goodsid');
  480. $.post("{!! yzWebUrl('shop.goods') !!}"
  481. , {'op': 'goods_qrcode', id: goodsid, url: url}
  482. , function (qr) {
  483. if (qr.img) {
  484. var goodsqr = qr.img;
  485. var element = document.getElementById(goodsid);
  486. element.src = goodsqr;
  487. }
  488. }
  489. , "json"
  490. );
  491. $(this).addClass("selected");
  492. },
  493. function () {
  494. $(this).removeClass("selected");
  495. })
  496. function fastChange(id, type, value) {
  497. $.ajax({
  498. url: "{!! yzWebUrl('shop.goods') !!}",
  499. type: "post",
  500. data: {op: 'change', id: id, type: type, value: value},
  501. cache: false,
  502. success: function () {
  503. location.reload();
  504. }
  505. })
  506. }
  507. $(function () {
  508. $("form").keypress(function (e) {
  509. if (e.which == 13) {
  510. return false;
  511. }
  512. });
  513. $('.tdedit input').keydown(function (event) {
  514. if (event.keyCode == 13) {
  515. var group = $(this).closest('.input-group');
  516. var type = group.find('button').data('type');
  517. var goodsid = group.find('button').data('goodsid');
  518. var val = $.trim($(this).val());
  519. if (type == 'title' && val == '') {
  520. return;
  521. }
  522. group.prev().show().find('span').html(val);
  523. group.hide();
  524. fastChange(goodsid, type, val);
  525. }
  526. })
  527. $('.tdedit').mouseover(function () {
  528. $(this).find('.fa-pencil').show();
  529. }).mouseout(function () {
  530. $(this).find('.fa-pencil').hide();
  531. });
  532. $('.fa-edit-item').click(function () {
  533. var group = $(this).closest('span').hide().next();
  534. group.show().find('button').unbind('click').click(function () {
  535. var type = $(this).data('type');
  536. var goodsid = $(this).data('goodsid');
  537. var val = $.trim(group.find(':input').val());
  538. if (type == 'title' && val == '') {
  539. Tip.show(group.find(':input'), '请输入名称!');
  540. return;
  541. }
  542. group.prev().show().find('span').html(val);
  543. group.hide();
  544. fastChange(goodsid, type, val);
  545. });
  546. })
  547. })
  548. function setProperty(obj, id, type) {
  549. $(obj).html($(obj).html() + "...");
  550. $.post("{!! yzWebUrl('goods.goods.index') !!}"
  551. , {'op': 'setgoodsproperty', id: id, type: type, plugin: "", data: obj.getAttribute("data")}
  552. , function (d) {
  553. $(obj).html($(obj).html().replace("...", ""));
  554. if (type == 'type') {
  555. $(obj).html(d.data == '1' ? '实体物品' : '虚拟物品');
  556. }
  557. if (type == 'status') {
  558. $(obj).html(d.data == '1' ? '{{$lang['putaway']}}' : '{{$lang['soldout']}}');
  559. }
  560. $(obj).attr("data", d.data);
  561. if (d.result == 1) {
  562. $(obj).toggleClass("label-info text-pinfo");
  563. }
  564. }
  565. , "json"
  566. );
  567. }
  568. </script>
  569. <link rel="stylesheet" type="text/css" href="{{static_url('css/font-awesome.min.css')}}">
  570. {{--<link href="{{static_url('yunshop/goods/goods.css')}}" media="all" rel="stylesheet" type="text/css"/>--}}
  571. <div class="right-titpos">
  572. <ul class="add-snav">
  573. <li class="active"><a href="#"><i class="fa fa-circle-o" style="color: #33b5d2;"></i>商品编辑</a></li>
  574. </ul>
  575. </div>
  576. {{--<div class="main rightlist">--}}
  577. <form id="goods-edit" action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
  578. <div class="panel-default panel-center">
  579. <!-- <div class="panel-heading">
  580. {if empty($goods['id'])}添加商品{else}编辑商品{/if}
  581. </div> -->
  582. <div class="top">
  583. <ul class="add-shopnav" id="myTab">
  584. <li class="active"><a href="#tab_basic">基本信息</a></li>
  585. <li><a href="#tab_des">{{$lang['shopdesc']}}</a></li>
  586. <li><a href="#tab_param">属性</a></li>
  587. <li><a href="#tab_option">{{$lang['shopoption']}}</a></li>
  588. @section('goods_widget_title')
  589. @foreach(\app\common\modules\widget\Widget::current()->getItem('goods') as $key=>$value)
  590. <li><a href="#{{$key}}">{{$value['title']}}</a></li>
  591. @endforeach
  592. @show
  593. </ul>
  594. </div>
  595. <div class="info">
  596. <div class="panel-body">
  597. <div class="tab-content">
  598. <div class="tab-pane active" id="tab_basic">@include('goods.basic')</div>
  599. <div class="tab-pane" id="tab_des">@include('goods.des')</div>
  600. <div class="tab-pane" id="tab_param">@include('goods.tpl.param')</div>
  601. <div class="tab-pane" id="tab_option">@include('goods.tpl.option')</div>
  602. @section('goods_widget_view')
  603. @foreach(\app\common\modules\widget\Widget::current()->getItem('goods') as $key=>$value)
  604. <div class="tab-pane"
  605. id="{{$key}}">{!! widget($value['class'], ['goods_id'=> $goods->id])!!}</div>
  606. @endforeach
  607. @show
  608. </div>
  609. <div class="form-group col-sm-12 mrleft40 border-t">
  610. <input type="submit" name="submit" value="{{$lang['shopsubmit']}}" class="btn btn-success"
  611. onclick="return formcheck()"/>
  612. <input type="hidden" name="token" value="{{$var['token']}}"/>
  613. @section('back')
  614. <input type="button" name="back" value="返回列表" class="btn btn-default back"/>
  615. @show
  616. </div>
  617. </div>
  618. </div>
  619. </div>
  620. </form>
  621. {{--</div>--}}
  622. @endsection('content')