/**
 * Make sure the charset of the page using this script is
 * set to utf-8 or you will not get the correct results.
 */
var utf8 = (function () {
    var highSurrogateMin = 0xd800,
        highSurrogateMax = 0xdbff,
        lowSurrogateMin  = 0xdc00,
        lowSurrogateMax  = 0xdfff,
        surrogateBase    = 0x10000;
    
    function isHighSurrogate(charCode) {
        return highSurrogateMin <= charCode && charCode <= highSurrogateMax;
    }
    
    function isLowSurrogate(charCode) {
        return lowSurrogateMin <= charCode && charCode <= lowSurrogateMax;
    }
    
    function combineSurrogate(high, low) {
        return ((high - highSurrogateMin) << 10) + (low - lowSurrogateMin) + surrogateBase;
    }
    
    /**
     * Convert charCode to JavaScript String
     * handling UTF16 surrogate pair
     */
    function chr(charCode) {
        var high, low;
        
        if (charCode < surrogateBase) {
            return String.fromCharCode(charCode);
        }
        
        // convert to UTF16 surrogate pair
        high = ((charCode - surrogateBase) >> 10) + highSurrogateMin,
        low  = (charCode & 0x3ff) + lowSurrogateMin;
        
        return String.fromCharCode(high, low);
    }
    
    /**
     * Convert JavaScript String to an Array of
     * UTF8 bytes
     * @export
     */
    function stringToBytes(str) {
        var bytes = [],
            strLength = str.length,
            strIndex = 0,
            charCode, charCode2;
        
        while (strIndex < strLength) {
            charCode = str.charCodeAt(strIndex++);
            
            // handle surrogate pair
            if (isHighSurrogate(charCode)) {
                if (strIndex === strLength) {
                    throw new Error('Invalid format');
                }
                
                charCode2 = str.charCodeAt(strIndex++);
                
                if (!isLowSurrogate(charCode2)) {
                    throw new Error('Invalid format');
                }
                
                charCode = combineSurrogate(charCode, charCode2);
            }
            
            // convert charCode to UTF8 bytes
            if (charCode < 0x80) {
                // one byte
                bytes.push(charCode);
            }
            else if (charCode < 0x800) {
                // two bytes
                bytes.push(0xc0 | (charCode >> 6));
                bytes.push(0x80 | (charCode & 0x3f));
            }
            else if (charCode < 0x10000) {
                // three bytes
                bytes.push(0xe0 | (charCode >> 12));
                bytes.push(0x80 | ((charCode >> 6) & 0x3f));
                bytes.push(0x80 | (charCode & 0x3f));
            }
            else {
                // four bytes
                bytes.push(0xf0 | (charCode >> 18));
                bytes.push(0x80 | ((charCode >> 12) & 0x3f));
                bytes.push(0x80 | ((charCode >> 6) & 0x3f));
                bytes.push(0x80 | (charCode & 0x3f));
            }
        }
        
        return bytes;
    }

    /**
     * Convert an Array of UTF8 bytes to
     * a JavaScript String
     * @export
     */
    function bytesToString(bytes) {
        var str = '',
            length = bytes.length,
            index = 0,
            byte,
            charCode;
        
        while (index < length) {
            // first byte
            byte = bytes[index++];
            
            if (byte < 0x80) {
                // one byte
                charCode = byte;
            }
            else if ((byte >> 5) === 0x06) {
                // two bytes
                charCode = ((byte & 0x1f) << 6) | (bytes[index++] & 0x3f);
            }
            else if ((byte >> 4) === 0x0e) {
                // three bytes
                charCode = ((byte & 0x0f) << 12) | ((bytes[index++] & 0x3f) << 6) | (bytes[index++] & 0x3f);
            }
            else {
                // four bytes
                charCode = ((byte & 0x07) << 18) | ((bytes[index++] & 0x3f) << 12) | ((bytes[index++] & 0x3f) << 6) | (bytes[index++] & 0x3f);
            }
            
            str += chr(charCode);
        }
        
        return str;
    }
    
    return {
        stringToBytes: stringToBytes,
        bytesToString: bytesToString
    };
}());

'use strict';

