/**
* 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',
'ngAnimate',
'ngCookies'
]);
angular.module('app').run(['$rootScope', '$state', '$stateParams', 'auth2Service',
function($rootScope, $state, $stateParams, auth2Service) {
$rootScope.$state = $state;
$rootScope.$stateParams = $stateParams;
var locationChangeStartOff = $rootScope.$on('$locationChangeStart', function(event) {
auth2Service.checkAuthByServer();
});
}
]).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.resultQue', {
url: '/resultQue',
templateUrl: 'templates/webChat-4.html',
controller: 'ResultController'
})
.state('webChat.online', {
url: '/online',
templateUrl: 'templates/webChat-5.html',
controller: 'WebController'
})
.state('webChat.pageView', {
url: '/pageView',
params: { data: {} }, //
templateUrl: 'templates/webChat-6.html',
controller: 'DetailController'
});
}
]);
angular.module('templatescache', []).run(['$templateCache', function($templateCache) {$templateCache.put('templates/home.html','
\n
\n\n
\n \n \n\n
\n
\n
\n
\u6B64\u529F\u80FD\u6B63\u5728\u5168\u529B\u5F00\u53D1\u4E2D\uFF0C\u656C\u8BF7\u671F\u5F85
\n
\u5173\u95ED\n
\n
\n
\n
\n
{{addr.regeocode.addressComponent.district}}\u6682\u4E0D\u652F\u6301\u6B64\u529F\u80FD
\n
\u5173\u95ED\n
\n
\n
\n
');
$templateCache.put('templates/webChat-1.html','\n \n
\n
\n
\n\n
\n
\u54A8\u8BE2\u6295\u8BC9
\n
\n\n
\n
\n
');
$templateCache.put('templates/webChat-2.html','\n \n
\n
\n
\n\n
\n
\u67E5\u8BE2\u8BC4\u4EF7
\n
\n\n
\n
\n
');
$templateCache.put('templates/webChat-3.html','\n \n
\n
\n
\n\n
\n
\u52A8\u6001\u4FE1\u606F
\n
\n\n
\n
\n
');
$templateCache.put('templates/webChat-4.html','');
$templateCache.put('templates/webChat-5.html','');
$templateCache.put('templates/webChat-6.html','\r\n \r\n
\r\n
12345\u653F\u52A1\u670D\u52A1\u70ED\u7EBF
\r\n
\r\n
\r\n
\r\n \u6EE1\u610F\u8BC4\u4EF7\uFF1A\r\n \r\n \r\n \r\n \r\n \r\n
\r\n
\r\n
\r\n
\r\n
\u5B98\u65B9\u7B54\u590D\uFF1A\u6B63\u5728\u5904\u7406\u4E2D...
\r\n
\r\n
 . . .
\r\n
\r\n
\r\n
\u6807      \u9898\uFF1A{{boudle.title}}
\r\n
\u63D0\u4EA4\u65F6\u95F4\uFF1A{{boudle.createDate}}
\r\n
\u7528\u6237\u59D3\u540D\uFF1A{{boudle.name}}
\r\n
\u624B\u673A\u53F7\u7801\uFF1A{{boudle.mobile}}
\r\n
\u95EE\u9898\u63CF\u8FF0\uFF1A{{boudle.describe}}
\r\n
\u56FE\u7247\u63CF\u8FF0\uFF1A
\r\n
\r\n
![]()
\r\n
\r\n
\u6240\u5728\u4F4D\u7F6E\uFF1A
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n
\r\n
');
$templateCache.put('templates/webChat.html','\n\n\n');}]);
'use strict';
angular.module('app').controller('DetailController', ['$scope', 'userService', 'messageService', '$stateParams', '$timeout', function($scope, userService, messageService, $stateParams, $timeout) {
$scope.boudle = $stateParams.data;
$scope.expand = false;
$scope.$on('$viewContentLoaded', function() {
//初始化
var clientWidth = document.documentElement.clientWidth || window.innerWidth;
var innerWidth = Math.max(Math.min(clientWidth, 600), 320);
$scope.imgShow = true;
$scope.mapShow = true;
$scope.imgSize = "thumbnail images";
messageService.getAsset($stateParams.data.id,
function(response) {
if (response.data.length > 0) {
$scope.boudle.assets = response.data;
for (var i = 0; i < $scope.boudle.assets.length; i++) {
if ($scope.boudle.assets[i].data && $scope.boudle.assets[i].assetType == 1) {
$scope.boudle.assets[i].data = JSON.parse($scope.boudle.assets[i].data);
$scope.boudle.assets[i].data.src = '/ws12345' + $scope.boudle.assets[i].data.src;
} else if ($scope.boudle.assets[i].assetType == 0) {
$scope.positions = JSON.parse($scope.boudle.assets[i].data);
$scope.boudle.assets.splice(i, 1);
i = i - 1;
}
}
console.log(response.data);
console.log($scope.boudle);
console.log($scope.positions);
//图片
$scope.imgNum = $scope.boudle.assets.length;
if (innerWidth <= 480) {
if ($scope.imgNum == 1) {
$scope.imgSize = "thumbnail images one";
} else if ($scope.imgNum == 2) {
$scope.imgSize = "thumbnail images two";
} else if ($scope.imgNum >= 3) {
$scope.imgSize = "thumbnail images three";
} else if ($scope.imgNum == 0) {
$scope.imgShow = false;
}
}
//定位
if ($scope.positions) {
var map = new AMap.Map('containerResult', {
resizeEnable: true,
center: [$scope.positions.position.lng, $scope.positions.position.lat],
zoom: 17
});
var marker = new AMap.Marker({
map: map,
position: [$scope.positions.position.lng, $scope.positions.position.lat]
});
map.plugin(["AMap.Geocoder"], function() {
var geocoder = new AMap.Geocoder({
radius: 1000,
extensions: "all"
});
geocoder.getAddress([$scope.positions.position.lng, $scope.positions.position.lat], 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;
} else {
alert("错误:获取地址出错");
}
});
});
} else {
$scope.mapShow = false;
}
} else {
$scope.imgShow = false;
$scope.mapShow = false;
history.back(-1);
}
$timeout();
},
function(error) {
history.back(-1);
}
);
//加载屏幕适应
if (innerWidth > 480) {
angular.element(".viewModal").removeClass("phone");
angular.element("#content .text-message").addClass("pc-text");
angular.element(".imgpreview .thumbnail").addClass("img-pc");
} else if (innerWidth <= 480) {
angular.element("#content .text-message").removeClass("pc-text");
angular.element(".imgpreview .thumbnail").removeClass("img-pc");
angular.element(".viewModal").addClass("phone");
};
//加载拖拽功能模块
var oBox = $(".modal-backdrop")[0],
odrop = $(".viewModal")[0];
odrop.onmousedown = function(e) {
var oClientX = (e || event).clientX; //鼠标位置距离最左端长度
var oClientY = (e || event).clientY; //鼠标位置距离最左端长度
var oLeftX = odrop.offsetLeft; //line相对父元素的长度
var oTopY = odrop.offsetTop;
document.onmousemove = function(e) {
var LeftX = oLeftX + ((e || event).clientX - oClientX);
var TopY = oTopY + ((e || event).clientY - oClientY);
odrop.style.margin = 0;
// LineX < 150 && (LineX = 150);
// LineX > 300 && (LineX = 300);
odrop.style.left = LeftX + "px";
odrop.style.top = TopY + "px";
return false;
};
document.onmouseup = function() {
document.onmousemove = null;
document.onmouseup = null;
odrop.releaseCapture && odrop.releaseCapture(); //将鼠标事件退回
};
odrop.setCapture && odrop.setCapture(); //将后续的mouse事件都发送给当前对象
return false;
};
});
$scope.assess = function() {
var star = $(".optionsStar");
console.log(star);
if (star[0].checked) {
angular.element(".options1").addClass("actived");
} else if (star[1].checked) {
angular.element(".options2").addClass("actived");
} else if (star[2].checked) {
angular.element(".options3").addClass("actived");
}
};
$scope.starChange = function(event) {
var star = $(event.target);
console.log(star);
if (star[0].id == "optionsRadios1") {
angular.element(".radio .glyphicon-star").removeClass("actived");
angular.element(".options1").addClass("actived");
} else if (star[0].id == "optionsRadios2") {
angular.element(".radio .glyphicon-star").removeClass("actived");
angular.element(".options2").addClass("actived");
} else if (star[0].id == "optionsRadios3") {
angular.element(".radio .glyphicon-star").removeClass("actived");
angular.element(".options3").addClass("actived");
}
};
$scope.assessSure = function() {
var star = $(".optionsStar");
var ass = $(".ass");
console.log(star, ass);
if (star[0].checked) {
angular.element(".star .glyphicon-star").addClass("actived");
$("#lable")[0].textContent = "非常满意";
$scope.boudle.assOption = "非常满意";
} else if (star[1].checked) {
angular.element(".star .glyphicon-star").removeClass("actived");
angular.element(".two").addClass("actived");
angular.element(".three").addClass("actived");
angular.element(".four").addClass("actived");
angular.element(".five").addClass("actived");
$("#lable")[0].textContent = "基本满意";
$scope.boudle.assOption = "基本满意";
} else if (star[2].checked) {
angular.element(".star .glyphicon-star").removeClass("actived");
angular.element(".four").addClass("actived");
angular.element(".five").addClass("actived");
$("#lable")[0].textContent = "不满意";
$scope.boudle.assOption = "不满意";
}
ass[0].disabled = true;
ass[0].textContent = "已评";
$scope.boudle.isAssessed = 1;
console.log($scope.boudle);
};
$scope.expands = function(event) {
var actived = $(event.target);
console.log(actived);
if (actived[0].textContent.indexOf("展开") !== -1) {
$scope.expand = true;
} else if (actived[0].textContent.indexOf("收起") !== -1) {
$scope.expand = false;
}
};
$scope.imgView = function(event) {
$(".viewModal")[0].style.top = 0;
$(".viewModal")[0].style.left = 0;
angular.element(".onView").removeClass("onView");
var img = $(event.target);
img[0].className = "onView";
if (img[0].naturalWidth > img[0].naturalHeight) {
angular.element(".image-view").addClass("width-Img");
} else {
angular.element(".image-view").removeClass("width-Img");
}
$scope.imgUrl = img[0].src;
$(".image-big").remove();
$(".image-view").append('
');
};
$scope.restAddress = function() {
var map = new AMap.Map('containerResult', {
resizeEnable: true,
center: [$scope.positions.position.lng, $scope.positions.position.lat],
zoom: 17
});
var marker = new AMap.Marker({
map: map,
position: [$scope.positions.position.lng, $scope.positions.position.lat]
});
};
}]);
'use strict';
angular.module('app').controller('HomeController', ['$scope', '$state', '$timeout', 'userService', function($scope, $state, $timeout, userService) {
$scope.getAddSuccess = true;
$scope.currentUser = userService.getMe();
$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");
}
console.log(userService.getMe());
//加载sdk
ysf.on({
'onload': function() {
$scope.sdk = true;
}
});
//加载地图,调用浏览器定位服务
var map, geolocation;
map = new AMap.Map('', {
resizeEnable: true,
zoom: 17
});
map.plugin('AMap.Geolocation', function() {
geolocation = new AMap.Geolocation({
enableHighAccuracy: true, //是否使用高精度定位,默认:true
timeout: 30000, //超过30秒后停止定位,默认:无穷大
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
});
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);
var activeClick = $(e.target);
//activeClick[0].parentElement.dataset.target = "#phoneLoginModal";
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() {
var g = (/1[7358]\d{9}/).exec($scope.currentUser.Mobile);
console.log(g);
//console.log($scope.mobile, $scope.sdk);
if ($scope.currentUser.Mobile.length == 11 && $scope.sdk) {
userService.update($scope.currentUser);
ysf.config({
uid: $scope.currentUser.Id, // 用户Id
name: $scope.currentUser.Nickname, // 用户名称
email: $scope.addr.regeocode.formattedAddress, // 用户邮箱
mobile: $scope.currentUser.Mobile, // 用户电话
success: function() { // 成功回调
ysf.open();
console.log('success');
},
error: function() { // 错误回调
// handle error
//ysf.open();
alert('error!!!');
}
});
} else {
alert("请正确输入手机号码");
}
};
}]);
'use strict';
angular.module('app').controller('ResultController', ['$scope', 'userService', 'messageService', '$state', function($scope, userService, messageService, $state) {
//lxtalkClient.Invoke('{FB60F992-A0FD-47B3-AAA7-E80DF209C5A4}', '_Register', '', $scope);
// $scope.results = [{
// date: '2017-08-16 11:11:11',
// title: "测试测试",
// name: '浙江万赛软件科技有限公司',
// mobile: '15906422850',
// describe: '近日办公助手出现程序被360软件拦截,导致软件奔溃或者被360删除。已被删除的用户需要重新下载安装,然后在360中添加信任,未被删除的用户直接添加信任。添加信任办法如下:打开360安全窗口,单击“木马查杀”图标——在木马查杀窗口中,单击左下角“信任区”图标,然后单击下面的“添加信任目录”按钮——选择办公助手安装的路径,确定就可以了。以上操作有困难的用户可致电2091970咨询指导或申请远程协助解决。',
// assets: []
// },
// ];
$scope.load = false;
messageService.getAll(
function(reponse) {
$scope.results = reponse.data;
$scope.load = true;
//console.log($scope.results);
},
function(error) { alert("error!"); }
);
$scope.viewDetail = function(result) {
//$scope.bundleId = result.id;
$state.go("webChat.pageView", { data: result }, { inherit: false });
};
}]);
'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: -1,
//不超过2000个字符
describe: '',
//不超过50个字符
name: '',
//手机号码
mobile: '',
//所属县市
country_Id: '丽水市本级',
//不超过100个字符
title: '',
/// 类型
/// 0我要咨询;1我要投诉;2我要建议;3领导信箱;4我要举报 5纠错
type: 2, //2
//是否建议 0-投诉 1-建议
advice: 1,
//是否公开互联网(0否 1是)
isPublic: 0,
assets: []
};
$scope.currentUser = userService.getMe();
$scope.bundle.name = $scope.currentUser.Nickname;
$scope.bundle.mobile = $scope.currentUser.Mobile;
$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>form>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");
angular.element(".userInfo .selects").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].naturalWidth > img[0].naturalHeight) {
angular.element(".image-view").addClass("width-Img");
} else {
angular.element(".image-view").removeClass("width-Img");
}
$scope.imgUrl = img[0].src;
$(".image-big").remove();
$(".image-view").append('
');
};
$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(e) {
$scope.bundle.describe = _.trim($(".descr")[0].textContent).substr(0, 2000);
$scope.bundle.describe = $scope.bundle.describe.replace(/ /g, " ");
var mobReg = (/^1[34578]\d{9}$/).exec($scope.bundle.mobile);
if (mobReg && $scope.bundle.describe) {
$(e.target)[0].dataset.target = "#information";
var imgs = $(".images");
for (var i = 0, len = imgs.length; i < len; i++) {
$scope.bundle.assets.push({ assetType: 1, data: imgs[i].firstElementChild.src });
};
if ($scope.mapPosition)
$scope.bundle.assets.push({ assetType: 0, data: JSON.stringify({ info: $scope.mapPosition.info, district: $scope.mapPosition.addressComponent.district, address: $scope.mapPosition.formattedAddress, position: $scope.mapPosition.position }) });
console.log($scope.bundle);
$scope.submiting = true;
messageService.submit($scope.bundle,
function() {
$scope.submiting = false;
$scope.successed = true;
$scope.bundle.title = "";
$scope.bundle.describe = $(".descr")[0].textContent = "";
imgs.remove();
$scope.bundle.assets = [];
},
function() {
$scope.submiting = false;
$scope.falied = true;
$scope.bundle.assets = [];
});
} else if (!mobReg) {
$(e.target)[0].dataset.target = "";
alert("手机号码有误");
} else if (mobReg && $scope.bundle.describe == "") {
$(e.target)[0].dataset.target = "";
alert("标题或投诉内容不能为空");
} else {
$(e.target)[0].dataset.target = "";
alert("手机号码有误或者投诉内容为空");
}
};
$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('
');
angular.element(".images").addClass("one");
} else if (imgNum == 1) {
$("#imgpreview").append('
');
angular.element(".images").removeClass("one");
angular.element(".images").addClass("two");
} else if (imgNum >= 2) {
$("#imgpreview").append('
');
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: '',
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: 30000, //超过30秒后停止定位,默认:无穷大
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
});
map.addControl(geolocation);
geolocation.getCurrentPosition();
AMap.event.addListener(geolocation, 'complete', onComplete); //返回定位信息
AMap.event.addListener(geolocation, 'error', onError); //返回定位出错信息
function onComplete(data) {
map.clearMap();
map.setZoomAndCenter(17, [data.position.lng, data.position.lat]);
scope.mapPosition = data;
var geocoder = new AMap.Geocoder({
radius: 1000,
extensions: "all"
});
var marker = new AMap.Marker({
map: map,
position: [data.position.lng, data.position.lat],
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;
} else {
alert("错误A:定位失败");
}
});
map.on('click', function(e) {
marker.setPosition(e.lnglat);
geocoder.getAddress(e.lnglat, function(status, result) {
if (status == 'complete' && result.info === 'OK') {
scope.mapPosition.position = e.lnglat;
//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;
} else {
alert("错误B:定位失败");
}
});
});
}
function onError(data) {
alert("错误C:定位失败");
}
});
}
}
})();
(function() {
'use strict';
angular
.module('app')
.service('auth2Service', auth2Service);
auth2Service.$inject = ['$cookies', '$http', '$location'];
function auth2Service($cookies, $http, $location) {
this.checkAuthByResponse = checkAuthByResponse;
this.checkAuthByCookie = checkAuthByCookie;
this.checkAuthByServer = checkAuthByServer;
function checkAuthByResponse(response) {
if (response.status == 501) {
window.location = $cookies.get('BaseUrl');
}
}
function checkAuthByServer() {
$http.get($cookies.get('BaseUrl') + 'api/auth/check').then(
function() {
},
checkAuthByResponse
);
}
function checkAuthByCookie() {
return $cookies.get('User') != "" || $cookies.get('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($cookies.get('BaseUrl') + 'api/bundle', bundle).then(successCallback, failsCallback);
}
this.getAll = function(successCallback, failsCallback) {
$http.get($cookies.get('BaseUrl') + 'api/bundle/all').then(successCallback, failsCallback);
}
this.getDe = function(bundleId, successCallback, failsCallback) {
$http.get($cookies.get('BaseUrl') + 'api/bundle/detail/' + bundleId).then(successCallback, failsCallback);
}
this.getAsset = function(bundleId, successCallback, failsCallback) {
$http.get($cookies.get('BaseUrl') + 'api/asset/byBundleId/' + bundleId).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;
this.update = update;
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($cookies.get('BaseUrl') + 'api/user').then(
function(response) {
this.me = response.data;
},
function(response) {
this.me = {};
auth2Service.checkAuthByResponse(response);
}
);
return this.me;
}
function update(u) {
if (u.Id != undefined)
$http.post($cookies.get('BaseUrl') + 'api/user', u).then(
function(response) {
console.log(response.data)
},
function(response) {
console.log(response.data)
}
);
}
}
})();