common.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. function IEVersion() {
  2. var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
  3. var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE<11浏览器
  4. if(isIE) {
  5. if (document.all && document.addEventListener && window.atob) {
  6. console.log('IE10');
  7. var inset_IECont = document.createElement("div");
  8. inset_IECont.innerHTML = '<div class="IE-Tips"><div class="Tip-container"><div class="IE-Tips-text">您当前使用的浏览器版本过低,为了获得最佳的浏览体验,建议您下载<a href="https://kingdeecms-1252177366.cos.ap-guangzhou.myqcloud.com/browser/chrome55.exe" target="_blank">谷歌浏览器</a>或将IE浏览器升级到11及以上版本。有任何问题,欢迎电话咨询<span>4008-830-830</span></div><div class="IE-Tips-btn"><p class="IE-Tips-btn-close">关闭</p></div></div></div>';
  9. document.body.insertBefore(inset_IECont, document.body.firstElementChild);
  10. }
  11. }
  12. }
  13. IEVersion();
  14. $('.IE-Tips-btn-close').click(function (){
  15. $('.IE-Tips').hide()
  16. })
  17. // 百度监控代码
  18. var _hmt = _hmt || [];
  19. (function() {
  20. var hm = document.createElement("script");
  21. hm.src = "https://hm.baidu.com/hm.js?aff7fbe8fcb98b060541077cc76465f2";
  22. var s = document.getElementsByTagName("script")[0];
  23. s.parentNode.insertBefore(hm, s);
  24. })();
  25. // 判断设备是否是移动端
  26. /* var agents = [
  27. "android",
  28. "iphone",
  29. "ipad",
  30. "ipod",
  31. "symbianos",
  32. "windows phone"
  33. ];
  34. var ua = navigator.userAgent.toLowerCase();
  35. for (var a=0;a<agents.length;a++){
  36. console.log(ua)
  37. if(ua.indexOf(agents[a])>=0){
  38. if(window.location.host != 'm.kingdee.com'){
  39. window.location.href = "https://m.kingdee.com"+window.location.pathname;
  40. }
  41. }
  42. } */
  43. var CONFIG = {
  44. api: 'https://www.kingdee.com',
  45. ftp: 'https://m.kingdee.com:8010/',
  46. };
  47. if (document.documentElement.clientWidth < 750) {
  48. remInit()
  49. if(document.getElementsByClassName("wrap").length>0){
  50. document.getElementsByClassName("wrap")[0].style.opacity = "0";
  51. }
  52. } else {
  53. if(document.getElementsByClassName("wrap").length>0){
  54. document.getElementsByClassName("wrap")[0].style.opacity = "1";
  55. }
  56. }
  57. function remInit() {
  58. (function (doc, win) {
  59. var docEl = doc.documentElement,
  60. resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
  61. recalc = function () {
  62. var clientWidth = docEl.clientWidth;
  63. if (!clientWidth) return;
  64. if (clientWidth >= 750) {
  65. docEl.style.fontSize = '100px';
  66. } else {
  67. docEl.style.fontSize = 100 * (clientWidth / 750) + 'px';
  68. }
  69. setTimeout(function () {
  70. document.getElementsByClassName("wrap")[0].style.opacity = "1";
  71. }, 300)
  72. };
  73. if (!doc.addEventListener) return;
  74. win.addEventListener(resizeEvt, recalc, false);
  75. doc.addEventListener('DOMContentLoaded', recalc, false);
  76. })(document, window);
  77. (function () {
  78. if (typeof (WeixinJSBridge) == "undefined") {
  79. document.addEventListener("WeixinJSBridgeReady", function (e) {
  80. setTimeout(function () {
  81. WeixinJSBridge.invoke('setFontSizeCallback', {
  82. "fontSize": 0
  83. }, function (res) {
  84. // alert(JSON.stringify(res));
  85. });
  86. }, 0);
  87. });
  88. } else {
  89. setTimeout(function () {
  90. WeixinJSBridge.invoke('setFontSizeCallback', {
  91. "fontSize": 0
  92. }, function (res) {
  93. // alert(JSON.stringify(res));
  94. });
  95. }, 0);
  96. }
  97. })();
  98. }
  99. /*!
  100. * jQuery Cookie Plugin v1.4.1
  101. * https://github.com/carhartl/jquery-cookie
  102. *
  103. * Copyright 2013 Klaus Hartl
  104. * Released under the MIT license
  105. */
  106. (function (factory) {
  107. if (typeof define === 'function' && define.amd) {
  108. // AMD
  109. define(['jquery'], factory);
  110. } else if (typeof exports === 'object') {
  111. // CommonJS
  112. factory(require('jquery'));
  113. } else {
  114. // Browser globals
  115. factory(jQuery);
  116. }
  117. }(function ($) {
  118. var pluses = /\+/g;
  119. function encode(s) {
  120. return config.raw ? s : encodeURIComponent(s);
  121. }
  122. function decode(s) {
  123. return config.raw ? s : decodeURIComponent(s);
  124. }
  125. function stringifyCookieValue(value) {
  126. return encode(config.json ? JSON.stringify(value) : String(value));
  127. }
  128. function parseCookieValue(s) {
  129. if (s.indexOf('"') === 0) {
  130. // This is a quoted cookie as according to RFC2068, unescape...
  131. s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
  132. }
  133. try {
  134. // Replace server-side written pluses with spaces.
  135. // If we can't decode the cookie, ignore it, it's unusable.
  136. // If we can't parse the cookie, ignore it, it's unusable.
  137. s = decodeURIComponent(s.replace(pluses, ' '));
  138. return config.json ? JSON.parse(s) : s;
  139. } catch (e) { }
  140. }
  141. function read(s, converter) {
  142. var value = config.raw ? s : parseCookieValue(s);
  143. return $.isFunction(converter) ? converter(value) : value;
  144. }
  145. var config = $.cookie = function (key, value, options) {
  146. // Write
  147. if (value !== undefined && !$.isFunction(value)) {
  148. options = $.extend({}, config.defaults, options);
  149. if (typeof options.expires === 'number') {
  150. var days = options.expires, t = options.expires = new Date();
  151. t.setTime(+t + days * 864e+5);
  152. }
  153. return (document.cookie = [
  154. encode(key), '=', stringifyCookieValue(value),
  155. options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
  156. options.path ? '; path=' + options.path : '',
  157. options.domain ? '; domain=' + options.domain : '',
  158. options.secure ? '; secure' : ''
  159. ].join(''));
  160. }
  161. // Read
  162. var result = key ? undefined : {};
  163. // To prevent the for loop in the first place assign an empty array
  164. // in case there are no cookies at all. Also prevents odd result when
  165. // calling $.cookie().
  166. var cookies = document.cookie ? document.cookie.split('; ') : [];
  167. for (var i = 0, l = cookies.length; i < l; i++) {
  168. var parts = cookies[i].split('=');
  169. var name = decode(parts.shift());
  170. var cookie = parts.join('=');
  171. if (key && key === name) {
  172. // If second argument (value) is a function it's a converter...
  173. result = read(cookie, value);
  174. break;
  175. }
  176. // Prevent storing a cookie that we couldn't decode.
  177. if (!key && (cookie = read(cookie)) !== undefined) {
  178. result[name] = cookie;
  179. }
  180. }
  181. return result;
  182. };
  183. config.defaults = {};
  184. $.removeCookie = function (key, options) {
  185. if ($.cookie(key) === undefined) {
  186. return false;
  187. }
  188. // Must not alter options, thus extending a fresh object...
  189. $.cookie(key, '', $.extend({}, options, { expires: -1 }));
  190. return !$.cookie(key);
  191. };
  192. }));
  193. function _GetQueryString(name) {
  194. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  195. var r = window.location.search.substr(1).match(reg);
  196. if (r != null) return decodeURI(r[2]); return null;
  197. };
  198. jQuery(document).ready(function ($) {
  199. var utm_source = encodeURI(_GetQueryString("utm_source")),
  200. utm_medium = encodeURI(_GetQueryString("utm_medium")),
  201. utm_content = encodeURI(_GetQueryString("utm_content")),
  202. utm_term = encodeURI(_GetQueryString("utm_term")),
  203. utm_campaign = encodeURI(_GetQueryString("utm_campaign")),
  204. channelCode = encodeURI(_GetQueryString("channelCode")),
  205. activeCode = encodeURI(_GetQueryString("activeCode"));
  206. if(utm_source !== null && utm_source !== 'null' && utm_source !== undefined && utm_source !== 'undefined') {
  207. // console.log('从新赋值cookie utm_source')
  208. $.cookie('utm_source', utm_source, {
  209. // domain: 'jdy.com',
  210. path: '/'
  211. });
  212. }
  213. if(utm_medium !== null && utm_medium !== 'null' && utm_medium !== undefined && utm_medium !== 'undefined') {
  214. // console.log('从新赋值cookie utm_medium')
  215. $.cookie('utm_medium', utm_medium, {
  216. // domain: 'jdy.com',
  217. path: '/'
  218. });
  219. }
  220. if(utm_content !== null && utm_content !== 'null' && utm_content !== undefined && utm_content !== 'undefined') {
  221. // console.log('从新赋值cookie utm_content')
  222. $.cookie('utm_content', utm_content, {
  223. // domain: 'jdy.com',
  224. path: '/'
  225. });
  226. }
  227. if(utm_term !== null && utm_term !== 'null' && utm_term !== undefined && utm_term !== 'undefined') {
  228. // console.log('从新赋值cookie utm_term')
  229. $.cookie('utm_term', utm_term, {
  230. // domain: 'jdy.com',
  231. path: '/'
  232. });
  233. }
  234. if(utm_campaign !== null && utm_campaign !== 'null' && utm_campaign !== undefined && utm_campaign !== 'undefined') {
  235. // console.log('从新赋值cookie utm_campaign')
  236. $.cookie('utm_campaign', utm_campaign, {
  237. // domain: 'jdy.com',
  238. path: '/'
  239. });
  240. }
  241. if(channelCode !== null && channelCode !== 'null' && channelCode !== undefined && channelCode !== 'undefined') {
  242. // console.log('从新赋值cookie channelCode')
  243. $.cookie('channelCode', channelCode, {
  244. // domain: 'jdy.com',
  245. path: '/'
  246. });
  247. }
  248. if(activeCode !== null && activeCode !== 'null' && activeCode !== undefined && activeCode !== 'undefined') {
  249. // console.log('从新赋值cookie activeCode')
  250. $.cookie('activeCode', activeCode, {
  251. // domain: 'jdy.com',
  252. path: '/'
  253. });
  254. }
  255. // utm_source == null ? "" : $.cookie('utm_source', utm_source);
  256. // $.cookie('utm_source', utm_source, {
  257. // domain: 'jdy.com',
  258. // path: '/'
  259. // });
  260. // utm_medium == null ? "" : $.cookie('utm_medium', utm_medium);
  261. // $.cookie('utm_medium', utm_medium, {
  262. // domain: 'jdy.com',
  263. // path: '/'
  264. // });
  265. // utm_content == null ? "" : $.cookie('utm_content', utm_content);
  266. // $.cookie('utm_content', utm_content, {
  267. // domain: 'jdy.com',
  268. // path: '/'
  269. // });
  270. // utm_term == null ? "" : $.cookie('utm_term', utm_term);
  271. // $.cookie('utm_term', utm_term, {
  272. // domain: 'jdy.com',
  273. // path: '/'
  274. // });
  275. // utm_campaign == null ? "" : $.cookie('utm_campaign', utm_campaign);
  276. // $.cookie('utm_campaign', utm_campaign, {
  277. // domain: 'jdy.com',
  278. // path: '/'
  279. // });
  280. // channelCode == null ? "" : $.cookie('channelCode', channelCode);
  281. // $.cookie('channelCode', channelCode, {
  282. // domain: 'jdy.com',
  283. // expires: 10,
  284. // path: '/'
  285. // });
  286. // activeCode == null ? "" : $.cookie('activeCode', activeCode);
  287. // $.cookie('activeCode', activeCode, {
  288. // domain: 'jdy.com',
  289. // expires: 10,
  290. // path: '/'
  291. // });
  292. })