var app = angular.module('app', [
    'ui.router',
    'templatescache',
    'ui.bootstrap',
    'ngAnimate',
    'ngCookies'
]);
angular.module('app').run(['$rootScope', '$state', '$stateParams',
    function($rootScope, $state, $stateParams) {
        $rootScope.$state = $state;
        $rootScope.$stateParams = $stateParams;
    }
]).config(['$stateProvider', '$urlRouterProvider',
    function($stateProvider, $urlRouterProvider) {
        $urlRouterProvider.otherwise('/home'); //
        $stateProvider.state('home', {
                url: '/home',
                templateUrl: 'templates/home.html',
                controller: 'HomeController'
            })
            .state('webChat', {
                url: '/webChat',
                templateUrl: 'templates/webChat.html',
                controller: 'WebController'
            })
            .state('webChat.conComplain', {
                url: '/conComplain',
                templateUrl: 'templates/webChat-1.html',
                controller: 'WebController'
            })
            .state('webChat.queryEv', {
                url: '/queryEv',
                templateUrl: 'templates/webChat-2.html',
                controller: 'WebController'
            })
            .state('webChat.dyInfo', {
                url: '/dyInfo',
                templateUrl: 'templates/webChat-3.html',
                controller: 'WebController'
            })
            .state('webChat.phoneLogin', {
                url: '/phoneLogin',
                templateUrl: 'templates/webChat-4.html',
                controller: 'WebController'
            }).state('webChat.online', {
                url: '/online',
                templateUrl: 'templates/webChat-5.html',
                controller: 'WebController'
            });
    }
]);
angular.module('templatescache', []).run(['$templateCache', function($templateCache) {$templateCache.put('templates/home.html','<div class="main">\r\n    <header>\r\n        <!--<div class="header111">\r\n            <img src="../img/webChatImg/banner.png" alt="">\r\n        </div>-->\r\n        <div class="swiper-container">\r\n            <div class="swiper-wrapper">\r\n                <div class="swiper-slide"><img src="../img/webChatImg/banner.png" alt=""></div>\r\n                <div class="swiper-slide"><img src="../img/webChatImg/banner.png" alt=""></div>\r\n                <div class="swiper-slide"><img src="../img/webChatImg/banner.png" alt=""></div>\r\n            </div>\r\n            <!-- \u5982\u679C\u9700\u8981\u5206\u9875\u5668 -->\r\n            <div class="swiper-pagination"></div>\r\n            <!-- \u5982\u679C\u9700\u8981\u5BFC\u822A\u6309\u94AE -->\r\n            <!--<div class="swiper-button-prev"></div>\r\n            <div class="swiper-button-next"></div>-->\r\n            <!-- \u5982\u679C\u9700\u8981\u6EDA\u52A8\u6761 -->\r\n            <!--<div class="swiper-scrollbar"></div>-->\r\n        </div>\r\n    </header>\r\n\r\n    <content>\r\n        <div></div>\r\n    </content>\r\n\r\n    <footer>\r\n        <div class="bg">\r\n            <img src="../img/webChatImg/bg2.jpg" alt="">\r\n        </div>\r\n        <div class="contain" ng-cloak>\r\n            <div class="inquire" ng-cloak>\r\n                <a href="http://www.lszszw.gov.cn/Search.aspx">\r\n                    <img class="breath size1" src="../img/webChatImg/\u81EA\u52A9\u54A8\u8BE2.png" alt=""><span class="explain">\u81EA\u52A9\u54A8\u8BE2</span>\r\n                </a>\r\n            </div>\r\n            <div class="call" ng-cloak>\r\n                <a href="tel:057812345">\r\n                    <img class="breath size2" src="../img/webChatImg/12345.png" alt=""><span class="explain">\u62E8\u625312345</span>\r\n                </a>\r\n            </div>\r\n            <div class="online" ng-cloak>\r\n                <a data-toggle="modal" href="">\r\n                    <img class="breath size3" ng-click="onOnlineClick($event)" src="../img/webChatImg/\u5728\u7EBF\u670D\u52A1.png" alt=""><span ng-click="onOnlineClick($event)" class="explain">\u5728\u7EBF\u670D\u52A1</span>\r\n                </a>\r\n            </div>\r\n            <div class="email" ng-cloak>\r\n                <a ui-sref="webChat.online">\r\n                    <img class="breath size4" src="../img/webChatImg/\u7F51\u4E0A\u4FE1\u7BB1.png" alt=""><span class="explain">\u7F51\u4E0A\u4FE1\u7BB1</span>\r\n                </a>\r\n            </div>\r\n            <div class="result" ng-cloak>\r\n                <a href="">\r\n                    <img class="breath size5" src="../img/webChatImg/\u7ED3\u679C\u67E5\u8BE2.png" alt=""><span class="explain">\u7ED3\u679C\u67E5\u8BE2</span>\r\n                </a>\r\n            </div>\r\n\r\n            <div class="logo">\r\n                <img src="../img/webChatImg/logo.png" alt="">\r\n            </div>\r\n        </div>\r\n    </footer>\r\n    <div class="modal fade errorLogin" id="errorLoginModal" tabindex="-2" data-backdrop="static" role="dialog" aria-labelledby="errorLoginModalLabel" aria-hidden="true">\r\n        <div class="modal-info">\r\n            <p>{{addr.regeocode.addressComponent.district}}\u6682\u4E0D\u652F\u6301\u6B64\u529F\u80FD</p>\r\n            <a href="" data-dismiss="modal" style="color:#888;">\u5173\u95ED</a>\r\n        </div>\r\n    </div>\r\n    <div class="modal fade phoneLogin" id="phoneLoginModal" tabindex="-2" data-backdrop="static" role="dialog" aria-labelledby="phoneLoginModalLabel" aria-hidden="true">\r\n        <div class="modal-info">\r\n            <p>\u8BF7\u8F93\u5165\u624B\u673A\u53F7\u7801</p>\r\n            <input class="form-control input-sm" type="text" ng-model="mobile">\r\n            <a ng-click="onlineService()">\u786E\u5B9A</a>\r\n            <a href="" data-dismiss="modal" style="color:#888;">\u5173\u95ED</a>\r\n        </div>\r\n    </div>\r\n</div>');
$templateCache.put('templates/webChat-1.html','<div class="ui-webView">\r\n    <div class="header">\r\n        <span onClick="javascript :history.back(-1);" class="glyphicon glyphicon-arrow-left"></span><span>\u54A8\u8BE2\u6295\u8BC9</span><span ui-sref="home" class="glyphicon glyphicon-home"></span>\r\n    </div>\r\n    <div class="webContent-1">\r\n        <div class="webImg-1">\r\n        </div>\r\n\r\n        <div class="circular" id="1">\r\n            <span> <p>\u54A8\u8BE2\u6295\u8BC9</p> </span>\r\n        </div>\r\n\r\n        <div class="web-button">\r\n            <div style="height:50px"></div>\r\n            <a href="tel:12345">\r\n                <button type="button" class="btn btn-block">\r\n                \r\n                    <span class="glyphicon glyphicon-comment" aria-hidden="true"></span>\r\n                    <p>\u4EBA\u5DE5\u5BA2\u670D</p>  \r\n                </button>\r\n            </a>\r\n            <a href="https://zjwskj.qiyukf.com/client?k=e52a7ac21a88369ef6c38c56b54c810e&wp=1" target="_blank">\r\n                <button type="button" class="btn btn-block">\r\n                   <span class=" glyphicon glyphicon-phone-alt" aria-hidden="true"></span>\r\n                   <p>\u5728\u7EBF\u54A8\u8BE2</p>\r\n              \r\n               </button>\r\n            </a>\r\n            <button type="button" class="btn btn-block" ui-sref="webChat.online">\r\n              <span class="glyphicon glyphicon-globe" aria-hidden="true"></span>\r\n                  <p>\u7F51\u4E0A\u6295\u8BC9</p>  \r\n            </button>\r\n        </div>\r\n    </div>\r\n</div>');
$templateCache.put('templates/webChat-2.html','<div class="ui-webView">\r\n    <div class="header">\r\n        <span onClick="javascript :history.back(-1);" class="glyphicon glyphicon-arrow-left"></span><span>\u67E5\u8BE2\u8BC4\u4EF7</span><span ui-sref="home" class="glyphicon glyphicon-home"></span>\r\n    </div>\r\n    <div class="webContent-1">\r\n        <div class="webImg-1">\r\n        </div>\r\n\r\n        <div class="circular" id="color2">\r\n            <span> <p>\u67E5\u8BE2\u8BC4\u4EF7</p> </span>\r\n        </div>\r\n\r\n        <div class="web-button" id="btn2">\r\n            <div style="height:50px"></div>\r\n            <button type="button" class="btn  btn-block">\r\n            <span class="glyphicon glyphicon-phone" aria-hidden="true"></span>\r\n            <p>\u624B\u673A\u53F7\u67E5\u8BE2</p>  \r\n        </button>\r\n            <button type="button" class="btn btn-block">\r\n             <span class="glyphicon glyphicon-barcode" aria-hidden="true"></span>\r\n             <p>\u67E5\u8BE2\u7801\u67E5\u8BE2</p>  \r\n          </button>\r\n        </div>\r\n    </div>\r\n</div>');
$templateCache.put('templates/webChat-3.html','<div class="ui-webView">\r\n    <div class="header">\r\n        <span onClick="javascript :history.back(-1);" class="glyphicon glyphicon-arrow-left"></span><span>\u52A8\u6001\u4FE1\u606F</span><span ui-sref="home" class="glyphicon glyphicon-home"></span>\r\n    </div>\r\n    <div class="webContent-1">\r\n        <div class="webImg-1">\r\n        </div>\r\n\r\n        <div class="circular" id="color3">\r\n            <span> <p>\u52A8\u6001\u4FE1\u606F</p> </span>\r\n        </div>\r\n\r\n        <div class="web-button" id="btn3">\r\n            <div style="height:50px"></div>\r\n            <button type="button" class="btn  btn-block">\r\n           <span class="glyphicon glyphicon-comment" aria-hidden="true"></span>\r\n           <p>\u5E73\u53F0\u7B80\u4ECB</p>  \r\n        </button>\r\n            <button type="button" class="btn btn-block">\r\n            <span class=" glyphicon glyphicon-phone-alt btn3-2" aria-hidden="true"></span>\r\n            <p>\u9886\u5BFC\u63A5\u542C\u9884\u544A</p>  \r\n          </button>\r\n            <button type="button" class="btn  btn-block">\r\n             <span class="glyphicon glyphicon-globe" aria-hidden="true"></span>\r\n             <p>\u5DE5\u4F5C\u52A8\u6001</p>  \r\n        </button>\r\n        </div>\r\n    </div>\r\n</div>');
$templateCache.put('templates/webChat-4.html','');
$templateCache.put('templates/webChat-5.html','<div class="header">\r\n    <span onClick="javascript :history.back(-1);" class="glyphicon glyphicon-arrow-left"></span><span>\u7F51\u4E0A\u4FE1\u7BB1</span><span ui-sref="home" class="glyphicon glyphicon-home"></span>\r\n</div>\r\n<div class="webContent-2" ng-click="footShow($event)">\r\n    <!--<div class="webimg-2">\r\n        <img src="../img/\u4ED9\u5BAB\u6E56.jpg">\r\n    </div>-->\r\n\r\n    <div class="userInfo">\r\n        <div><span>\u59D3&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp\u540D\uFF1A</span><input class="form-control input-sm" type="text" placeholder="\u5355\u884C\u8F93\u5165" ng-model="bundle.uesrName" ng-focus="footHide()"><span class="certificate">*</span></div>\r\n        <div><span>\u624B\u673A\u53F7\u7801\uFF1A</span><input class="form-control input-sm" type="text" placeholder="\u5355\u884C\u8F93\u5165" ng-model="bundle.uesrMobile" ng-focus="footHide()"><span class="certificate">*</span></div>\r\n        <div><span>\u6295\u8BC9\u5185\u5BB9\uFF1A</span>\r\n            <div class="text-message descr" contenteditable="plaintext-only" ng-focus="footHide()"></div><span class="certificate">*</span>\r\n        </div>\r\n        <div class="image"><span>\u56FE&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp\u7247\uFF1A</span>\r\n            <div id="imgpreview">\r\n            </div>\r\n            <button type="button" class="btn btn-primary"><span class="glyphicon glyphicon-open"></span></button>\r\n            <input id="file" type="file" name="file" multiple="multiple" onchange=\'angular.element(this).scope().imgPreview(this)\' />\r\n        </div>\r\n        <div><span>\u6240\u5728\u4F4D\u7F6E\uFF1A</span>\r\n            <select id="result" class="form-control input-sm">\r\n                <option></option>\r\n                <option></option>\r\n                <option></option>\r\n            </select>\r\n            <div class="glyphicon glyphicon-map-marker cover-white"></div>\r\n            <div class="text-map">\r\n                <gaode-map id="container"></gaode-map>\r\n            </div>\r\n        </div>\r\n        <div class="button-bottom">\r\n            <button type="button" class="btn btn-default" ng-click="submit()" data-toggle="modal" data-target="#information">\u63D0\u4EA4</button>\r\n        </div>\r\n        <div class="modal fade information" id="information" tabindex="-2" data-backdrop="static" role="dialog" aria-labelledby="infoModalLabel" aria-hidden="true">\r\n            <div class="modal-info submit" ng-show="submiting">\r\n                <p>&nbsp<img src="../img/Loading.gif" alt="">&nbsp&nbsp&nbsp</p>\r\n                <p style="margin:-5px auto 0px;">&nbsp\u6B63\u5728\u4E0A\u4F20\u6570\u636E . . .</p>\r\n            </div>\r\n            <div class="modal-info success" ng-show="successed">\r\n                <p>\u4E0A\u4F20\u6210\u529F</p>\r\n                <a data-dismiss="modal" ng-click="successed=flase">\u786E\u5B9A</a>\r\n            </div>\r\n        </div>\r\n        <div class="modal fade viewModal" id="viewModal" tabindex="-2" data-backdrop="static" role="dialog" aria-labelledby="viewModalLabel" aria-hidden="true">\r\n            <button type="button" class="close" aria-hidden="true" ng-click="sure=true"><span class="glyphicon glyphicon-trash"></span></button>\r\n            <a class="thumbnail image-view"></a>\r\n            <div class="modal-info sure" ng-show="sure">\r\n                <p>\u786E\u5B9A\u5220\u9664\uFF1F</p>\r\n                <a data-dismiss="modal" ng-click="delSure()">\u786E\u5B9A</a>\r\n                <a ng-click="sure=flase" style="color:#888;">\u53D6\u6D88</a>\r\n            </div>\r\n        </div>\r\n    </div>\r\n</div>');
$templateCache.put('templates/webChat.html','<header>\r\n</header>\r\n<content ui-view class="fade-in-right-big"></content>\r\n\r\n<footer class="foot">\r\n</footer>');}]);
'use strict';

