説明なし

customerGiftAdd.blade.php 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. @extends('admin/master')
  2. @section('content')
  3. <body>
  4. @if(count($errors) > 0)
  5. <div class="Huialert Huialert-info" id="error">
  6. @foreach($errors->all() as $error)
  7. <li>{{$error}}</li>
  8. @endforeach
  9. </div>
  10. @endif
  11. <div class="page-container">
  12. <form action="/admin/customer/giftStore" method="post" class="form form-horizontal" enctype="multipart/form-data">
  13. <input type="hidden" name="_token" value="{{ csrf_token() }}" />
  14. <div class="row cl">
  15. <label class="form-label col-xs-4 col-sm-2"><font color='red'>* </font>搜索选择商品:</label>
  16. <div class="formControls col-xs-6 col-sm-6">
  17. <input type='text' class="input-text" autocomplete="off" name='goods_name' placeholder="输入关键词搜索商品,C仓必须选择" value="{{old('goods_name')}}"/>
  18. <ul id="good_sku"></ul>
  19. </div>
  20. </div>
  21. <div class="row cl">
  22. <label class="form-label col-xs-4 col-sm-2">
  23. <font color='red'>* </font>已选择商品:</label>
  24. <div id='goods_o' name='goods_o_con' class="formControls col-xs-6 col-sm-6">
  25. </div>
  26. </div>
  27. <div class="row cl">
  28. <label class="form-label col-xs-4 col-sm-2">
  29. 类型:</label>
  30. <div class="formControls col-xs-6 col-sm-6">
  31. <select style="text-align:center" id='type' name="type" class="select-box">
  32. <option value="1" @if(old('type')==1) selected @endif>生日赠礼</option>
  33. <option value="0" @if(old('type')==0) selected @endif>12月赠礼</option>
  34. </select>
  35. </div>
  36. </div>
  37. <div class="row cl">
  38. <label class="form-label col-xs-4 col-sm-2">
  39. 日期:</label>
  40. <div class="formControls col-xs-6 col-sm-6">
  41. <input type="text" onfocus="WdatePicker({ dateFmt:'yyyy-MM' })" autocomplete="off" class="input-text Wdate" name="mtime" value="{{old('mtime')}}">
  42. <br>
  43. </div>
  44. </div>
  45. <div class="row cl">
  46. <div class="col-9 col-offset-2">
  47. <button class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>&nbsp;
  48. <button class="btn btn-default" type="reset" onclick="return_index();">&nbsp;&nbsp;返回&nbsp;&nbsp;</button>&nbsp;
  49. {{--<a href="javascript:void(0)" class="btn btn-default radius" onclick="redirect('{{url('/admin/admin/all')}}')">返回并查看结果</a>--}}
  50. </div>
  51. </div>
  52. </form>
  53. </div>
  54. <!--_footer 作为公共模版分离出去-->
  55. <script type="text/javascript" src="/admin/lib/jquery/1.9.1/jquery.min.js"></script>
  56. <script type="text/javascript" src="/admin/lib/layer/2.4/layer.js"></script>
  57. <script type="text/javascript" src="/admin/static/h-ui/js/H-ui.min.js"></script>
  58. <script type="text/javascript" src="/admin/static/h-ui.admin/js/H-ui.admin.js"></script>
  59. <!--/_footer 作为公共模版分离出去-->
  60. <!--请在下方写此页面业务相关的脚本-->
  61. <script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
  62. <script type="text/javascript">
  63. $(function(){
  64. setTimeout("$('#error').hide()",3000);
  65. var dtime = today();
  66. $('#createTime').val(dtime);
  67. var tdate = today_date();
  68. $('#delivery').val(tdate);
  69. $('#category').change(function(){
  70. category = $('#category').val();
  71. if(category==''){
  72. return false;
  73. }
  74. $.ajax({
  75. 'url':'/admin/order/categoods/'+category,
  76. 'type': 'get',
  77. 'dataType':'json',
  78. 'success' : function(data){
  79. str = '<option value=\'0\'>-- 选择商品 --<\/option>';
  80. $.each(data, function(i, va){
  81. var props = va.props_name;
  82. if(props != ''){
  83. props = '【' + props + '】';
  84. }
  85. var price = va.price;
  86. if(price > 0){
  87. price = '【¥' + price + '元】';
  88. }else{
  89. price = '';
  90. }
  91. str += '<option value="'+va.id+'">' + va.goods_name + props + price +'<\/option>';
  92. })
  93. $('#goods').html(str);
  94. }
  95. });
  96. })
  97. });
  98. function add_goods(goods_id,sku_id,name,props_name,price,is_weigh){
  99. //只可以选择一种商品
  100. var length = $('#goods_o').children().length;
  101. if(length > 0){
  102. alert('只可以添加一个商品,请先移除现有商品');
  103. return false;
  104. }
  105. var gnum = $("#gnum"+sku_id).val();
  106. var weigh_unit = '数量';
  107. var weigh_note = '';
  108. var weigh_unit_name = '';
  109. if(is_weigh == 1){
  110. weigh_unit = '重量';
  111. weigh_unit_name = '(斤)';
  112. weigh_note = '<font color=\'red\'> (称重商品,至少0.5斤) <\/font>';
  113. }
  114. if(gnum){
  115. var n = gnum;
  116. n = parseFloat(n)+1
  117. $("#gnum"+sku_id).val(n);
  118. }
  119. else{
  120. var str = "<div>"+name+' 【 规格:'+props_name+' 价格:¥'+price+" 】&nbsp; <input type='hidden' name='skus[]' value="+sku_id+" \/><font style=\"font-weight: bold;\">"+weigh_unit+" <\/font><button style='width:14px;' type='button' onclick=\"cut_num("+sku_id+","+ price + ","+ is_weigh +")\">-<\/button><div style=\"display:inline-block\" id='gnum_con"+ sku_id +"' ><input style='width:40px;' id='gnum"+ sku_id +"' class='gnums' onkeyup='sync_money();' price="+price+" is_weigh="+is_weigh+" type=\'text\' name=\'gnum[]\' value=1 \/><\/div><button style='width:14px;' type='button' onclick=\"add_num("+sku_id+","+ price + ","+ is_weigh +")\">+<\/button>"+weigh_unit_name+" &nbsp;&nbsp;<button type='button' onclick='del_sku(this, "+sku_id+","+ price + ")'> 移除<\/button> &nbsp;&nbsp;"+weigh_note+"<\/div>";
  121. $("#goods_o").append(str);
  122. sessionStorage.setItem('goods_o_con',$("#goods_o").html());
  123. }
  124. sync_money()
  125. document.getElementById('good_sku').style.display='none'
  126. return false;
  127. }
  128. function add_num(sku_id, price, is_weigh){
  129. var gnum = $("#gnum"+sku_id).val();
  130. var n = gnum;
  131. n = parseFloat(n)+1
  132. $("#gnum"+sku_id).val(n);
  133. $("#gnum_con" + sku_id).html("<input style='width:40px;' id='gnum"+ sku_id +"' class='gnums' onkeyup='sync_money();' price="+price+" is_weigh="+is_weigh+" type=\'text\' name=\'gnum[]\' value=" + n + " \/>")
  134. sessionStorage.setItem('goods_o_con',$("#goods_o").html());
  135. sync_money()
  136. return false;
  137. }
  138. function cut_num(sku_id, price, is_weigh){
  139. var gnum = $("#gnum"+sku_id).val();
  140. var n = gnum;
  141. if(n == 1){
  142. return false;
  143. }
  144. n = parseFloat(n)-1;
  145. $("#gnum"+sku_id).val(n);
  146. $("#gnum_con" + sku_id).html("<input style='width:40px;' id='gnum"+ sku_id +"' class='gnums' onkeyup='sync_money();' price="+price+" is_weigh="+is_weigh+" type=\'text\' name=\'gnum[]\' value=" + n + " \/>")
  147. sessionStorage.setItem('goods_o_con',$("#goods_o").html());
  148. sync_money()
  149. return false;
  150. }
  151. function del_sku(obj, sku_id, price){
  152. //console.log(obj)
  153. var gnum = $("#gnum"+sku_id).val();
  154. $(obj).parent().remove();
  155. sessionStorage.setItem('goods_o_con',$("#goods_o").html());
  156. sync_money();
  157. }
  158. function sync_money(){
  159. var gnums = new Array();
  160. var total = 0;
  161. $('.gnums').each(function(key, value){
  162. var gnum = $(this).val();
  163. var price = $(this).attr('price');
  164. total = total + parseFloat(price) * parseFloat(gnum);
  165. });
  166. if(total>0){
  167. $("#should_amount").val(total);
  168. $("#should_amount_show").html(total);
  169. }else{
  170. $("#should_amount").val('');
  171. $("#should_amount_show").html('');
  172. }
  173. return false;
  174. }
  175. function today(){
  176. var today=new Date();
  177. var h=today.getFullYear();
  178. var m=today.getMonth()+1;
  179. var d=today.getDate();
  180. var hh=today.getHours();
  181. var mm=today.getMinutes();
  182. var ss=today.getSeconds();
  183. m= m<10?"0"+m:m;
  184. d= d<10?"0"+d:d;
  185. hh = hh < 10 ? "0" + hh:hh;
  186. mm = mm < 10 ? "0" + mm:mm;
  187. ss = ss < 10 ? "0" + ss:ss;
  188. return h+"-"+m+"-"+d+" "+hh+":"+mm+":"+ss;
  189. }
  190. function today_date(){
  191. var today=new Date();
  192. var h=today.getFullYear();
  193. var m=today.getMonth()+1;
  194. var d=today.getDate();
  195. var hh=today.getHours();
  196. var mm=today.getMinutes();
  197. var ss=today.getSeconds();
  198. m= m<10?"0"+m:m;
  199. d= d<10?"0"+d:d;
  200. hh = hh < 10 ? "0" + hh:hh;
  201. mm = mm < 10 ? "0" + mm:mm;
  202. ss = ss < 10 ? "0" + ss:ss;
  203. return h+"-"+m+"-"+d;
  204. }
  205. function getGoods(){
  206. var name = $('input[name=goods_name]').val();
  207. if(!name){
  208. return false;
  209. }
  210. $.ajax({
  211. 'url': '/admin/goods/searchSkus?name='+name,
  212. 'type': 'get',
  213. 'dateType': 'json',
  214. success:function(data){
  215. if(data != '0'){
  216. data = eval("("+data+")");
  217. }
  218. }
  219. })
  220. }
  221. function to_verify(){
  222. if(!form_verify()){
  223. return false;
  224. }
  225. $("input[name=status]").val('1');
  226. var warehouse = $("#warehouse").val();
  227. if(warehouse == 3){
  228. var if_good = $('.gnums');
  229. if(!if_good.length){
  230. layer.msg('仓库C必须选择商品!',{icon:2,time:1500});
  231. return false;
  232. }
  233. }
  234. $(".btn").attr("disabled",true);
  235. //console.log('disabled')
  236. $("#order-form").submit();
  237. return true;
  238. }
  239. // $("#goods_o").append(sessionStorage.getItem('goods_o_con'));
  240. $('input[name=goods_name]').on('keyup focus', function(){
  241. var name = $('input[name=goods_name]').val();
  242. if(!name){
  243. return false;
  244. }
  245. $.ajax({
  246. 'url': '/admin/goods/searchSkus?name='+name,
  247. 'type': 'get',
  248. 'dateType': 'json',
  249. success:function(data){
  250. if(data != '0'){
  251. data = eval("("+data+")");
  252. var str = '';
  253. for (var i = 0, l = data.length; i < l; i++) {
  254. var item = data[i];
  255. var weigh_t = '';
  256. if(item.is_weigh==1){
  257. weigh_t = '【按半斤称重】';
  258. }
  259. if(item.is_white == 0 && item.quantity <= 0){
  260. weigh_t += '<font color="red">【库存不足】<\/font>';
  261. str += '<li>'+ item.name+'【 规格:'+item.propsName+'&nbsp;&nbsp; 价格:¥'+item.price +' 】'+weigh_t+'<\/li>'
  262. }
  263. else{
  264. str += '<li onclick=\'add_goods('+item.goods_id+','+item.sku_id+',"'+item.name+'","'+item.propsName+'",'+item.price+','+item.is_weigh+');\'>'+ item.name+'【 规格:'+item.propsName+'&nbsp;&nbsp; 价格:¥'+item.price +' 】'+weigh_t+'<\/li>'
  265. }
  266. // '<p onclick=\'add_goods('+item.goods_id+','+item.sku_id+',"'+item.name+'","'+item.propsName+'",'+item.price+');\'>'+ item.name+' '+item.propsName+' ¥'+item.price +'<\/p>';
  267. }
  268. document.getElementById('good_sku').innerHTML = str;
  269. document.getElementById('good_sku').style.display='block'
  270. }
  271. }
  272. })
  273. });
  274. $("body").on('click', function(){
  275. $('input[name=goods_name]').on('click',function(e){
  276. e.stopPropagation();
  277. });
  278. document.getElementById('good_sku').style.display='none'
  279. })
  280. function weigh_verify(){
  281. var if_no = 0;
  282. $('.gnums').each(function(key, value){
  283. var gnum = $(this).val();
  284. gnum = parseFloat(gnum);
  285. var is_weigh = $(this).attr('is_weigh');
  286. if(gnum<0.5){
  287. if_no = 1;
  288. return;
  289. }
  290. if(is_weigh == 0 && gnum%1 != 0){
  291. if_no = 2;
  292. return;
  293. }
  294. if(is_weigh == 1 && gnum%0.5 != 0){
  295. if_no = 3;
  296. return;
  297. }
  298. });
  299. return if_no;
  300. }
  301. /*返回*/
  302. function return_index(){
  303. location.href='/admin/customer/giftList';
  304. }
  305. </script>
  306. </body>
  307. @endsection