dyjh 6 years ago
parent
commit
542cc9a06b

+ 35 - 11
app/Http/Controllers/Admin/Base/IndexController.php

xqd xqd
@@ -11,6 +11,7 @@ namespace App\Http\Controllers\Admin\Base;
 
 use App\Http\Controllers\Admin\Controller;
 use App\Models\AdminUserModel;
+use App\Models\AlbumAgentModel;
 use App\Models\AlbumStatisticalModel;
 use App\Models\AlbumUserModel;
 use App\Models\AlbumWatchRecord;
@@ -44,21 +45,44 @@ class IndexController extends Controller
         }
         return view('admin.base.index.index',compact('menus'));
     }
-    function welcome() {
-        $time = mktime(24,60,60,date('m'),date('d'),date('Y'));
+    function welcome()
+    {
+        $time = mktime(24, 60, 60, date('m'), date('d'), date('Y'));
         $day = '[';
         $count = '[';
-        for($i=15;$i>=1;$i--){
-            $startTime = $time-$i*86400;
-            $day .= "\"".date('m-d',$startTime)."\",";
-            $start_time = date('Y-m-d H:i:s',$startTime);
-            $end_time = date('Y-m-d H:i:s',$startTime+86400);
+        for ($i = 15; $i >= 1; $i --) {
+            $startTime = $time - $i * 86400;
+            $day .= "\"" . date('m-d', $startTime) . "\",";
+            $start_time = date('Y-m-d H:i:s', $startTime);
+            $end_time = date('Y-m-d H:i:s', $startTime + 86400);
             $num = AlbumWatchRecord::where([['store_id',$this->getStoreId()],['created_at','>=',$start_time],['created_at','<=',$end_time],['action',4]])->groupBy('open_id')->count();
-            $count .= $num.",";
+            $count .= $num . ",";
+        }
+        $agents = AlbumAgentModel::where('status', 1)->get()->toArray();
+        $data = array();
+        $geoCoordMap = (object)[];
+        foreach ($agents as $key => $val) {
+            $count_all = AlbumWatchRecord::where([
+                ['agent_id', $val['id']],
+                ['store_id', $this->getStoreId()]
+            ])->groupBy('open_id')->count();
+            $data[] = (object)[
+                'name' => $val['realname'],
+                'value' => $count_all
+            ];
+            $name = $val['realname'];
+            $geoCoordMap->$name = [$val['lon'], $val['lat']];
         }
-        $day = substr($day,0,strlen($day)-1).']';
-        $count = substr($count,0,strlen($count)-1).']';
-        return view('admin.base.index.welcome',['day'=>$day,'count'=>$count]);
+        $data = json_encode($data);
+        $geoCoordMap = json_encode($geoCoordMap);
+        $day = substr($day, 0, strlen($day) - 1) . ']';
+        $count = substr($count, 0, strlen($count) - 1) . ']';
+        return view('admin.base.index.welcome', [
+            'day' => $day,
+            'count' => $count,
+            'data' => $data,
+            'geoCoordMap' => $geoCoordMap
+        ]);
     }
 
     public function getData(Request $request)

+ 4 - 4
app/Http/Controllers/Api/V1/AlbumController.php

xqd
@@ -1991,12 +1991,12 @@ class AlbumController extends Controller
 
         if($userAuth->is_dealer!=1) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '该用户不是经销商!', $validator->messages());
        $user_agent = AlbumAgentModel::where('user_id',$userAuth->id)->first();
-        $customer = CustomerDetailsModel::where([['store_id',$store_id],['open_id',$open_id],['agent_id',$user_agent->id]])->first(['purpose_level','comment','tips','address']);
+        $customer = CustomerDetailsModel::where([['store_id',$store_id],['open_id',$open_id],['agent_id',$user_agent->id]])->first(['purpose_level','comment','tips','address'])->toArray();
         if(!empty($customer)){
             $user = AlbumUserModel::where([['store_id',$store_id],['open_id',$open_id]])->first();
-            $customer->phone = $user->phone;
-            $customer->avatar = $user->avatar;
-            $customer->username = $user->username;
+            $customer['phone'] = $user->phone;
+            $customer['avatar'] = $user->avatar;
+            $customer['username'] = $user->username;
         }
         return $this->api(compact('customer'));
     }

File diff suppressed because it is too large
+ 21 - 0
public/base/js/bmap.min.js


+ 211 - 1
resources/views/admin/base/index/welcome.blade.php

xqd xqd xqd xqd
@@ -2,6 +2,8 @@
 
 @section('content')
     <script type="text/javascript" src="/base/js/echarts.min.js"></script>
+    <script type="text/javascript" src="/base/js/bmap.min.js"></script>
+    <script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=ilwzGs0qcpFhGZz0lkMtHR81edFj08L8"></script>
     <style>
         .statistical {
 
@@ -214,6 +216,7 @@
         .index_info_box {width:60px;}
     </style>
     <div class="wrapper wrapper-content">
+        <div id="container_map" style="height: 300px;background-color: red;"></div>
         <div class="switch">
             <div id="7">7天</div>
             <div id="15" class="active_switch">15天</div>
@@ -296,7 +299,6 @@
                 areaStyle: {}
             }]
         };
-        ;
         if (option && typeof option === "object") {
             myChart.setOption(option, true);
         }
@@ -325,5 +327,213 @@
         $(document).ready(function(){
             $('#7').click();
         })