angular.module('app').controller('HomeController', ['$scope', '$state', '$timeout', function($scope, $state, $timeout) {
    $scope.getAddSuccess = true;

    $scope.$on('$viewContentLoaded', function() {
        //加载轮播
        var swiper = new Swiper('.swiper-container', {
            pagination: '.swiper-pagination',
            paginationClickable: true,
            loop: true,
            autoplayDisableOnInteraction: false,
            autoplay: 5000,
            effect: 'coverflow',
            slidesPerView: 'auto',
            centeredSlides: true,
            spaceBetween: -55,
            coverflow: {
                rotate: 30,
                stretch: 0,
                depth: 60,
                modifier: 1,
                slideShadows: false
            }
        });
        //加载字体适应
        var clientWidth = document.documentElement.clientWidth || window.innerWidth;
        var innerWidth = Math.max(Math.min(clientWidth, 480), 320);
        console.log(innerWidth);
        if (innerWidth < 350) {
            angular.element(".explain").removeClass("font-15");
            angular.element(".explain").addClass("font-12");
        } else if (innerWidth > 400) {
            angular.element(".explain").removeClass("font-12");
            angular.element(".explain").addClass("font-15");
        }
        //加载sdk
        ysf.on({
            'onload': function() {
                $scope.sdk = true;
            }
        });
        //加载地图，调用浏览器定位服务
        var map, geolocation, marker, geocoder, regeocoder;
        map = new AMap.Map('', {
            resizeEnable: true,
            zoom: 17
        });
        map.plugin('AMap.Geolocation', function() {
            geolocation = new AMap.Geolocation({
                enableHighAccuracy: true, //是否使用高精度定位，默认:true
                timeout: 10000, //超过10秒后停止定位，默认：无穷大
                maximumAge: 0, //定位结果缓存0毫秒，默认：0
                convert: true, //自动偏移坐标，偏移后的坐标为高德坐标，默认：true
                showButton: true, //显示定位按钮，默认：true
                buttonPosition: 'RB', //定位按钮停靠位置，默认：'LB'，左下角
                buttonOffset: new AMap.Pixel(10, 20), //定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
                showMarker: true, //定位成功后在定位到的位置显示点标记，默认：true
                showCircle: true, //定位成功后用圆圈表示定位精度范围，默认：true
                panToLocation: true, //定位成功后将定位到的位置作为地图中心点，默认：true
                zoomToAccuracy: true, //定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
                useNative: true
            });
            map.addControl(geolocation);
            geolocation.getCurrentPosition();
            AMap.event.addListener(geolocation, 'complete', onComplete); //返回定位信息
            AMap.event.addListener(geolocation, 'error', onError); //返回定位出错信息

            function onComplete(data) {
                $scope.getAddSuccess = true;
                var geocoder = new AMap.Geocoder({
                    radius: 1000,
                    extensions: "all"
                });
                console.log("获取地址");
                geocoder.getAddress(data.position, function(status, result) {
                    if (status === 'complete' && result.info === 'OK') {
                        $scope.addr = result;
                        $timeout();
                    }
                });
            };

            function onError(data) {
                $scope.getAddSuccess = false;
            };
        });
    });

    $scope.onOnlineClick = function(e) {
        console.log($scope.sdk);
        $scope.mobile = "";
        var activeClick = $(e.target);
        //console.log(activeClick);
        if (!$scope.getAddSuccess) {
            alert("获取地址失败，请开启手机GPS定位功能，并允许获取地理位置授权");
            window.location.reload();
        } else if (!$scope.addr && $scope.getAddSuccess) {
            alert("地理位置获取中，请稍后");
        } else if ($scope.addr.regeocode.addressComponent.district === '莲都区') {
            //activeClick[0].parentElement.parentElement.dataset.target = "#phoneLoginModal";
            activeClick[0].parentElement.dataset.target = "#phoneLoginModal";
        } else {
            //activeClick[0].parentElement.parentElement.dataset.target = "#errorLoginModal";
            activeClick[0].parentElement.dataset.target = "#errorLoginModal";
        }
    };

    $scope.onlineService = function() {
        //console.log($scope.mobile, $scope.sdk);
        if ($scope.mobile.length == 11 && $scope.sdk) {
            ysf.config({
                uid: $scope.mobile, // 用户Id
                name: '微信用户', // 用户名称
                email: $scope.addr.regeocode.formattedAddress, // 用户邮箱
                mobile: $scope.mobile, // 用户电话
                success: function() { // 成功回调
                    ysf.open();
                    console.log('success');
                },
                error: function() { // 错误回调
                    // handle error
                    //ysf.open();
                    alert('error!!!');
                }
            });
        } else {
            alert("请正确输入手机号码");
        }
    };
}]);
'use strict';

