123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931 |
- @extends('admin/master')
- @section('content')
- <body>
- @if(count($errors) > 0)
- <div class="Huialert Huialert-info" id="error">
- @foreach($errors->all() as $error)
- <li>{{$error}}</li>
- @endforeach
- </div>
- @endif
- <style type="text/css">
- #good_sku{
- position: absolute;
- z-index: 9;
- background: #ffffff;
- box-shadow: 1px 1px 1px 1px #ccc;
- width: calc(100% - 30px);
- }
- #good_sku li{
- font-size: 12px;
- line-height: 24px;
- cursor: pointer;
- padding: 5px 10px;
- }
- #good_sku li:hover{
- background: #eaeaea;
- }
- </style>
- <div class="page-container">
- <form id='order-form' action="/admin/order/store" method="post" class="form form-horizontal" enctype="multipart/form-data" onkeypress="return event.keyCode != 13;">
- <input type="hidden" name="_token" value="{{ csrf_token() }}" />
- <input type="hidden" name="status" value="0" />
-
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- <font color='red'>* </font>买家姓名:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <input type="text" class="input-text" value="{{old('customerName')}}" placeholder="请输入名称" name="customerName">
- </div>
- </div>
-
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- <font color='red'>* </font>买家手机号:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <input type="text" class="input-text" value="{{old('buyer_phone')}}" placeholder="" onkeyup="getVip()" name="buyer_phone">
- </div>
- </div>
- <div id='use_coupon_div' class="row cl" style="display: none">
- <label class="form-label col-xs-4 col-sm-2">
- <font color='red'>* </font>是否使用优惠券:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <input type="radio" name="use_coupon" value="0" checked disabled>
- <label for="status-0" style="margin-right: 27px;">否</label>
- <input id='use_coupon_1' type="radio" name="use_coupon" value="1" disabled>
- <label for="status-1">是</label>
- </div>
- </div>
-
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- <font color='red'>* </font>收件人姓名:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <input type="text" class="input-text" value="{{old('receiverName')}}" placeholder="" name="receiverName">
- </div>
- </div>
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- <font color='red'>* </font>收件人手机号:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <input type="text" class="input-text" value="{{old('receiverMobile')}}" placeholder="" onkeyup="getAddress()" name="receiverMobile">
- </div>
- </div>
- <div id='fanTime_div' class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- <font color='red'>* </font>加粉时间:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <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')}}">
- </div>
- </div>
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- <font color='red'>* </font>省/直辖市:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <input type="text" class="input-text" value="{{old('receiverState')}}" placeholder="" name="receiverState">
- </div>
- </div>
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- <font color='red'>* </font>市:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <input type="text" class="input-text" value="{{old('receiverCity')}}" placeholder="" name="receiverCity">
- </div>
- </div>
- <!--div class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- 区:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <input type="text" class="input-text" value="{{old('receiverDistrict')}}" placeholder="" name="receiverDistrict">
- </div>
- </div>
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- 街道:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <input type="text" class="input-text" value="{{old('receiverStreet')}}" placeholder="" name="receiverStreet">
- </div>
- </div-->
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- <font color='red'>* </font>详细地址:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <input type="text" class="input-text" value="{{old('receiverAddress')}}" placeholder="" name="receiverAddress">
- </div>
- </div>
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- <font color='red'>* </font>预发货时间:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <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>
- </div>
- </div>
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- <font color='red'>* </font>发货仓库:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <span class="select-box">
- <select size="1" name="warehouse" id='warehouse'>
- <option value="0" @if(old('warehouse')=='0') selected @endif>- 请选择 -</option>
- @foreach($warehouseArr as $warehouseVal=>$warehouseName)
- <option value="{{$warehouseVal}}" @if(old('warehouse') == $warehouseVal) selected @endif>{{$warehouseName}}</option>
- @endforeach
- </select>
- </span>
- </div>
- <input type="hidden" value="" id="warehouse_status">
- </div>
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2"><font color='red'>* </font>搜索选择商品:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <input type='text' class="input-text" autocomplete="off" name='goods_name' placeholder="输入关键词搜索商品,C仓必须选择" value="{{old('goods_name')}}"/>
- <ul id="good_sku"></ul>
- </div>
- </div><br>
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- <font color='red'>* </font>已选择商品:</label>
- <div id='goods_o' name='goods_o_con' class="formControls col-xs-6 col-sm-6">
-
- </div>
-
- </div><br>
- <div id='m_gift_div' class="row cl" style="display: none">
- <label class="form-label col-xs-4 col-sm-2">
- <font color='red'> </font>选择会员当月赠品</label>
- <div class="formControls col-xs-6 col-sm-6">
- <span class="select-box">
- <select size="1" name="m_gift_id" id='m_gift'>
- <option value="0" @if(old('m_gift_id')=='0') selected @endif>- 请选择 -</option>
- @foreach($m_gift as $item)
- <option value="{{$item['id']}}" @if(old('m_gift_id')==$item['id']) selected @endif>{{$item['goods_name']}}【{{$item['propsName']}} ¥{{$item['price']}}】</option>
- @endforeach
- </select>
- </span>
- </div>
- </div>
- @if(!empty($b_gift))
- <div id='b_gift_div' class="row cl" style="display: none">
- <label class="form-label col-xs-4 col-sm-2">
- <font color='red'> </font>是否使用生日套餐</label>
- <div class="formControls col-xs-6 col-sm-6">
- <input type="radio" name="use_b_gift" value="0" checked disabled >
- <label for="status-0" style="margin-right: 27px;">否</label>
- <input id='use_b_gift_1' type="radio" name="use_b_gift" value="1" disabled>
- <label for="status-1">是</label>
- </div>
- </div>
- <div id='b_gift_list' class="row cl" style="display: none">
- <label class="form-label col-xs-4 col-sm-2">
- <font color='red'> </font>生日套餐包含:</label>
- <div class="formControls col-xs-6 col-sm-6">
- @foreach($b_gift as $item)
- {{$item['goods_name']}}【{{$item['propsName']}} ¥{{$item['price']}}】 x {{$item['num']}}<br>
- @endforeach
- </div>
- </div>
- @endif
- <div class="row cl" style='display: none'>
- <label class="form-label col-xs-4 col-sm-2">
- 应收金额:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <span id='should_amount_show'>{{old('should_amount')}}</span>
- <input id='should_amount' type="hidden" class="input-text" value="{{old('should_amount')}}" placeholder="" name="should_amount">
- </div>
- </div>
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- <font color='red'>* </font>实收金额:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <input id='receivedAmount' type="text" class="input-text" value="{{old('receivedAmount')}}" placeholder="" name="receivedAmount">
- </div>
- </div>
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- <font color='red'>* </font>支付方式:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <input type="radio" name="payment_type" value="1" @if(old('payment_type')==='1') checked @else checked @endif>
- <label for="status-1" style="margin-right: 27px;">微信支付</label>
- <!--input type="radio" name="payment_type" value="2" @if(old('payment_type')==='2') checked @endif>
- <label for="status-0">付款码支付</label-->
- <input type="radio" name="payment_type" value="3" @if(old('payment_type')==='3') checked @endif>
- <label for="status-0" style="margin-right: 27px;">个体户支付</label>
- @if($self_role != '分销销售' && $self_role != '分销管理员')
- <input type="radio" name="payment_type" value="4" @if(old('payment_type')==='4') checked @endif>
- <label for="status-0">充值卡支付</label>
- @endif
- </div>
- </div>
- <div class="row cl" style="display: none" id='deposit_div'>
- <label class="form-label col-xs-4 col-sm-2">
- <font color='red'> </font>充值卡号:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <input id='deposit_phone' type="text" class="input-text" onkeyup="getBalance()" value="{{old('deposit_phone')}}" placeholder="" name="deposit_phone">
- <font color='red' id='vip_pay'></font>
- </div>
- </div>
- <!--div class="row cl" style="display: none" id='deposit_div'>
- <label class="form-label col-xs-4 col-sm-2">
- <font color='red'> </font>充值卡号:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <input id='deposit_phone_i' type="text" class="input-text" value="{{old('deposit_phone')}}" placeholder="*默认收货人手机号" disabled name="deposit_phone_i">
- <input id='deposit_phone' type="hidden" class="input-text" value="{{old('deposit_phone')}}" placeholder="" name="deposit_phone">
- <font color='red' id='vip_pay'></font>
- </div>
- </div-->
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- <font color='red'>* </font>是否退补单:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <input type="radio" name="is_refund" value="0" @if(old('is_refund')==='0') checked @else checked @endif>
- <label for="status-1" style="margin-right: 27px;">否</label>
- <input type="radio" name="is_refund" value="1" @if(old('is_refund')==='1') checked @endif>
- <label for="status-0">是</label>
- </div>
- </div>
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- 应该退补差价:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <input type="text" class="input-text" value="{{old('refund_price')}}" placeholder="" name="refund_price">
- </div>
- </div>
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- <font color='red'>* </font>下单时间:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <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>
- </div>
- </div>
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- 买家备注:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <textarea class="textarea" placeholder="填写买家备注..." name="buyerMemo">{{old('buyerMemo')}}</textarea>
- </div>
- </div>
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- 卖家备注:</label>
- <div class="formControls col-xs-6 col-sm-6">
- <textarea class="textarea" placeholder="填写卖家备注..." name="sellerMemo">{{old('sellerMemo')}}</textarea>
- </div>
- </div>
- @if(0)
- @if($self_role !='销售' && $self_role != '分销销售' )
- <div class="row cl">
- <label class="form-label col-xs-4 col-sm-2">
- 选择销售员(不选默认当前用户):</label>
- <div class="formControls col-xs-6 col-sm-6">
- <span class="select-box">
- <select size="1" name="team" id='team'>
- <option value="0" @if(old('team')=='') selected @endif>选择团队</option>
- @foreach($teamlist as $v)
- <option value="{{$v['id']}}" @if(old('team')==$v['id']) selected @endif>{{$v['name']}}</option>
- @endforeach
- </select>
- <select id='admins' size="1" name="admin_id">
- <option value="0" @if(old('admin_id')=='') selected @endif>-- 选择销售 --</option>
- @foreach($adminlist as $v)
- <option value="{{$v['id']}}" @if(old('admin_id')==$v['id']) selected @endif>{{$v['realname']}}</option>
- @endforeach
- </select>
-
- </span>
- </div>
- </div>
- @endif
- @endif
-
- <div class="row cl">
- <div class="col-9 col-offset-2">
- <button class="btn btn-primary radius" type='button' onclick="to_submit()" value=" 保存 "> 保存 </button>
- <button class="btn btn-primary radius" type='button' onclick="to_verify()" value=" 保存并提审 "> 保存并提审 </button>
- <button class="btn btn-default" type="reset" onclick="return_index();"> 返回 </button>
- </div>
- </div>
- </form>
- </div>
- <!--_footer 作为公共模版分离出去-->
- <script type="text/javascript" src="/admin/lib/jquery/1.9.1/jquery.min.js"></script>
- <script type="text/javascript" src="/admin/lib/layer/2.4/layer.js"></script>
- <script type="text/javascript" src="/admin/static/h-ui/js/H-ui.min.js"></script>
- <script type="text/javascript" src="/admin/static/h-ui.admin/js/H-ui.admin.js"></script>
- <!--/_footer 作为公共模版分离出去-->
- <!--请在下方写此页面业务相关的脚本-->
- <script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
- <script type="text/javascript">
- $(function(){
- setTimeout("$('#error').hide()",3000);
- var dtime = today();
- $('#createTime').val(dtime);
- var tdate = today_date();
- $('#delivery').val(tdate);
- $('#category').change(function(){
- category = $('#category').val();
- if(category==''){
- return false;
- }
- $.ajax({
- 'url':'/admin/order/categoods/'+category,
- 'type': 'get',
- 'dataType':'json',
- 'success' : function(data){
- str = '<option value=\'0\'>-- 选择商品 --<\/option>';
- $.each(data, function(i, va){
- var props = va.props_name;
- if(props != ''){
- props = '【' + props + '】';
- }
- var price = va.price;
- if(price > 0){
- price = '【¥' + price + '元】';
- }else{
- price = '';
- }
- str += '<option value="'+va.id+'">' + va.goods_name + props + price +'<\/option>';
- })
-
- $('#goods').html(str);
- }
- });
- })
- $('#team').change(function(){
- team = $('#team').val();
- if(team==''){
- return false;
- }
- $.ajax({
- 'url':'/admin/order/teamAdmins/'+team,
- 'type': 'get',
- 'dataType':'json',
- 'success' : function(data){
- str = '<option value=\'0\'>-- 选择销售 --<\/option>';
- $.each(data, function(i, va){
- str += '<option value="'+va.id+'">' + va.realname +'<\/option>';
- })
-
- $('#admins').html(str);
- }
- });
- })
- $('input[type=radio][name=payment_type]').change(function () {
- var payment_type = $("input[type='radio'][name='payment_type']:checked").val();
- if(payment_type==4){
- var phone = $("input[name=receiverMobile]").val();
- $("#deposit_phone").val(phone);
- $("#deposit_div").show();
- //获取充值卡余额
- var reg = /^1\d{10}$/
- if(!reg.test(phone)){
- return false;
- }
- $.ajax({
- 'url':'/admin/cust/getBalance/'+phone,
- 'type': 'get',
- 'success' : function(data){
- var str = '【充值卡余额为:'+data+'元】';
- $("#vip_pay").html(str);
- }
- });
- }else{
- $("#deposit_div").hide();
- }
- })
-
- });
- function getBalance(){
- var phone = $("input[name=deposit_phone]").val();
- var reg = /^1\d{10}$/
- if(!reg.test(phone)){
- $("#vip_pay").html('【充值卡余额为:0元】');
- return false;
- }
- //获取充值卡余额
- $.ajax({
- 'url':'/admin/cust/getBalance/'+phone,
- 'type': 'get',
- 'success' : function(data){
- var str = '【充值卡余额为:'+data+'元】';
- $("#vip_pay").html(str);
- }
- });
- }
- /*返回*/
- function return_index(){
- location.href='/admin/order/index';
- }
- function add_goods(goods_id,sku_id,name,props_name,price,is_weigh,quantity,is_white,warehouse,warehouse_name){
- var gnum = $("#gnum"+sku_id).val();
- var weigh_unit = '数量';
- var weigh_note = '';
- var weigh_unit_name = '';
- //默认仓库判断逻辑
- var warehouse_now = $('#warehouse').val();
- var warehouse_status = $('#warehouse_status').val();
- if(warehouse_now == 0) {
- if(warehouse_status == '') {
- $('#warehouse').val(warehouse);
- }
- } else {
- //判断所选择商品所在仓库于现有仓库是否一致
- if(warehouse_status == '') {
- if(warehouse_now != warehouse) {
- layer.confirm('选择商品所属仓库与当前选择仓库不一致,请确认(点击重新选择其他仓库会将现在所选发货仓库清空)',{
- btn: ['确认当前选择仓库','重新选择其他仓库']
- },function(index){
- layer.close(index);
- },function(){
- $('#warehouse').val('0');
- })
- $('#warehouse_status').val('1');
- }
- }
- }
- if(is_weigh == 1){
- weigh_unit = '重量';
- weigh_unit_name = '(斤)';
- weigh_note = '<font color=\'red\'> (称重商品,至少0.5斤) <\/font>';
- }
- if(gnum){
- var n = gnum;
- n = parseFloat(n)+1
- $("#gnum"+sku_id).val(n);
- }
- else{
- var quantity_str = '库存:'+quantity;
- if(is_white==1){
- quantity_str = '虚拟库存';
- }
- var str = "<div>"+name+' 【 规格:'+props_name+' '+quantity_str+" 】 "+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+" <button type='button' onclick='del_sku(this, "+sku_id+","+ price + ")'> 移除<\/button> "+weigh_note+"<\/div>";
- $("#goods_o").append(str);
- sessionStorage.setItem('goods_o_con',$("#goods_o").html());
- }
- sync_money()
- document.getElementById('good_sku').style.display='none'
- return false;
- }
- function add_num(sku_id, price, is_weigh, quantity, is_white){
- var gnum = $("#gnum"+sku_id).val();
- var n = gnum;
- n = parseFloat(n)+1
- $("#gnum"+sku_id).val(n);
-
- $("#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 + " \/>")
- sessionStorage.setItem('goods_o_con',$("#goods_o").html());
- sync_money()
- return false;
- }
- function cut_num(sku_id, price, is_weigh, quantity, is_white){
- var gnum = $("#gnum"+sku_id).val();
- var n = gnum;
- if(n == 1){
- return false;
- }
- n = parseFloat(n)-1;
- $("#gnum"+sku_id).val(n);
- $("#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 + " \/>")
- sessionStorage.setItem('goods_o_con',$("#goods_o").html());
- sync_money()
- return false;
- }
- function del_sku(obj, sku_id, price){
- //console.log(obj)
- var gnum = $("#gnum"+sku_id).val();
- $(obj).parent().remove();
- sessionStorage.setItem('goods_o_con',$("#goods_o").html());
- sync_money();
- }
- function sync_money(){
- var gnums = new Array();
- var total = 0;
- $('.gnums').each(function(key, value){
- var gnum = $(this).val();
- var price = $(this).attr('price');
- total = total + parseFloat(price) * parseFloat(gnum);
- });
- if(total>0){
- $("#should_amount").val(total);
- $("#should_amount_show").html(total);
- }else{
- $("#should_amount").val('');
- $("#should_amount_show").html('');
- }
- return false;
- }
- function today(){
- var today=new Date();
- var h=today.getFullYear();
- var m=today.getMonth()+1;
- var d=today.getDate();
- var hh=today.getHours();
- var mm=today.getMinutes();
- var ss=today.getSeconds();
- m= m<10?"0"+m:m;
- d= d<10?"0"+d:d;
- hh = hh < 10 ? "0" + hh:hh;
- mm = mm < 10 ? "0" + mm:mm;
- ss = ss < 10 ? "0" + ss:ss;
- return h+"-"+m+"-"+d+" "+hh+":"+mm+":"+ss;
- }
- function today_date(){
- var today=new Date();
- var h=today.getFullYear();
- var m=today.getMonth()+1;
- var d=today.getDate();
- var hh=today.getHours();
- var mm=today.getMinutes();
- var ss=today.getSeconds();
- m= m<10?"0"+m:m;
- d= d<10?"0"+d:d;
- hh = hh < 10 ? "0" + hh:hh;
- mm = mm < 10 ? "0" + mm:mm;
- ss = ss < 10 ? "0" + ss:ss;
- return h+"-"+m+"-"+d;
- }
- function getAddress(){
- var phone = $('input[name=receiverMobile]').val();
- var reg = /^1\d{10}$/
- if(reg.test(phone)){
- $.ajax({
- 'url': '/admin/order/getAddress?phone='+phone,
- 'type': 'get',
- 'dateType': 'json',
- success:function(data){
- if(data != '0'){
- data = eval("("+data+")");
- $("input[name=receiverState]").val(data.receiverState);
- $("input[name=receiverCity]").val(data.receiverCity);
- //$("input[name=receiverDistrict]").val(data.receiverDistrict);
- //$("input[name=receiverStreet]").val(data.receiverStreet);
- $("input[name=receiverAddress]").val(data.receiverAddress);
- $("input[name=fanTime]").val(data.fanTime);
- $("#fanTime_div").hide();
- }
- else{
- $("#fanTime_div").show();
- }
- }
- })
- }
- }
- // function getGoods(){
- // var name = $('input[name=goods_name]').val();
- // if(!name){
- // return false;
- // }
- // $.ajax({
- // 'url': '/admin/goods/searchSkus',
- // 'type': 'get',
- // 'data':{name:name},
- // 'dateType': 'json',
- // success:function(data){
- // if(data != '0'){
- // data = eval("("+data+")");
- // }
- // }
- // })
- // }
- function to_verify(){
- if(!form_verify()){
- return false;
- }
- $("input[name=status]").val('1');
- var warehouse = $("#warehouse").val();
- if(warehouse == 3){
- var if_good = $('.gnums');
- if(!if_good.length){
- layer.msg('仓库C必须选择商品!',{icon:2,time:1500});
- return false;
- }
- }
- $(".btn").attr("disabled",true);
- //console.log('disabled')
- $("#order-form").submit();
- return true;
- }
- function to_submit(){
- if(!form_verify()){
- return false;
- }
- $("input[name=status]").val('0');
- //console.log('disabled1')
- var warehouse = $("#warehouse").val();
- if(warehouse == 3){
- var if_good = $('.gnums');
- if(!if_good.length){
- layer.msg('仓库C必须选择商品!',{icon:2,time:1500});
- return false;
- }
- }
- $(".btn").attr("disabled",true);
- $("#order-form").submit();
- return true;
- }
- $("#goods_o").append(sessionStorage.getItem('goods_o_con'));
- $('input[name=goods_name]').on('keyup focus', function(){
- var name = $('input[name=goods_name]').val();
- name = name.replace(/\s+/g,"");
- if(!name){
- return false;
- }
- $.ajax({
- 'url': '/admin/goods/searchSkus',
- 'type': 'get',
- 'data':{name:name},
- 'dateType': 'json',
- success:function(data){
- if(data != '0'){
- data = eval("("+data+")");
- var str = '';
- for (var i = 0, l = data.length; i < l; i++) {
- var item = data[i];
- var weigh_t = '';
- if(item.is_weigh==1){
- weigh_t = '【按半斤称重】';
- }
- if(item.is_white == 0 && item.quantity <= 0){
- weigh_t += '<font color="red">【库存不足】<\/font>';
- str += '<li>'+ item.name+'【 规格:'+item.propsName+' 】'+weigh_t+ ' '+ item.warehouse_name +'<\/li>'
- }
- else{
- 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+' 】'+weigh_t+ ' '+ item.warehouse_name +'<\/li>'
- }
- // '<p onclick=\'add_goods('+item.goods_id+','+item.sku_id+',"'+item.name+'","'+item.propsName+'",'+item.price+');\'>'+ item.name+' '+item.propsName+' ¥'+item.price +'<\/p>';
- }
- document.getElementById('good_sku').innerHTML = str;
- document.getElementById('good_sku').style.display='block'
-
- }
- }
- })
-
-
- });
- $("body").on('click', function(){
- $('input[name=goods_name]').on('click',function(e){
- e.stopPropagation();
- });
- document.getElementById('good_sku').style.display='none'
- })
- function weigh_verify(){
- var if_no = 0;
- $('.gnums').each(function(key, value){
- var gnum = $(this).val();
- gnum = parseFloat(gnum);
- var is_weigh = $(this).attr('is_weigh');
- if(gnum<0.5){
- if_no = 1;
- return;
- }
- if(is_weigh == 0 && gnum%1 != 0){
- if_no = 2;
- return;
- }
- if(is_weigh == 1 && gnum%0.5 != 0){
- if_no = 3;
- return;
- }
- var quantity = $(this).attr('quantity');
- var is_white = $(this).attr('is_white');
- if(is_white==0 && gnum>quantity){
- if_no=4;
- return;
- }
- });
- return if_no;
- }
- function form_verify(){
- var customerName = $("input[name=customerName]").val();
- if(!customerName){
- layer.msg('买家姓名不能为空!',{icon:2,time:1500});
- return false;
- }
- var receiverName = $("input[name=receiverName]").val();
- if(!receiverName){
- layer.msg('收件人姓名不能为空!',{icon:2,time:1500});
- return false;
- }
- var receiverMobile = $("input[name=receiverMobile]").val();
- if(!receiverMobile){
- layer.msg('收件人手机号不能为空!',{icon:2,time:1500});
- return false;
- }
- var preg = /^1[3456789]\d{9}$/;
- if(!preg.test(receiverMobile)){
- layer.msg('收件人手机号格式有误!',{icon:2,time:1500});
- return false;
- }
- var fanTime = $("input[name=fanTime]").val();
- if(!fanTime){
- layer.msg('加粉时间不能为空!',{icon:2,time:1500});
- return false;
- }
- var tdate = today_date();
- if(fanTime>tdate){
- layer.msg('加粉时间不能超过今天!',{icon:2,time:1500});
- return false;
- }
- var receiverState = $("input[name=receiverState]").val();
- if(!receiverState){
- layer.msg('省份不能为空!',{icon:2,time:1500});
- return false;
- }
- var receiverCity = $("input[name=receiverCity]").val();
- if(!receiverCity){
- layer.msg('城市不能为空!',{icon:2,time:1500});
- return false;
- }
- var receiverAddress = $("input[name=receiverAddress]").val();
- if(!receiverAddress){
- layer.msg('详细地址不能为空!',{icon:2,time:1500});
- return false;
- }
- var delivery_date = $("input[name=delivery_date]").val();
- if(!delivery_date){
- layer.msg('预发货时间不能为空!',{icon:2,time:1500});
- return false;
- }
-
- var warehouse = $("#warehouse").val();
- if(warehouse<1){
- layer.msg('仓库必须选择!',{icon:2,time:1500});
- return false;
- }
- var receivedAmount = $("input[name=receivedAmount]").val();
- if(!receivedAmount){
- layer.msg('实付金额不能为空!',{icon:2,time:1500});
- return false;
- }
- if(isNaN(receivedAmount)){
- layer.msg('实付金额必须为数字!',{icon:2,time:1500});
- return false;
- }
- //验证称重>0.5
- var if_no = weigh_verify();
- if(if_no > 0){
- if(if_no == 1){
- layer.msg('商品数量填写有误!',{icon:2,time:1500});
- }
- if(if_no == 2){
- layer.msg('非称重商品数量必须为整数!',{icon:2,time:1500});
- }
- if(if_no == 3){
- layer.msg('称重商品重量必须为0.5的倍数!',{icon:2,time:1500});
- }
- if(if_no == 4){
- layer.msg('商品数量不得大于库存量!',{icon:2,time:1500});
- }
- return false;
- }
- //验证充值卡
- var is_ok = 1;
- var payment_type = $("input[type='radio'][name='payment_type']:checked").val();
- if(payment_type==4){
- //使用充值卡不能使用优惠券验证
- use_coupon = $("input[type='radio'][name='use_coupon']:checked").val();
- if(use_coupon == 1){
- layer.msg('充值卡不能和优惠券同时使用!',{icon:2,time:1500});
- return false;
- }
- var phone = $("input[name=deposit_phone]").val();
- if(!phone){
- is_ok = 0;
- }
- //获取充值卡余额
- $.ajax({
- url:'/admin/cust/getBalance/'+phone,
- type: 'get',
- async:false,
- success : function(data){
- data=parseFloat(data);
- receivedAmount=parseFloat(receivedAmount);
- if(data<receivedAmount){
- is_ok = 0;
- }else{
- is_ok = 1;
- }
- }
- });
- if(is_ok==0){
- layer.msg('充值卡余额不足,请充值或选择其他付款方式!',{icon:2,time:1500});
- return false;
- }
- }
- return true;
- }
- function getVip(){
- var phone = $('input[name=buyer_phone]').val();
- var reg = /^1\d{10}$/
- if(reg.test(phone)){
- $.ajax({
- 'url': '/admin/order/getVip?phone='+phone,
- 'type': 'get',
- 'dateType': 'json',
- success:function(data){
- data = eval("("+data+")");
- if(data.code==0){
- if(data.data.coupons == 1){
- $("input[name=use_coupon]").removeAttr('disabled');
- //$("#use_coupon_1").attr("checked","checked");
- $("#use_coupon_div").show();
- }
- if(data.data.if_m_gift == 1){
- $("#m_gift").removeAttr('disabled');
- $("#m_gift_div").show();
- }
- if(data.data.if_b_gift == 1){
- $("input[name=use_b_gift]").removeAttr('disabled');
- //$("#use_b_gift_1").attr("checked","checked");
- $("#b_gift_div").show();
- $("#b_gift_list").show();
- }
- }else{
- $("input[name=use_coupon]").attr('disabled','disabled');
- $("#m_gift").attr('disabled','disabled');
- $("input[name=use_b_gift]").attr('disabled','disabled');
- $("#use_coupon_div").hide();
- $("#m_gift_div").hide();
- $("#b_gift_div").hide();
- $("#b_gift_list").hide();
- }
-
- }
- })
- }
- else{
- $("input[name=use_coupon]").attr('disabled','disabled');
- $("#m_gift").attr('disabled','disabled');
- $("input[name=use_b_gift]").attr('disabled','disabled');
- $("#use_coupon_div").hide();
- $("#m_gift_div").hide();
- $("#b_gift_div").hide();
- $("#b_gift_list").hide();
- }
- }
- </script>
- </body>
- @endsection
|