goods.blade.php.bf 31 KB

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