create.blade.php 10.5 KB
@extends ('backend.layouts.app')

@section ('title', trans('labels.backend.machine.management') . ' | ' . trans('labels.backend.machine.create'))

@section('page-header')
    <h1>
        {{ trans('labels.backend.machine.management') }}
        <small>{{ trans('labels.backend.machine.create') }}</small>
    </h1>
@endsection

@section('content')
    {{ Form::open(['route' => 'admin.machine.store', 'class' => 'form-horizontal', 'method' => 'post']) }}

    {{ Form::hidden('lat', null, ['id' => 'lat']) }}
    {{ Form::hidden('lng', null, ['id' => 'lng']) }}
    <div class="box box-success">
        <div class="box-header with-border">
            <h3 class="box-title">{{ trans('labels.backend.machine.create') }}</h3>

            <div class="box-tools pull-right">
                @include('backend.machine.includes.partials.machine-header-button')
            </div><!--box-tools pull-right-->
        </div><!-- /.box-header -->

        <div class="box-body">

            
               

            <div class="form-group">
                {{ Form::label('city_name', trans('validation.attributes.backend.machine.city_name'), ['class' => 'col-lg-2 control-label']) }}

                <div class="col-lg-10">
                    {{ Form::hidden('ad_code', null, ['id' => 'ad_code']) }}
                    {{ Form::text('city_name', null, ['id' => 'city_name', 'class' => 'form-control', 'data-toggle'=>'city-picker', 'placeholder' => trans('validation.attributes.backend.machine.city_name')]) }}
                </div><!--col-lg-10-->
            </div><!--form control-->

            <div class="form-group">
                {{ Form::label('address', trans('validation.attributes.backend.machine.address').":", ['class' => 'col-lg-2 control-label']) }}


                <div class="col-lg-10">
                    {{ Form::text('address', null, ['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.machine.address')]) }}
                </div><!--col-lg-10-->
            </div><!--form control-->

            <div class="form-group">
                {{ Form::label('', '', ['class' => 'col-lg-2 control-label']) }}

                <div class="col-lg-10">
                    <button id="getLocation" class="btn btn-primary pull-right" type="button">{{trans('validation.attributes.backend.machine.getLocation')}}</button>
                </div><!--col-lg-10-->
            </div><!--form control-->

            <div class="form-group">
                {{ Form::label('map_address', trans('validation.attributes.backend.machine.map_address').":", ['class' => 'col-lg-2 control-label']) }}

                <div class="col-lg-10">
                    <div id="container" style="width:100%;height: 400px;"></div>
                </div><!--col-lg-10-->
            </div><!--form control-->


            <div class="form-group">
                {{ Form::label('deposit', trans('validation.attributes.backend.machine.deposit').":", ['class' => 'col-lg-2 control-label']) }}

                <div class="col-lg-10">
                    {{ Form::number('deposit', null, ['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.machine.deposit')]) }}
                </div><!--col-lg-10-->
            </div><!--form control-->


            <div class="form-group">
                {{ Form::label('one_day_price', trans('validation.attributes.backend.machine.one_day_price').":", ['class' => 'col-lg-2 control-label']) }}

                <div class="col-lg-10">
                    {{ Form::number('one_day_price', null, ['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.machine.one_day_price')]) }}
                </div><!--col-lg-10-->
            </div><!--form control-->


            <div class="form-group">
                {{ Form::label('free_time', trans('validation.attributes.backend.machine.free_time').":", ['class' => 'col-lg-2 control-label']) }}

                <div class="col-lg-10">
                    {{ Form::number('free_time', null, ['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.machine.free_time')]) }}
                </div><!--col-lg-10-->
            </div><!--form control-->

            <div class="form-group">
                {{ Form::label('business_id', trans('validation.attributes.backend.machine.business_id').":", ['class' => 'col-lg-2 control-label']) }}

                <div class="col-lg-10">
                    {{ Form::select('business_id',$business,'all', ['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.machine.business_id')]) }}
                </div><!--col-lg-10-->
            </div><!--form control-->

            <div class="form-group">
                {{ Form::label('spot_id', trans('validation.attributes.backend.machine.spot_id').":", ['class' => 'col-lg-2 control-label']) }}

                <div class="col-lg-10">
                    {{ Form::select('spot_id', $spot,'all', ['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.machine.spot_id')]) }}
                </div><!--col-lg-10-->
            </div>

            <div class="form-group">
                {{ Form::label('type', trans('validation.attributes.backend.machine.type').":", ['class' => 'col-lg-2 control-label']) }}

                <div class="col-lg-10">
                    {{ Form::select('type', ['1'=>'大机柜','2'=>'小机柜'],'all', ['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.machine.type')]) }}
                </div><!--col-lg-10-->
            </div>

            <!--仓口数-->
            {{--<div class="form-group">--}}
                {{--{{ Form::label('hatch_number', trans('validation.attributes.backend.machine.hatch_number').":", ['class' => 'col-lg-2 control-label']) }}--}}

                {{--<div class="col-lg-10">--}}
                    {{--{{ Form::number('hatch_number', null, ['class' => 'form-control', 'placeholder' => trans('validation.attributes.backend.machine.hatch_number')]) }}--}}
                {{--</div><!--col-lg-10-->--}}
            {{--</div>--}}
            <div class="box box-success">
                <div class="box-body">
                    <div class="pull-left">
                        {{ link_to_route('admin.machine.index', trans('buttons.general.cancel'), [], ['class' => 'btn btn-danger btn-xs']) }}
                    </div><!--pull-left-->

                    <div class="pull-right">
                        {{ Form::submit(trans('buttons.general.crud.create'), ['class' => 'btn btn-success btn-xs']) }}
                    </div><!--pull-right-->

                    <div class="clearfix"></div>
                </div><!-- /.box-body -->
            </div><!--box-->
        </div>
    </div>
    {{ Form::close() }}



