123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- $(document).ready(function() {
- editor=UE.getEditor('content', {
- toolbars: [
- ['bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript',
- 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor',
- 'backcolor', 'insertorderedlist', 'insertunorderedlist','simpleupload', 'selectall', 'cleardoc','justifycenter',
- 'fontfamily', 'fontsize', 'paragraph']
- ]
- });
- $("#qa_form").submit(function () {
- var flad = checkForm();
- if(!flad){
- return false;
- }
- $("#changeTJ").attr("style","display: none");
- $("#addIJ").attr("style", "display: none");
- $("#projectBtn").attr("style", "margin: 20px;background: #f2a734;font-size: 14px;width: 110px");
- $("#qa_form").ajaxSubmit({
- success: function (data) {
- if(data.status == "SUCCESS"){
- Showbo.Msg.alert("操作成功");
- setTimeout('myrefresh()',1000); //指定1秒刷新一次
- } else if(data.status == "ERROR"){
- Showbo.Msg.alert("操作失败");
- var thisURL = document.URL
- var version = thisURL.substring(thisURL.indexOf('=') + 1);
- if (version == thisURL) {
- $("#changeTJ").attr("style", "display: none");
- $("#addIJ").attr("style", "margin: 20px;background: #f2a734;font-size: 14px;width: 110px");
- } else {
- $("#changeTJ").attr("style", "margin: 20px;background: #f2a734;font-size: 14px;width: 110px");
- $("#addIJ").attr("style", "display: none");
- }
- $("#projectBtn").attr("style", "display: none");
- } else if(data.status == "BEYOND"){
- Showbo.Msg.alert(data.desc);
- }
- },
- });
- return false;
- });
- getmanu();
- });
- function myrefresh() {
- window.location.href ="/iflytek/about_us.html";
- }
- function getmanu(){
- var thisURL = document.URL
- var version = thisURL.substring(thisURL.indexOf('=')+1);
- if(version==thisURL){
- $("#changeTJ").attr("style","margin: 20px;background: #f2a734;font-size: 14px;width: 110px;display: none");
- $("#addIJ").attr("style","margin: 20px;background: #f2a734;font-size: 14px;width: 110px");
- }else{
- $("#changeTJ").attr("style","margin: 20px;background: #f2a734;font-size: 14px;width: 110px");
- $("#addIJ").attr("style","margin: 20px;background: #f2a734;font-size: 14px;width: 110px;display: none");
- }
- $("#changeid").val(version);
- $.ajax({
- url: " " + baseConfig.URL.aboutUsfindByid + "",
- type: "POST",
- async: false,
- cache: false,
- data: { id: version},
- success: function (data) {
- if(data.status=="SUCCESS"){
- $("#title").val(data.rec.title);
- $("#creattime").val(data.rec.creattime);
- $("#para").val(data.rec.para);
- $("#content").html(data.rec.content);
- var getfileurl=data.rec.fileurl;
- var imgurl=data.rec.imgurl;
- var index = getfileurl.lastIndexOf("/");
- var filename = getfileurl.substr(index+1);
- var indeximg = imgurl.lastIndexOf("/");
- var fileimgname = imgurl.substr(indeximg+1);
- if(getfileurl!=null&&getfileurl!=""){
- $("#other0").val(filename);
- }
- if(imgurl!=null&&imgurl!=""){
- $("#firstimg").val(fileimgname);
- }
- }
- }
- });
- }
- function addnoticenews() {
- document.getElementById("qa_form").action=" "+baseConfig.URL.aboutUsaddnews + "";
- $("#qa_form").submit();
- }
- function changenoticenews() {
- document.getElementById("qa_form").action=" "+baseConfig.URL.aboutUsupdatenews + "";
- $("#qa_form").submit();
- }
- function checkForm(){
- var content= editor.getContentTxt();
- if (content == "" || content==null) {
- Showbo.Msg.alert("请填写内容!");
- return false;
- }
- if ($.trim($('#title').val()) == "" ||$('#title').val()==null) {
- Showbo.Msg.alert("请填写标题!");
- return false;
- }
- if ($.trim($('#para').val()) == "" ||$('#para').val()==null) {
- Showbo.Msg.alert("请填写分类!");
- return false;
- }
- return true;
- }
- var count = 0;
- var num = 0;
- function PreviewImage(imgFile) {
- var length = $("#sc").children("div").length;
- if(length >=6){
- $("#csgo1").html("附件只可以上传5张");
- $("#csgo0").attr("style", "display:block");
- return false;
- }
- //定义路径var path;
- var name= $(imgFile).val().split("\\").pop();
- document.getElementById("other"+count+"").style.display="none";
- //添加显示图片的HTML元素
- count += 1;
- $(".img-cont"+num).append("<input id='img"+count+"' width='220' height='110' value='"+name+"' " +
- " style='width:300px;border:none;' /><button onclick='del("+num+")' " +
- "style='background: #fff;color: #1d4795;height: 20px;padding: 0 20px;margin-left: 40px;'>删除</button>");
- num += 1;
- $("#sc").append(" <div class='img-cont"+num+" img_up ad-btn'><input style='color: #fff;border:none;' " +
- "type='file' name='other"+count+"' id='other"+count+"' class='upload-input' onchange='PreviewImage(this)'/>" +"</div>");
- }
- function del(cl) {
- $(".img-cont"+cl).remove();
- }
- function checkFileExt(filename)
- {
- var flag = false; //状态
- var arr = ["jpg","png","jpeg","bmp"];
- //取出上传文件的扩展名
- var index = filename.lastIndexOf(".");
- var ext = filename.substr(index+1);
- //循环比较
- for(var i=0;i<arr.length;i++)
- {
- if(ext == arr[i])
- {
- flag = true; //一旦找到合适的,立即退出循环
- break;
- }
- }
- //条件判断
- if(!flag){
- Showbo.Msg.alert("请上传正确的图片格式(jpg jpeg png bmp)!");
- return false;
- }
- }
|