Silent 7 лет назад
Родитель
Сommit
d19501791b

+ 24 - 0
app/Http/Controllers/Admin/Base/LocationController.php

xqd
@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Http\Controllers\Admin\Base;
+
+use Illuminate\Http\Request;
+use App\Http\Controllers\Admin\Controller;
+
+class LocationController extends Controller
+{
+    public function index(Request $request)
+    {
+        $location = $request->input('location');
+
+        $items = explode(',', $location);
+        if(count($items) < 2) {
+            $lat = '39.91652';
+            $lng = '116.397128';
+        } else {
+            $lat = $items[0];
+            $lng = $items[1];
+        }
+        return view('admin.base.locations.index', compact('lat', 'lng'));
+    }
+}

+ 58 - 0
resources/views/admin/base/locations/index.blade.php

xqd
@@ -0,0 +1,58 @@
+@extends('admin.layout')
+
+@section('header')
+<script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp"></script>
+<style>
+
+</style>
+@endsection
+
+@section('content')
+<div class="wrapper wrapper-content animated fadeInRight">
+	<div class="row">
+		<div class="col-sm-12">
+			<div id="location-container"></div>
+		</div>
+	</div>
+	<div class="row">
+		<div class="col-sm-8">
+			<input class="form-control" type="text" id="location-keyword-input">
+		</div>
+		<div class="col-sm-4">
+			<div class="btn btn-primary" id="location-keyword-search">搜索</div>
+		</div>
+	</div>
+</div>
+@endsection
+
+@section('footer')
+<script type="text/javascript">
+$(function() {
+    var map = new qq.maps.Map(document.getElementById('location-container'),{
+        center: new qq.maps.LatLng('{{ $lat }}', '{{ $lng }}'),
+        zoom: 13
+    });
+    //添加监听事件   获取鼠标单击事件
+    qq.maps.event.addListener(map, 'click', function(event) {
+        var marker = new qq.maps.Marker({
+            position:event.latLng,
+            map:map
+        });
+
+        qq.maps.event.addListener(map, 'click', function(event) {
+            marker.setMap(null);
+        });
+
+        var searchService = new qq.maps.SearchService({
+            panel:document.getElementById('location-keyword-search'),
+            map : map
+        });
+
+        var regionText = $('#location-keyword-input').val();
+
+        searchService.setLocation(regionText);
+        searchService.search();
+    });
+});
+</script>
+@endsection

+ 13 - 1
resources/views/admin/settings/system.blade.php

xqd
@@ -55,7 +55,19 @@
 <script type="text/javascript">
 $(function () {
     $('#location-select').on('click', function () {
-       alert('ok');
+        var location = '{{ $check_card_location->value }}';
+        layer.open({
+            type: 2,
+            title: '选择地点',
+            shadeClose: true,
+            shade: 0.8,
+            area: ['80%', '90%'],
+            content: '/admin/Base/Location/index?location=' + location,
+            btn: ['确定'],
+            yes: function(index, layer_body) {
+
+            }
+        });
     });
 })
 </script>