wechatReplyConfigAddCtrl.js
4.37 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
(function (angular) {
function wechatReplyConfigAddCtrl($scope, params, $http, $uibModalInstance, $uibModal,systemService,$filter,$rootScope) {
$scope.receiveMsgTypeList = [{id:'text',name:'文本消息'},{id:'event',name:'事件'}];
$scope.replyMsgTypeList = [{id:'text',name:'文本消息'},{id:'image',name:'图片消息'},{id:'news',name:'图文消息'},{id:'video',name:'视频消息'},{id:'voice',name:'语音消息'}];
$scope.receiveEventList=[{id:'subscribe',name:'关注'},{id:'SCAN',name:'扫码'},{id:'LOCATION',name:'上报地理位置'},{id:'CLICK',name:'点击菜单'},{id:'VIEW',name:'点击菜单链接'}];
$scope.id = params.wechatReplyId;
$scope.wechatConfigList = [];
$scope.ok = function () {
if($scope.creatForm.$invalid){
$scope.isInValidate = true;
return false;
}
var params = {};
if($scope.id){
params.id = $scope.id;
}
params.wechatAppid = $scope.info.wechatConfig.wechatAppid;
params.msgType = $scope.info.msgType.id;
if(params.msgType == 'text'){
params.content = $scope.info.content;
}else if(params.msgType == 'event'){
params.event = $scope.info.event.id;
if($scope.info.eventKey){
params.eventKey = $scope.info.eventKey;
}
}
params.replyMsgType = $scope.info.replyMsgType.id;
if(params.replyMsgType == 'text'){
params.replyContent = $scope.info.replyContent;
}else if(params.replyMsgType == 'image' || params.replyMsgType == 'voice' || params.replyMsgType == 'video'){
params.replyMediaId = $scope.info.replyMediaId;
if(params.replyMsgType == 'video'){
if($scope.info.replyTitle){
params.replyTitle = $scope.info.replyTitle;
}
if($scope.info.replyDescription){
params.replyDescription = $scope.info.replyDescription;
}
}
}else if(params.replyMsgType == 'news'){
params.replyTitle = $scope.info.replyTitle;
params.replyDescription = $scope.info.replyDescription;
params.replyPicUrl = $scope.info.replyPicUrl;
params.replyUrl = $scope.info.replyUrl;
}
params.orderNo = $scope.info.orderNo;
params.remark = $scope.info.remark;
systemService.addOrUpdateWechatReplyConfig(params,function(res){
if(res.returnCode == 0){
swal({type: 'success',title: '',text: res.message||'操作成功',showConfirmButton:false,timer: 1500},function(){
window.sweetAlert.close();
$uibModalInstance.close();
});
}else{
swal({type: 'error',title: '',text: res.message||'操作失败',timer: 1500},function(){window.sweetAlert.close();});
}
});
};
$scope.init = function(){
$scope.info={};
systemService.listWechatConfig({appType:'BIZ'},function(res){
if(res.returnCode == 0){
$scope.wechatConfigList = res.data;
if($scope.id){
systemService.getWechatReplyConfigById({'id':$scope.id},function(res){
if(res.returnCode == 0){
$scope.info = res.data;
angular.forEach($scope.receiveMsgTypeList, function(r){
if(r.id == $scope.info.msgType){
$scope.info.msgType = r;
}
if(r.id == 'event'){
angular.forEach($scope.receiveEventList, function(r){
if(r.id == $scope.info.event){
$scope.info.event = r;
}
});
}
});
angular.forEach($scope.replyMsgTypeList, function(r){
if(r.id == $scope.info.replyMsgType){
$scope.info.replyMsgType = r;
}
});
angular.forEach($scope.wechatConfigList, function(r){
if(r.wechatAppid == $scope.info.wechatAppid){
$scope.info.wechatConfig = r;
}
});
}else{
swal({type: 'error',title: '',text: res.message||'查询失败',timer: 1500},function(){window.sweetAlert.close();});
}
})
}
}
});
};
$scope.init();
}
angular.module('system').controller('wechatReplyConfigAddCtrl', wechatReplyConfigAddCtrl);
})(angular);