liveCtrl.js
3.74 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
(function(angular) {
function liveCtrl($scope, DTOptionsBuilder, DTColumnBuilder, wechatauthService, $uibModal, $q, $state, ext) {
$scope.model = {
liveInfoSearch: '', //直播名称或房间号
merchantInfoSearch: '' //商户名称或商户号
}
const status = {
101: '直播中',
102: '未开始',
103: '已结束',
104: '禁播',
105: '暂停',
106: '异常',
107: '已过期',
}
const thirdPartyTagStatus = ['小程序后台创建', '自主创建', '共享']
$scope.search = () => {
var params = angular.extend({}, $scope.model);
$scope.dtInstance.query({
condition: params
})
}
$scope.dtColumns = [
// startTime
DTColumnBuilder.newColumn(null).withOption('width', 140).withTitle('直播时间')
.renderWith((e, dt, data, config) => data.liveStatus < 103 ? data.startTime : `${data.startTime}\n${data.endTime}`),
DTColumnBuilder.newColumn(null).withOption('width', 200).withTitle('直播间信息')
.renderWith((e, dt, data, config) => `<div class='live-info'>
<div class='text'>
<div class='name'>${data.name}</div>
<div>房间号\t\t${data.roomId}</div>
<div>主播:${data.anchorName}</div>
</div>
</div>`),
DTColumnBuilder.newColumn('liveStatus').withOption('width', 200).withTitle('直播状态')
.renderWith(data => `<div>${status[data]}</div>`),
DTColumnBuilder.newColumn('thirdPartyTag').withOption('width', 200).withTitle('直播来源')
.renderWith(function(e, dt, node, config) {
if (!node.type || node.type == 0) {
return '管理员创建';
} else {
var tag = node.type == 1 ? '创建' : '共享';
if (node.createdBy != node.merchantName) {
return node.createdBy + tag + '<br>' + node.merchantName;
} else {
return node.merchantName + tag;
}
}
}),
DTColumnBuilder.newColumn('merchantName').withOption('width', 200).withTitle('直播门店')
.renderWith(
function(e, dt, node, config) {
if (node.merchantNames) {
var names = node.merchantNames.split(",");
var name = "";
for (var i in names) {
name = name + names[i] + '<br>';
}
return name;
} else {
return '--';
}
}),
DTColumnBuilder.newColumn(null).withTitle(() => '操作')
.withOption('width', 150)
.renderWith((e, dt, data, config) => `<span class="btn btn-link btn-xs" functional-contrl fc-menu="live" fc-attrname="shareLiveRoom" ng-click='changeMerchant(${data.id})'>修改直播门店</span>`)
]
$scope.dtOptions = DTOptionsBuilder.newOptions()
.withFixedColumns({
rightColumns: 1
})
$scope.dtInstance = {
serverData: wechatauthService.getLiveInfo
}
$scope.synchroLiveRoom = () => {
var params = angular.extend({}, $scope.model);
wechatauthService.synchroLiveRoom(res => {
console.log(res)
$scope.dtInstance.query({
condition: params
})
})
}
$scope.changeMerchant = id => {
$uibModal.open({
templateUrl: 'biz/wechatauth/view/liveModal.html',
controller: 'liveModalCtrl',
size: 'lg',
resolve: {
sendProConfig: function() {
return {
id: id
}
}
}
}).result.then(function(val) {
//关闭弹框后执行方法
var params = angular.extend({}, $scope.model);
$scope.dtInstance.query({
condition: params
})
}, function() {})
}
}
angular.module('wechatauth').controller('liveCtrl', liveCtrl)
})(angular);