aboutUsadd.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. $(document).ready(function() {
  2. editor=UE.getEditor('content', {
  3. toolbars: [
  4. ['bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript',
  5. 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor',
  6. 'backcolor', 'insertorderedlist', 'insertunorderedlist','simpleupload', 'selectall', 'cleardoc','justifycenter',
  7. 'fontfamily', 'fontsize', 'paragraph']
  8. ]
  9. });
  10. $("#qa_form").submit(function () {
  11. var flad = checkForm();
  12. if(!flad){
  13. return false;
  14. }
  15. $("#changeTJ").attr("style","display: none");
  16. $("#addIJ").attr("style", "display: none");
  17. $("#projectBtn").attr("style", "margin: 20px;background: #f2a734;font-size: 14px;width: 110px");
  18. $("#qa_form").ajaxSubmit({
  19. success: function (data) {
  20. if(data.status == "SUCCESS"){
  21. Showbo.Msg.alert("操作成功");
  22. setTimeout('myrefresh()',1000); //指定1秒刷新一次
  23. } else if(data.status == "ERROR"){
  24. Showbo.Msg.alert("操作失败");
  25. var thisURL = document.URL
  26. var version = thisURL.substring(thisURL.indexOf('=') + 1);
  27. if (version == thisURL) {
  28. $("#changeTJ").attr("style", "display: none");
  29. $("#addIJ").attr("style", "margin: 20px;background: #f2a734;font-size: 14px;width: 110px");
  30. } else {
  31. $("#changeTJ").attr("style", "margin: 20px;background: #f2a734;font-size: 14px;width: 110px");
  32. $("#addIJ").attr("style", "display: none");
  33. }
  34. $("#projectBtn").attr("style", "display: none");
  35. } else if(data.status == "BEYOND"){
  36. Showbo.Msg.alert(data.desc);
  37. }
  38. },
  39. });
  40. return false;
  41. });
  42. getmanu();
  43. });
  44. function myrefresh() {
  45. window.location.href ="/iflytek/about_us.html";
  46. }
  47. function getmanu(){
  48. var thisURL = document.URL
  49. var version = thisURL.substring(thisURL.indexOf('=')+1);
  50. if(version==thisURL){
  51. $("#changeTJ").attr("style","margin: 20px;background: #f2a734;font-size: 14px;width: 110px;display: none");
  52. $("#addIJ").attr("style","margin: 20px;background: #f2a734;font-size: 14px;width: 110px");
  53. }else{
  54. $("#changeTJ").attr("style","margin: 20px;background: #f2a734;font-size: 14px;width: 110px");
  55. $("#addIJ").attr("style","margin: 20px;background: #f2a734;font-size: 14px;width: 110px;display: none");
  56. }
  57. $("#changeid").val(version);
  58. $.ajax({
  59. url: " " + baseConfig.URL.aboutUsfindByid + "",
  60. type: "POST",
  61. async: false,
  62. cache: false,
  63. data: { id: version},
  64. success: function (data) {
  65. if(data.status=="SUCCESS"){
  66. $("#title").val(data.rec.title);
  67. $("#creattime").val(data.rec.creattime);
  68. $("#para").val(data.rec.para);
  69. $("#content").html(data.rec.content);
  70. var getfileurl=data.rec.fileurl;
  71. var imgurl=data.rec.imgurl;
  72. var index = getfileurl.lastIndexOf("/");
  73. var filename = getfileurl.substr(index+1);
  74. var indeximg = imgurl.lastIndexOf("/");
  75. var fileimgname = imgurl.substr(indeximg+1);
  76. if(getfileurl!=null&&getfileurl!=""){
  77. $("#other0").val(filename);
  78. }
  79. if(imgurl!=null&&imgurl!=""){
  80. $("#firstimg").val(fileimgname);
  81. }
  82. }
  83. }
  84. });
  85. }
  86. function addnoticenews() {
  87. document.getElementById("qa_form").action=" "+baseConfig.URL.aboutUsaddnews + "";
  88. $("#qa_form").submit();
  89. }
  90. function changenoticenews() {
  91. document.getElementById("qa_form").action=" "+baseConfig.URL.aboutUsupdatenews + "";
  92. $("#qa_form").submit();
  93. }
  94. function checkForm(){
  95. var content= editor.getContentTxt();
  96. if (content == "" || content==null) {
  97. Showbo.Msg.alert("请填写内容!");
  98. return false;
  99. }
  100. if ($.trim($('#title').val()) == "" ||$('#title').val()==null) {
  101. Showbo.Msg.alert("请填写标题!");
  102. return false;
  103. }
  104. if ($.trim($('#para').val()) == "" ||$('#para').val()==null) {
  105. Showbo.Msg.alert("请填写分类!");
  106. return false;
  107. }
  108. return true;
  109. }
  110. var count = 0;
  111. var num = 0;
  112. function PreviewImage(imgFile) {
  113. var length = $("#sc").children("div").length;
  114. if(length >=6){
  115. $("#csgo1").html("附件只可以上传5张");
  116. $("#csgo0").attr("style", "display:block");
  117. return false;
  118. }
  119. //定义路径var path;
  120. var name= $(imgFile).val().split("\\").pop();
  121. document.getElementById("other"+count+"").style.display="none";
  122. //添加显示图片的HTML元素
  123. count += 1;
  124. $(".img-cont"+num).append("<input id='img"+count+"' width='220' height='110' value='"+name+"' " +
  125. " style='width:300px;border:none;' /><button onclick='del("+num+")' " +
  126. "style='background: #fff;color: #1d4795;height: 20px;padding: 0 20px;margin-left: 40px;'>删除</button>");
  127. num += 1;
  128. $("#sc").append(" <div class='img-cont"+num+" img_up ad-btn'><input style='color: #fff;border:none;' " +
  129. "type='file' name='other"+count+"' id='other"+count+"' class='upload-input' onchange='PreviewImage(this)'/>" +"</div>");
  130. }
  131. function del(cl) {
  132. $(".img-cont"+cl).remove();
  133. }
  134. function checkFileExt(filename)
  135. {
  136. var flag = false; //状态
  137. var arr = ["jpg","png","jpeg","bmp"];
  138. //取出上传文件的扩展名
  139. var index = filename.lastIndexOf(".");
  140. var ext = filename.substr(index+1);
  141. //循环比较
  142. for(var i=0;i<arr.length;i++)
  143. {
  144. if(ext == arr[i])
  145. {
  146. flag = true; //一旦找到合适的,立即退出循环
  147. break;
  148. }
  149. }
  150. //条件判断
  151. if(!flag){
  152. Showbo.Msg.alert("请上传正确的图片格式(jpg jpeg png bmp)!");
  153. return false;
  154. }
  155. }