123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920 |
- $(function() {
- var baseUrl = "http://www.ekexiu.com";
- loginStatus();
-
- var oProfessor = [];
- var sevriceId = GetQueryString("serviceId");
- var re, reEnd, ue = UE.getEditor('editor', {}),
- temp = [];
-
-
-
- if(sevriceId) {
- $("#deleteResource").removeClass("disableLi").addClass("deleteResource");
- getRecourceMe();
- }
- function loginStatus() {
- $.ajax({
- type: "get",
- async:false,
- url:"/ajax/sys/user",
- success:function (data) {
- if(data.success == true) {
- var userid = data.data.id;
- if (userid == undefined || userid.length == 0 || userid == "null") {
- location.href = "http://"+window.location.host+"/html/index.html";
- }
- }else {
- location.href = "http://"+window.location.host+"/html/index.html";
- }
- }
- });
- }
- function GetQueryString(name) {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
- var r = window.location.search.substr(1).match(reg);
- var context = "";
- if(r != null)
- context = r[2];
- reg = null;
- r = null;
- return context == null || context == "" || context == "undefined" ? "" : decodeURI(context);
- }
- function hotKey(sel, num) {
- $(sel).bind({
- paste: function(e) {
- var pastedText;
- if (window.clipboardData && window.clipboardData.getData) {
- pastedText = $(this).val() + window.clipboardData.getData('Text');
- }else{
- pastedText = $(this).val() + e.originalEvent.clipboardData.getData('Text');
- }
- $(this).val(pastedText);
- var $this = $(this);
- setTimeout(function() {
- if($this.val().trim()) {
- $this.siblings("button").show();
- } else {
- $this.siblings("button").hide();
- }
- }, 1);
- e.preventDefault();
- },
- cut: function(e) {
- var $this = $(this);
- setTimeout(function() {
- if($this.val().trim()) {
- $this.siblings("button").show();
- } else {
- $this.siblings("button").hide();
- }
- }, 1);
- },
- blur: function() {
- var $this = $(this);
- setTimeout(function() {
- $this.siblings(".keydrop").hide();
- }, 500)
- },
- focus: function() {
- $(this).siblings(".keydrop").show();
- },
- keyup: function(e) {
- var ti=$(this).val();
- var $t=this;
- $t.comr=ti;
- var $this=$(this);
- if($(this).val().trim()) {
- $(this).siblings("button").show();
- var lNum = $.trim($(this).val()).length;
- if(0 < lNum) {
- setTimeout(function(){
- if( ti===$t.comr && ti!== $t.comrEnd) {
- var tt=ti;
- $t.comrEnd=tt;
- $("#addKeyword").show();
- $.ajax({
- "url": "/ajax/article/qaHotKey",
- "type": "GET",
- "success": function(data) {
- console.log(data);
- if(data.success) {
- if($t.comrEnd==tt) {
- if(data.data.length == 0) {
- $this.siblings(".keydrop").addClass("displayNone");
- $this.siblings(".keydrop").find("ul").html("");
- } else {
- $this.siblings(".keydrop").removeClass("displayNone");
- var oSr = "";
- for(var i = 0; i < Math.min(data.data.length,5); i++) {
- oSr += '<li>' + data.data[i].caption + '<div class="closeThis"></div></li>';
- }
- $this.siblings(".keydrop").find("ul").html(oSr);
- }
- }
- } else {
- $this.siblings(".keydrop").addClass("displayNone");
- $this.siblings(".keydrop").find("ul").html("");
- }
- },
- "data": {
- "key": $this.val()
- },
- dataType: "json",
- 'error': function() {
- $.MsgBox.Alert('提示', '服务器连接超时!');
- }
- });
- }
- },500);
- }
- } else {
- $(this).siblings("button").hide();
- $(this).siblings(".keydrop").addClass("displayNone");
- $(this).siblings(".keydrop").find("ul").html("");
- }
- }
- })
- $(".keydrop").on("click", "li", function() {
- var oValue = $(this).text();
- var oJudge = $(this).parents(".col-w-12").siblings().find("ul.ulspace li");
- var addNum = $(this).parents(".keydrop").siblings("input").attr("data-num");
- for(var i = 0; i < oJudge.length; i++) {
- if(oValue == oJudge[i].innerText) {
- $.MsgBox.Alert('提示', '添加内容不能重复');
- return;
- }
- }
- $(this).parents(".col-w-12").siblings().find("ul.ulspace").append('<li>' + oValue + '<div class="closeThis"></div></li>');
- $(this).parents(".keydrop").siblings("input").val("");
- $(this).parents(".keydrop").siblings("button").hide();
- if(oJudge.length == addNum - 1) {
- $(this).parents(".keydrop").siblings("input").val("");
- $(this).parents(".col-w-12").hide();
- }
- $(this).parent("ul").html("")
- })
- if(num == 1) {
- return;
- } else {
- $(".addButton").siblings("input").keypress(function(){
- var e = event || window.event;
- if(e.keyCode == 13) {
- var oValue = $(this).val().trim();
- var oJudge = $(this).parent().siblings().find("ul.ulspace li");
- var addContent = $(this).attr("data-pro");
- var addNum = $(this).attr("data-num");
- var addfontSizeNum = $(this).attr("data-fontSizeN");
- if(!oValue) {
- $.MsgBox.Alert('提示', '请先填写内容');
- return;
- }
- if(oValue.length > addfontSizeNum) {
- $.MsgBox.Alert('提示', addContent);
- return;
- }
- for(var i = 0; i < oJudge.length; i++) {
- if(oValue == oJudge[i].innerText) {
- $.MsgBox.Alert('提示', '添加内容不能重复');
- return;
- }
- }
- $(this).parent().siblings().find("ul.ulspace").append('<li>' + oValue + '<div class="closeThis"></div></li>');
- $(this).siblings(".addButton").hide();
- $(this).val("");
- if(oJudge.length == addNum - 1) {
- $(this).val("").parents(".col-w-12").hide();
- }
- $(this).siblings(".keydrop").find("ul").html("");
- }
- })
- $(".addButton").click(function() {
- var oValue = $(this).siblings("input").val().trim();
- var oJudge = $(this).parent().siblings().find("ul.ulspace li");
- var addContent = $(this).siblings("input").attr("data-pro");
- var addNum = $(this).siblings("input").attr("data-num");
- var addfontSizeNum = $(this).siblings("input").attr("data-fontSizeN");
- if(!oValue) {
- $.MsgBox.Alert('提示', '请先填写内容');
- return;
- }
- if(oValue.length > addfontSizeNum) {
- $.MsgBox.Alert('提示', addContent);
- return;
- }
- for(var i = 0; i < oJudge.length; i++) {
- if(oValue == oJudge[i].innerText) {
- $.MsgBox.Alert('提示', '添加内容不能重复');
- return;
- }
- }
- $(this).parent().siblings().find("ul.ulspace").append('<li>' + oValue + '<div class="closeThis"></div></li>');
- $(this).hide();
- $(this).siblings("input").val("");
- if(oJudge.length == addNum - 1) {
- $(this).val("").parents(".col-w-12").hide();
- }
- $(this).siblings(".keydrop").find("ul").html("");
- })
- }
- }
- function limitObj(obj,maxNum){
- $(obj).bind({
- paste: function(e) {
- if($(this).val().length==""){
- $(this).parent().siblings(".btnModel").attr("disabled", true);
- }else{
- $(this).parent().siblings(".btnModel").attr("disabled", false);
- }
- var pastedText;
- if (window.clipboardData && window.clipboardData.getData) {
- pastedText = $(this).val() + window.clipboardData.getData('Text');
- }
- else {
- pastedText = $(this).val() + e.originalEvent.clipboardData.getData('Text');
- }
- $(this).val(pastedText);
- setTimeout(function() {
- $(this).siblings().find("em").text($(obj).val().length);
- }, 1);
- e.preventDefault();
- },
- cut: function(e) {
- if($(this).val().length==""){
- $(this).parent().siblings(".btnModel").attr("disabled", true);
- }else{
- $(this).parent().siblings(".btnModel").attr("disabled", false);
- }
- setTimeout(function() {
- $(obj).siblings().find("em").text($(obj).val().length);
- }, 1);
- },
- focus: function(e) {
- $(obj).parents("li").find(".frmconmsg").show();
- $(obj).siblings().find("em").text($(obj).val().length);
- },
- blur: function(e) {
- $(obj).parents("li").find(".frmconmsg").hide();
- },
- keyup: function(e) {
- if($(this).val().length==""){
- $(this).parent().siblings(".btnModel").attr("disabled", true);
- }else{
- $(this).parent().siblings(".btnModel").attr("disabled", false);
- }
- if($(this).val().length > maxNum) {
- $(obj).val($(obj).val().substring(0, maxNum));
- e.preventDefault();
- }
- setTimeout(function() {
- $(obj).siblings().find("em").text($(obj).val().length);
- }, 1);
- }
- });
- }
- function ajaxRequist(url, obj, type, fn) {
- $.ajax({
- url: url,
- data: obj,
- dataType: 'json',
- type: type,
- traditional: true,
- success: function(data) {
- if(data.success) {
- fn(data)
- }
- },
- error: function(xhr, type, errorThrown) {
- $.MsgBox.Alert('提示', '服务器请求失败');
- }
- });
- }
- function getRecourceMe() {
- $.ajax({
- "url": baseUrl+"/ajax/ware/qo",
- "type": "GET",
- "success": function(data) {
- if(data.success) {
- $("#uploadDd").siblings().remove();
- $("#fileList").append("<dd></dd><dd></dd>");
- temp = [];
- resourceHtml(data.data);
- }
- },
- "data": {
- "id": sevriceId
- },
- dataType: "json",
- 'error': function() {
- $.MsgBox.Alert('提示', '服务器连接超时!');
- }
- });
- }
-
- function resourceHtml($da) {
- $("#resourceName").val($da.name);
- if($da.cnt) {
- $("#modelNumber").val($da.cnt);
- autoGrow.call($("#modelNumber")[0])
- }
- if($da.cooperation) {
- $("#remarkContent").val($da.cooperation);
- }
- if($da.keywords) {
- var oSub = $da.keywords.split(",");
- var oSt = "";
- for(var i = 0; i < oSub.length; i++) {
- oSt += '<li>' + oSub[i] + '<div class="closeThis"></div></li>'
- }
- $("#keyWordlist").html(oSt);
- if(oSub.length > 4) {
- $("#KeyWord").parent().addClass("displayNone");
- }
- } else {
- $("#keyWordlist").html("");
- }
- if($da.descp) {
- ue.ready(function() {
- ue.setContent($da.descp);
- });
- }
- if($da.images) {
- var arr = [];
- var oImg = $da.images.split(",");
- for(var i = 0; i < oImg.length; i++) {
- var oString = '<dd>' +
- '<div class="imgItem">' +
- '<img src="' + "http://www.ekexiu.com/data/ware" + oImg[i] + '"/>' +
- '</div>' +
- '<div class="file-panel">' +
- '<span class="cancel" flag=1></span>' +
- '</div>' +
- '</dd>'
- arr[i] = oString;
- temp[i] = oImg[i];
- }
- $("#fileList dd").eq(2).remove();
- if(oImg.length == 1) {
- $("#fileList").prepend(arr[0]);
- } else if(oImg.length == 2) {
- $("#fileList dd").eq(1).remove();
- $("#fileList").prepend(arr[1]);
- $("#fileList").prepend(arr[0]);
- } else if(oImg.length == 3) {
- $("#fileList dd").eq(1).remove();
- $("#fileList").prepend(arr[2]);
- $("#fileList").prepend(arr[1]);
- $("#fileList").prepend(arr[0]);
- }
- }
- }
- var uploader = WebUploader.create({
- auto: true,
- fileNumLimit: 3,
- swf: '../js/webuploader/Uploader.swf',
- server: baseUrl+'/ajax/ware/upload',
- fileSingleSizeLimit: 2 * 1024 * 1024,
- pick: {
- id: "#filePicker",
- multiple: false
- },
- accept: {
- title: 'Images',
- extensions: 'jpg,jpeg,png',
- mimeTypes: 'image/jpg,image/png,image/jpeg'
- }
- });
-
- uploader.on('fileQueued', function(file) {
- var $len = $("#fileList").find("img").length;
- fileId = file.id;
- if($len == 0 || $len == 1) {
- var oRemove = $("#fileList").find("dd");
- oRemove.eq(oRemove.length - 1).remove();
- }
- var $li = $(
- '<dd>' +
- '<div class="imgItem" id="' + file.id + '">' +
- '<img />' +
- '</div>' +
-
- '</dd>'
- ),
- $btns = $('<div class="file-panel">' +
- '<span class="cancel"></span>' +
- '</div>').appendTo($li),
- $img = $li.find('img');
- var $list = $("#fileList");
- if($len == 1) {
- $list.find("dd").eq(0).after($li)
- } else if($len == 2) {
- $list.find("dd").eq(1).after($li)
- } else {
- $list.prepend($li);
- }
-
-
-
- uploader.makeThumb(file, function(error, src) {
- if(error) {
- $img.replaceWith('<span>不能预览</span>');
- return;
- }
- $img.attr('src', src);
- }, 1, 1);
- });
- uploader.onError = function(code) {
- $.MsgBox.Alert('提示', '请上传jpg、jpeg、png格式的图片,大小不超过2M')
- };
- uploader.on('uploadSuccess', function(file, data) {
- if(data.success) {
- temp.push(data.data[0].uri);
- uploader.removeFile(fileId);
- } else {
- $.MsgBox.Alert('提示', '只支持jpeg/jpg/png格式的图片');
- }
- });
-
- $("#fileList").on("click", ".cancel", function() {
- var flag = $(this).attr("flag");
- var oNum = $(this).parents("dd").index();
- temp.splice(oNum, 1);
- $(this).parent().parent().remove();
- var $len = $("#fileList").find("img").length;
- if($len != 2) {
- $("#fileList").append("<dd></dd>")
- }
- });
-
- $("#resourceName").bind({
- focus: function() {
- $("#resourceNamePrompt").show();
- },
- blur: function() {
- $("#resourceNamePrompt").hide();
- },
- keyup: function() {
- if($(this).val().length > 30) {
- $(this).val($(this).val().substr(0, 30));
- }
- }
- })
- hotKey(".oinput");
-
- $("#KeyWord").on({
- focus: function() {
- $("#keyPrompt").text("最多可添加5个关键词,每个关键词15字以内");
- },
- blur: function() {
- $("#keyPrompt").text("");
- }
- })
- $("#keyWordlist").on("click", ".closeThis", function() {
- $(this).parent().remove();
- var liNum = $("#keyWordlist").find("li").length;
- if(liNum < 5) {
- $("#keyWordlist").parents(".keyResult").siblings("div.col-w-12").show();
- }
- })
-
- $("#modelNumber").bind({
- focus: function() {
- $("#model").show();
- },
- blur: function() {
- $("#model").hide();
- },
- keyup: function() {
- if($(this).val().length > 250) {
- $(this).val($(this).val().substr(0, 250));
- }
- },
- input: function() {
- autoGrow.call(this);
- }
- });
- function autoGrow() {
- document.getElementById("tt").style.width = this.scrollWidth + "px";
- document.getElementById("tt").value = this.value;
- this.style.height = document.getElementById("tt").scrollHeight + "px";
- }
- $("#remarkContent").bind({
- focus: function() {
- $("#remark").show();
- },
- blur: function() {
- $("#remark").hide();
- }
- });
-
- limitObj("#remarkContent", 1000);
-
- $(".goFabu").click(function() {
- var oYes = term();
- if(oYes == 0) {
- return;
- }
- $.MsgBox.Confirm("提示", "确认发布该服务?", ajsPost);
- })
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- function term() {
- var reName = $.trim($("#resourceName").val());
- var len=$("#expertli").find(".selectAdd");
- if(reName == "") {
- $.MsgBox.Alert('提示', '请输入服务名称。');
- return 0;
- }
-
-
-
-
- }
- function keyW() {
- var industrys = $("#keyWordlist li");
- var industryAll = "";
- if(industrys.size() > 0) {
- for(var i = 0; i < industrys.size(); i++) {
- industryAll += industrys[i].innerText.trim();
- industryAll += ',';
- };
- industryAll = industryAll.substring(0, industryAll.length - 1);
- }
- return industryAll;
- }
-
- function ajsPost(pa1, pa2) {
- var oUrl;
- if(sevriceId) {
- oUrl = baseUrl+"/ajax/ware/publish/conUpdate";
- }
-
-
-
- if(pa1) {
- oUrl = pa1
- }
- console.log(oProfessor)
-
- var $data = {
- name: $("#resourceName").val(),
- cooperation: $("#remarkContent").val(),
- keywords: keyW(),
- cnt: $("#modelNumber").val(),
- descp: ue.getContent(),
- images: temp.join(",")
-
-
- };
- if(sevriceId) {
- $data.id = sevriceId;
- }
- ajaxRequist(oUrl, $data, "POST", function(data) {
- if(data.success) {
- if(pa2 == 1) {
- if(!sevriceId)
- sevriceId = data.data;
- $("#deleteResource").removeClass("disableLi").addClass("deleteResource");
- window.open("../sevricePreview.html?sevriceId=" + sevriceId);
- getRecourceMe();
-
- } else if(pa2 == 2) {
- $("#deleteResource").removeClass("disableLi").addClass("deleteResource");
- if(!sevriceId)
- sevriceId = data.data;
- $.MsgBox.Alert('提示', '服务已保存草稿。');
- $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
- getRecourceMe();
- } else {
- $.MsgBox.Alert('提示', '服务发布成功!');
- $("#mb_msgicon").css("background", 'url("images/sign_icon_chenggong_nor.png") 0% 0% / contain');
-
- }
- } else {
- if(data.code == 90) {
- $.MsgBox.Alert('提示', '由于操作时间过久,上传图片已失效,请重新上传。');
- }
- }
- })
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- })
|