Нет описания

ordercreate.blade.php 36KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830
  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. <style type="text/css">
  12. #good_sku{
  13. position: absolute;
  14. z-index: 9;
  15. background: #ffffff;
  16. box-shadow: 1px 1px 1px 1px #ccc;
  17. width: calc(100% - 30px);
  18. }
  19. #good_sku li{
  20. font-size: 12px;
  21. line-height: 24px;
  22. cursor: pointer;
  23. padding: 5px 10px;
  24. }
  25. #good_sku li:hover{
  26. background: #eaeaea;
  27. }
  28. </style>
  29. <div class="page-container">
  30. <form id='order-form' action="/admin/fxorder/store" method="post" class="form form-horizontal" enctype="multipart/form-data" onkeypress="return event.keyCode != 13;">
  31. <input type="hidden" name="_token" value="{{ csrf_token() }}" />
  32. <input type="hidden" name="status" value="0" />
  33. <input type='hidden' name='last_url' value="{{$last_url}}"/>
  34. <div class="row cl">
  35. <label class="form-label col-xs-4 col-sm-2">
  36. <font color='red'>* </font>买家姓名:</label>
  37. <div class="formControls col-xs-6 col-sm-6">
  38. <input type="text" class="input-text" value="{{old('customerName')}}" placeholder="请输入名称" name="customerName">
  39. </div>
  40. </div>
  41. <div class="row cl">
  42. <label class="form-label col-xs-4 col-sm-2">
  43. <font color='red'>* </font>收件人姓名:</label>
  44. <div class="formControls col-xs-6 col-sm-6">
  45. <input type="text" class="input-text" value="{{old('receiverName')}}" placeholder="" name="receiverName">
  46. </div>
  47. </div>
  48. <div class="row cl">
  49. <label class="form-label col-xs-4 col-sm-2">
  50. <font color='red'>* </font>收件人手机号:</label>
  51. <div class="formControls col-xs-6 col-sm-6">
  52. <input type="text" class="input-text" value="{{old('receiverMobile')}}" placeholder="" onkeyup="getAddress()" name="receiverMobile">
  53. </div>
  54. </div>
  55. <div id='fanTime_div' class="row cl">
  56. <label class="form-label col-xs-4 col-sm-2">
  57. <font color='red'>* </font>加粉时间:</label>
  58. <div class="formControls col-xs-6 col-sm-6">
  59. <input id="stime" type="text" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' })" autocomplete="off" class="input-text Wdate" style="width:22%;text-align:center;" name="fanTime" value="{{old('fanTime')}}">
  60. </div>
  61. </div>
  62. <div class="row cl">
  63. <label class="form-label col-xs-4 col-sm-2">
  64. <font color='red'>* </font>省/直辖市:</label>
  65. <div class="formControls col-xs-6 col-sm-6">
  66. <input type="text" class="input-text" value="{{old('receiverState')}}" placeholder="" name="receiverState">
  67. </div>
  68. </div>
  69. <div class="row cl">
  70. <label class="form-label col-xs-4 col-sm-2">
  71. <font color='red'>* </font>市:</label>
  72. <div class="formControls col-xs-6 col-sm-6">
  73. <input type="text" class="input-text" value="{{old('receiverCity')}}" placeholder="" name="receiverCity">
  74. </div>
  75. </div>
  76. <!--div class="row cl">
  77. <label class="form-label col-xs-4 col-sm-2">
  78. 区:</label>
  79. <div class="formControls col-xs-6 col-sm-6">
  80. <input type="text" class="input-text" value="{{old('receiverDistrict')}}" placeholder="" name="receiverDistrict">
  81. </div>
  82. </div>
  83. <div class="row cl">
  84. <label class="form-label col-xs-4 col-sm-2">
  85. 街道:</label>
  86. <div class="formControls col-xs-6 col-sm-6">
  87. <input type="text" class="input-text" value="{{old('receiverStreet')}}" placeholder="" name="receiverStreet">
  88. </div>
  89. </div-->
  90. <div class="row cl">
  91. <label class="form-label col-xs-4 col-sm-2">
  92. <font color='red'>* </font>详细地址:</label>
  93. <div class="formControls col-xs-6 col-sm-6">
  94. <input type="text" class="input-text" value="{{old('receiverAddress')}}" placeholder="" name="receiverAddress">
  95. </div>
  96. </div>
  97. @if($self_role !='分销销售' && $self_role != '分销管理员' )
  98. <div class="row cl">
  99. <label class="form-label col-xs-4 col-sm-2">
  100. <font color='red'>* </font>商品信息:</label>
  101. <div class="formControls col-xs-6 col-sm-6">
  102. <textarea class="textarea" placeholder="填写商品详细信息,A或B仓必填" name="goods_note">{{old('goods_note')}}</textarea>
  103. </div>
  104. </div>
  105. @endif
  106. <div class="row cl">
  107. <label class="form-label col-xs-4 col-sm-2">
  108. <font color='red'>* </font>预发货时间:</label>
  109. <div class="formControls col-xs-6 col-sm-6">
  110. <input id="delivery" type="text" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' })" autocomplete="off" class="input-text Wdate" style="width:22%;text-align:center;" name="delivery_date" value="{{old('delivery_date')}}"> <font color='red'> *默认今天 </font>
  111. </div>
  112. </div>
  113. @if($self_role !='分销销售' && $self_role != '分销管理员' )
  114. <div class="row cl">
  115. <label class="form-label col-xs-4 col-sm-2">
  116. 物流单号:</label>
  117. <div class="formControls col-xs-6 col-sm-6">
  118. <input type="text" class="input-text" value="{{old('logistics_id')}}" placeholder="" name="logistics_id">
  119. </div>
  120. </div>
  121. @endif
  122. <div class="row cl">
  123. <label class="form-label col-xs-4 col-sm-2">
  124. <font color='red'>* </font>发货仓库:</label>
  125. <div class="formControls col-xs-6 col-sm-6">
  126. <span class="select-box">
  127. <select size="1" name="warehouse" id='warehouse'>
  128. @if($self_role == '超级管理员' || $self_role == '售后管理员')
  129. <option value="0" @if(old('warehouse')=='0') selected @endif>- 请选择 -</option>
  130. <option value="1" @if(old('warehouse')=='1') selected @endif>A仓库</option>
  131. <option value="2" @if(old('warehouse')=='2') selected @endif>B仓库</option>
  132. <option value="3" @if(old('warehouse')=='3') selected @endif>C仓库</option>
  133. @else
  134. <option value="3" selected >C仓库</option>
  135. @endif
  136. </select>
  137. </span>
  138. </div>
  139. </div>
  140. @if($self_role !='销售' && $self_role != '分销销售')
  141. <div class="row cl">
  142. <label class="form-label col-xs-4 col-sm-2">
  143. 成本:</label>
  144. <div class="formControls col-xs-6 col-sm-6">
  145. <input type="text" class="input-text" value="{{old('cost')}}" placeholder="" name="cost">
  146. </div>
  147. </div>
  148. @endif
  149. <div class="row cl">
  150. <label class="form-label col-xs-4 col-sm-2"><font color='red'>* </font>搜索选择商品:</label>
  151. <div class="formControls col-xs-6 col-sm-6">
  152. <input type='text' class="input-text" autocomplete="off" name='goods_name' placeholder="输入关键词搜索商品,C仓必须选择" value="{{old('goods_name')}}"/>
  153. <ul id="good_sku"></ul>
  154. </div>
  155. </div><br>
  156. <div class="row cl">
  157. <label class="form-label col-xs-4 col-sm-2">
  158. <font color='red'>* </font>已选择商品:</label>
  159. <div id='goods_o' name='goods_o_con' class="formControls col-xs-6 col-sm-6">
  160. </div>
  161. </div><br>
  162. <div class="row cl">
  163. <label class="form-label col-xs-4 col-sm-2">
  164. 应收金额:</label>
  165. <div class="formControls col-xs-6 col-sm-6">
  166. <span id='should_amount_show'>{{old('should_amount')}}</span>
  167. <input id='should_amount' type="hidden" class="input-text" value="{{old('should_amount')}}" placeholder="" name="should_amount">
  168. </div>
  169. </div>
  170. <div class="row cl">
  171. <label class="form-label col-xs-4 col-sm-2">
  172. <font color='red'>* </font>实收金额:</label>
  173. <div class="formControls col-xs-6 col-sm-6">
  174. <input id='receivedAmount' type="text" class="input-text" value="{{old('receivedAmount')}}" placeholder="" name="receivedAmount">
  175. </div>
  176. </div>
  177. <div class="row cl">
  178. <label class="form-label col-xs-4 col-sm-2">
  179. <font color='red'>* </font>支付方式:</label>
  180. <div class="formControls col-xs-6 col-sm-6">
  181. <input type="radio" name="payment_type" value="1" @if(old('payment_type')==='1') checked @else checked @endif>
  182. <label for="status-1" style="margin-right: 27px;">微信支付</label>
  183. <!--input type="radio" name="payment_type" value="2" @if(old('payment_type')==='2') checked @endif>
  184. <label for="status-0">付款码支付</label-->
  185. <input type="radio" name="payment_type" value="3" @if(old('payment_type')==='3') checked @endif>
  186. <label for="status-0" style="margin-right: 27px;">个体户支付</label>
  187. @if($self_role != '分销销售' && $self_role != '分销管理员')
  188. <input type="radio" name="payment_type" value="4" @if(old('payment_type')==='4') checked @endif>
  189. <label for="status-0">充值卡支付</label>
  190. @endif
  191. </div>
  192. </div>
  193. <!--div class="row cl" style="display: none" id='deposit_div'>
  194. <label class="form-label col-xs-4 col-sm-2">
  195. <font color='red'> </font>充值卡号:</label>
  196. <div class="formControls col-xs-6 col-sm-6">
  197. <input id='deposit_phone' type="text" class="input-text" onkeyup="getBalance()" value="{{old('deposit_phone')}}" placeholder="" name="deposit_phone">
  198. <font color='red' id='vip_pay'></font>
  199. </div>
  200. </div-->
  201. <div class="row cl" style="display: none" id='deposit_div'>
  202. <label class="form-label col-xs-4 col-sm-2">
  203. <font color='red'> </font>充值卡号:</label>
  204. <div class="formControls col-xs-6 col-sm-6">
  205. <input id='deposit_phone_i' type="text" class="input-text" value="{{old('deposit_phone')}}" placeholder="*默认收货人手机号" disabled name="deposit_phone_i">
  206. <input id='deposit_phone' type="hidden" class="input-text" value="{{old('deposit_phone')}}" placeholder="" name="deposit_phone">
  207. <font color='red' id='vip_pay'></font>
  208. </div>
  209. </div>
  210. <div class="row cl">
  211. <label class="form-label col-xs-4 col-sm-2">
  212. <font color='red'>* </font>是否退补单:</label>
  213. <div class="formControls col-xs-6 col-sm-6">
  214. <input type="radio" name="is_refund" value="0" @if(old('is_refund')==='0') checked @else checked @endif>
  215. <label for="status-1" style="margin-right: 27px;">否</label>
  216. <input type="radio" name="is_refund" value="1" @if(old('is_refund')==='1') checked @endif>
  217. <label for="status-0">是</label>
  218. </div>
  219. </div>
  220. <div class="row cl">
  221. <label class="form-label col-xs-4 col-sm-2">
  222. 应该退补差价:</label>
  223. <div class="formControls col-xs-6 col-sm-6">
  224. <input type="text" class="input-text" value="{{old('refund_price')}}" placeholder="" name="refund_price">
  225. </div>
  226. </div>
  227. <div class="row cl">
  228. <label class="form-label col-xs-4 col-sm-2">
  229. <font color='red'>* </font>下单时间:</label>
  230. <div class="formControls col-xs-6 col-sm-6">
  231. <input id="createTime" type="text" autocomplete="off" class="input-text" style="width:22%;text-align:center;" name="createTime" value="{{$createTime}}" disabled> <font color='red'> *默认当前时间 </font>
  232. </div>
  233. </div>
  234. <div class="row cl">
  235. <label class="form-label col-xs-4 col-sm-2">
  236. 买家备注:</label>
  237. <div class="formControls col-xs-6 col-sm-6">
  238. <textarea class="textarea" placeholder="填写买家备注..." name="buyerMemo">{{old('buyerMemo')}}</textarea>
  239. </div>
  240. </div>
  241. <div class="row cl">
  242. <label class="form-label col-xs-4 col-sm-2">
  243. 卖家备注:</label>
  244. <div class="formControls col-xs-6 col-sm-6">
  245. <textarea class="textarea" placeholder="填写卖家备注..." name="sellerMemo">{{old('sellerMemo')}}</textarea>
  246. </div>
  247. </div>
  248. @if(0)
  249. @if($self_role !='销售' && $self_role != '分销销售' )
  250. <div class="row cl">
  251. <label class="form-label col-xs-4 col-sm-2">
  252. 选择销售员(不选默认当前用户):</label>
  253. <div class="formControls col-xs-6 col-sm-6">
  254. <span class="select-box">
  255. <select size="1" name="team" id='team'>
  256. <option value="0" @if(old('team')=='') selected @endif>选择团队</option>
  257. @foreach($teamlist as $v)
  258. <option value="{{$v['id']}}" @if(old('team')==$v['id']) selected @endif>{{$v['name']}}</option>
  259. @endforeach
  260. </select>
  261. <select id='admins' size="1" name="admin_id">
  262. <option value="0" @if(old('admin_id')=='') selected @endif>-- 选择销售 --</option>
  263. @foreach($adminlist as $v)
  264. <option value="{{$v['id']}}" @if(old('admin_id')==$v['id']) selected @endif>{{$v['realname']}}</option>
  265. @endforeach
  266. </select>
  267. &nbsp;&nbsp;
  268. </span>
  269. </div>
  270. </div>
  271. @endif
  272. @endif
  273. <div class="row cl">
  274. <div class="col-9 col-offset-2">
  275. <button class="btn btn-primary radius" type='button' onclick="to_submit()" value="&nbsp;&nbsp;保存&nbsp;&nbsp;">&nbsp;&nbsp;保存&nbsp;&nbsp;</button>&nbsp;
  276. <button class="btn btn-primary radius" type='button' onclick="to_verify()" value="&nbsp;&nbsp;保存并提审&nbsp;&nbsp;">&nbsp;&nbsp;保存并提审&nbsp;&nbsp;</button>&nbsp;
  277. <button class="btn btn-default" type="reset" onclick="return_index();">&nbsp;&nbsp;返回&nbsp;&nbsp;</button>&nbsp;
  278. </div>
  279. </div>
  280. </form>
  281. </div>
  282. <!--_footer 作为公共模版分离出去-->
  283. <script type="text/javascript" src="/admin/lib/jquery/1.9.1/jquery.min.js"></script>
  284. <script type="text/javascript" src="/admin/lib/layer/2.4/layer.js"></script>
  285. <script type="text/javascript" src="/admin/static/h-ui/js/H-ui.min.js"></script>
  286. <script type="text/javascript" src="/admin/static/h-ui.admin/js/H-ui.admin.js"></script>
  287. <!--/_footer 作为公共模版分离出去-->
  288. <!--请在下方写此页面业务相关的脚本-->
  289. <script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
  290. <script type="text/javascript">
  291. $(function(){
  292. setTimeout("$('#error').hide()",3000);
  293. var dtime = today();
  294. $('#createTime').val(dtime);
  295. var tdate = today_date();
  296. $('#delivery').val(tdate);
  297. $('#category').change(function(){
  298. category = $('#category').val();
  299. if(category==''){
  300. return false;
  301. }
  302. $.ajax({
  303. 'url':'/admin/fxorder/categoods/'+category,
  304. 'type': 'get',
  305. 'dataType':'json',
  306. 'success' : function(data){
  307. str = '<option value=\'0\'>-- 选择商品 --<\/option>';
  308. $.each(data, function(i, va){
  309. var props = va.props_name;
  310. if(props != ''){
  311. props = '【' + props + '】';
  312. }
  313. var price = va.price;
  314. if(price > 0){
  315. price = '【¥' + price + '元】';
  316. }else{
  317. price = '';
  318. }
  319. str += '<option value="'+va.id+'">' + va.goods_name + props + price +'<\/option>';
  320. })
  321. $('#goods').html(str);
  322. }
  323. });
  324. })
  325. $('#team').change(function(){
  326. team = $('#team').val();
  327. if(team==''){
  328. return false;
  329. }
  330. $.ajax({
  331. 'url':'/admin/fxorder/teamAdmins/'+team,
  332. 'type': 'get',
  333. 'dataType':'json',
  334. 'success' : function(data){
  335. str = '<option value=\'0\'>-- 选择销售 --<\/option>';
  336. $.each(data, function(i, va){
  337. str += '<option value="'+va.id+'">' + va.realname +'<\/option>';
  338. })
  339. $('#admins').html(str);
  340. }
  341. });
  342. })
  343. $('input[type=radio][name=payment_type]').change(function () {
  344. var payment_type = $("input[type='radio'][name='payment_type']:checked").val();
  345. if(payment_type==4){
  346. var phone = $("input[name=receiverMobile]").val();
  347. $("#deposit_phone").val(phone);
  348. $("#deposit_phone_i").val(phone);
  349. $("#deposit_div").show();
  350. //获取充值卡余额
  351. var reg = /^1\d{10}$/
  352. if(!reg.test(phone)){
  353. return false;
  354. }
  355. $.ajax({
  356. 'url':'/admin/cust/getBalance/'+phone,
  357. 'type': 'get',
  358. 'success' : function(data){
  359. var str = '【充值卡余额为:'+data+'元】';
  360. $("#vip_pay").html(str);
  361. }
  362. });
  363. }else{
  364. $("#deposit_div").hide();
  365. }
  366. })
  367. });
  368. function getBalance(){
  369. var phone = $("input[name=deposit_phone]").val();
  370. var reg = /^1\d{10}$/
  371. if(!reg.test(phone)){
  372. $("#vip_pay").html('【充值卡余额为:0元】');
  373. return false;
  374. }
  375. //获取充值卡余额
  376. $.ajax({
  377. 'url':'/admin/cust/getBalance/'+phone,
  378. 'type': 'get',
  379. 'success' : function(data){
  380. var str = '【充值卡余额为:'+data+'元】';
  381. $("#vip_pay").html(str);
  382. }
  383. });
  384. }
  385. /*返回*/
  386. function return_index(){
  387. location.href='/admin/fxorder/index';
  388. }
  389. function add_goods(goods_id,sku_id,name,props_name,price,is_weigh,quantity,is_white){
  390. var gnum = $("#gnum"+sku_id).val();
  391. var weigh_unit = '数量';
  392. var weigh_note = '';
  393. var weigh_unit_name = '';
  394. if(is_weigh == 1){
  395. weigh_unit = '重量';
  396. weigh_unit_name = '(斤)';
  397. weigh_note = '<font color=\'red\'> (称重商品,至少0.5斤) <\/font>';
  398. }
  399. if(gnum){
  400. var n = gnum;
  401. n = parseFloat(n)+1
  402. $("#gnum"+sku_id).val(n);
  403. }
  404. else{
  405. var quantity_str = '库存:'+quantity;
  406. if(is_white==1){
  407. quantity_str = '虚拟库存';
  408. }
  409. var str = "<div>"+name+' 【 规格:'+props_name+' 价格:¥'+price+' '+quantity_str+" 】&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 +","+ quantity + ","+ is_white +")\">-<\/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+" quantity="+quantity+" is_white="+is_white+" 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 + ","+ quantity + ","+ is_white +")\">+<\/button>"+weigh_unit_name+" &nbsp;&nbsp;<button type='button' onclick='del_sku(this, "+sku_id+","+ price + ")'> 移除<\/button> &nbsp;&nbsp;"+weigh_note+"<\/div>";
  410. $("#goods_o").append(str);
  411. sessionStorage.setItem('goods_o_con',$("#goods_o").html());
  412. }
  413. sync_money()
  414. document.getElementById('good_sku').style.display='none'
  415. return false;
  416. }
  417. function add_num(sku_id, price, is_weigh, quantity, is_white){
  418. var gnum = $("#gnum"+sku_id).val();
  419. var n = gnum;
  420. n = parseFloat(n)+1
  421. $("#gnum"+sku_id).val(n);
  422. $("#gnum_con" + sku_id).html("<input style='width:40px;' id='gnum"+ sku_id +"' class='gnums' onkeyup='sync_money();' price="+price+" is_weigh="+is_weigh+" quantity="+quantity+" is_white="+is_white+" type=\'text\' name=\'gnum[]\' value=" + n + " \/>")
  423. sessionStorage.setItem('goods_o_con',$("#goods_o").html());
  424. sync_money()
  425. return false;
  426. }
  427. function cut_num(sku_id, price, is_weigh, quantity, is_white){
  428. var gnum = $("#gnum"+sku_id).val();
  429. var n = gnum;
  430. if(n == 1){
  431. return false;
  432. }
  433. n = parseFloat(n)-1;
  434. $("#gnum"+sku_id).val(n);
  435. $("#gnum_con" + sku_id).html("<input style='width:40px;' id='gnum"+ sku_id +"' class='gnums' onkeyup='sync_money();' price="+price+" is_weigh="+is_weigh+" quantity="+quantity+" is_white="+is_white+" type=\'text\' name=\'gnum[]\' value=" + n + " \/>")
  436. sessionStorage.setItem('goods_o_con',$("#goods_o").html());
  437. sync_money()
  438. return false;
  439. }
  440. function del_sku(obj, sku_id, price){
  441. //console.log(obj)
  442. var gnum = $("#gnum"+sku_id).val();
  443. $(obj).parent().remove();
  444. sessionStorage.setItem('goods_o_con',$("#goods_o").html());
  445. sync_money();
  446. }
  447. function sync_money(){
  448. var gnums = new Array();
  449. var total = 0;
  450. $('.gnums').each(function(key, value){
  451. var gnum = $(this).val();
  452. var price = $(this).attr('price');
  453. total = total + parseFloat(price) * parseFloat(gnum);
  454. });
  455. if(total>0){
  456. $("#should_amount").val(total);
  457. $("#should_amount_show").html(total);
  458. }else{
  459. $("#should_amount").val('');
  460. $("#should_amount_show").html('');
  461. }
  462. return false;
  463. }
  464. function today(){
  465. var today=new Date();
  466. var h=today.getFullYear();
  467. var m=today.getMonth()+1;
  468. var d=today.getDate();
  469. var hh=today.getHours();
  470. var mm=today.getMinutes();
  471. var ss=today.getSeconds();
  472. m= m<10?"0"+m:m;
  473. d= d<10?"0"+d:d;
  474. hh = hh < 10 ? "0" + hh:hh;
  475. mm = mm < 10 ? "0" + mm:mm;
  476. ss = ss < 10 ? "0" + ss:ss;
  477. return h+"-"+m+"-"+d+" "+hh+":"+mm+":"+ss;
  478. }
  479. function today_date(){
  480. var today=new Date();
  481. var h=today.getFullYear();
  482. var m=today.getMonth()+1;
  483. var d=today.getDate();
  484. var hh=today.getHours();
  485. var mm=today.getMinutes();
  486. var ss=today.getSeconds();
  487. m= m<10?"0"+m:m;
  488. d= d<10?"0"+d:d;
  489. hh = hh < 10 ? "0" + hh:hh;
  490. mm = mm < 10 ? "0" + mm:mm;
  491. ss = ss < 10 ? "0" + ss:ss;
  492. return h+"-"+m+"-"+d;
  493. }
  494. function getAddress(){
  495. var phone = $('input[name=receiverMobile]').val();
  496. var reg = /^1\d{10}$/
  497. if(reg.test(phone)){
  498. $.ajax({
  499. 'url': '/admin/fxorder/getAddress?phone='+phone,
  500. 'type': 'get',
  501. 'dateType': 'json',
  502. success:function(data){
  503. if(data != '0'){
  504. data = eval("("+data+")");
  505. $("input[name=receiverState]").val(data.receiverState);
  506. $("input[name=receiverCity]").val(data.receiverCity);
  507. //$("input[name=receiverDistrict]").val(data.receiverDistrict);
  508. //$("input[name=receiverStreet]").val(data.receiverStreet);
  509. $("input[name=receiverAddress]").val(data.receiverAddress);
  510. $("input[name=fanTime]").val(data.fanTime);
  511. $("#fanTime_div").hide();
  512. }
  513. else{
  514. $("#fanTime_div").show();
  515. }
  516. }
  517. })
  518. }
  519. }
  520. function getGoods(){
  521. var name = $('input[name=goods_name]').val();
  522. if(!name){
  523. return false;
  524. }
  525. $.ajax({
  526. 'url': '/admin/goods/searchSkus?name='+name,
  527. 'type': 'get',
  528. 'dateType': 'json',
  529. success:function(data){
  530. if(data != '0'){
  531. data = eval("("+data+")");
  532. }
  533. }
  534. })
  535. }
  536. function to_verify(){
  537. if(!form_verify()){
  538. return false;
  539. }
  540. $("input[name=status]").val('1');
  541. var warehouse = $("#warehouse").val();
  542. if(warehouse == 3){
  543. var if_good = $('.gnums');
  544. if(!if_good.length){
  545. layer.msg('仓库C必须选择商品!',{icon:2,time:1500});
  546. return false;
  547. }
  548. }
  549. $(".btn").attr("disabled",true);
  550. //console.log('disabled')
  551. $("#order-form").submit();
  552. return true;
  553. }
  554. function to_submit(){
  555. if(!form_verify()){
  556. return false;
  557. }
  558. $("input[name=status]").val('0');
  559. //console.log('disabled1')
  560. var warehouse = $("#warehouse").val();
  561. if(warehouse == 3){
  562. var if_good = $('.gnums');
  563. if(!if_good.length){
  564. layer.msg('仓库C必须选择商品!',{icon:2,time:1500});
  565. return false;
  566. }
  567. }
  568. $(".btn").attr("disabled",true);
  569. $("#order-form").submit();
  570. return true;
  571. }
  572. $("#goods_o").append(sessionStorage.getItem('goods_o_con'));
  573. $('input[name=goods_name]').on('keyup focus', function(){
  574. var name = $('input[name=goods_name]').val();
  575. if(!name){
  576. return false;
  577. }
  578. $.ajax({
  579. 'url': '/admin/goods/searchSkus',
  580. 'type': 'get',
  581. 'data':{name:name},
  582. 'dateType': 'json',
  583. success:function(data){
  584. if(data != '0'){
  585. data = eval("("+data+")");
  586. var str = '';
  587. for (var i = 0, l = data.length; i < l; i++) {
  588. var item = data[i];
  589. var weigh_t = '';
  590. if(item.is_weigh==1){
  591. weigh_t = '【按半斤称重】';
  592. }
  593. if(item.is_white == 0 && item.quantity <= 0){
  594. weigh_t += '<font color="red">【库存不足】<\/font>';
  595. str += '<li>'+ item.name+'【 规格:'+item.propsName+'&nbsp;&nbsp; 价格:¥'+item.price +' 】'+weigh_t+'<\/li>'
  596. }
  597. else{
  598. str += '<li onclick=\'add_goods('+item.goods_id+','+item.sku_id+',"'+item.name+'","'+item.propsName+'",'+item.price+','+item.is_weigh+','+item.quantity+','+item.is_white+');\'>'+ item.name+'【 规格:'+item.propsName+'&nbsp;&nbsp; 价格:¥'+item.price +' 】'+weigh_t+'<\/li>'
  599. }
  600. // '<p onclick=\'add_goods('+item.goods_id+','+item.sku_id+',"'+item.name+'","'+item.propsName+'",'+item.price+');\'>'+ item.name+' '+item.propsName+' ¥'+item.price +'<\/p>';
  601. }
  602. document.getElementById('good_sku').innerHTML = str;
  603. document.getElementById('good_sku').style.display='block'
  604. }
  605. }
  606. })
  607. });
  608. $("body").on('click', function(){
  609. $('input[name=goods_name]').on('click',function(e){
  610. e.stopPropagation();
  611. });
  612. document.getElementById('good_sku').style.display='none'
  613. })
  614. function weigh_verify(){
  615. var if_no = 0;
  616. $('.gnums').each(function(key, value){
  617. var gnum = $(this).val();
  618. gnum = parseFloat(gnum);
  619. var is_weigh = $(this).attr('is_weigh');
  620. if(gnum<0.5){
  621. if_no = 1;
  622. return;
  623. }
  624. if(is_weigh == 0 && gnum%1 != 0){
  625. if_no = 2;
  626. return;
  627. }
  628. if(is_weigh == 1 && gnum%0.5 != 0){
  629. if_no = 3;
  630. return;
  631. }
  632. var quantity = $(this).attr('quantity');
  633. var is_white = $(this).attr('is_white');
  634. if(is_white==0 && gnum>quantity){
  635. if_no=4;
  636. return;
  637. }
  638. });
  639. return if_no;
  640. }
  641. function form_verify(){
  642. var customerName = $("input[name=customerName]").val();
  643. if(!customerName){
  644. layer.msg('买家姓名不能为空!',{icon:2,time:1500});
  645. return false;
  646. }
  647. var receiverName = $("input[name=receiverName]").val();
  648. if(!receiverName){
  649. layer.msg('收件人姓名不能为空!',{icon:2,time:1500});
  650. return false;
  651. }
  652. var receiverMobile = $("input[name=receiverMobile]").val();
  653. if(!receiverMobile){
  654. layer.msg('收件人手机号不能为空!',{icon:2,time:1500});
  655. return false;
  656. }
  657. var preg = /^1[3456789]\d{9}$/;
  658. if(!preg.test(receiverMobile)){
  659. layer.msg('收件人手机号格式有误!',{icon:2,time:1500});
  660. return false;
  661. }
  662. var fanTime = $("input[name=fanTime]").val();
  663. if(!fanTime){
  664. layer.msg('加粉时间不能为空!',{icon:2,time:1500});
  665. return false;
  666. }
  667. var tdate = today_date();
  668. if(fanTime>tdate){
  669. layer.msg('加粉时间不能超过今天!',{icon:2,time:1500});
  670. return false;
  671. }
  672. var receiverState = $("input[name=receiverState]").val();
  673. if(!receiverState){
  674. layer.msg('省份不能为空!',{icon:2,time:1500});
  675. return false;
  676. }
  677. var receiverCity = $("input[name=receiverCity]").val();
  678. if(!receiverCity){
  679. layer.msg('城市不能为空!',{icon:2,time:1500});
  680. return false;
  681. }
  682. var receiverAddress = $("input[name=receiverAddress]").val();
  683. if(!receiverAddress){
  684. layer.msg('详细地址不能为空!',{icon:2,time:1500});
  685. return false;
  686. }
  687. var delivery_date = $("input[name=delivery_date]").val();
  688. if(!delivery_date){
  689. layer.msg('预发货时间不能为空!',{icon:2,time:1500});
  690. return false;
  691. }
  692. var warehouse = $("#warehouse").val();
  693. if(warehouse<1){
  694. layer.msg('仓库必须选择!',{icon:2,time:1500});
  695. return false;
  696. }
  697. var receivedAmount = $("input[name=receivedAmount]").val();
  698. if(!receivedAmount){
  699. layer.msg('实付金额不能为空!',{icon:2,time:1500});
  700. return false;
  701. }
  702. if(isNaN(receivedAmount)){
  703. layer.msg('实付金额必须为数字!',{icon:2,time:1500});
  704. return false;
  705. }
  706. //验证称重>0.5
  707. var if_no = weigh_verify();
  708. if(if_no > 0){
  709. if(if_no == 1){
  710. layer.msg('商品数量填写有误!',{icon:2,time:1500});
  711. }
  712. if(if_no == 2){
  713. layer.msg('非称重商品数量必须为整数!',{icon:2,time:1500});
  714. }
  715. if(if_no == 3){
  716. layer.msg('称重商品重量必须为0.5的倍数!',{icon:2,time:1500});
  717. }
  718. if(if_no == 4){
  719. layer.msg('商品数量不得大于库存量!',{icon:2,time:1500});
  720. }
  721. return false;
  722. }
  723. //验证充值卡
  724. var is_ok = 1;
  725. var payment_type = $("input[type='radio'][name='payment_type']:checked").val();
  726. if(payment_type==4){
  727. var phone = $("input[name=deposit_phone]").val();
  728. if(!phone){
  729. is_ok = 0;
  730. }
  731. //获取充值卡余额
  732. $.ajax({
  733. url:'/admin/cust/getBalance/'+phone,
  734. type: 'get',
  735. async:false,
  736. success : function(data){
  737. data=parseFloat(data);
  738. receivedAmount=parseFloat(receivedAmount);
  739. if(data<receivedAmount){
  740. is_ok = 0;
  741. }else{
  742. is_ok = 1;
  743. }
  744. }
  745. });
  746. if(is_ok==0){
  747. layer.msg('充值卡余额不足,请充值或选择其他付款方式!',{icon:2,time:1500});
  748. return false;
  749. }
  750. }
  751. return true;
  752. }
  753. </script>
  754. </body>
  755. @endsection