|
<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">
|
<link href="css/tablestyle.css" rel="stylesheet">
|
</head>
|
|
<body>
|
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
|
</nav>
|
<div id="mainbody">
|
<div id="sidebar">
|
<dl>
|
</dl>
|
</div>
|
<div id="neirong">
|
<div class="header">
|
<h4 class="shujutitle">修改视频分类</h4>
|
<div class="fenge"></div>
|
</div>
|
<table class="table">
|
<tbody>
|
<tr>
|
<td>
|
<form class="form-horizontal" role="form">
|
<div class="form-group">
|
<label for="input1" class="changdu3 control-label">分类名称</label>
|
<div class="col-sm-3">
|
<input type="text" class="form-control" id="input1" placeholder="">
|
</div>
|
</div>
|
</form>
|
</td>
|
</tr>
|
</tbody>
|
</table>
|
<table class="table">
|
<tbody>
|
<tr>
|
<td>
|
<form class="form-horizontal" role="form">
|
<div class="form-group">
|
<label for="input2" class="changdu3 control-label">分类图标</label>
|
<div class="col-sm-3">
|
<img src="#" />
|
<input type="file" id="exampleInputFile" enctype="multipart/form-data">
|
<input type="text" class="form-control" id="input2" placeholder="">
|
</div>
|
</div>
|
</form>
|
</td>
|
</tr>
|
</tbody>
|
</table>
|
<table class="table">
|
<tbody>
|
<tr>
|
<td>
|
<form class="form-horizontal" role="form">
|
<div class="form-group">
|
<label for="input3" class="changdu3 control-label">排序权重</label>
|
<div class="col-sm-3">
|
<input type="text" class="form-control" id="input3" placeholder="">
|
</div>
|
</div>
|
</form>
|
</td>
|
</tr>
|
</tbody>
|
</table>
|
<table class="table">
|
<tbody>
|
<tr>
|
<td>
|
<form class="form-horizontal" role="form">
|
<div class="form-group">
|
<label for="input3" class="changdu3 control-label">分类页面上面显示</label>
|
<input type="checkbox" class="checkbox" id="input5" placeholder="">
|
</div>
|
</form>
|
</td>
|
</tr>
|
</tbody>
|
</table>
|
<table class="table">
|
<tbody>
|
<tr>
|
<td>
|
<form class="form-horizontal" role="form">
|
<div class="form-group">
|
<label for="input3" class="changdu3 control-label">主页标题上面显示</label>
|
<input type="checkbox" class="checkbox" id="input6" placeholder="">
|
</div>
|
</form>
|
</td>
|
</tr>
|
</tbody>
|
</table>
|
<table class="table">
|
<tbody>
|
<tr>
|
<td>
|
<form class="form-horizontal" role="form">
|
<div class="form-group">
|
<label for="input6" class="changdu3 control-label">备注</label>
|
<div class="col-sm-3">
|
<textarea cols="4" class="form-control" id="input4"></textarea>
|
</div>
|
</div>
|
</form>
|
</td>
|
</tr>
|
</tbody>
|
</table>
|
<div class="button0">
|
<div class="button">
|
<button type="button" name="save" class="btn btn-primary">保存</button>
|
</div>
|
<div class="button">
|
<button type="button" name="cancel" class="btn btn-primary">取消</button>
|
</div>
|
</div>
|
</div>
|
<script src="js/jquery.min.js"></script>
|
<script src="js/bootstrap.min.js"></script>
|
<script src="layer/layer.js"></script>
|
<script src="js/nav.js"></script>
|
<script>
|
$(function() {
|
var curpath = location.href;
|
var key = getArgsFromHref(curpath, "key");
|
|
$.post("api/videoType/getVideoType", { "id": key }, function(data) {
|
if(data.code == 0) {
|
var videoType = data.videoType;
|
var name = videoType.name;
|
var beizhu = videoType.beizhu;
|
var icon = videoType.icon;
|
var orderby = videoType.orderby;
|
var show = videoType.show==1?true:false;
|
var showTitle = videoType.showTitle==1?true:false;
|
$("#input1").val(name);
|
$("#input2").val(icon);
|
$("img").attr("src", icon);
|
$("#input3").val(orderby);
|
$("#input4").val(beizhu);
|
$("#input5")[0].checked=show;
|
$("#input6")[0].checked=showTitle;
|
}
|
}, "json");
|
|
$("#input2").focusout(function() {
|
if($("#exampleInputFile").val() == "") {
|
$("img").attr("src", $(this).val());
|
}
|
});
|
|
$("#exampleInputFile").bind("change", function() {
|
var path = $(this).val();
|
if(path != "") {
|
$("img").attr("src", path);
|
}
|
});
|
|
$("button[name='cancel']").bind("click", function() {
|
window.open("shiping-fenlei.html", '_self');
|
})
|
|
$("button[name='save']").bind("click", function() {
|
var orderby = $("#input3").val();
|
var name = $("#input1").val();
|
var beizhu = $("#input4").val();
|
var iconFile = $("input[type='file']")[0].files[0];
|
var iconUrl = $("#input2").val();
|
var show = $("#input5")[0].checked?"1":"0";
|
var showtitle = $("#input6")[0].checked?"1":"0";
|
if(iconFile != null) {
|
var formData = new FormData();
|
var filename = $("input[type='file']").val();
|
formData.append("file", iconFile);
|
formData.append("name", filename);
|
$.ajax({
|
url: "api/videoType/updateVideoTypeFile",
|
type: 'POST',
|
data: formData,
|
dataType: "json",
|
// 告诉jQuery不要去处理发送的数据
|
processData: false,
|
// 告诉jQuery不要去设置Content-Type请求头
|
contentType: false,
|
beforeSend: function() {
|
console.log("正在进行,请稍候");
|
},
|
success: function(data, responseStr) {
|
if(data.code == 0) {
|
updateVideoType(key, orderby, name, beizhu, data.path, iconUrl,show,showtitle);
|
} else if(data.code == 1) {
|
updateVideoType(key, orderby, name, beizhu, "", iconUrl,show,showtitle);
|
} else {
|
layer.msg("上传图片失败,请重新操作!");
|
}
|
},
|
error: function(responseStr) {
|
console.log("error");
|
alert("error");
|
}
|
});
|
} else {
|
updateVideoType(key, orderby, name, beizhu, "", iconUrl,show,showtitle);
|
}
|
})
|
});
|
</script>
|
<script>
|
function updateVideoType(key, orderby, name, beizhu, iconFile, iconUrl,show,showtitle) {
|
$.post("api/videoType/updateVideoType", { "id": key, "orderby": orderby, "name": name, "beizhu": beizhu, "iconFile": iconFile, "iconUrl": iconUrl,"show":show,"showTitle":showtitle }, function(data) {
|
if(data == "yes") {
|
layer.alert('保存成功!', {
|
icon: 1,
|
skin: 'layer-ext-seaing'
|
});
|
} else {
|
layer.alert('保存失败!', {
|
icon: 2,
|
skin: 'layer-ext-seaing'
|
});
|
}
|
}, "text")
|
}
|
|
function getArgsFromHref(sHref, sArgName) {
|
var args = sHref.split("?");
|
var retval = "";
|
|
if(args[0] == sHref) /*参数为空*/ {
|
return retval; /*无需做任何处理*/
|
}
|
var str = args[1];
|
args = str.split("&");
|
for(var i = 0; i < args.length; i++) {
|
str = args[i];
|
var arg = str.split("=");
|
if(arg.length <= 1) continue;
|
if(arg[0] == sArgName) retval = arg[1];
|
}
|
return retval;
|
}
|
</script>
|
</body>
|
|
</html>
|