addAppealCtrl.js
5.04 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
(function (angular) {
function addAppealCtrl($scope,complainSuggestService,$stateParams,$state,$http,$sce,Upload) {
$scope.param = $stateParams;
$scope.saveSubmiting = false;
$scope.imageArr = [];
$scope.videoUrl = null;
$scope.saveInfo=function(){
var infoForm = $scope.infoForm;
// console.log(infoForm)
if(!$scope.hasSelectTag && $scope.complainSuggestType == 1){
$scope.isInValidate = true;
return false;
}
if($scope.complainSuggestType == 1 && $scope.imageArr.length == 0 && !$scope.videoUrl){
$scope.isInValidate = true;
return false;
}
if(infoForm.$invalid){
$scope.isInValidate = true;
return false;
}
$scope.submitInfo();
};
$scope.submitInfo = function(){
if($scope.saveSubmiting){
return;
}
$scope.saveSubmiting = true;
var params = {};
params.orderCode = $scope.param.orderCode;
params.productCode = $scope.param.productCode;
params.type = 3;
params.userPhone = $scope.info.supplierPhone;
params.description = $scope.info.description;
var imgList = [];
for(var i = 0;i<$scope.imageArr.length;i++){
imgList.push($scope.imageArr[i].imgSrc);
}
params.imgList = imgList;
params.videoUrl = $scope.videoUrl;
params.loss = $scope.info.loss;
complainSuggestService.add(params,function(res){
$scope.saveSubmiting = false;
if(res.returnCode == 0){
swal({type: 'success',title: '',text: res.message||'提交成功',showConfirmButton:false,timer: 1500,allowOutsideClick: false},function(){
window.sweetAlert.close();
$scope.backTo();
});
}else{
swal({type: 'error',title: '',text: res.message||'操作失败',timer: 1500,allowOutsideClick: false},function(){
window.sweetAlert.close();
});
}
});
};
// 统一弹窗
function popTips(type, text, timer) {
timer = timer || 1000
swal({
type: type,
title: '',
html: true,
text: text,
showConfirmButton: false,
timer: timer
});
}
/**
* 上传图片
* */
$scope.uploadImage=function(file, errFiles){
if(file == null){
if(errFiles != null && errFiles.length > 0){
console.log(errFiles)
// $scope.imgError = true;
popTips('error', '只能上传800KB以内的PNG,JPG格式的图片')
}
return;
}
if(file.size > 800 * 1024 || !/^image\/(jpg|png|jpeg)+$/.test(file.type)){
// $scope.imgError = true;
popTips('error', '只能上传800KB以内的PNG,JPG格式的图片')
return;
}
// $scope.imgError = false;
$scope.showLoadingImg = true;
Upload.upload({
url: 'common/uploadImage',
//上传的同时带的参数
//data: { 'username': $scope.username },
file: file
}).success(function (data, status, headers, config) {
if(data.returnCode == 0){
$scope.imageArr.push({'imgSrc':data.data});//data.data
}
$scope.showLoadingImg = false;
}).error(function (data, status, headers, config) {
$scope.showLoadingImg = false;
});
};
/**
* 删除图片
*/
$scope.delImg = index => {
$scope.imageArr.splice(index,1)
}
$scope.uploadVideo=function(file, errFiles){
if(file == null){
if(errFiles != null && errFiles.length > 0){
console.log(errFiles);
// $scope.videoError = true;
popTips('error', '只能上传20MB以内的mp4,AVI,wma,rmvb格式的视频')
}
return;
}
if(file.size > 20 * 1024 * 1024){
// $scope.videoError = true;
popTips('error', '只能上传20MB以内的mp4,AVI,wma,rmvb格式的视频')
return;
}
$scope.showLoadingVideo = true;
Upload.upload({
url: 'common/uploadVideo',
//上传的同时带的参数
//data: { 'username': $scope.username },
file: file
}).success(function (data, status, headers, config) {
if(data.returnCode == 0){
$scope.videoUrl = data.data;
}
$scope.showLoadingVideo = false;
}).error(function (data, status, headers, config) {
$scope.showLoadingVideo = false;
});
};
/**
* 删除视频
*/
$scope.delVideo = function() {
$scope.videoUrl = null
}
$scope.trustUrl =function(url){
return $sce.trustAsResourceUrl(url);
}
$scope.backTo=function(){
$state.go('electronicDirectory.opinionFeedbackMaintenance');//2表示产品查看页
}
$scope.init=function(){
};
$scope.init();
}
angular.module('electronicDirectory',['ngFileUpload','ngSanitize'])
.controller('addAppealCtrl', addAppealCtrl);
})(angular);