wechatMenuConfigAddCtrl.js
2.92 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
(function (angular) {
function wechatMenuConfigAddCtrl($scope, params, $http, $uibModalInstance, $uibModal,systemService,$filter,$rootScope) {
$scope.wechatMenuTypeList = [{id:'',name:'父菜单'},{id:'view',name:'网页'},{id:'click',name:'点击'},{id:'miniprogram',name:'小程序'}];
$scope.id = params.wechatMenuId;
$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.name = $scope.info.name;
if($scope.info.type && $scope.info.type.id){
params.type = $scope.info.type.id;
if(params.type == 'click'){
params.menuKey = $scope.info.menuKey;
}else if(params.type == 'view'){
params.url = $scope.info.url;
}else if(params.type == 'miniprogram'){
params.url = $scope.info.url;
params.appid = $scope.info.appid;
params.pagepath = $scope.info.pagepath;
}
params.parentId = $scope.info.parentId;
}
params.orderNo = $scope.info.orderNo;
systemService.addOrUpdateWechatMenuConfig(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.getWechatMenuConfigById({'id':$scope.id},function(res){
if(res.returnCode == 0){
$scope.info = res.data;
angular.forEach($scope.wechatMenuTypeList, function(r){
if(r.id == $scope.info.type){
$scope.info.type = 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('wechatMenuConfigAddCtrl', wechatMenuConfigAddCtrl);
})(angular);