angular.module('app').controller('WebController', ['$scope', '$timeout', 'userService', 'messageService', function($scope, $timeout, userService, messageService) {
    //lxtalkClient.Invoke('{FB60F992-A0FD-47B3-AAA7-E80DF209C5A4}', '_Register', '', $scope);
    $scope.bundle = {
        //userId: userService.getMe().Id,
        userId: 0,
        uesrName: "",
        uesrMobile: "",
        descr: "",
        position: {},
        imgSources: [],
    };

    $scope.$on('$viewContentLoaded', function() {
        var clientWidth = document.documentElement.clientWidth || window.innerWidth;
        var innerWidth = Math.max(Math.min(clientWidth, 480), 320);
        //console.log(innerWidth);
        if (innerWidth > 350) {
            angular.element(".userInfo>div>span").addClass("font-14");
            angular.element(".certificate").addClass("font-14");
            angular.element(".userInfo .input-sm ").addClass("font-13");
            angular.element(".userInfo .text-message").addClass("font-13");
        } else {
            angular.element(".font-13").removeClass("font-13");
            angular.element(".font-14").removeClass("font-14");
        }
    });

    $scope.imgView = function(event) {
        angular.element(".onView").removeClass("onView");
        var img = $(event.target);
        img[0].className = "onView";
        if (img[0].naturalHeight * 3 > (img[0].naturalWidth + 10) * 4) {
            angular.element(".image-view").removeClass("width-Img");
            angular.element(".viewModal").addClass("height-Img");
        } else if (img[0].naturalWidth > img[0].naturalHeight) {
            angular.element(".viewModal").removeClass("height-Img");
            angular.element(".image-view").addClass("width-Img");
        } else {
            angular.element(".viewModal").removeClass("height-Img");
            angular.element(".image-view").removeClass("width-Img");
        }
        $scope.imgUrl = img[0].src;
        $(".image-big").remove();
        $(".image-view").append('<img class="image-big" src="' + $scope.imgUrl + '" data-dismiss="modal">');
    };

    $scope.delSure = function() {
        $scope.sure = false;
        var imgs = $(".images");
        $(".image-big").remove();
        for (var i = 0, len = imgs.length; i < len; i++) {
            if (imgs[i].firstElementChild.className == "onView") {
                imgs[i].remove();
                var imgNum = $("#imgpreview").find('img').length;
                if (imgNum == 2) {
                    angular.element(".images").removeClass("three");
                    angular.element(".images").addClass("two");
                } else if (imgNum = 1) {
                    angular.element(".images").removeClass("two");
                    angular.element(".images").addClass("one");
                }
                return;
            }
        };
    };

    // $scope.actived = function($event) {
    //     var activeClick = $($event.target);
    //     if (activeClick[0].nodeName == "A") {
    //         angular.element(".Aa").removeClass("activeColor");
    //         angular.element(".glyphicon").removeClass("activeColor");
    //         activeClick.addClass("activeColor");
    //     } else if (activeClick[0].nodeName == "SPAN") {
    //         angular.element(".Aa").removeClass("activeColor");
    //         angular.element(".glyphicon").removeClass("activeColor");
    //         activeClick.addClass("activeColor");
    //         $(activeClick[0].parentElement).addClass("activeColor");
    //     }
    // };

    // $scope.footHide = function() {
    //     angular.element(".foot").addClass("hide");
    // };
    // $scope.footShow = function($event) {
    //     var activeClick = $($event.target);
    //     if (activeClick[0].className == "form-control input-sm" || activeClick[0].className == "text-message") {
    //         angular.element(".foot").addClass("hide");
    //     } else {
    //         $timeout(function() {
    //             angular.element(".foot").removeClass("hide");
    //         }, 400);
    //     }
    // };

    $scope.submit = function() {
        $scope.submiting = true;
        var imgs = $(".images");
        for (var i = 0, len = imgs.length; i < len; i++) {
            $scope.bundle.imgSources.push({ type: 1, source: imgs[i].firstElementChild.src });
        };
        $scope.bundle.descr = $(".descr")[0].textContent;
        $scope.bundle.position = $scope.position;
        console.log($scope.bundle);
        $timeout(function() {
            $scope.submiting = false;
            $scope.successed = true;
        }, 3000);
        //messageService.submit($scope.bundle, "successCallback", "failsCallback");
        // $scope.bundle.uesrName = "";
        // $scope.bundle.uesrMobile = "";
        // $scope.bundle.descr = $(".descr")[0].textContent = "";
        // $scope.bundle.position = {};
        // $scope.bundle.imgSources = [];
    };

    $scope.imgPreview = function(fileDom) {
        //判断是否支持FileReader
        if (window.FileReader) {
            var reader = new FileReader();
        } else {
            alert("您的设备不支持图片预览功能，如需该功能请升级您的设备！");
        };
        //获取文件
        var file = fileDom.files[0];
        var imageType = /^image\//;
        //是否是图片
        if (!imageType.test(file.type)) {
            alert("请选择图片！");
            return;
        };
        $("#file")[0].value = "";
        //读取完成
        reader.onload = function(e) {
            // //获取图片dom
            // var img = document.getElementById("preview");
            // //图片路径设置为读取的图片
            // img.src = e.target.result;
            var img = new Image,
                width = 1080, //image resize
                quality = 0.9, //image quality
                canvas = document.createElement("canvas"),
                drawer = canvas.getContext("2d");
            img.src = this.result;

            $(img).on('load', function() {
                $(img).off('load');
                var imgNum = $("#imgpreview").find('img').length;
                canvas.width = width;
                canvas.height = width * (img.height / img.width);
                drawer.drawImage(img, 0, 0, canvas.width, canvas.height);
                img.src = canvas.toDataURL(file.type, quality);

                if (imgNum == 0) {
                    $("#imgpreview").append('<a data-toggle="modal" data-target="#viewModal" class="thumbnail images"><img onClick="angular.element(this).scope().imgView(event)" src="' + img.src + '"></a>');
                    angular.element(".images").addClass("one");
                } else if (imgNum == 1) {
                    $("#imgpreview").append('<a data-toggle="modal" data-target="#viewModal" class="thumbnail images"><img onClick="angular.element(this).scope().imgView(event)" src="' + img.src + '"></a>');
                    angular.element(".images").removeClass("one");
                    angular.element(".images").addClass("two");
                } else if (imgNum >= 2) {
                    $("#imgpreview").append('<a data-toggle="modal" data-target="#viewModal" class="thumbnail images"><img onClick="angular.element(this).scope().imgView(event)" src="' + img.src + '"></a>');
                    angular.element(".images").removeClass("two");
                    angular.element(".images").addClass("three");
                }
            });
        };
        reader.readAsDataURL(file);
    };

}]);
(function() {
    'use strict';

    angular
        .module('app')
        .directive('gaodeMap', Directive);
    Directive.$inject = [];

    function Directive() {
        var directive = {
            link: link,
            restrict: 'E',
            template: '<div id="container"></div>',
            replace: true,
            scope: false
                // scope: {
                //     options: '='
                // }
        };
        return directive;

        function link(scope, element, attrs) {
            var map, geolocation, marker, geocoder;
            //加载地图，调用浏览器定位服务
            map = new AMap.Map('container', {
                resizeEnable: true,
                zoom: 17
            });
            map.plugin('AMap.Geolocation', function() {
                geolocation = new AMap.Geolocation({
                    enableHighAccuracy: true, //是否使用高精度定位，默认:true
                    timeout: 10000, //超过10秒后停止定位，默认：无穷大
                    maximumAge: 0, //定位结果缓存0毫秒，默认：0
                    convert: true, //自动偏移坐标，偏移后的坐标为高德坐标，默认：true
                    showButton: true, //显示定位按钮，默认：true
                    buttonPosition: 'RB', //定位按钮停靠位置，默认：'LB'，左下角
                    buttonOffset: new AMap.Pixel(10, 20), //定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
                    showMarker: true, //定位成功后在定位到的位置显示点标记，默认：true
                    showCircle: true, //定位成功后用圆圈表示定位精度范围，默认：true
                    panToLocation: true, //定位成功后将定位到的位置作为地图中心点，默认：true
                    zoomToAccuracy: true, //定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
                    useNative: true
                });
                map.addControl(geolocation);
                geolocation.getCurrentPosition();
                AMap.event.addListener(geolocation, 'complete', onComplete); //返回定位信息
                AMap.event.addListener(geolocation, 'error', onError); //返回定位出错信息

                function onComplete(data) {
                    map.clearMap();
                    scope.position = data;
                    var geocoder = new AMap.Geocoder({
                        radius: 1000,
                        extensions: "all"
                    });
                    var marker = new AMap.Marker({
                        map: map,
                        bubble: false,
                        visible: true
                    });

                    geocoder.getAddress(data.position, function(status, result) {
                        if (status == 'complete' && result.info === 'OK') {
                            //console.log(result);
                            $("#result")[0][0].textContent = result.regeocode.formattedAddress.substring(6);
                            $("#result")[0][1].textContent = result.regeocode.pois[0].name;
                            $("#result")[0][2].textContent = result.regeocode.pois[1].name;
                        }
                    });

                    map.on('click', function(e) {
                        marker.setPosition(e.lnglat);
                        geocoder.getAddress(e.lnglat, function(status, result) {
                            if (status == 'complete' && result.info === 'OK') {
                                //console.log($("#result"));
                                //var sub = result.regeocode.formattedAddress.indexOf(result.regeocode.aois[0].name)
                                $("#result")[0][0].textContent = result.regeocode.formattedAddress.substring(6);
                                $("#result")[0][1].textContent = result.regeocode.pois[0].name;
                                $("#result")[0][2].textContent = result.regeocode.pois[1].name;
                                $("#result")[0].selectedIndex = 0;
                            }
                        })
                    });
                }

                function onError(data) {}

            });

        }
    }
})();
(function() {
    'use strict';

    angular
        .module('app')
        .service('auth2Service', auth2Service);

    auth2Service.$inject = ['$cookies', '$http'];

    function auth2Service($cookies, $http) {
        this.checkAuthByResponse = checkAuthByResponse;
        this.checkAuthByCookie = checkAuthByCookie;

        function checkAuthByResponse(response) {
            if (response.status == 501) {
                window.location = "/home";
            }
        }

        function checkAuthByCookie() {
            return $cookies.user != "" || $cookies.user != undefined;
        }
    }
})();
'use strict';

angular.module('app').service('messageService', ['$http', '$cookies', '$location', 'userService', function($http, $cookies, $location, userService) {
    var self = this;

    this.submit = function(bundle, successCallback, failsCallback) {
        bundle.userId = userService.getMe().Id;
        $http.post($location.protocol() + '://' + $location.host() + ':' + $location.port() + '/api/bundle', bundle).then(successCallback, failsCallback);
    }
}]);
(function() {
    'use strict';

    angular
        .module('app')
        .service('userService', userService);

    userService.$inject = ['$http', '$cookies', 'auth2Service'];

    function userService($http, $cookies, auth2Service) {
        this.getMe = getMe;

        function getMe() {
            if (this.me != undefined)
                return this.me;
            if ($cookies.get('User') != "" || $cookies.get('User') != undefined) {
                this.me = JSON.parse($cookies.get('User'));
                return this.me;
            }

            if (this.me === undefined)
                $http.get('/api/user').then(
                    function(response) {
                        this.me = response.data;
                    },
                    function(response) {
                        this.me = {};
                        auth2Service.checkAuthByResponse(response);
                    }
                );
        }
    }
})();