edit.blade.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. @extends('layouts.base')
  2. @section('content')
  3. @section('title', trans('套餐详情'))
  4. <script type="text/javascript">
  5. window.optionchanged = false;
  6. require(['bootstrap'], function () {
  7. $('#myTab a').click(function (e) {
  8. e.preventDefault();
  9. $(this).tab('show');
  10. })
  11. });
  12. require(['util'], function (u) {
  13. $('#cp').each(function () {
  14. u.clip(this, $(this).text());
  15. });
  16. });
  17. function formCheck() {
  18. var checkResult = true;
  19. var reg = /(^[-+]?[1-9]\d*(\.\d{1,2})?$)|(^[-+]?[0]{1}(\.\d{1,2})?$)/; //金额字段验证,后两位小数
  20. var numerictype = /^(0|[1-9]\d*)$/; //整数验证
  21. var thumb = /\.(gif|jpg|jpeg|png|GIF|JPG|PNG)$/;
  22. 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})/;
  23. //套餐标题不能为空
  24. if ($(':input[name="package[title]"]').val() == '') {
  25. $('#myTab a[href="#tab_basic"]').tab('show');
  26. alert("请输入套餐名称!");
  27. Tip.focus("#package_title", "请输入套餐名称!");
  28. checkResult = false;
  29. return checkResult;
  30. }
  31. //套餐标题不能超过40字符
  32. if ($(':input[name="package[title]"]').val().length >= '50') {
  33. $('#myTab a[href="#tab_basic"]').tab('show');
  34. alert("套餐名称不能超过50个字符!");
  35. Tip.focus("#package_title", "套餐名称不能超过50个字符!");
  36. checkResult = false;
  37. return checkResult;
  38. }
  39. //图片如果不为空则类型必须为图片
  40. if ($.trim($(':input[name="package[thumb]"]').val()) != '') {
  41. if (!thumb.test($.trim($(':input[name="package[thumb]"]').val()))) {
  42. $('#myTab a[href="#tab_basic"]').tab('show');
  43. alert("图片类型必须是.gif,jpeg,jpg,png中的一种.");
  44. Tip.focus(':input[name="package[thumb]"]', '图片类型必须是.gif,jpeg,jpg,png中的一种.');
  45. checkResult = false;
  46. return checkResult;
  47. }
  48. }
  49. //套餐商品必须
  50. if ($(':input[name="package[category][sort][]"]').length <= 0 || $(':input[name="package[category][cate_name][]"]').length <= 0 || $(':input[name="package[category][goods_ids][]"]').length <= 0) {
  51. $('#myTab a[href="#tab_basic"]').tab('show');
  52. alert("请选择套餐商品!");
  53. checkResult = false;
  54. return checkResult;
  55. }
  56. else{
  57. //遍历每一个排序,必须填写并且为数字
  58. $(':input[name="package[category][sort][]"]').each(function(){
  59. if ($(this).val() == '') {
  60. $('#myTab a[href="#tab_basic"]').tab('show');
  61. alert("请输入栏目排序!");
  62. Tip.focus($(this), "请输入栏目排序!");
  63. checkResult = false;
  64. return checkResult;
  65. }
  66. if (!numerictype.test($(this).val())) {
  67. $('#myTab a[href="#tab_basic"]').tab('show');
  68. alert("栏目排序必须为数字!");
  69. Tip.focus($(this), "栏目排序必须为数字!");
  70. checkResult = false;
  71. return checkResult;
  72. }
  73. });
  74. if(!checkResult) {
  75. return checkResult;
  76. }
  77. //栏目
  78. $(':input[name="package[category][cate_name][]"]').each(function(){
  79. if ($(this).val() == '') {
  80. $('#myTab a[href="#tab_basic"]').tab('show');
  81. alert("栏目不能为空!");
  82. Tip.focus($(this), "栏目不能为空!");
  83. checkResult = false;
  84. return checkResult;
  85. }
  86. if ($(this).val().length >= '50') {
  87. $('#myTab a[href="#tab_basic"]').tab('show');
  88. alert("栏目名称不能超过50个字符!");
  89. Tip.focus($(this), "栏目名称不能超过50个字符!");
  90. checkResult = false;
  91. return checkResult;
  92. }
  93. });
  94. if(!checkResult) {
  95. return checkResult;
  96. }
  97. //商品id
  98. $(':input[name="package[category][goods_ids][]"]').each(function(){
  99. if ($(this).val() == '') {
  100. $('#myTab a[href="#tab_basic"]').tab('show');
  101. alert("请选择商品!");
  102. Tip.focus($(this), "商品为空,请选择商品!");
  103. checkResult = false;
  104. return checkResult;
  105. }
  106. });
  107. if (!checkResult) {
  108. return checkResult;
  109. }
  110. }
  111. //优惠价格如果填写,则必须数字
  112. if ($.trim($(':input[name="package[on_sale_price]"]').val()) != '') {
  113. if (!reg.test($(':input[name="package[on_sale_price]"]').val())) {
  114. $('#myTab a[href="#tab_basic"]').tab('show');
  115. alert("套餐优惠价格格式错误,必须为数字并且最多两位小数!");
  116. Tip.focus(':input[name="package[on_sale_price]"]', '套餐优惠价格格式错误,最多两位小数.');
  117. checkResult = false;
  118. return checkResult;
  119. }
  120. }
  121. //搭配,如果开启则必须有其他套餐选择,关闭则不需要
  122. if ($(':input[name="package[other_package_status]"]').get(0).checked) {
  123. if($(':input[name="package[other_package_ids][]"]').length == 0) {
  124. $('#myTab a[href="#tab_basic"]').tab('show');
  125. alert("请选择搭配套餐!");
  126. checkResult = false;
  127. return checkResult;
  128. } else {
  129. //对每一个id都要验证
  130. $(':input[name="package[other_package_ids][]"]').each(function(){
  131. if($(this).val() == '') {
  132. $('#myTab a[href="#tab_basic"]').tab('show');
  133. alert("搭配套餐不能为空!");
  134. checkResult = false;
  135. return checkResult;
  136. }
  137. });
  138. }
  139. }
  140. //幻灯片,如果有,则它的排序必须为数字
  141. if ($('.carousel_is_open').length > 0) {
  142. $('.carousel_sort').each(function(){
  143. if ($(this).val() == '') {
  144. $('#myTab a[href="#tab_carousel"]').tab('show');
  145. alert("幻灯片排序必须填写并且为数字!");
  146. checkResult = false;
  147. return checkResult;
  148. }
  149. if (!numerictype.test($(this).val())) {
  150. $('#myTab a[href="#tab_carousel"]').tab('show');
  151. alert("幻灯片排序必须是数字!");
  152. checkResult = false;
  153. return checkResult;
  154. }
  155. });
  156. }
  157. return checkResult;
  158. }
  159. </script>
  160. <script type="text/javascript">
  161. //鼠标划过显示商品链接二维码
  162. $('.umphp').hover(function () {
  163. var url = $(this).attr('data-url');
  164. var goodsid = $(this).attr('data-goodsid');
  165. $.post("{!! yzWebUrl('shop.goods') !!}"
  166. , {'op': 'goods_qrcode', id: goodsid, url: url}
  167. , function (qr) {
  168. if (qr.img) {
  169. var goodsqr = qr.img;
  170. var element = document.getElementById(goodsid);
  171. element.src = goodsqr;
  172. }
  173. }
  174. , "json"
  175. );
  176. $(this).addClass("selected");
  177. },
  178. function () {
  179. $(this).removeClass("selected");
  180. })
  181. function fastChange(id, type, value) {
  182. $.ajax({
  183. url: "{!! yzWebUrl('shop.goods') !!}",
  184. type: "post",
  185. data: {op: 'change', id: id, type: type, value: value},
  186. cache: false,
  187. success: function () {
  188. location.reload();
  189. }
  190. })
  191. }
  192. $(function () {
  193. $("form").keypress(function (e) {
  194. if (e.which == 13) {
  195. return false;
  196. }
  197. });
  198. $('.tdedit input').keydown(function (event) {
  199. if (event.keyCode == 13) {
  200. var group = $(this).closest('.input-group');
  201. var type = group.find('button').data('type');
  202. var goodsid = group.find('button').data('goodsid');
  203. var val = $.trim($(this).val());
  204. if (type == 'title' && val == '') {
  205. return;
  206. }
  207. group.prev().show().find('span').html(val);
  208. group.hide();
  209. fastChange(goodsid, type, val);
  210. }
  211. })
  212. $('.tdedit').mouseover(function () {
  213. $(this).find('.fa-pencil').show();
  214. }).mouseout(function () {
  215. $(this).find('.fa-pencil').hide();
  216. });
  217. $('.fa-edit-item').click(function () {
  218. var group = $(this).closest('span').hide().next();
  219. group.show().find('button').unbind('click').click(function () {
  220. var type = $(this).data('type');
  221. var goodsid = $(this).data('goodsid');
  222. var val = $.trim(group.find(':input').val());
  223. if (type == 'title' && val == '') {
  224. Tip.show(group.find(':input'), '请输入名称!');
  225. return;
  226. }
  227. group.prev().show().find('span').html(val);
  228. group.hide();
  229. fastChange(goodsid, type, val);
  230. });
  231. })
  232. })
  233. </script>
  234. <link rel="stylesheet" type="text/css" href="{{static_url('css/font-awesome.min.css')}}">
  235. <div class="right-titpos">
  236. <ul class="add-snav">
  237. <li class="active"><a href="#"><i class="fa fa-circle-o" style="color: #33b5d2;"></i>套餐信息</a></li>
  238. </ul>
  239. </div>
  240. <form id="goods-edit" action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
  241. <div class="panel-default panel-center">
  242. @if(!empty($package['id']))
  243. <input type="hidden" name="package[id]" value="{{ $package['id'] }}" />
  244. <input type="hidden" name="route" value="plugin.goods-package.admin.package.edit" id="route" />
  245. @else
  246. <input type="hidden" name="route" value="plugin.goods-package.admin.package.create" id="route" />
  247. @endif
  248. <div class="top">
  249. <ul class="add-shopnav" id="myTab">
  250. <li class="active"><a href="#tab_basic">基本信息</a></li>
  251. <li><a href="#tab_share">分享设置</a></li>
  252. <li><a href="#tab_carousel">幻灯片</a></li>
  253. <li><a href="#tab_desc">套餐描述</a></li>
  254. </ul>
  255. </div>
  256. <div class="info">
  257. <div class="panel-body">
  258. <div class="tab-content">
  259. <div class="tab-pane active" id="tab_basic">@include('Yunshop\GoodsPackage::admin.detail.basic')</div>
  260. <div class="tab-pane" id="tab_share">@include('Yunshop\GoodsPackage::admin.detail.share')</div>
  261. <div class="tab-pane" id="tab_carousel">@include('Yunshop\GoodsPackage::admin.carousel.carousel_list')</div>
  262. <div class="tab-pane" id="tab_desc">@include('Yunshop\GoodsPackage::admin.detail.desc')</div>
  263. </div>
  264. <div class="form-group col-sm-12 mrleft40 border-t">
  265. <input type="submit" name="submit" value="提交" onclick="return formCheck()" class="btn btn-success"/> <!-- -->
  266. <input type="hidden" name="token" value="{{$var['token']}}"/>
  267. @section('back')
  268. <a href="{{yzWebUrl('plugin.goods-package.admin.package.index')}}"><input type="button" name="back" style='margin-left:10px;' value="返回列表" class="btn btn-default" /></a>
  269. @show
  270. </div>
  271. </div>
  272. </div>
  273. </div>
  274. </form>
  275. {{--</div>--}}
  276. @endsection('content')