<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>
|