portal html css js resource

articalModify.js 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. $(function() {
  2. loginStatus();//判断个人是否登录
  3. valUser();
  4. var articleId = GetQueryString("articleId");
  5. var experarray = [];
  6. var resourcesarray = [];
  7. var $data = {};
  8. var modifyTimeval;
  9. var settime = false;
  10. var hbur,hburEnd;
  11. var pr,prEnd;
  12. var re,reEnd;
  13. articleshow();
  14. relevantExperts();
  15. relevantResources();
  16. //校验标题
  17. $("#newstitle").on({
  18. focus: function() {
  19. $(this).prev().find("span").text("50字以内");
  20. },
  21. blur: function() {
  22. $(this).prev().find("span").text("");
  23. },
  24. keyup: function() {
  25. if($(this).val().length > 50) {
  26. $(this).val($(this).val().substr(0, 50));
  27. }
  28. }
  29. })
  30. //校验关键字
  31. $("#KeyWord").on({
  32. focus: function() {
  33. $("#keyPrompt").text("最多可添加5个关键词,每个关键词15字以内");
  34. },
  35. blur: function() {
  36. $("#keyPrompt").text("");
  37. },
  38. keyup: function() {
  39. var ti=$(this).val();
  40. hbur=ti;
  41. if($(this).val()==""){
  42. $(".frmadd").addClass("displayNone");
  43. $(".keydrop ul").html("");
  44. $(".keydrop").addClass("displayNone");
  45. return;
  46. }else{
  47. $(".frmadd").removeClass("displayNone");
  48. }
  49. if($(this).val().length > 15) {
  50. $(this).val($(this).val().substr(0, 15));
  51. }
  52. setTimeout(function(){
  53. if( ti===hbur && ti!== hburEnd) {
  54. KeyWordList(ti);
  55. }
  56. },500)
  57. }
  58. })
  59. //添加关键字
  60. $("#addkeyWord").on("click", function() {
  61. var keyWord = $("#KeyWord").val();
  62. keyWordlen(keyWord);
  63. $(".frmadd").addClass("displayNone");
  64. $(".keydrop ul").html("");
  65. $(".keydrop").addClass("displayNone");
  66. })
  67. //点击搜出的关键字添加
  68. $(".keydrop").on("click", "p", function() {
  69. var keyWord = $(this).text();
  70. $(".frmadd").addClass("displayNone");
  71. keyWordlen(keyWord)
  72. $(".keydrop ul").html("");
  73. $(".keydrop").addClass("displayNone");
  74. })
  75. //删除关键字
  76. $("#keyWordlist").on("click", ".closeThis", function() {
  77. $(this).parent().remove();
  78. var plength = $(".keyResult li p").length;
  79. if(plength < 5) {
  80. $("#KeyWord").removeClass("displayNone");
  81. }
  82. $(".keydrop ul").html("");
  83. $(".keydrop").addClass("displayNone");
  84. })
  85. //组合关键字
  86. function captiureSubInd(subIndu) {
  87. var industrys = $("#" + subIndu + "");
  88. var industryAll = "";
  89. if(industrys.size() > 0) {
  90. for(var i = 0; i < industrys.size(); i++) {
  91. industryAll += industrys[i].innerText;
  92. industryAll += ',';
  93. };
  94. industryAll = industryAll.substring(0, industryAll.length - 1);
  95. }
  96. return industryAll;
  97. }
  98. function keyWordlen(keyWord) {
  99. $("#KeyWord").val("");
  100. var plength = $(".keyResult li p");
  101. for(var i = 0; i < plength.length; i++) {
  102. if(plength[i].innerText == keyWord) {
  103. $("#keyPrompt").text("关键词已存在");
  104. return;
  105. }
  106. }
  107. if(plength.length > 3) {
  108. $("#KeyWord").addClass("displayNone");
  109. $("#keyWordlist").append("<li class='delkeylist'><p class='h2Font'>" + keyWord + "</p><div class='closeThis'></div></li>");
  110. } else {
  111. $("#keyWordlist").append("<li class='delkeylist'><p class='h2Font'>" + keyWord + "</p><div class='closeThis'></div></li>");
  112. }
  113. }
  114. function KeyWordList(seValue) {
  115. hburEnd=seValue;
  116. $.ajax({
  117. "url": "/ajax/dataDict/qaHotKey",
  118. "type": "get",
  119. "data": {
  120. "key": $("#KeyWord").val()
  121. },
  122. "success": function(data) {
  123. console.log(data);
  124. if(data.success) {
  125. if(hburEnd == seValue){
  126. var itemlist = '';
  127. $("#keydropList").html("");
  128. for(var i = 0; i < Math.min(data.data.length,5); i++) {
  129. var itemlist = '<li><p class="h2Font"></p></li>';
  130. $itemlist = $(itemlist);
  131. $("#keydropList").append($itemlist);
  132. $itemlist.find(".h2Font").text(data.data[i].caption);
  133. }
  134. $(".keydrop").removeClass("displayNone");
  135. }
  136. } else {
  137. //$(".keydrop").addClass("displayNone");
  138. //$(".keydrop ul").html("");
  139. }
  140. },
  141. "error": function() {
  142. $.MsgBox.Alert('提示', '链接服务器超时')
  143. }
  144. });
  145. }
  146. //拆解关键字
  147. function industryShow(data,industryList){
  148. if(data != undefined && data.length != 0 ){
  149. var subs = new Array();
  150. if(data.indexOf(',')){
  151. subs = data.split(',');
  152. }else{
  153. subs[0] = data;
  154. }
  155. if(subs.length>0){
  156. for (var i = 0; i < subs.length; i++)
  157. {
  158. $("#"+industryList+"").append('<li class="delkeylist"><p class="h2Font">'+ subs[i] +'</p><div class="closeThis"></div></li>');
  159. };
  160. }
  161. if(subs.length>4){
  162. $("#KeyWord").addClass("displayNone");
  163. }
  164. }
  165. }
  166. //校验右侧专家和资源
  167. $("#checkZj").on("focus",function(){
  168. $(this).prev().find("span").text("最多选择5位专家");
  169. })
  170. $("#checkZy").on("focus",function(){
  171. $(this).prev().find("span").text("最多选择5个资源");
  172. })
  173. $("#checkZj,#checkZy").on("blur",function(){
  174. $(this).prev().find("span").text("");
  175. })
  176. $("#checkZj").on("keyup", function() {
  177. var _this = this;
  178. var ti=$(this).val();
  179. pr=ti;
  180. if($(this).val()=="") {
  181. return;
  182. }
  183. setTimeout(function(){
  184. if( ti===pr && ti!== prEnd) {
  185. checkZj(_this,ti);
  186. }
  187. },500)
  188. })
  189. $("#checkZy").on("keyup", function() {
  190. var ti=$(this).val();
  191. re=ti;
  192. if($(this).val()=="") {
  193. return;
  194. }
  195. var _this = this;
  196. setTimeout(function(){
  197. if( ti===re && ti!== reEnd) {
  198. checkZy(_this,ti);
  199. }
  200. },500)
  201. })
  202. $("#expertlist").on("click","li",function(){
  203. var _this = this;
  204. expertlist(_this,"该专家已选择");
  205. });
  206. $("#resouselist").on("click","li",function(){
  207. var _this = this;
  208. expertlist(_this,"该资源已选择");
  209. });
  210. //点击右侧搜索出的专家和资源列表
  211. function expertlist(_this,title){
  212. var liId = $(_this).html();
  213. var plength = $(_this).parents(".otherBlock").find(".addexpert li");
  214. for(var i=0;i<plength.length;i++){
  215. if(plength[i].innerHTML==liId){
  216. $(_this).parents(".otherBlock").find(".aboutTit span").text(title);
  217. $(_this).parents(".otherBlock").find(".form-drop").addClass("displayNone");
  218. $(_this).parents(".otherBlock").find("input").val("");
  219. return;
  220. }
  221. }
  222. if(plength.length > 3) {
  223. $(_this).parents(".otherBlock").find("input").hide();
  224. $(_this).parents(".otherBlock").find(".addexpert").append($(_this).clone());
  225. $(_this).parents(".otherBlock").find("input").val("");
  226. $(_this).parents(".otherBlock").find(".form-drop").addClass("displayNone");
  227. }else{
  228. $(_this).parents(".otherBlock").find(".addexpert").append($(_this).clone());
  229. $(_this).parents(".otherBlock").find("input").val("");
  230. $(_this).parents(".otherBlock").find(".form-drop").addClass("displayNone");
  231. }
  232. }
  233. //删除右侧搜索出的专家和资源
  234. $(".addexpert").on("click",".deleteThis",function(){
  235. var plength = $(this).parent().parent().find("li").length;
  236. if(plength < 6){
  237. $(this).parents(".otherBlock").find("input").show();
  238. }
  239. $(this).parent().remove();
  240. })
  241. function checkZj(_this,prd) {
  242. prEnd=prd;
  243. $.ajax({
  244. "url": "/ajax/professor/qaByName",
  245. "type": "get",
  246. "data": {
  247. "name": $("#checkZj").val(),
  248. "total": 3
  249. },
  250. "success": function(data) {
  251. console.log(data);
  252. if(data.success) {
  253. if(data.data != "") {
  254. if(prEnd == prd){
  255. $(_this).next().removeClass("displayNone");
  256. var itemlist = '';
  257. $("#expertlist").html("");
  258. for(var i = 0; i < data.data.length; i++) {
  259. var itemlist = '<li id="usid" class="flexCenter">';
  260. itemlist += '<div class="madiaHead useHead" id="userimg"></div>';
  261. itemlist += '<div class="madiaInfo">';
  262. itemlist += '<p class="ellipsisSty"><span class="h1Font" id="name"></span><span class="h2Font" style="margin-left:10px;" id="title"></span></p>';
  263. itemlist += '<p class="h2Font ellipsisSty" id="orgName"></p>';
  264. itemlist += '</div><div class="deleteThis"></div></li>';
  265. $itemlist = $(itemlist);
  266. $("#expertlist").append($itemlist);
  267. var datalist = data.data[i];
  268. $itemlist.attr("data-id", datalist.id);
  269. $itemlist.find("#name").text(datalist.name);
  270. $itemlist.find("#title").text(datalist.title);
  271. $itemlist.find("#orgName").text(datalist.orgName);
  272. if(datalist.hasHeadImage == 1) {
  273. $itemlist.find("#userimg").attr("style", "background-image: url(/images/head/" + datalist.id + "_l.jpg);");
  274. }
  275. }
  276. }
  277. } else {
  278. $(_this).next().addClass("displayNone");
  279. }
  280. } else {
  281. $(_this).next().addClass("displayNone");
  282. }
  283. },
  284. "error": function() {
  285. $.MsgBox.Alert('提示', '链接服务器超时')
  286. }
  287. });
  288. }
  289. function checkZy(_this,prd) {
  290. reEnd=prd;
  291. $.ajax({
  292. "url": "/ajax/resource/qaByName",
  293. "type": "get",
  294. "data": {
  295. "resourceName": $("#checkZy").val(),
  296. "rows": 3
  297. },
  298. "success": function(data) {
  299. console.log(data);
  300. if(data.success) {
  301. if(data.data != "") {
  302. if(reEnd==prd) {
  303. $(_this).next().removeClass("displayNone");
  304. var itemlist = '';
  305. $("#resouselist").html("");
  306. for(var i = 0; i < data.data.length; i++) {
  307. var itemlist = '<li id="usid" class="flexCenter">';
  308. itemlist += '<div class="madiaHead resouseHead" id="userimg"></div>';
  309. itemlist += '<div class="madiaInfo">';
  310. itemlist += '<p class="h1Font ellipsisSty" id="resourceName"></p>';
  311. itemlist += '<p class="h2Font ellipsisSty" id="name"></p>';
  312. itemlist += '</div><div class="deleteThis"></div></li>';
  313. $itemlist = $(itemlist);
  314. $("#resouselist").append($itemlist);
  315. var datalist = data.data[i];
  316. $itemlist.attr("data-id", datalist.resourceId);
  317. $itemlist.find("#resourceName").text(datalist.resourceName);
  318. if(datalist.resourceType==1){
  319. $itemlist.find("#name").text(datalist.professor.name);
  320. }else{
  321. $itemlist.find("#name").text(datalist.organization.name);
  322. }
  323. if(datalist.images.length > 0) {
  324. $itemlist.find("#userimg").attr("style", "background-image: url(/data/resource/" + datalist.images[0].imageSrc + ");");
  325. }
  326. }
  327. }
  328. } else {
  329. $(_this).next().addClass("displayNone");
  330. }
  331. } else {
  332. $(_this).next().addClass("displayNone");
  333. }
  334. },
  335. "error": function() {
  336. $.MsgBox.Alert('提示', '链接服务器超时')
  337. }
  338. });
  339. }
  340. //初始化数据
  341. function articleshow(){
  342. $.ajax({
  343. "url" : "/ajax/article/query",
  344. "type" : "GET" ,
  345. "dataType" : "json",
  346. "data" :{"articleId":articleId},
  347. "success" : function(data) {
  348. console.log(data)
  349. if (data.success){
  350. $("#keyWordlist").html("");
  351. $("#newstitle").val(data.data.articleTitle);
  352. if(data.data.articleImg){
  353. $("#uploader").attr("style", "background-image: url(/data/article/" + data.data.articleImg + ");");
  354. $(".upFront").hide();
  355. $(".upBackbtn").show();
  356. }
  357. ue.ready(function() {
  358. if(data.data.articleContent==undefined){
  359. var datadescp ="";
  360. }else{
  361. var datadescp = data.data.articleContent;
  362. }
  363. ue.setContent(datadescp);
  364. });
  365. industryShow(data.data.subject,"keyWordlist");
  366. modifyTimeval = data.data.modifyTime;
  367. }
  368. },
  369. "error":function(){
  370. $.MsgBox.Alert('提示','链接服务器超时')
  371. }
  372. });
  373. }
  374. //相关专家
  375. function relevantExperts(){
  376. $.ajax({
  377. "url": "/ajax/article/ralatePro",
  378. "type": "get",
  379. "dataType" : "json",
  380. "data" :{"articleId":articleId},
  381. "success": function(data) {
  382. if(data.success && data.data) {
  383. for(var i = 0; i < data.data.length; i++) {
  384. var professorId = data.data[i].professorId;
  385. relevantExpertsList(professorId)
  386. }
  387. }
  388. },
  389. "error": function() {
  390. $.MsgBox.Alert('提示', '链接服务器超时')
  391. }
  392. });
  393. }
  394. //相关专家信息
  395. function relevantExpertsList(professorId){
  396. $.ajax({
  397. "url" : "/ajax/professor/info/"+professorId,
  398. "type" : "GET" ,
  399. "dataType" : "json",
  400. "success" : function(data) {
  401. console.log(data);
  402. if (data.success && data.data){
  403. var itemlist = '';
  404. var itemlist = '<li id="usid">';
  405. itemlist += '<div class="madiaHead useHead" id="userimg"></div>';
  406. itemlist += '<div class="madiaInfo">';
  407. itemlist += '<p class="ellipsisSty"><span class="h1Font" id="name"></span><span class="h2Font" style="margin-left:10px;" id="title"></span></p>';
  408. itemlist += '<p class="h2Font ellipsisSty" id="orgName"></p>';
  409. itemlist += '</div><div class="deleteThis"></div></li>';
  410. $itemlist = $(itemlist);
  411. $("#expertli").append($itemlist);
  412. var datalist = data.data;
  413. $itemlist.attr("data-id",datalist.id);
  414. $itemlist.find("#name").text(datalist.name);
  415. $itemlist.find("#title").text(datalist.title);
  416. $itemlist.find("#orgName").text(datalist.orgName);
  417. if(datalist.hasHeadImage==1) {
  418. $itemlist.find("#userimg").attr("style", "background-image: url(/images/head/" + datalist.id + "_l.jpg);");
  419. }
  420. }
  421. },
  422. "error":function(){
  423. $.MsgBox.Alert('提示','链接服务器超时')
  424. }
  425. });
  426. }
  427. //相关资源
  428. function relevantResources(){
  429. $.ajax({
  430. "url": "/ajax/article/ralateRes",
  431. "type": "get",
  432. "dataType" : "json",
  433. "data" :{"articleId":articleId},
  434. "success": function(data) {
  435. if(data.success && data.data) {
  436. for(var i = 0; i < data.data.length; i++) {
  437. var resourceId = data.data[i].resourceId;
  438. relevantResourcesList(resourceId)
  439. }
  440. }
  441. },
  442. "error": function() {
  443. $.MsgBox.Alert('提示', '链接服务器超时')
  444. }
  445. });
  446. }
  447. //相关资源信息
  448. function relevantResourcesList(resourceId){
  449. $.ajax({
  450. "url" : "/ajax/resource/resourceInfo",
  451. "type" : "GET" ,
  452. "dataType" : "json",
  453. "data" :{"resourceId":resourceId},
  454. "success" : function(data) {
  455. console.log(data);
  456. if (data.success && data.data){
  457. var itemlist = '<li id="usid">';
  458. itemlist += '<div class="madiaHead resouseHead" id="userimg"></div>';
  459. itemlist += '<div class="madiaInfo">';
  460. itemlist += '<p class="h2Font ellipsisSty" id="resourceName"></p>';
  461. itemlist += '<p class="h1Font" id="name"></p>';
  462. itemlist += '</div><div class="deleteThis"></div></li>';
  463. $itemlist = $(itemlist);
  464. $("#resources").append($itemlist);
  465. var datalist = data.data;
  466. $itemlist.attr("data-id", datalist.resourceId);
  467. $itemlist.find("#resourceName").text(datalist.resourceName);
  468. $itemlist.find("#name").text(datalist.editProfessor.name);
  469. if(datalist.images.length > 0) {
  470. $itemlist.find("#userimg").attr("style", "background-image: url(/data/resource/" + datalist.images[0].imageSrc + ");");
  471. }
  472. }
  473. },
  474. "error":function(){
  475. $.MsgBox.Alert('提示','链接服务器超时')
  476. }
  477. });
  478. }
  479. var titleflase = false;
  480. //交验图片和标题不能为空
  481. function noTitleImg(){
  482. //var ImageKey = $("#uploader").attr("data-id");
  483. var newstitle = $("#newstitle").val();
  484. /*if(ImageKey==""){
  485. $(".imgtis").text("请上传封面图片");
  486. }else{
  487. $(".imgtis").text("");
  488. imgflase = true;
  489. }*/
  490. if(newstitle==""){
  491. $.MsgBox.Alert('提示', '请输入文章标题')
  492. return;
  493. }else{
  494. $("#aboutTit span").text("");
  495. titleflase = true;
  496. }
  497. }
  498. //获取相关专家
  499. function expertli(){
  500. experarray=[];
  501. $("#expertli li").each(function(i){
  502. var liid = $(this).attr("data-id");
  503. experarray.push(liid);
  504. });
  505. return $.unique(experarray);
  506. }
  507. //获取相关专家
  508. function resourcesli(){
  509. resourcesarray=[];
  510. $("#resources li").each(function(i){
  511. var liid = $(this).attr("data-id");
  512. resourcesarray.push(liid);
  513. });
  514. return $.unique(resourcesarray);
  515. }
  516. //文章发布
  517. $("#release").on("click",function(){
  518. noTitleImg();
  519. if(titleflase){
  520. $.MsgBox.Confirm("提示","确认发布该文章?",newsAdd);
  521. }
  522. })
  523. //文章存草稿
  524. $("#draft").on("click",function(){
  525. noTitleImg();
  526. if(titleflase){
  527. draftAdd(1);
  528. }
  529. })
  530. //文章预览
  531. $("#preview").on("click",function(){
  532. noTitleImg();
  533. if(titleflase){
  534. draftAdd(2);
  535. }
  536. })
  537. //删除文章
  538. $("#delete").on("click",function(){
  539. $.MsgBox.Confirm("提示","确认删除该文章?",newsDelet);
  540. })
  541. //定时文章发布
  542. $("#setTimeIssue").on("click", function() {
  543. //$(".form_datetime").val(timeGeshi(modifyTimeval));
  544. noTitleImg();
  545. if(titleflase) {
  546. $(".blackcover2").fadeIn();
  547. $(".modelContain").show();
  548. $("body").addClass("modelOpen");
  549. $(".mb_btnOk").on("click", function() {
  550. var modifyTimeval = $(".form_datetime").val();
  551. settime = true;
  552. setTimeIssue(st6(modifyTimeval),settime);
  553. })
  554. }
  555. })
  556. /*获取数据*/
  557. function getdata(publishTime,settime) {
  558. expertli();//相关专家
  559. resourcesli();//相关咨询
  560. $data.articleId = articleId;
  561. $data.professorId = userid;
  562. $data.articleTitle = $("#newstitle").val();
  563. $data.subject = captiureSubInd("keyWordlist .delkeylist");
  564. $data.articleImg = $("#uploader").attr("data-id");
  565. $data.articleContent = ue.getContent();
  566. $data.professors = experarray;
  567. $data.resources = resourcesarray;
  568. if(settime) {
  569. $data.publishTime = publishTime;
  570. }
  571. console.log($data);
  572. }
  573. /*文章添加*/
  574. function newsAdd(){
  575. getdata();
  576. $.ajax({
  577. "url" : "/ajax/article/save",
  578. "type" : "post" ,
  579. "dataType" : "json",
  580. "data" :$data,
  581. "traditional": true, //传数组必须加这个
  582. "success" : function(data) {
  583. console.log(data);
  584. if (data.success){
  585. articleId = data.data;
  586. $.MsgBox.Alert("提示","文章发表成功!",function articalList(){
  587. location.href = "articalList.html";
  588. });
  589. $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
  590. } else {
  591. if(data.code==90) {
  592. $.MsgBox.Alert('提示', '由于操作时间过久,上传图片已失效,请重新上传。');
  593. }else{
  594. $.MsgBox.Alert("提示", "文章发表失败!");
  595. }
  596. }
  597. },
  598. "error":function(){
  599. $.MsgBox.Alert('提示','链接服务器超时')
  600. }
  601. });
  602. }
  603. /*文章定时发布*/
  604. function setTimeIssue(publishTime,settime) {
  605. var opublishTime=publishTime+"01";
  606. getdata(opublishTime,settime);
  607. $.ajax({
  608. "url": "/ajax/article/timing",
  609. "type": "post",
  610. "dataType": "json",
  611. "data": $data,
  612. "traditional": true, //传数组必须加这个
  613. "success": function(data) {
  614. console.log(data);
  615. if(data.success) {
  616. articleId = data.data;
  617. location.href = "articalList.html";
  618. } else {
  619. if(data.code==90) {
  620. $.MsgBox.Alert('提示', '由于操作时间过久,上传图片已失效,请重新上传。');
  621. }else{
  622. $.MsgBox.Alert("提示", "文章发表失败!");
  623. }
  624. }
  625. },
  626. "error": function() {
  627. $.MsgBox.Alert('提示', '链接服务器超时')
  628. }
  629. });
  630. }
  631. /*文章添加草稿和文章预览*/
  632. function draftAdd(num){
  633. getdata();
  634. $.ajax({
  635. "url" : "/ajax/article/draft",
  636. "type" : "post" ,
  637. "dataType" : "json",
  638. "data" :$data,
  639. "traditional": true, //传数组必须加这个
  640. "success" : function(data) {
  641. console.log(data);
  642. if(num==1){
  643. if (data.success){
  644. articleId = data.data;
  645. $.MsgBox.Alert("提示","文章已保存草稿。");
  646. $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
  647. articleshow();
  648. }else{
  649. if(data.code==90) {
  650. $.MsgBox.Alert('提示', '由于操作时间过久,上传图片已失效,请重新上传。');
  651. }else{
  652. $.MsgBox.Alert("提示", "文章发表失败!");
  653. }
  654. }
  655. }
  656. if(num==2){
  657. if(data.success) {
  658. $("#hidearticleId").val(data.data);
  659. articleId = data.data;
  660. $("#delete").removeClass("disableLi").addClass("odele");
  661. fa = true;
  662. }else{
  663. if(data.code==90) {
  664. $.MsgBox.Alert('提示', '由于操作时间过久,上传图片已失效,请重新上传。');
  665. }else{
  666. $.MsgBox.Alert("提示", "文章发表失败!");
  667. }
  668. }
  669. if(fa) {
  670. window.open("articalPreview.html?articleId=" + articleId)
  671. }
  672. }
  673. },
  674. "error":function(){
  675. $.MsgBox.Alert('提示','链接服务器超时')
  676. }
  677. });
  678. }
  679. /*文章删除*/
  680. function newsDelet() {
  681. $.ajax({
  682. "url" : "/ajax/article/deleteArticle",
  683. "type" : "POST",
  684. "dataType" : "json",
  685. "data": {
  686. "articleId": articleId
  687. },
  688. "success" : function($data) {
  689. if ($data.success) {
  690. location.href = "articalList.html";
  691. }
  692. },
  693. "error":function(){
  694. $.MsgBox.Alert('提示','链接服务器超时')
  695. }
  696. })
  697. }
  698. function st6(osr) {
  699. var tim = osr.substring(0, 4) + osr.substring(5, 7) + osr.substring(8, 10) + osr.substring(11, 13) + osr.substring(14, 16);
  700. return tim;
  701. }
  702. function timeGeshi(otm) {
  703. var otme = otm.substring(0, 4) + "-" + otm.substring(4, 6).replace(/\b(0+)/gi, "") + "-" + otm.substring(6, 8).replace(/\b(0+)/gi, "") + " " + otm.substring(8, 10)+ ":" + otm.substring(10, 12);
  704. return otme;
  705. }
  706. });