@extends('admin.layout')
@section('header')

    <link href="{{ session()->get('is_we7')=='true'?'/addons/online_album/public':'' }}/base/css/fileinput.css" media="all" rel="stylesheet" type="text/css" />

    <script src="{{ session()->get('is_we7')=='true'?'/addons/online_album/public':'' }}/base/js/fileinput.js" type="text/javascript"></script>
    <script src="{{ session()->get('is_we7')=='true'?'/addons/online_album/public':'' }}/base/js/fileinput_locale_zh.js" type="text/javascript"></script>

@endsection
@section('content')

    <?php
    if (!isset($data)) $data = array();
    if (!$data && session("data")) {
        $data = session("data");
    }
    if (!$data && session('_old_input')) {
        $data = session("_old_input");
    }
    ?>
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>系统设置</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link"> <i class="fa fa-chevron-up"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div class="row">
                            <div class="col-lg-10">
                                <form name="form_product" id="form-validation" action=""
                                      class="form-horizontal form-validation" accept-charset="UTF-8" method="post">


                                        <div class="form-group">

                                            <label class="control-label col-sm-3">产品跳转小程序appID</label>

                                            <div class="col-sm-9">
                                                <input id="data_app_id" name="data[goods_app_id]" class="form-control"
                                                       value="{{ $data['goods_app_id'] or ''}}" required=""
                                                       aria-required="true"
                                                       placeholder="">
                                            </div>

                                        </div>
                                        <div class="form-group">

                                            <label class="control-label col-sm-3">产品跳转小程序的url</label>

                                            <div class="col-sm-9">
                                                <input id="data_app_path" name="data[goods_app_path]"
                                                       class="form-control"
                                                       value="{{ $data['goods_app_path'] or ''}}" required=""
                                                       aria-required="true"
                                                       placeholder="">
                                            </div>

                                        </div>


                                        <div class="form-group">

                                            <label class="control-label col-sm-3">售后小程序appID</label>

                                            <div class="col-sm-9">
                                                <input id="data_service_app_id" name="data[service_app_id]"
                                                       class="form-control"
                                                       value="{{ $data['service_app_id'] or ''}}" required=""
                                                       aria-required="true"
                                                       placeholder="">
                                            </div>

                                        </div>
                                        <div class="form-group">

                                            <label class="control-label col-sm-3">售后小程序appSecret</label>

                                            <div class="col-sm-9">
                                                <input id="data_service_app_secret" name="data[service_app_secret]"
                                                       class="form-control"
                                                       value="{{ $data['service_app_secret'] or ''}}" required=""
                                                       aria-required="true" placeholder="">
                                            </div>

                                        </div>

                                        <div class="form-group">

                                            <label class="control-label col-sm-3">打印机型号</label>

                                            <div class="col-sm-9">
                                                <label class="radio-inline">
                                                    <input type="radio" name="data[print_type]" value="1"
                                                           @if(isset($data['print_type']) && $data['print_type'] == '1')checked="checked" @endif/>飞鹅
                                                </label>
                                                <label class="radio-inline">
                                                    <input type="radio" name="data[print_type]" value="2"
                                                           @if(isset($data['print_type']) && $data['print_type'] == '2')checked="checked" @endif/>365
                                                </label>
                                            </div>

                                        </div>




                                    <div class="form-group">

                                        <label class="control-label col-sm-3">是否开启关注公众号</label>

                                        <div class="col-sm-9">
                                            <label class="radio-inline">
                                                <input type="radio" name="data[getFocus]" value="1"
                                                       @if(isset($data['getFocus']) && $data['getFocus'] == '1')checked="checked" @endif/>是
                                            </label>
                                            <label class="radio-inline">
                                                <input type="radio" name="data[getFocus]" value="0"
                                                       @if(isset($data['getFocus']) && $data['getFocus'] == '0')checked="checked" @endif/>否
                                            </label>
                                        </div>

                                    </div>

                                        <div class="form-group">

                                            <label class="control-label col-sm-3">打印机编号</label>

                                            <div class="col-sm-9">
                                                <input id="data_print_no" name="data[print_no]" class="form-control"
                                                       value="{{ $data['print_no'] or ''}}" placeholder="">
                                            </div>

                                        </div>
                                        <div class="form-group">

                                            <label class="control-label col-sm-3">打印机秘钥</label>

                                            <div class="col-sm-9">
                                                <input id="data_print_key" name="data[print_key]" class="form-control"
                                                       value="{{ $data['print_key'] or ''}}" placeholder="">
                                            </div>

                                        </div>

                                    <div class="form-group">
                                        <label class="control-label col-sm-3">&nbsp;</label>
                                        <div class="col-sm-9">
                                            <input type="hidden" name="_referer"
                                                   value="<?php echo urlencode(request()->server('HTTP_REFERER'));?>"/>
                                            <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>"/>
                                            <input type="submit" class="btn btn-success" style="margin-right:20px;">
                                            <input type="reset" class="btn btn-default">
                                        </div>
                                    </div>

                                </form>
                            </div>
                            <!-- /.col-lg-10 -->
                        </div>
                        <!-- /.row -->
                    </div>
                </div>
            </div>
        </div>


        <div class="modal fade" id="myModal" tabindex="-1" role="dialog"
             aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog" style="min-width:60%;">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title" id="myModalLabel">
                            选择坐标
                        </h4>
                    </div>
                    <div class="modal-body">
                        <div id="container" style="width: 100%;min-height: 400px;"></div>
                        <div id="myPageTop">
                            <table>
                                <tr>
                                    <td>
                                        <label>按关键字搜索：</label>
                                    </td>
                                    <td>

                                    </td>

                                </tr>
                                <tr>
                                    <td>
                                        <input style="margin-right: 10px;min-width:300px"
                                               value="{{ isset($data['address'])?$data['address'] : "" }}" type="text"
                                               placeholder="请输入关键字进行搜索" id="tipinput">
                                    </td>
                                    <td>
                                        <div style="margin-right: 10px;" class="btn btn-sm btn-primary"
                                             id="confirm">显示搜索点
                                        </div>
                                    </td>
                                    <td class="column2">
                                        <input type="hidden" readonly="true" id="lnglat">
                                    </td>
                                </tr>
                            </table>
                            <br>
                            <button type="button" id="modal-close" class="btn btn-sm btn-primary text-center"
                                    data-dismiss="modal">确认位置信息
                            </button>
                        </div>
                        <div id="panel"></div>
                    </div>

                </div><!-- /.modal-content -->
            </div><!-- /.modal -->
        </div>
    </div>


    <script type="text/javascript">
        var map = new AMap.Map("container", {
            resizeEnable: true,
            zoom: 10
        });
        $("#confirm").click(function () {
            var val = $('#tipinput').val();
            AMap.service(["AMap.PlaceSearch"], function () {
                var placeSearch = new AMap.PlaceSearch({ //构造地点查询类
                    pageSize: 5,
                    pageIndex: 1,
                    map: map,
                    panel: "panel"
                });
                placeSearch.search(val);
            });
        });

        //为地图注册click事件获取鼠标点击出的经纬度坐标
        var clickEventListener = map.on('click', function (e) {
            document.getElementById("lnglat").value = e.lnglat.getLng() + ',' + e.lnglat.getLat();
        });

        AMap.plugin('AMap.Geocoder', function () {
            var geocoder = new AMap.Geocoder({});
            var marker = new AMap.Marker({
                map: map,
                bubble: true
            })
            map.on('click', function (e) {
                console.log(e);
                marker.setPosition(e.lnglat);
                $('#lon').val(e.lnglat.getLng());
                $('#lat').val(e.lnglat.getLat());
                geocoder.getAddress(e.lnglat, function (status, result) {
                    if (status == 'complete') {
                        console.log(result);
                        document.getElementById('tipinput').value = result.regeocode.formattedAddress
                    }
                })
            })

        });
        $("#modal-close").click(function () {
            var b = ($('#tipinput').val());
            console.log(b);
            $('#map').val(b);
            $('#add').val(b);
        });
        /*  $('.sg-datepicker').datepicker({
              format: 'yyyy-mm-dd',
              language: 'zh-CN'
          });*/
    </script>
@endsection