2<!DOCTYPE html>
|
<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">
|
<title>修改推荐版块</title>
|
<link href="css/bootstrap.min.css" rel="stylesheet">
|
<link href="css/maincontent.css" rel="stylesheet">
|
<link href="css/tablestyle.css" rel="stylesheet">
|
<style>
|
.form-group {
|
margin-bottom: 30px;
|
}
|
|
.checkbox input[type=checkbox] {
|
top: 6px;
|
}
|
</style>
|
</head>
|
|
<body>
|
<nav class="navbar navbar-default navbar-fixed-top">
|
</nav>
|
<div id="mainbody">
|
<div id="sidebar">
|
<dl>
|
</dl>
|
</div>
|
<div id="neirong">
|
<div class="erjidh">
|
<ol class="breadcrumb">
|
<li>
|
<a href="guanli-bankuai.html">版块栏目</a>
|
</li>
|
<li class="active">修改推荐版块</li>
|
</ol>
|
</div>
|
<div class="header">
|
<h4 class="shujutitle">板块设置</h4>
|
<div class="fenge"></div>
|
</div>
|
<form class="form-horizontal" role="form">
|
<div class="form-group">
|
<label for="input1" class="changdu1 control-label">Id</label>
|
<div class="col-sm-7">
|
<input type="text" class="form-control" id="bkid" readonly="readonly">
|
</div>
|
</div>
|
<div class="form-group">
|
<label for="input1" class="changdu1 control-label">名称</label>
|
<div class="col-sm-7">
|
<input type="text" class="form-control" id="name" placeholder="必须填写">
|
</div>
|
</div>
|
<div class="form-group">
|
<label for="input2" class="changdu1 control-label">最多数量</label>
|
<div class="col-sm-7">
|
<input type="text" class="form-control" id="counts" placeholder="必须填写">
|
</div>
|
</div>
|
<div class="form-group">
|
<label for="input2" class="changdu1 control-label">是否显示</label>
|
<div class="col-sm-7">
|
<div class="checkbox">
|
<label>
|
<input type="checkbox" id="show" value="#">
|
</label>
|
</div>
|
</div>
|
</div>
|
<div class="form-group">
|
<label for="input6" class="changdu1 control-label">图片地址</label>
|
<div class="col-sm-7">
|
<input type="text" class="form-control" id="picurl" placeholder="">
|
<input type="file" id="exampleInputFile" enctype="multipart/form-data" accept="image/*">
|
</div>
|
</div>
|
<div class="form-group">
|
<label for="input6" class="changdu1 control-label">图片跳转</label>
|
<div class="col-sm-7">
|
<input type="text" class="form-control" id="jumpurl" placeholder="">
|
</div>
|
</div>
|
<div class="form-group">
|
<label for="input6" class="changdu1 control-label">排序权重</label>
|
<div class="col-sm-7">
|
<input type="text" class="form-control" id="orderby" placeholder="">
|
</div>
|
</div>
|
<div class="header">
|
<h4 class="shujutitle">详情设置</h4>
|
<div class="fenge"></div>
|
</div>
|
<div class="form-group">
|
<label for="input6" class="changdu1 control-label">详情图片地址</label>
|
<div class="col-sm-7">
|
<input type="text" class="form-control" id="dpicurl" placeholder="">
|
<input type="file" enctype="multipart/form-data" accept="image/*">
|
</div>
|
</div>
|
<div class="form-group">
|
<label for="input6" class="changdu1 control-label">详情样式</label>
|
<div class="col-sm-7" id="container">
|
</div>
|
</div>
|
<div class="button0">
|
<div class="button">
|
<button type="button" class="btn btn-primary save">保存</button>
|
</div>
|
<div class="button">
|
<input type="reset" class="btn btn-default" value="重置" />
|
</div>
|
</div>
|
</form>
|
|
</div>
|
</div>
|
|
<script src="//cdn.bootcss.com/jquery/1.10.1/jquery.min.js"></script>
|
<script src="js/bootstrap.min.js"></script>
|
<script src="js/nav.js"></script>
|
<script src="layer/layer.js"></script>
|
<script type="text/javascript" src="js/ueditor.config.js"></script>
|
<script type="text/javascript" src="js/ueditor.all.js"></script>
|
<!--<script id="container" name="content" type="text/plain">
|
这里写你的初始化内容
|
</script>-->
|
<script type="text/javascript">
|
serverPath = "";
|
var ue = UE.getEditor('container', {
|
elementPathEnabled:false
|
});
|
</script>
|
<script>
|
var key;
|
var detailId=0;
|
$(function() {
|
|
key = getArgsFromHref(location.href,"key");
|
page = getArgsFromHref(location.href,"page");
|
$("#bkid").val(key);
|
$.post('api/v1/section/getSection', {
|
'id':key
|
}, function(data) {
|
if(data.code == "0") {
|
var section = data.data;
|
$("#name").val(section.name);
|
$("#orderby").val(section.orderby);
|
$("#show").attr("checked",section.show);
|
$("#picurl").val(section.picUrl);
|
$("#jumpurl").val(section.jumpUrl);
|
$("#counts").val(section.counts);
|
} else {
|
layer.msg("加载失败");
|
}
|
}, 'json');
|
|
$.post('api/v1/sectiondetail/getSectionDetail',{"rsid":key},function(data){
|
|
setDetailData(data);
|
|
},'json')
|
|
$(".save").click(function() {
|
|
var picture = $("#picurl").val();
|
var iconFile = $("input[type='file']")[0].files[0];
|
if(iconFile == null){
|
if(picture.length <= 0){
|
layer.msg("图片不能为空!");
|
return;
|
}
|
}
|
|
if(iconFile != null){
|
var formData = new FormData();
|
var filename = $("input[type='file']").eq(0).val();
|
formData.append("file",iconFile);
|
formData.append("name",filename);
|
$.ajax({
|
url : "api/v1/upload/uploadImg",
|
type : 'POST',
|
data : formData,
|
dataType : "json",
|
// 告诉jQuery不要去处理发送的数据
|
processData : false,
|
// 告诉jQuery不要去设置Content-Type请求头
|
contentType : false,
|
beforeSend:function(){
|
console.log("正在进行,请稍候");
|
},
|
success : function(data,responseStr) {
|
$("#picurl").val(data.data);
|
save();
|
},
|
error : function(responseStr) {
|
alert("error");
|
}
|
});
|
}else{
|
save();
|
}
|
|
}
|
|
);
|
|
});
|
|
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;
|
}
|
|
function save(){
|
var index = layer.load(0, {
|
'shade': false
|
});
|
$.post('api/v1/section/updateSection', {
|
'id':key,
|
'name': $("#name").val(),
|
'orderby': $("#orderby").val(),
|
'show': $("#show").is(":checked") ? true : false,
|
'picUrl': $("#picurl").val(),
|
'jumpUrl': $("#jumpurl").val(),
|
'counts': $("#counts").val()
|
}, function(data) {
|
if(data.code == "0") {
|
detail();
|
} else {
|
layer.alert('保存失败!', {
|
icon: 2,
|
skin: 'layer-ext-seaing'
|
});
|
}
|
layer.close(index);
|
}, 'json');
|
}
|
|
function setDetailData(data){
|
if(data.code==0){
|
var detail = data.data.sectionDetail;
|
detailId=detail.id;
|
$("#dpicurl").val(detail.picUrl);
|
$(".view").append(detail.htmlCode);
|
ue.ready(function() {
|
//设置编辑器的内容
|
ue.setContent(detail.htmlCode);
|
});
|
}
|
}
|
|
function detail(){
|
|
var iconFile2 = $("input[type='file']")[1].files[0];
|
// if(iconFile2 == null){
|
// if(picture2.length <= 0){
|
// layer.msg("详情图片不能为空!");
|
// return;
|
// }
|
// }
|
if(iconFile2 != null){
|
var formData = new FormData();
|
var filename = $("input[type='file']").eq(1).val();
|
formData.append("file",iconFile2);
|
formData.append("name",filename);
|
$.ajax({
|
url : "api/v1/upload/uploadImg",
|
type : 'POST',
|
data : formData,
|
dataType : "json",
|
// 告诉jQuery不要去处理发送的数据
|
processData : false,
|
// 告诉jQuery不要去设置Content-Type请求头
|
contentType : false,
|
beforeSend:function(){
|
console.log("正在进行,请稍候");
|
},
|
success : function(data,responseStr) {
|
$("#dpicurl").val(data.data);
|
saveDetail();
|
},
|
error : function(responseStr) {
|
alert("error");
|
}
|
});
|
}else{
|
saveDetail();
|
}
|
|
|
}
|
|
function saveDetail(){
|
var content= UE.getEditor('container').getContent();
|
var dpicurl = $("#dpicurl").val();
|
$.post("api/v1/sectiondetail/saveSectionDetail",{"id":detailId,"picUrl":dpicurl,"htmlCode":content,"recommendSection.id":key},function(data){
|
if(data.code==0){
|
layer.alert('保存成功!', {
|
icon: 1,
|
skin: 'layer-ext-seaing',
|
yes:function(){
|
location.href="guanli-bankuai.html?page="+page;
|
}
|
});
|
}
|
},'json')
|
}
|
|
</script>
|
</body>
|
|
</html>
|