competitionStore.js 2.95 KB
(function(angular) {
    function competitionStore($scope, aiNicheService, Utils) {
        $scope.displayTable = true;
        $scope.timePicked = '';
        $scope.timePick = function (timePicked) {
            this.timePicked = timePicked;
        };

        // 这边定义一个 init 方法
        $scope.umcInstance = {
            init: function () {
                //$scope.umcInstance.setMapStyle();
                $scope.umcInstance.setMapFeatures();
                var shopPoint,info;
                //点
                aiNicheService.getLngLatShop(function (response) {
                    if(response.data && response.data.lngLatShop != null){
                        shopPoint = response.data.lngLatShop;
                        info = response.data.store_name;
                        $scope.umcInstance.residenceCircle(shopPoint,info);
                    }
                });

                getCarPermanentInfoWay();

                $scope.tableSearch = function(){
                    $scope.umcInstance.clearMarker();
                    getCarPermanentInfoWay();
                };
            }
        };

        //常驻地标点
        var LngLat = {};
        var getCarPermanentInfoWay = function () {

            $scope.carPermanentInfo = [];
            var params = getParams();
            //清空之前的点,初始化
            LngLat = {};
            aiNicheService.getCarPermanentInfo(params,function(response) {
                $scope.carPermanentInfo = response.data;
                // angular.forEach(response.data,function (item) {
                //     LngLat.push(item.location);
                //     LngLat.push(item.id);
                //     LngLat.push(item.name);
                // });

                LngLat = response.data;
                $scope.umcInstance.residenceMarkers(LngLat);
            });
        };

        function getParams() {
            var obj = {};

            if($scope.timePicked==4){
                obj.minDistance = 0;
                obj.maxDistance = 5;
            }
            if($scope.timePicked==3){
                obj.minDistance = 5;
                obj.maxDistance = 10;
            }
            if($scope.timePicked==2){
                obj.minDistance = 10;
                obj.maxDistance = 20;
            }
            if($scope.timePicked==1){
                obj.minDistance = 20;
                obj.maxDistance = 300;
            }
            return obj;
        }

        $scope.exportExcel = function () {
            if ($scope.isExporting) return;
            var params = getParams();
            var options = {
                url: "carPermanent/exportCarPermanent"
            };
            Utils.exportExcel(options, params, function () {
                $scope.$apply(function () {
                    $scope.isExporting = false
                })
            });
        };
    }

    angular.module('AIniche', ['map']).controller('competitionStore', competitionStore)

})(angular);