+
+
+    </script>
+    <script type="text/javascript">
+        var data = "{{ $data }}";
+        data = JSON.parse(data.replace(/&quot;/g,'\"'));
+        var geoCoordMap = "{{ $geoCoordMap }}";
+        geoCoordMap = JSON.parse(geoCoordMap.replace(/&quot;/g,'\"'));
+        var dom_map = document.getElementById("container_map");
+        var myChart_map = echarts.init(dom_map);
+        var app = {};
+        option = null;
+
+
+        var convertData = function (data) {
+            var res = [];
+            for (var i = 0; i < data.length; i++) {
+                var geoCoord = geoCoordMap[data[i].name];
+                if (geoCoord) {
+                    res.push({
+                        name: data[i].name,
+                        value: geoCoord.concat(data[i].value)
+                    });
+                }
+            }
+            return res;
+        };
+
+        option = {
+            title: {
+                text: '全国经销商分布图',
+                left: 'center'
+            },
+            tooltip : {
+                trigger: 'item'
+            },
+            tooltip : {
+                trigger: 'item',
+                formatter: function(data){
+                    //console.log(data)
+                    return data.name+': '+data.value[2];
+                }
+            },
+            bmap: {
+                center: [104.114129, 37.550339],
+                zoom: 5,
+                roam: true,
+                mapStyle: {
+                    styleJson: [{
+                        'featureType': 'water',
+                        'elementType': 'all',
+                        'stylers': {
+                            'color': '#d1d1d1'
+                        }
+                    }, {
+                        'featureType': 'land',
+                        'elementType': 'all',
+                        'stylers': {
+                            'color': '#f3f3f3'
+                        }
+                    }, {
+                        'featureType': 'railway',
+                        'elementType': 'all',
+                        'stylers': {
+                            'visibility': 'off'
+                        }
+                    }, {
+                        'featureType': 'highway',
+                        'elementType': 'all',
+                        'stylers': {
+                            'color': '#fdfdfd'
+                        }
+                    }, {
+                        'featureType': 'highway',
+                        'elementType': 'labels',
+                        'stylers': {
+                            'visibility': 'off'
+                        }
+                    }, {
+                        'featureType': 'arterial',
+                        'elementType': 'geometry',
+                        'stylers': {
+                            'color': '#fefefe'
+                        }
+                    }, {
+                        'featureType': 'arterial',
+                        'elementType': 'geometry.fill',
+                        'stylers': {
+                            'color': '#fefefe'
+                        }
+                    }, {
+                        'featureType': 'poi',
+                        'elementType': 'all',
+                        'stylers': {
+                            'visibility': 'off'
+                        }
+                    }, {
+                        'featureType': 'green',
+                        'elementType': 'all',
+                        'stylers': {
+                            'visibility': 'off'
+                        }
+                    }, {
+                        'featureType': 'subway',
+                        'elementType': 'all',
+                        'stylers': {
+                            'visibility': 'off'
+                        }
+                    }, {
+                        'featureType': 'manmade',
+                        'elementType': 'all',
+                        'stylers': {
+                            'color': '#d1d1d1'
+                        }
+                    }, {
+                        'featureType': 'local',
+                        'elementType': 'all',
+                        'stylers': {
+                            'color': '#d1d1d1'
+                        }
+                    }, {
+                        'featureType': 'arterial',
+                        'elementType': 'labels',
+                        'stylers': {
+                            'visibility': 'off'
+                        }
+                    }, {
+                        'featureType': 'boundary',
+                        'elementType': 'all',
+                        'stylers': {
+                            'color': '#fefefe'
+                        }
+                    }, {
+                        'featureType': 'building',
+                        'elementType': 'all',
+                        'stylers': {
+                            'color': '#d1d1d1'
+                        }
+                    }, {
+                        'featureType': 'label',
+                        'elementType': 'labels.text.fill',
+                        'stylers': {
+                            'color': '#999999'
+                        }
+                    }]
+                }
+            },
+            series : [
+                {
+                    name: '',
+                    type: 'scatter',
+                    coordinateSystem: 'bmap',
+                    data: convertData(data),
+                    symbolSize: function (val) {
+                        return val[2] / 10;
+                    },
+                    label: {
+                        normal: {
+                            formatter: '{b}',
+                            position: 'right',
+                            show: false
+                        },
+                        emphasis: {
+                            show: true
+                        }
+                    },
+                    itemStyle: {
+                        normal: {
+                            color: 'purple'
+                        }
+                    }
+                },
+                {
+                    name: 'Top 5',
+                    type: 'effectScatter',
+                    coordinateSystem: 'bmap',
+                    data: convertData(data.sort(function (a, b) {
+                        return b.value - a.value;
+                    }).slice(0, 6)),
+                    symbolSize: function (val) {
+                        return val[2] / 10;
+                    },
+                    showEffectOn: 'render',
+                    rippleEffect: {
+                        brushType: 'stroke'
+                    },
+                    hoverAnimation: true,
+                    label: {
+                        normal: {
+                            formatter: '{b}',
+                            position: 'right',
+                            show: true
+                        }
+                    },
+                    itemStyle: {
+                        normal: {
+                            color: 'purple',
+                            shadowBlur: 10,
+                            shadowColor: '#333'
+                        }
+                    },
+                    zlevel: 1
+                }
+            ]
+        };;
+        if (option && typeof option === "object") {
+            myChart_map.setOption(option, true);
+        }
     </script>
 @endsection

Some files were not shown because too many files changed in this diff