portal html css js resource

common.js 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. $(document).ready(function() {
  2. $(".unlogin").removeClass("displayNone");
  3. var footerHeight = $("footer").outerHeight(true);
  4. $('#container').css("padding-bottom", footerHeight + "px");
  5. //窗口大小变更事件
  6. $(window).resize(function() {
  7. footerHeight = $("footer").outerHeight(true);
  8. $('#container').css("padding-bottom", footerHeight + "px");
  9. //console.log(footerHeight)
  10. });
  11. $(document).scroll(function() {
  12. var top = $(document).scrollTop();
  13. if(top == 0) {
  14. $(".navheader").removeClass("navhdown");
  15. } else {
  16. $(".navheader").addClass("navhdown");
  17. }
  18. })
  19. //退出登录转态
  20. $("#exitLogin").on("click", function() {
  21. exit();
  22. })
  23. //判断登录转态
  24. var orgId = $.cookie("orgId");
  25. if(orgId && orgId != "null" && orgId != null) {
  26. $(".unlogin").addClass("displayNone");
  27. $(".onlogin").removeClass("displayNone");
  28. $.ajax("/ajax/image/hasOrgLogo", {
  29. data: {
  30. "id": orgId
  31. },
  32. type: "GET",
  33. dataType: 'json',
  34. async: false,
  35. success: function($data) {
  36. if($data.success) {
  37. if($data.data) {
  38. $("#imglogo").attr("src", "/images/org/" + orgId + ".jpg");
  39. }
  40. }
  41. },
  42. error: function() {
  43. $.MsgBox.Alert('提示', '服务器请求失败')
  44. },
  45. });
  46. } else {
  47. $(".unlogin").removeClass("displayNone");
  48. $(".onlogin").addClass("displayNone");
  49. }
  50. });
  51. //Model模态框打开关闭
  52. function modelOpen() {
  53. $(".blackcover").fadeIn();
  54. $(".modelContain").slideDown();
  55. $("body").addClass("modelOpen");
  56. }
  57. function modelClose() {
  58. $(".modelContain").slideUp();
  59. $(".blackcover").fadeOut();
  60. $("body").removeClass("modelOpen");
  61. }
  62. function exit() {
  63. $.cookie('orgId', null, {
  64. path: "/"
  65. });
  66. $.cookie('orgAuth', null, {
  67. path: "/"
  68. });
  69. $.cookie('orgEmail', null, {
  70. path: "/"
  71. });
  72. $.cookie('orgName', null, {
  73. path: "/"
  74. });
  75. $.cookie('orgType', null, {
  76. path: "/"
  77. });
  78. location.href = "cmp-settled-log.html"
  79. }
  80. //截取url传值
  81. function GetQueryString(name) {
  82. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  83. var r = window.location.search.substr(1).match(reg); //��ȡurl��"?"�����ַ�����ƥ��
  84. var context = "";
  85. if(r != null)
  86. context = r[2];
  87. reg = null;
  88. r = null;
  89. return context == null || context == "" || context == "undefined" ? "" : decodeURI(context);
  90. }
  91. //转换格式
  92. function changeTime(dealtime) {
  93. var s = dealtime;
  94. //console.log(s);
  95. if(dealtime.length == 8) {
  96. var y = s.substr(0, 4);
  97. var m = s.substr(4, 2);
  98. var d = s.substr(6, 2);
  99. var formatTime = y + "-" + m + "-" + d;
  100. return formatTime;
  101. } else {
  102. var y = s.substr(0, 4);
  103. var m = s.substr(4, 2);
  104. var d = s.substr(6, 2);
  105. var h = s.substr(8, 2);
  106. var minute = s.substr(10, 2);
  107. var formatTime = y + "-" + m + "-" + d + " " + h + ":" + minute;
  108. return formatTime;
  109. }
  110. }
  111. //过滤特殊字符
  112. function replaceStr(s) {
  113. var pattern = new RegExp("-");
  114. var rs = "";
  115. for(var i = 0; i < s.length; i++) {
  116. rs = rs + s.substr(i, 1).replace(pattern, '');
  117. }
  118. return rs;
  119. }
  120. //根据用户输入的Email跳转到相应的电子邮箱首页
  121. var hash = {
  122. 'qq.com': 'http://mail.qq.com',
  123. 'gmail.com': 'http://mail.google.com',
  124. 'sina.com': 'http://mail.sina.com.cn',
  125. '163.com': 'http://mail.163.com',
  126. '126.com': 'http://mail.126.com',
  127. 'yeah.net': 'http://www.yeah.net/',
  128. 'sohu.com': 'http://mail.sohu.com/',
  129. 'tom.com': 'http://mail.tom.com/',
  130. 'sogou.com': 'http://mail.sogou.com/',
  131. '139.com': 'http://mail.10086.cn/',
  132. 'hotmail.com': 'http://www.hotmail.com',
  133. 'live.com': 'http://login.live.com/',
  134. 'live.cn': 'http://login.live.cn/',
  135. 'live.com.cn': 'http://login.live.com.cn',
  136. '189.com': 'http://webmail16.189.cn/webmail/',
  137. 'yahoo.com.cn': 'http://mail.cn.yahoo.com/',
  138. 'yahoo.cn': 'http://mail.cn.yahoo.com/',
  139. 'eyou.com': 'http://www.eyou.com/',
  140. '21cn.com': 'http://mail.21cn.com/',
  141. '188.com': 'http://www.188.com/',
  142. 'ustb.edu.cn': 'http://mail.ustb.edu.cn/',
  143. 'foxmail.coom': 'http://www.foxmail.com'
  144. };
  145. /*标志*/
  146. function autho() {
  147. if(arguments[0] == 1) {
  148. return {
  149. "sty": "authicon-pro",
  150. "title": "科袖认证专家"
  151. }
  152. } else {
  153. if(arguments[1] == 1) {
  154. return {
  155. "sty": "authicon-staff-ok",
  156. "title": "企业认证员工"
  157. }
  158. } else {
  159. if(arguments[2] == 3) {
  160. return {
  161. "sty": "authicon-real",
  162. "title": "实名认证用户"
  163. }
  164. } else {
  165. return {
  166. "sty": "e",
  167. "title": " "
  168. }
  169. }
  170. }
  171. }
  172. }
  173. /*选择省份*/
  174. $(document).on("click", "#Province li a", function() {
  175. var aVal = $(this).text();
  176. $(this).parent().parent().parent().find('.mr_show').text(aVal);
  177. $(this).parent().parent().parent().find('input[name=cho_Province]').val(aVal);
  178. if($("#oprovince").text() == "请选择企业总部所在省或直辖市") {
  179. $("#oprovince").removeClass("mr_select");
  180. $("#ocity").removeClass("mr_select");
  181. } else {
  182. $("#oprovince").addClass("mr_select");
  183. $("#ocity").removeClass("mr_select");
  184. }
  185. });
  186. /*选择城市填充js */
  187. $(document).on("click", "#City li a", function() {
  188. var aVal = $(this).text();
  189. $(this).parent().parent().parent().find('.mr_show').text(aVal);
  190. $(this).parent().parent().parent().find('input[name=cho_City]').val(aVal);
  191. if($("#ocity").text() == "请选择企业总部所在城市") {
  192. $("#ocity").removeClass("mr_select");
  193. } else {
  194. $("#ocity").addClass("mr_select");
  195. }
  196. });
  197. function hotKey(sel) {
  198. $(sel).bind({
  199. paste: function(e) {
  200. var pastedText;
  201. if (window.clipboardData  &&  window.clipboardData.getData)  {  // IE
  202.             
  203. pastedText  = $(this).val() +  window.clipboardData.getData('Text');          
  204. else  {            
  205. pastedText  = $(this).val() +  e.originalEvent.clipboardData.getData('Text'); //e.clipboardData.getData('text/plain');
  206.           
  207. }
  208. $(this).val(pastedText);
  209. var $this = $(this);
  210. setTimeout(function() {
  211. if($this.val().trim()) {
  212. $this.siblings("button").show();
  213. } else {
  214. $this.siblings("button").hide();
  215. }
  216. }, 1);
  217. e.preventDefault();
  218. },
  219. cut: function(e) {
  220. var $this = $(this);
  221. setTimeout(function() {
  222. if($this.val().trim()) {
  223. $this.siblings("button").show();
  224. } else {
  225. $this.siblings("button").hide();
  226. }
  227. }, 1);
  228. },
  229. blur: function() {
  230. var $this = $(this);
  231. setTimeout(function() {
  232. $this.siblings(".keydrop").hide();
  233. }, 500)
  234. },
  235. focus: function() {
  236. $(this).siblings(".keydrop").show();
  237. },
  238. keyup: function(e) {
  239. if($(this).val().trim()) {
  240. $(this).siblings("button").show();
  241. var lNum = $.trim($(this).val()).length;
  242. if(0 < lNum) {
  243. var $this = $(this)
  244. $("#addKeyword").show();
  245. $.ajax({
  246. "url": "/ajax/dataDict/qaHotKey",
  247. "type": "GET",
  248. "success": function(data) {
  249. console.log(data);
  250. if(data.success) {
  251. if(data.data.length == 0) {
  252. $this.siblings(".keydrop").addClass("displayNone");
  253. $this.siblings(".keydrop").find("ul").html("");
  254. } else {
  255. $this.siblings(".keydrop").removeClass("displayNone");
  256. var oSr = "";
  257. for(var i = 0; i < data.data.length; i++) {
  258. oSr += '<li>' + data.data[i].caption + '<div class="closeThis"></div></li>';
  259. }
  260. $this.siblings(".keydrop").find("ul").html(oSr);
  261. }
  262. } else {
  263. $this.siblings(".keydrop").addClass("displayNone");
  264. $this.siblings(".keydrop").find("ul").html("");
  265. }
  266. },
  267. "data": {
  268. "key": $(this).val()
  269. },
  270. dataType: "json",
  271. 'error': function() {
  272. $.MsgBox.Alert('提示', '服务器连接超时!');
  273. }
  274. });
  275. }
  276. } else {
  277. $(this).siblings("button").hide();
  278. $(this).siblings(".keydrop").addClass("displayNone");
  279. $(this).siblings(".keydrop").find("ul").html("");
  280. }
  281. }
  282. })
  283. $(".keydrop").on("click", "li", function() {
  284. var oValue = $(this).text();
  285. var oJudge = $(this).parents(".col-w-12").siblings().find("ul.ulspace li");
  286. var addNum=$(this).parents(".keydrop").siblings("input").attr("data-num");
  287. for(var i = 0; i < oJudge.length; i++) {
  288. if(oValue == oJudge[i].innerText) {
  289. $.MsgBox.Alert('提示', '添加内容不能重复');
  290. return;
  291. }
  292. }
  293. $(this).parents(".col-w-12").siblings().find("ul.ulspace").append('<li>' + oValue + '<div class="closeThis"></div></li>');
  294. $(this).parents(".keydrop").siblings("input").val("");
  295. $(this).parents(".keydrop").siblings("button").hide();
  296. if(oJudge.length == addNum-1) {
  297. $(this).parents(".keydrop").siblings("input").val("");
  298. $(this).parents(".col-w-12").hide();
  299. }
  300. $(this).parent("ul").html("")
  301. })
  302. /*添加*/
  303. $("button:contains('添加')").click(function() {
  304. var oValue = $(this).siblings("input").val().trim();
  305. var oJudge = $(this).parent().siblings().find("ul.ulspace li");
  306. var addContent=$(this).siblings("input").attr("data-pro");
  307. var addNum=$(this).siblings("input").attr("data-num");
  308. var addfontSizeNum=$(this).siblings("input").attr("data-fontSizeN");
  309. if(!oValue) {
  310. $.MsgBox.Alert('提示', '请先填写内容');
  311. return;
  312. }
  313. if(oValue.length > addfontSizeNum) {
  314. $.MsgBox.Alert('提示', addContent);
  315. return;
  316. }
  317. for(var i = 0; i < oJudge.length; i++) {
  318. if(oValue == oJudge[i].innerText) {
  319. $.MsgBox.Alert('提示', '添加内容不能重复');
  320. return;
  321. }
  322. }
  323. $(this).parent().siblings().find("ul.ulspace").append('<li>' + oValue + '<div class="closeThis"></div></li>');
  324. $(this).hide();
  325. $(this).siblings("input").val("");
  326. if(oJudge.length == addNum-1) {
  327. $(this).val("").parents(".col-w-12").hide();
  328. }
  329. $(this).siblings(".keydrop").find("ul").html("");
  330. })
  331. }
  332. /*时间转换*/
  333. function TimeTr(dealtime) {
  334. var myDate = new Date();
  335. var s = dealtime;
  336. var y = s.substr(0, 4);
  337. var m = s.substr(4, 2);
  338. var d = s.substr(6, 2);
  339. var h = s.substr(8, 2);
  340. var minute = s.substr(10, 2);
  341. var formatTime = m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 " + h + ":" + minute;
  342. if(y != myDate.getFullYear()) {
  343. formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 " + h + ":" + minute;
  344. }
  345. return formatTime;
  346. }
  347. /*时间格式转换*/
  348. //function timeTran(otm) {
  349. // var month, day, hour, minu;
  350. // var monFirst = otm.substring(4, 5);
  351. // var dayFirst = otm.substring(6, 7);
  352. // if(monFirst == "0") {
  353. // month = otm.substring(5, 6)
  354. // } else {
  355. // month = otm.substring(4, 6)
  356. // }
  357. // if(dayFirst == "0") {
  358. // day = otm.substring(7, 8);
  359. // } else {
  360. // day = otm.substring(6, 8);
  361. // }
  362. // hour = otm.substring(8, 10);
  363. // minu = otm.substring(10, 12);
  364. // return month + "月" + day + "日 " + hour + ":" + minu;
  365. //}