weappNicknameAuditCtrl.js
3.19 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
;(function (angular) {
function weappNicknameAuditCtrl ($scope, DTOptionsBuilder, DTColumnBuilder, wechatauthService, $uibModal, $q, $state, ext) {
// 审核状态,1:审核中,2:审核失败,3:审核成功
const statusMap = {
'': '全部',
'1': '审核中',
'2': '审核失败',
'3': '审核成功'
}
$scope.model = {
type: 'merchantName',
type_val: '',
auditStat: '',
search,
searchTxt: '',
statusMap
}
function search () {
var __params = getParams()
$scope.dtInstance.query(__params)
}
// 统一处理请求
function __request (action, params) {
var __def = $q.defer()
// return new Promise((resolve,reject)=>{
wechatauthService[action](params, function (result) {
if (result.returnCode == '0') {
__def.resolve(result)
}else {
alerter(result.message)
__def.reject()
}
})
return __def.promise
// })
}
/**
接口请求 与业务无关 ======end======
*/
$scope.do = function (action, merchantId) {
$scope.model[action](merchantId)
}
$scope.dtColumns = [
DTColumnBuilder.newColumn('merchantId').withOption('width', 140).withTitle('商户号'),
DTColumnBuilder.newColumn('merchantName').withOption('width', 140).withTitle('商户名称'),
DTColumnBuilder.newColumn('logo').withOption('width', 140).withTitle('小程序图标')
.renderWith(data => `<img src="${data}" width="50px" height="50px">`),
DTColumnBuilder.newColumn('nickname').withOption('width', 200).withTitle('小程序名称'),
DTColumnBuilder.newColumn('appId').withOption('width', 200).withTitle('小程序应用ID'),
DTColumnBuilder.newColumn('auditId').withOption('width', 200).withTitle('审核单id'),
DTColumnBuilder.newColumn('auditStat').withOption('width', 200).withTitle('审核状态')
.renderWith(data => statusMap[data]),
DTColumnBuilder.newColumn('failReason').withOption('width', 200).withTitle('失败原因'),
DTColumnBuilder.newColumn('updatedDate').withOption('width', 200).withTitle('更新时间'),
]
$scope.dtOptions = DTOptionsBuilder.newOptions()
.withOption('id', 'id')
$scope.dtInstance = {
serverData: wechatauthService.loadWeappNicknameAuditList
}
function getParams () {
var obj = {}
obj[$scope.model.type] = $scope.model.searchTxt
var {auditStat} = $scope.model
var condition = angular.extend({}, obj, {auditStat})
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 alerter (message, type) {
swal({
type: type || 'error',
title: '',
text: message || '',
showConfirmButton: false,
timer: 1500
}, function () {
swal.close()
})
}
;(function init () {
})()
}
angular.module('wechatauth').controller('weappNicknameAuditCtrl', weappNicknameAuditCtrl)
})(angular)