app-b349c27127.js 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  1. /**
  2. * Make sure the charset of the page using this script is
  3. * set to utf-8 or you will not get the correct results.
  4. */
  5. var utf8 = (function () {
  6. var highSurrogateMin = 0xd800,
  7. highSurrogateMax = 0xdbff,
  8. lowSurrogateMin = 0xdc00,
  9. lowSurrogateMax = 0xdfff,
  10. surrogateBase = 0x10000;
  11. function isHighSurrogate(charCode) {
  12. return highSurrogateMin <= charCode && charCode <= highSurrogateMax;
  13. }
  14. function isLowSurrogate(charCode) {
  15. return lowSurrogateMin <= charCode && charCode <= lowSurrogateMax;
  16. }
  17. function combineSurrogate(high, low) {
  18. return ((high - highSurrogateMin) << 10) + (low - lowSurrogateMin) + surrogateBase;
  19. }
  20. /**
  21. * Convert charCode to JavaScript String
  22. * handling UTF16 surrogate pair
  23. */
  24. function chr(charCode) {
  25. var high, low;
  26. if (charCode < surrogateBase) {
  27. return String.fromCharCode(charCode);
  28. }
  29. // convert to UTF16 surrogate pair
  30. high = ((charCode - surrogateBase) >> 10) + highSurrogateMin,
  31. low = (charCode & 0x3ff) + lowSurrogateMin;
  32. return String.fromCharCode(high, low);
  33. }
  34. /**
  35. * Convert JavaScript String to an Array of
  36. * UTF8 bytes
  37. * @export
  38. */
  39. function stringToBytes(str) {
  40. var bytes = [],
  41. strLength = str.length,
  42. strIndex = 0,
  43. charCode, charCode2;
  44. while (strIndex < strLength) {
  45. charCode = str.charCodeAt(strIndex++);
  46. // handle surrogate pair
  47. if (isHighSurrogate(charCode)) {
  48. if (strIndex === strLength) {
  49. throw new Error('Invalid format');
  50. }
  51. charCode2 = str.charCodeAt(strIndex++);
  52. if (!isLowSurrogate(charCode2)) {
  53. throw new Error('Invalid format');
  54. }
  55. charCode = combineSurrogate(charCode, charCode2);
  56. }
  57. // convert charCode to UTF8 bytes
  58. if (charCode < 0x80) {
  59. // one byte
  60. bytes.push(charCode);
  61. }
  62. else if (charCode < 0x800) {
  63. // two bytes
  64. bytes.push(0xc0 | (charCode >> 6));
  65. bytes.push(0x80 | (charCode & 0x3f));
  66. }
  67. else if (charCode < 0x10000) {
  68. // three bytes
  69. bytes.push(0xe0 | (charCode >> 12));
  70. bytes.push(0x80 | ((charCode >> 6) & 0x3f));
  71. bytes.push(0x80 | (charCode & 0x3f));
  72. }
  73. else {
  74. // four bytes
  75. bytes.push(0xf0 | (charCode >> 18));
  76. bytes.push(0x80 | ((charCode >> 12) & 0x3f));
  77. bytes.push(0x80 | ((charCode >> 6) & 0x3f));
  78. bytes.push(0x80 | (charCode & 0x3f));
  79. }
  80. }
  81. return bytes;
  82. }
  83. /**
  84. * Convert an Array of UTF8 bytes to
  85. * a JavaScript String
  86. * @export
  87. */
  88. function bytesToString(bytes) {
  89. var str = '',
  90. length = bytes.length,
  91. index = 0,
  92. byte,
  93. charCode;
  94. while (index < length) {
  95. // first byte
  96. byte = bytes[index++];
  97. if (byte < 0x80) {
  98. // one byte
  99. charCode = byte;
  100. }
  101. else if ((byte >> 5) === 0x06) {
  102. // two bytes
  103. charCode = ((byte & 0x1f) << 6) | (bytes[index++] & 0x3f);
  104. }
  105. else if ((byte >> 4) === 0x0e) {
  106. // three bytes
  107. charCode = ((byte & 0x0f) << 12) | ((bytes[index++] & 0x3f) << 6) | (bytes[index++] & 0x3f);
  108. }
  109. else {
  110. // four bytes
  111. charCode = ((byte & 0x07) << 18) | ((bytes[index++] & 0x3f) << 12) | ((bytes[index++] & 0x3f) << 6) | (bytes[index++] & 0x3f);
  112. }
  113. str += chr(charCode);
  114. }
  115. return str;
  116. }
  117. return {
  118. stringToBytes: stringToBytes,
  119. bytesToString: bytesToString
  120. };
  121. }());
  122. 'use strict';
  123. var app = angular.module('app', [
  124. 'ui.router',
  125. 'templatescache',
  126. 'ui.bootstrap',
  127. 'ngAnimate',
  128. 'ngCookies'
  129. ]);
  130. angular.module('app').run(['$rootScope', '$state', '$stateParams','auth2Service',
  131. function ($rootScope, $state, $stateParams, auth2Service) {
  132. $rootScope.$state = $state;
  133. $rootScope.$stateParams = $stateParams;
  134. var locationChangeStartOff = $rootScope.$on('$locationChangeStart', function (event) {
  135. auth2Service.checkAuthByServer();
  136. });
  137. }
  138. ]).config(['$stateProvider', '$urlRouterProvider',
  139. function($stateProvider, $urlRouterProvider) {
  140. $urlRouterProvider.otherwise('/home'); //
  141. $stateProvider.state('home', {
  142. url: '/home',
  143. templateUrl: 'templates/home.html',
  144. controller: 'HomeController'
  145. })
  146. .state('webChat', {
  147. url: '/webChat',
  148. templateUrl: 'templates/webChat.html',
  149. controller: 'WebController'
  150. })
  151. .state('webChat.conComplain', {
  152. url: '/conComplain',
  153. templateUrl: 'templates/webChat-1.html',
  154. controller: 'WebController'
  155. })
  156. .state('webChat.queryEv', {
  157. url: '/queryEv',
  158. templateUrl: 'templates/webChat-2.html',
  159. controller: 'WebController'
  160. })
  161. .state('webChat.dyInfo', {
  162. url: '/dyInfo',
  163. templateUrl: 'templates/webChat-3.html',
  164. controller: 'WebController'
  165. })
  166. .state('webChat.phoneLogin', {
  167. url: '/phoneLogin',
  168. templateUrl: 'templates/webChat-4.html',
  169. controller: 'WebController'
  170. }).state('webChat.online', {
  171. url: '/online',
  172. templateUrl: 'templates/webChat-5.html',
  173. controller: 'WebController'
  174. });
  175. }
  176. ]);
  177. 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 data-toggle="modal" data-target="#info" href=""><!--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 data-toggle="modal" data-target="#info" 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 info" id="info" tabindex="-2" data-backdrop="static" role="dialog" aria-labelledby="infoModalLabel" aria-hidden="true">\r\n <div class="modal-info">\r\n <p>\u6B64\u529F\u80FD\u6B63\u5728\u5168\u529B\u5F00\u53D1\u4E2D\uFF0C\u656C\u8BF7\u671F\u5F85</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 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="currentUser.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>');
  178. $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>');
  179. $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>');
  180. $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>');
  181. $templateCache.put('templates/webChat-4.html','');
  182. $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.name" 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.mobile" 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>\u6B64\u529F\u80FD\u6682\u672A\u5F00\u653E\uFF0C\u656C\u8BF7\u671F\u5F85</p>\r\n <a data-dismiss="modal" ng-click="successed=false">\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>');
  183. $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>');}]);
  184. 'use strict';
  185. angular.module('app').controller('HomeController', ['$scope', '$state', '$timeout', 'userService', function ($scope, $state, $timeout, userService) {
  186. $scope.getAddSuccess = true;
  187. $scope.currentUser = userService.getMe();
  188. $scope.$on('$viewContentLoaded', function() {
  189. //加载轮播
  190. var swiper = new Swiper('.swiper-container', {
  191. pagination: '.swiper-pagination',
  192. paginationClickable: true,
  193. loop: true,
  194. autoplayDisableOnInteraction: false,
  195. autoplay: 5000,
  196. effect: 'coverflow',
  197. slidesPerView: 'auto',
  198. centeredSlides: true,
  199. spaceBetween: -55,
  200. coverflow: {
  201. rotate: 30,
  202. stretch: 0,
  203. depth: 60,
  204. modifier: 1,
  205. slideShadows: false
  206. }
  207. });
  208. //加载字体适应
  209. var clientWidth = document.documentElement.clientWidth || window.innerWidth;
  210. var innerWidth = Math.max(Math.min(clientWidth, 480), 320);
  211. console.log(innerWidth);
  212. if (innerWidth < 350) {
  213. angular.element(".explain").removeClass("font-15");
  214. angular.element(".explain").addClass("font-12");
  215. } else if (innerWidth > 400) {
  216. angular.element(".explain").removeClass("font-12");
  217. angular.element(".explain").addClass("font-15");
  218. }
  219. console.log(userService.getMe());
  220. //加载sdk
  221. ysf.on({
  222. 'onload': function() {
  223. $scope.sdk = true;
  224. }
  225. });
  226. //加载地图,调用浏览器定位服务
  227. var map, geolocation, marker, geocoder, regeocoder;
  228. map = new AMap.Map('', {
  229. resizeEnable: true,
  230. zoom: 17
  231. });
  232. map.plugin('AMap.Geolocation', function() {
  233. geolocation = new AMap.Geolocation({
  234. enableHighAccuracy: true, //是否使用高精度定位,默认:true
  235. timeout: 10000, //超过10秒后停止定位,默认:无穷大
  236. maximumAge: 0, //定位结果缓存0毫秒,默认:0
  237. convert: true, //自动偏移坐标,偏移后的坐标为高德坐标,默认:true
  238. showButton: true, //显示定位按钮,默认:true
  239. buttonPosition: 'RB', //定位按钮停靠位置,默认:'LB',左下角
  240. buttonOffset: new AMap.Pixel(10, 20), //定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20)
  241. showMarker: true, //定位成功后在定位到的位置显示点标记,默认:true
  242. showCircle: true, //定位成功后用圆圈表示定位精度范围,默认:true
  243. panToLocation: true, //定位成功后将定位到的位置作为地图中心点,默认:true
  244. zoomToAccuracy: true, //定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
  245. useNative: true
  246. });
  247. map.addControl(geolocation);
  248. geolocation.getCurrentPosition();
  249. AMap.event.addListener(geolocation, 'complete', onComplete); //返回定位信息
  250. AMap.event.addListener(geolocation, 'error', onError); //返回定位出错信息
  251. function onComplete(data) {
  252. $scope.getAddSuccess = true;
  253. var geocoder = new AMap.Geocoder({
  254. radius: 1000,
  255. extensions: "all"
  256. });
  257. console.log("获取地址");
  258. geocoder.getAddress(data.position, function(status, result) {
  259. if (status === 'complete' && result.info === 'OK') {
  260. $scope.addr = result;
  261. $timeout();
  262. }
  263. });
  264. };
  265. function onError(data) {
  266. $scope.getAddSuccess = false;
  267. };
  268. });
  269. });
  270. $scope.onOnlineClick = function(e) {
  271. console.log($scope.sdk);
  272. var activeClick = $(e.target);
  273. //activeClick[0].parentElement.dataset.target = "#phoneLoginModal";
  274. if (!$scope.getAddSuccess) {
  275. alert("获取地址失败,请开启手机GPS定位功能,并允许获取地理位置授权");
  276. window.location.reload();
  277. } else if (!$scope.addr && $scope.getAddSuccess) {
  278. alert("地理位置获取中,请稍后");
  279. } else if ($scope.addr.regeocode.addressComponent.district === '莲都区') {
  280. //activeClick[0].parentElement.parentElement.dataset.target = "#phoneLoginModal";
  281. activeClick[0].parentElement.dataset.target = "#phoneLoginModal";
  282. } else {
  283. //activeClick[0].parentElement.parentElement.dataset.target = "#errorLoginModal";
  284. activeClick[0].parentElement.dataset.target = "#errorLoginModal";
  285. }
  286. };
  287. $scope.onlineService = function() {
  288. //console.log($scope.mobile, $scope.sdk);
  289. if ($scope.currentUser.Mobile.length == 11 && $scope.sdk) {
  290. userService.update($scope.currentUser);
  291. ysf.config({
  292. uid: $scope.currentUser.Id, // 用户Id
  293. name: $scope.currentUser.Nickname, // 用户名称
  294. email: $scope.addr.regeocode.formattedAddress, // 用户邮箱
  295. mobile: $scope.currentUser.Mobile, // 用户电话
  296. success: function() { // 成功回调
  297. ysf.open();
  298. console.log('success');
  299. },
  300. error: function() { // 错误回调
  301. // handle error
  302. //ysf.open();
  303. alert('error!!!');
  304. }
  305. });
  306. } else {
  307. alert("请正确输入手机号码");
  308. }
  309. };
  310. }]);
  311. 'use strict';
  312. angular.module('app').controller('WebController', ['$scope', '$timeout', 'userService', 'messageService', function($scope, $timeout, userService, messageService) {
  313. //lxtalkClient.Invoke('{FB60F992-A0FD-47B3-AAA7-E80DF209C5A4}', '_Register', '', $scope);
  314. $scope.bundle = {
  315. userId: -1,
  316. //不超过2000个字符
  317. describe: '',
  318. //不超过50个字符
  319. name: '',
  320. //手机号码
  321. mobile: '',
  322. //不超过100个字符
  323. title: '',
  324. /// 类型
  325. /// 0我要咨询;1我要投诉;2我要建议;3领导信箱;4我要举报 5纠错
  326. type: 0,
  327. //是否建议 1-建议 0-投诉
  328. advice: '0',
  329. //是否公开互联网(1是;0否)
  330. isPublic: 0,
  331. assets: []
  332. };
  333. $scope.currentUser = userService.getMe();
  334. $scope.bundle.name = $scope.currentUser.Nickname;
  335. $scope.bundle.mobile = $scope.currentUser.Mobile;
  336. $scope.$on('$viewContentLoaded', function() {
  337. var clientWidth = document.documentElement.clientWidth || window.innerWidth;
  338. var innerWidth = Math.max(Math.min(clientWidth, 480), 320);
  339. //console.log(innerWidth);
  340. if (innerWidth > 350) {
  341. angular.element(".userInfo>div>span").addClass("font-14");
  342. angular.element(".certificate").addClass("font-14");
  343. angular.element(".userInfo .input-sm ").addClass("font-13");
  344. angular.element(".userInfo .text-message").addClass("font-13");
  345. } else {
  346. angular.element(".font-13").removeClass("font-13");
  347. angular.element(".font-14").removeClass("font-14");
  348. }
  349. });
  350. $scope.imgView = function(event) {
  351. angular.element(".onView").removeClass("onView");
  352. var img = $(event.target);
  353. img[0].className = "onView";
  354. if (img[0].naturalWidth > img[0].naturalHeight) {
  355. angular.element(".image-view").addClass("width-Img");
  356. } else {
  357. angular.element(".image-view").removeClass("width-Img");
  358. }
  359. $scope.imgUrl = img[0].src;
  360. $(".image-big").remove();
  361. $(".image-view").append('<img class="image-big" src="' + $scope.imgUrl + '" data-dismiss="modal">');
  362. };
  363. $scope.delSure = function() {
  364. $scope.sure = false;
  365. var imgs = $(".images");
  366. $(".image-big").remove();
  367. for (var i = 0, len = imgs.length; i < len; i++) {
  368. if (imgs[i].firstElementChild.className == "onView") {
  369. imgs[i].remove();
  370. var imgNum = $("#imgpreview").find('img').length;
  371. if (imgNum == 2) {
  372. angular.element(".images").removeClass("three");
  373. angular.element(".images").addClass("two");
  374. } else if (imgNum = 1) {
  375. angular.element(".images").removeClass("two");
  376. angular.element(".images").addClass("one");
  377. }
  378. return;
  379. }
  380. };
  381. };
  382. // $scope.actived = function($event) {
  383. // var activeClick = $($event.target);
  384. // if (activeClick[0].nodeName == "A") {
  385. // angular.element(".Aa").removeClass("activeColor");
  386. // angular.element(".glyphicon").removeClass("activeColor");
  387. // activeClick.addClass("activeColor");
  388. // } else if (activeClick[0].nodeName == "SPAN") {
  389. // angular.element(".Aa").removeClass("activeColor");
  390. // angular.element(".glyphicon").removeClass("activeColor");
  391. // activeClick.addClass("activeColor");
  392. // $(activeClick[0].parentElement).addClass("activeColor");
  393. // }
  394. // };
  395. // $scope.footHide = function() {
  396. // angular.element(".foot").addClass("hide");
  397. // };
  398. // $scope.footShow = function($event) {
  399. // var activeClick = $($event.target);
  400. // if (activeClick[0].className == "form-control input-sm" || activeClick[0].className == "text-message") {
  401. // angular.element(".foot").addClass("hide");
  402. // } else {
  403. // $timeout(function() {
  404. // angular.element(".foot").removeClass("hide");
  405. // }, 400);
  406. // }
  407. // };
  408. $scope.submit = function() {
  409. var imgs = $(".images");
  410. for (var i = 0, len = imgs.length; i < len; i++) {
  411. $scope.bundle.assets.push({ assetType: 1, data: imgs[i].firstElementChild.src });
  412. };
  413. $scope.bundle.describe = $(".descr")[0].textContent;
  414. if ($scope.mapPosition)
  415. $scope.bundle.assets.push({ assetType: 0, data: { info: $scope.mapPosition.info, district: $scope.mapPosition.addressComponent.district, address: $scope.mapPosition.formattedAddress, position: $scope.mapPosition.position } });
  416. console.log($scope.bundle);
  417. $scope.submiting = true;
  418. $timeout(function() {
  419. $scope.submiting = false;
  420. $scope.successed = true;
  421. }, 1000);
  422. //messageService.submit($scope.bundle, "successCallback", "failsCallback");
  423. // $scope.bundle.name = "";
  424. // $scope.bundle.mobile = "";
  425. // $scope.bundle.describe = $(".descr")[0].textContent = "";
  426. // $scope.bundle.assets = [];
  427. };
  428. $scope.imgPreview = function(fileDom) {
  429. //判断是否支持FileReader
  430. if (window.FileReader) {
  431. var reader = new FileReader();
  432. } else {
  433. alert("您的设备不支持图片预览功能,如需该功能请升级您的设备!");
  434. };
  435. //获取文件
  436. var file = fileDom.files[0];
  437. var imageType = /^image\//;
  438. //是否是图片
  439. if (!imageType.test(file.type)) {
  440. alert("请选择图片!");
  441. return;
  442. };
  443. $("#file")[0].value = "";
  444. //读取完成
  445. reader.onload = function(e) {
  446. // //获取图片dom
  447. // var img = document.getElementById("preview");
  448. // //图片路径设置为读取的图片
  449. // img.src = e.target.result;
  450. var img = new Image,
  451. width = 1080, //image resize
  452. quality = 0.9, //image quality
  453. canvas = document.createElement("canvas"),
  454. drawer = canvas.getContext("2d");
  455. img.src = this.result;
  456. $(img).on('load', function() {
  457. $(img).off('load');
  458. var imgNum = $("#imgpreview").find('img').length;
  459. canvas.width = width;
  460. canvas.height = width * (img.height / img.width);
  461. drawer.drawImage(img, 0, 0, canvas.width, canvas.height);
  462. img.src = canvas.toDataURL(file.type, quality);
  463. if (imgNum == 0) {
  464. $("#imgpreview").append('<a data-toggle="modal" data-target="#viewModal" class="thumbnail images"><img onClick="angular.element(this).scope().imgView(event)" src="' + img.src + '"></a>');
  465. angular.element(".images").addClass("one");
  466. } else if (imgNum == 1) {
  467. $("#imgpreview").append('<a data-toggle="modal" data-target="#viewModal" class="thumbnail images"><img onClick="angular.element(this).scope().imgView(event)" src="' + img.src + '"></a>');
  468. angular.element(".images").removeClass("one");
  469. angular.element(".images").addClass("two");
  470. } else if (imgNum >= 2) {
  471. $("#imgpreview").append('<a data-toggle="modal" data-target="#viewModal" class="thumbnail images"><img onClick="angular.element(this).scope().imgView(event)" src="' + img.src + '"></a>');
  472. angular.element(".images").removeClass("two");
  473. angular.element(".images").addClass("three");
  474. }
  475. });
  476. };
  477. reader.readAsDataURL(file);
  478. };
  479. }]);
  480. (function() {
  481. 'use strict';
  482. angular
  483. .module('app')
  484. .directive('gaodeMap', Directive);
  485. Directive.$inject = [];
  486. function Directive() {
  487. var directive = {
  488. link: link,
  489. restrict: 'E',
  490. template: '<div id="container"></div>',
  491. replace: true,
  492. scope: false
  493. // scope: {
  494. // options: '='
  495. // }
  496. };
  497. return directive;
  498. function link(scope, element, attrs) {
  499. var map, geolocation, marker, geocoder;
  500. //加载地图,调用浏览器定位服务
  501. map = new AMap.Map('container', {
  502. resizeEnable: true,
  503. zoom: 17
  504. });
  505. map.plugin('AMap.Geolocation', function() {
  506. geolocation = new AMap.Geolocation({
  507. enableHighAccuracy: true, //是否使用高精度定位,默认:true
  508. timeout: 10000, //超过10秒后停止定位,默认:无穷大
  509. maximumAge: 0, //定位结果缓存0毫秒,默认:0
  510. convert: true, //自动偏移坐标,偏移后的坐标为高德坐标,默认:true
  511. showButton: true, //显示定位按钮,默认:true
  512. buttonPosition: 'RB', //定位按钮停靠位置,默认:'LB',左下角
  513. buttonOffset: new AMap.Pixel(10, 20), //定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20)
  514. showMarker: true, //定位成功后在定位到的位置显示点标记,默认:true
  515. showCircle: true, //定位成功后用圆圈表示定位精度范围,默认:true
  516. panToLocation: true, //定位成功后将定位到的位置作为地图中心点,默认:true
  517. zoomToAccuracy: true, //定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
  518. useNative: true
  519. });
  520. map.addControl(geolocation);
  521. geolocation.getCurrentPosition();
  522. AMap.event.addListener(geolocation, 'complete', onComplete); //返回定位信息
  523. AMap.event.addListener(geolocation, 'error', onError); //返回定位出错信息
  524. function onComplete(data) {
  525. map.clearMap();
  526. scope.mapPosition = data;
  527. var geocoder = new AMap.Geocoder({
  528. radius: 1000,
  529. extensions: "all"
  530. });
  531. var marker = new AMap.Marker({
  532. map: map,
  533. bubble: false,
  534. visible: true
  535. });
  536. geocoder.getAddress(data.position, function(status, result) {
  537. if (status == 'complete' && result.info === 'OK') {
  538. //console.log(result);
  539. $("#result")[0][0].textContent = result.regeocode.formattedAddress.substring(6);
  540. $("#result")[0][1].textContent = result.regeocode.pois[0].name;
  541. $("#result")[0][2].textContent = result.regeocode.pois[1].name;
  542. } else {
  543. alert("错误A:定位失败");
  544. }
  545. });
  546. map.on('click', function(e) {
  547. marker.setPosition(e.lnglat);
  548. geocoder.getAddress(e.lnglat, function(status, result) {
  549. if (status == 'complete' && result.info === 'OK') {
  550. //console.log($("#result"));
  551. //var sub = result.regeocode.formattedAddress.indexOf(result.regeocode.aois[0].name)
  552. $("#result")[0][0].textContent = result.regeocode.formattedAddress.substring(6);
  553. $("#result")[0][1].textContent = result.regeocode.pois[0].name;
  554. $("#result")[0][2].textContent = result.regeocode.pois[1].name;
  555. $("#result")[0].selectedIndex = 0;
  556. } else {
  557. alert("错误B:定位失败");
  558. }
  559. });
  560. });
  561. }
  562. function onError(data) {}
  563. });
  564. }
  565. }
  566. })();
  567. (function() {
  568. 'use strict';
  569. angular
  570. .module('app')
  571. .service('auth2Service', auth2Service);
  572. auth2Service.$inject = ['$cookies', '$http', '$location'];
  573. function auth2Service($cookies, $http, $location) {
  574. this.checkAuthByResponse = checkAuthByResponse;
  575. this.checkAuthByCookie = checkAuthByCookie;
  576. this.checkAuthByServer = checkAuthByServer;
  577. function checkAuthByResponse(response) {
  578. if (response.status == 501) {
  579. window.location = "/home";
  580. }
  581. }
  582. function checkAuthByServer() {
  583. $http.get($cookies.get('BaseUrl') + '/api/auth/check').then(
  584. function () {
  585. },
  586. checkAuthByResponse
  587. );
  588. }
  589. function checkAuthByCookie() {
  590. return $cookies.get('User') != "" || $cookies.get('User') != undefined;
  591. }
  592. }
  593. })();
  594. 'use strict';
  595. angular.module('app').service('messageService', ['$http', '$cookies', '$location', 'userService', function($http, $cookies, $location, userService) {
  596. var self = this;
  597. this.submit = function(bundle, successCallback, failsCallback) {
  598. bundle.userId = userService.getMe().Id;
  599. $http.post($cookies.get('BaseUrl') + '/api/bundle', bundle).then(successCallback, failsCallback);
  600. }
  601. this.getAll = function (successCallback, failsCallback) {
  602. $http.get($cookies.get('BaseUrl') + '/api/bundle/all').then(successCallback, failsCallback);
  603. }
  604. this.getDe = function (bundleId, successCallback, failsCallback) {
  605. $http.get($cookies.get('BaseUrl') + '/api/bundle/detail/' + bundleId).then(successCallback, failsCallback);
  606. }
  607. }]);
  608. (function() {
  609. 'use strict';
  610. angular
  611. .module('app')
  612. .service('userService', userService);
  613. userService.$inject = ['$http', '$cookies', 'auth2Service'];
  614. function userService($http, $cookies, auth2Service) {
  615. this.getMe = getMe;
  616. this.update = update;
  617. function getMe() {
  618. if (this.me != undefined) {
  619. return this.me;
  620. }
  621. if ($cookies.get('User') != "" || $cookies.get('User') != undefined) {
  622. this.me = JSON.parse($cookies.get('User'));
  623. return this.me;
  624. }
  625. if (this.me === undefined)
  626. $http.get($cookies.get('BaseUrl') + '/api/user').then(
  627. function(response) {
  628. this.me = response.data;
  629. },
  630. function(response) {
  631. this.me = {};
  632. auth2Service.checkAuthByResponse(response);
  633. }
  634. );
  635. return this.me;
  636. }
  637. function update(u) {
  638. if (u.Id != undefined)
  639. $http.post($cookies.get('BaseUrl') + '/api/user', u).then(
  640. function (response) {
  641. console.log(response.data)
  642. },
  643. function (response) {
  644. console.log(response.data)
  645. }
  646. );
  647. }
  648. }
  649. })();