paymentAuthCtrl.js
4.67 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
(function(angular) {
function paymentAuthCtrl($scope, DTOptionsBuilder, DTColumnBuilder, wechatauthService, $uibModal, $q, $state,ext) {
$scope.binding = {
versions:[
{userVersion:'请选择',templateId:''}
],
objUpdateTime:null
}
$scope.model ={
type:'merchantName',
updateTime:'',
search,
searchTxt:'',
beginDate:'',
endDate:'',
specialMerchant:'specialMerchantId',
specialMerchant_txt:'',
takeOptions:{
eventHandlers: {
'apply.daterangepicker': function (ev, picker) {
$scope.model.beginDate = `${picker.startDate.format('YYYY-MM-DD')} 00:00:00`;
$scope.model.endDate = `${picker.endDate.format('YYYY-MM-DD')} 23:59:59`;
},
'cancel.daterangepicker':function (ev, picker) {
$scope.model.beginDate = ''
$scope.model.endDate = ''
$scope.binding.objUpdateTime={}
$scope.binding.objUpdateTime.startDate =null
$scope.binding.objUpdateTime.endDate =null
$scope.$apply()
}
}
},
confirm,
bind
};
function search(){
var __params= getParams()
$scope.dtInstance.query(__params);
}
//统一处理请求
function __request(action,params){
// return new Promise((resolve,reject)=>{
var __def = $q.defer()
wechatauthService[action](params,function(result){
if(result.returnCode == '0'){
__def.resolve(result.data)
}else{
alerter(result.message)
__def.reject(false)
}
})
return __def.promise
// })
}
$scope.dtColumns = [
DTColumnBuilder.newColumn('merchantName').withOption('width',140).withTitle('门店名称'),
DTColumnBuilder.newColumn('appLogo').withOption('width',140).withTitle('小程序图标')
.renderWith(function(data) { return `<img src="${data}" width="50px" height="50px">`}),
DTColumnBuilder.newColumn('appId').withOption('width',200).withTitle('AppID'),
DTColumnBuilder.newColumn('specialMerchantId').withOption('width',200).withTitle('特约商户号'),
DTColumnBuilder.newColumn('specialMerchantName').withOption('width',200).withTitle('特约商户全称'),
DTColumnBuilder.newColumn('specialMerchantType').withOption('width',200).withTitle('特约商户类型')
.renderWith(function(data){ return {'COMMON':'普通商户','PLATFORM':'平台商户'}[data]}),
DTColumnBuilder.newColumn('updatedDate').withOption('width',200).withTitle('更新时间'),
DTColumnBuilder.newColumn(null).withTitle(()=>'操作')
.withOption('width', 100)
.renderWith(function(data) { return `<a class="btn btn-link" ng-click="model.confirm(${data.id})">解除绑定</a>`})
];
$scope.dtOptions = DTOptionsBuilder.newOptions()
.withOption('id','id')
.withFixedColumns({
leftColumns: 0,
rightColumns: 1
})
.withOption('select', {
type: 'checkbox'
})
// .withDataProp('data.list')
.withButtons([{
text: '新增绑定',
className: 'btn btn-primary',
action: function (e, dt, node, config) {
$scope.model.bind()
}
}])
$scope.dtInstance = {
serverData: wechatauthService.searchSpecialMerchant
};
function getParams(){
var obj = {};
obj[$scope.model.type]=$scope.model.searchTxt
obj[$scope.model.specialMerchant]=$scope.model.specialMerchant_txt
const {beginDate,endDate} =$scope.model
var condition = angular.extend({},obj,{beginDate,endDate});
condition = removeEmptyParam(condition)
if($.isEmptyObject(condition)){
return {}
}
return {condition}
}
function removeEmptyParam(params){
for(var key in params){
!params[key] && delete params[key]
}
return params
}
function open(templateUrl,controller,defaultData,result,size){
$uibModal.open({
templateUrl,
controller,
size: size || 'md',
resolve: {
data: ()=> {
return {defaultData}
}
}
}).result.then(result)
}
function alerter(message,type){
swal({
type: type||'error',
title: '',
text: message||'',
showConfirmButton:false,
timer: 1500
},function(){
swal.close();
});
}
function bind(){
open('biz/wechatauth/view/operation/pa-merchant-bind.html','paMerchantBind',{request:__request},function(data){
alerter('新增绑定成功!','success')
search()
},'md')
}
function confirm(id){
open('biz/wechatauth/view/operation/confirm.html','confirm',{title:'解除绑定',content:'是否解除绑定商户号?'},function(data){
__request('unbindMerchant',{id}).then(function(result){
// alerter('解除绑定成功!','success')
result && search()
})
},'sm')
}
;(function init (){
// loadVersions()
})()
}
angular.module('wechatauth').controller('paymentAuthCtrl', paymentAuthCtrl)
})(angular);