@endsection

@section('after-scripts')


    {{ Html::script('js/backend/access/roles/script.js') }}


    {{ Html::script('https://webapi.amap.com/maps?v=1.3&key=8ee5d62b79b4e8a1e526bc4095d21fde') }}

    {{ Html::script('js/backend/city/city-picker.data.all.js') }}
    {{ Html::script('js/backend/city/city-picker.js') }}
    {{ Html::script('js/backend/city/script.js') }}
    {{ Html::style('css/city-picker.css') }}

    <script>
        $(function() {
            var lng = $('#lng').attr("value");
            var lat = $('#lat').attr("value")
            var map = new AMap.Map('container');
            map.setZoom(14);

            AMap.plugin(['AMap.ToolBar','AMap.Scale', 'AMap.Geolocation'],function(){
                var toolBar = new AMap.ToolBar();
                var scale = new AMap.Scale();

                geolocation = new AMap.Geolocation({
                    enableHighAccuracy: true,//是否使用高精度定位,默认:true
                    timeout: 10000,          //超过10秒后停止定位,默认:无穷大
                    maximumAge: 0,           //定位结果缓存0毫秒,默认:0
                    convert: true,           //自动偏移坐标,偏移后的坐标为高德坐标,默认:true
                    showButton: true,        //显示定位按钮,默认:true
                    buttonPosition: 'LB',    //定位按钮停靠位置,默认:'LB',左下角
                    buttonOffset: new AMap.Pixel(10, 20),//定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20)
                    showMarker: true,        //定位成功后在定位到的位置显示点标记,默认:true
                    showCircle: true,        //定位成功后用圆圈表示定位精度范围,默认:true
                    panToLocation: true,     //定位成功后将定位到的位置作为地图中心点,默认:true
                    zoomToAccuracy:true      //定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
                });

                geolocation.getCurrentPosition();
                map.addControl(toolBar);
                map.addControl(scale);
                map.addControl(geolocation);
            });

            var marker = new AMap.Marker();

            marker.setMap(map);
            marker.setDraggable(true);

            $("#getLocation").click(function(e){
                var city_name = $('#city_name').val();
                city_name = city_name.replace(/\//g, '');

                var detail_address = city_name + $('#address').val();

                AMap.service('AMap.Geocoder',function(){//回调函数
                    //实例化Geocoder
                    geocoder = new AMap.Geocoder({
                    });

                    var detailAddress = detail_address;
                    geocoder.getLocation(detailAddress, function(status, result) {
                        if (status === 'complete' && result.info === 'OK') {
                            marker.setPosition(result.geocodes[0].location);
                            map.setCenter(marker.getPosition());
                            $('#lat').val(result.geocodes[0].location.lat);
                            $('#lng').val(result.geocodes[0].location.lng);

                        }else{
                            alert("获取经纬度失败");
                        }
                    });
                })
            });

            map.on('click', function(e) {
                console.log('您在[ '+e.lnglat.getLng()+','+e.lnglat.getLat()+' ]的位置点击了地图!');
                marker.setPosition(e.lnglat);
                map.setCenter(marker.getPosition());
                $('#lat').val(e.lnglat.getLat());
                $('#lng').val(e.lnglat.getLng());
            });
        });

    </script>

@endsection