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

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

    <script src="{{ session()->get('is_we7')=='true'?'/addons/furnitureWe7/public':'' }}/base/js/fileinput.js" type="text/javascript"></script>
    <script src="{{ session()->get('is_we7')=='true'?'/addons/furnitureWe7/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">电子画报名称</label>

                                            <div class="col-sm-9">
                                                <input id="data_illustrated_name" name="data[illustrated_name]"
                                                       class="form-control" value="{{ $data['illustrated_name'] 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">
                                                <input id="data_name" name="data[name]" class="form-control"
                                                       value="{{ $data['name'] 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">
                                                {!!  widget('Tools.ImgUpload')->single('avatar',"data[avatar]", isset($data['avatar'])? $data['avatar'] : "") !!}

                                            </div>

                                        </div>

                                    <div class="form-group">

                                        <label class="control-label col-sm-3">厂家LOGO(130*130)</label>
                                        <div class="col-sm-9">
                                            {!!  widget('Tools.ImgUpload')->single2('/upload/logo','logo',"logo",  isset($data['logo'])? $data['logo'] : '',array("sizex"=>130,"sizey"=>130)) !!}
                                        </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[G_app_id]"
                                                   class="form-control"
                                                   value="{{ $data['G_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[G_app_secret]"
                                                   class="form-control"
                                                   value="{{ $data['G_app_secret'] or ''}}" required=""
                                                   aria-required="true" placeholder="">
                                        </div>

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

                                        <label class="control-label col-sm-3">公众号TemplateID</label>

                                        <div class="col-sm-9">
                                            <input id="data_wxaccount_template_id" name="data[wxaccount_template_id]"
                                                   class="form-control"
                                                   value="{{ $data['wxaccount_template_id'] or ''}}" 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[getPhone]" value="1"
                                                       @if(isset($data['getPhone']) && $data['getPhone'] == '1')checked="checked" @endif/>是
                                            </label>
                                            <label class="radio-inline">
                                                <input type="radio" name="data[getPhone]" value="0"
                                                       @if(isset($data['getPhone']) && $data['getPhone'] == '0')checked="checked" @endif/>否
                                            </label>
                                        </div>

                                    </div>



                                      <hr/>
                                   {{-- <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[app_id]" class="form-control"
                                                   value="{{ $data['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_app_secret" name="data[app_secret]" class="form-control"
                                                   value="{{ $data['app_secret'] 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_xyx_id" name="data[xyx_id]" class="form-control"
                                                       value="{{ $data['xyx_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_xyx_secret" name="data[xyx_secret]" class="form-control"
                                                       value="{{ $data['xyx_secret'] or ''}}" required=""
                                                       aria-required="true" placeholder="">
                                            </div>

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

                                            <label class="control-label col-sm-3">画册TemplateId</label>

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

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

                                            <label class="control-label col-sm-3">电话</label>

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

                                        </div>

                                        <!--引入高德地图API-->
                                        <script type="text/javascript"
                                                src="https://webapi.amap.com/maps?v=1.3&key=533117702a063eae1dc26c183a1ac7bb&plugin=AMap.Autocomplete"></script>
                                        <script type="text/javascript"
                                                src="https://cache.amap.com/lbs/static/addToolbar.js"></script>
                                        <div class="form-group">
                                            <label class="control-label col-sm-3">地址<span
                                                        style="color: red">*</span></label>
                                            <div class="col-sm-9">
                                                <input n name="data[address]" readonly="true"
                                                       value="{{$data['address'] or ''}}" class="form-control" id="add"
                                                       data-toggle="modal"
                                                       data-target="#myModal">
                                            </div>
                                        </div>

                                        <input type="hidden" name="lon" id="lon" value="{{$data['lon'] or ''}}">
                                        <input type="hidden" name="lat" id="lat" value="{{$data['lat'] or ''}}">

                                    <div class="form-group">

                                        <label class="control-label col-sm-3">画册广告图</label>
                                        <div class="col-sm-9">
                                            {!!  widget('Tools.ImgUpload')->multi2('/upload/banner','banner',"data[banner]", isset($data['banner'])? $data['banner'] : '',[]) !!}
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">经销商画报</label>
                                        <div class="col-sm-9">
                                            {{--     //{!! ueditor('') !!}--}}
                                            {!!  widget('Tools.ImgUpload')->multi2('/upload/agent_banner','agent_banner',"data[agent_banner]",  isset($data['agent_banner'])? $data['agent_banner'] : '') !!}
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="control-label col-sm-3">个人二维码画报
                                            <br/>
                                            <small class="text-navy">(440像素 * 440像素)</small>
                                           </label>
                                        <div class="col-sm-9">
                                            {!!  widget('Tools.ImgUpload')->single2('/upload/circleOfFriends','circleOfFriends',"circleOfFriends",  isset($data['circleOfFriends'])? $data['circleOfFriends'] : '',array("sizex"=>440,"sizey"=>440)) !!}
                                        </div>
                                    </div>
                                    <div class="form-group">

                                        <label class="control-label col-sm-3">个人二维码介绍语</label>

                                        <div class="col-sm-9">
                                            <input id="data_introduce" name="data[introduce]" class="form-control"
                                                   value="{{ $data['introduce'] 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[is_audit]" value="1"
                                                       @if(isset($data['is_audit']) && $data['is_audit'] == '1')checked="checked" @endif/>过审版
                                            </label>
                                            <label class="radio-inline">
                                                <input type="radio" name="data[is_audit]" value="0"
                                                       @if(isset($data['is_audit']) && $data['is_audit'] == '0')checked="checked" @endif/>应用版
                                            </label>
                                        </div>

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

                                        <label class="control-label col-sm-3">分享画面
                                            <br/>
                                            <small class="text-navy">(1080像素 * 1080像素)</small>
                                           </label>
                                        <div class="col-sm-9">
                                            {{--{!!  widget('Tools.ImgUpload')->single2('/upload/cover_pic','cover_pic',"cover_pic",  isset($data['cover_pic'])? $data['cover_pic'] : '',array("sizex"=>662,"sizey"=>510)) !!}--}}
                                            {!!  widget('Tools.ImgUpload')->single2('/upload/share_image','share_image',"share_image",  isset($data['share_image'])? $data['share_image'] : '',array("sizex"=>1080,"sizey"=>1080)) !!}
                                            <button type="button" onclick="layer.open({type: 2,area: ['80%', '90%'],content: '{{ U('Album/Manufacturer/viewShare')}}'});"  class="btn btn-primary col-sm-offset-3">查看示例</button>
                                        </div>
                                    </div>
                                    <div class="form-group">

                                        <label class="control-label col-sm-3">分享标题</label>

                                        <div class="col-sm-9">
                                            <input id="data_introduce" name="data[share_title]" class="form-control" value="{{ $data['share_title'] 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">
                                            {!!  widget('Tools.ImgUpload')->single('avatar',"data[avatar]", isset($data['avatar'])? $data['avatar'] : "") !!}

                                        </div>

                                    </div>
                                    <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">首页广告图片</label>

                                          <div class="col-sm-9">
                                              {!!  widget('Tools.ImgUpload')->single('advertising_pic',"data[advertising_pic]", isset($data['advertising_pic'])? $data['advertising_pic'] : "") !!}
                                          </div>

                                      </div>--}}

                                    <div class="form-group">

                                        <label class="control-label col-sm-3">家具首页广告图片</label>

                                        <div class="col-sm-9">
                                            {!!  widget('Tools.ImgUpload')->single('furniture_ads_pic',"data[furniture_ads_pic]", isset($data['furniture_ads_pic'])? $data['furniture_ads_pic'] : "") !!}
                                        </div>

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

                                        <label class="control-label col-sm-3">公告(不超过100字)</label>

                                        <div class="col-sm-9">
                                            <input id="data_notice" name="data[notice]" class="form-control"
                                                   value="{{ $data['notice'] 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[show_notice]" value="1"
                                                       @if(isset($data['show_notice']) && $data['show_notice'] == '1')checked="checked" @endif/>显示
                                            </label>
                                            <label class="radio-inline">
                                                <input type="radio" name="data[show_notice]" value="0"
                                                       @if(isset($data['show_notice']) && $data['show_notice'] == '0')checked="checked" @endif/>不显示
                                            </label>
                                        </div>

                                    </div>

                                    <div class="form-group">

                                        <label class="control-label col-sm-3">公告图标
                                            <br/>
                                            <small class="text-navy">(50像素 * 50像素)</small></label>
                                        <div class="col-sm-9">
                                            {!!  widget('Tools.ImgUpload')->single2('/upload/notice','notice_icon',"notice_icon",  isset($data['notice_icon'])? $data['notice_icon'] : '',array("sizex"=>50,"sizey"=>50)) !!}
                                        </div>

                                    </div>



                                    <hr/>
                                    {{-- <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[app_id]" class="form-control"
                                                    value="{{ $data['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_app_secret" name="data[app_secret]" class="form-control"
                                                    value="{{ $data['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">
                                            {!!  widget('Tools.ImgUpload')->multi2('/upload/banner','banner',"data[banner]", isset($data['banner'])? $data['banner'] : '',[]) !!}
                                        </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="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>视频列表</h5>
                    </div>
                    <div class="ibox-content">
                        <form enctype="multipart/form-data" method="post" action="{{ U('Album/Manufacturer/uploadVideo') }}">
                            <div class="form-group">
                                <input id="file-0b" class="file" type="file" name="video">
                            </div>
                            {{csrf_field()}}
                        </form>
                        <table class="table">
                            <thead>
                            <tr>
                                <th>#</th>
                                <th>链接</th>
                                <th>文件名</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            @if(!empty($video))
                                <tr>
                                    <td>{{ $video['id'] }}</td>
                                    <td>{{ $video['name'] }}</td>
                                    <td>{{ $video['url'] }}</td>
                                    <td>
                                        <div class="btn-group">
                                            <button data-toggle="dropdown"
                                                    class="btn btn-warning btn-sm dropdown-toggle"
                                                    aria-expanded="false">
                                                操作 <span class="caret"></span>
                                            </button>
                                            <ul class="dropdown-menu">
                                                <li><a href="{{ U('Album/Manufacturer/videoDel',['id'=>$video['id']])}}" onclick="return confirm('你确定执行删除操作？');">删除</a></li>
                                            </ul>
                                        </div>


                                    </td>
                                </tr>
                            @else
                                <tr>
                                    <td colspan="4">暂无文件</td>
                                </tr>
                            @endif

                            </tbody>
                        </table>

                    </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