$(function() { var params = window.location.href.split("?"); if (params.length > 1) { values = params[1].split("&"); if (values.length > 10) { var funcId = values[0].replace("id=", ""); var funcaircraft_type = ""; var funccard_name = ""; var funcbook = ""; var funcdescription = ""; var funcimg = ""; var funcinput_time = ""; var funcmajor_type = ""; var funcpublish_time = ""; var functype = ""; var functype_name = ""; var funcfile_path = ""; if (funcId !== "0") { funcaircraft_type = decodeURI(values[1].replace("aircraft_type=", "")); funccard_name = decodeURI(values[2].replace("author=", "")); funcbook = decodeURI(values[3].replace("book_name=", "")); funcdescription = decodeURI(values[4].replace("description=", "")); funcimg = decodeURI(values[5].replace("img=", "")); funcinput_time = decodeURI(values[6].replace("input_time=", "")); funcmajor_type = decodeURI(values[7].replace("major_type=", "")); funcpublish_time = decodeURI(values[8].replace("publish_time=", "")); functype = decodeURI(values[9].replace("type_id=", "")); functype_name = decodeURI(values[10].replace("type_name=", "")); funcfile_path = decodeURI(values[11].replace("file_path=", "")); // funcremarks = decodeURI(values[12].replace("remarks=", "")); } } } $("#aircraft_type").val(funcaircraft_type); $("#author").val(funccard_name); $("#book_name").val(funcbook); $("#description").val(funcdescription); $("#img").val(funcimg); $("#input_time").val(funcinput_time); $("#major_type").val(funcmajor_type); $("#publish_time").val(funcpublish_time); $("#type_id").val(functype); $("#type_name").val(functype_name); $("#file_path").val(funcfile_path); $("#box").attr('src', urlBase + funcfile_path); layui.use("form", function() { layui.form.render(); }); layui.use(["form", "layer", "upload"], function() { $ = layui.jquery; var form = layui.form, layer = layui.layer; //监听提交 form.on("switch(hide)", function(data) { isHide = data.elem.checked ? 1 : 0; }); form.on("submit(save)", function(data) { var func = data.field; func.id = funcId; let url = ""; url = "api/book/edit"; fetchJSON(url, func, "post", function(data) { if (data.status === 0) { var index = parent.layer.getFrameIndex(window.name); showMsg("修改成功", 1, 2000); parent.layer.close(index); } else { showMsg(data.msg, 2); } }); return false; }); }); });