Keine Beschreibung

ordercreate.blade.php 41KB

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