admin
2025-02-20 f537abe9f3646c739beaf15076246a2f71a347e9
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<html lang="zh-cn">
 
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="referrer" content="never">
    <title>电视直播-频道列表</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/maincontent.css" rel="stylesheet">
    <style>
 
        .content-container .container {
            min-height: 200px;
            background: white;
            padding-top: 10px;
 
        }
 
        .btn-delete {
            float: left;
            margin-bottom: 0;
            margin-left: 20px;
        }
 
        .form-item {
            margin-bottom: 10px;
            display: block !important;
        }
 
        .btn-sure {
            margin-top: 10px;
        }
 
 
    </style>
 
</head>
 
<body>
<nav class="navbar navbar-default navbar-fixed-top">
 
</nav>
<div id="mainbody">
    <div id="sidebar">
 
    </div>
    <div id="neirong">
 
        <ul class="nav nav-tabs">
            <li v-for="item,index in list" role="presentation" v-bind:class="{active:selectIndex==index}"
                v-on:click="selectResource(index)"><a href="#">{{item.name}}</a>
            </li>
            <a href="#">
                <button class="btn btn-primary" v-on:click="addResource">
                    <span class="glyphicon glyphicon-plus"></span>
                    添加
                </button>
            </a>
 
        </ul>
 
 
        <div class="content-container">
 
            <div v-for="item,index in list" class="container"
                 v-bind:style="{'display':selectIndex==index?'block':'none'}">
 
                <div class="col-lg-6 form-item">
                    <div class="input-group">
                      <span class="input-group-btn">
                        <button class="btn btn-default" type="button">播放链接</button>
                      </span>
                        <input type="text" :readonly="item.name=='咪咕'?true:false" v-model="item.playUrl"
                               class="form-control"
                               placeholder="请输入完整的播放链接">
                    </div>
                </div>
 
                <div class="col-lg-3 form-item">
                    <div class="input-group">
                      <span class="input-group-btn">
                        <button class="btn btn-default" type="button">权重</button>
                      </span>
                        <input type="text" v-model="item.weight"
                               class="form-control"
                               placeholder="请输入排序权重(正整数)">
                    </div>
                </div>
 
                <div style="clear: both;"></div>
 
                <button class="btn btn-danger btn-delete" v-on:click="deleteResource(index)">删除</button>
 
            </div>
 
            <button class="btn btn-primary btn-sure" v-on:click="sure">确定</button>
        </div>
 
 
    </div>
 
 
    <script src="js/jquery-1.9.1.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/page.js"></script>
    <script src="js/nav.js"></script>
    <script src="js/common.js"></script>
    <script src="js/vue.min.js"></script>
    <script src="layer/layer.js"></script>
    <script>
        $(function () {
 
            function getQueryString(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
                var r = window.location.search.substr(1).match(reg);
                if (r != null) return unescape(r[2]);
                return null;
            };
 
            const channelId = getQueryString("id");
 
            var app = new Vue({
                el: "#neirong",
                data: {
                    list: [],
                    selectIndex: 0,
                },
                methods: {
                    resourceList: function () {
                        var index = layer.load(1, {
                            shade: false
                        })
 
                        $.post('api/tvlive/channel/getChannelResourceList', {id: channelId}, function (data) {
                            layer.close(index);
                            if (data.code != 0)
                                return;
                            app.list = data.data.data;
                        }, 'json');
                    },
                    addResource: function () {
                        layer.prompt({title: '请输入来源名称', formType: 3}, function (text, index) {
                            layer.close(index);
                            if (text && text.length > 0) {
                                app.list.push({name: text});
                                if (app.selectIndex < 0) {
                                    app.selectIndex = 0;
                                }
                            }
                        });
                    },
                    selectResource: function (index) {
                        app.selectIndex = index;
                    },
 
                    deleteResource: function (index) {
                        app.list.splice(index, 1);
                        console.log(app.selectIndex + ":" + app.list.length);
                        if (app.selectIndex >= app.list.length) {
                            app.selectIndex = app.list.length - 1;
                        }
                    },
                    sure: function () {
                        layer.confirm('是否确定更改?', {
                            btn: ['确定', '取消'] //按钮
                        }, function () {
                            var index = layer.load(1, {
                                shade: false
                            })
                            $.post('api/tvlive/channel/updateChannelResources', {
                                id: channelId,
                                resources: JSON.stringify(app.list)
                            }, function (data) {
                                layer.close(index);
                                if (data.code != 0) {
                                    layer.msg(data.msg);
                                } else {
                                    layer.alert("更改成功");
                                    window.refresh();
                                }
 
                            }, 'json');
                        }, function () {
 
                        });
 
 
                    },
 
                    deleteSpecial: function (id, index) {
                        var indexDialog = layer.confirm('是否删除该条目?', {
                            btn: ['是', '否'] //按钮
                        }, function () {
                            $.post('api/homerecommend/deleteSpcial', {
                                'ids': id
                            }, function (data) {
                                layer.close(indexDialog);
                                if (data.code == 0) {
                                    if (index > -1) {
                                        app.list.splice(index, 1);
                                    } else {
                                        var ids = id.split(",");
                                        console.log(ids);
                                        for (var i = 0; i < ids.length; i++) {
                                            for (var j = 0; j < app.list.length; j++) {
                                                console.log(app.list[j].special.id + ":" + ids[i])
                                                if (app.list[j].special.id == ids[i]) {
                                                    app.list.splice(j, 1);
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                    layer.msg("删除成功");
                                } else {
                                    layer.msg(data.msg);
                                }
                            }, 'json');
                        }, function () {
 
                        });
                    },
                    edit: function (id) {
                        window.location.href = "edit-tuijian-home-labels.html?id=" + id;
                    },
                }
            });
            app.resourceList();
        });
    </script>
 
</body>
 
</html>