opinionController.js
1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
angular.module('myApp')
.controller('opinionController',['$scope','$rootScope','dingdaService','$state','globalService','$stateParams',
function($scope,$rootScope,dingdaService,$state,globalService,$stateParams){
$scope.opinion = "";
$scope.submit = function() {
if($scope.opinion.length == 0) {
return;
}
if($scope.opinion.length > 200) {
layer.open({
content: "超出字数限制",
time:2
});
} else {
var phoneType = navigator.userAgent.match(/\(.*?\)/);
var wx = navigator.userAgent.match(/MicroMessenger\/.*?[ ]/);
// alert(phoneType)
var data = {
content : $scope.opinion ,
latitude : $stateParams.latitude ,
longitude : $stateParams.longitude ,
phoneType : phoneType[0] ,
systemType : wx[0]
}
dingdaService.comment(data).success(function(data , status) {
if(data.meta.code != 200) {
layer.open({
content: data.meta.message,
time:2
});
return;
}
layer.open({
content: "评论成功",
time:2
});
setTimeout(function() {
location.reload();
} , 300);
history.back();
}).error(function(data , status){
alert(JSON.stringify(data))
})
}
}
}]);