common.js 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374
  1. /*
  2. * Date Format 1.2.3
  3. * (c) 2007-2009 Steven Levithan <stevenlevithan.com>
  4. * MIT license
  5. *
  6. * Includes enhancements by Scott Trenda <scott.trenda.net>
  7. * and Kris Kowal <cixar.com/~kris.kowal/>
  8. *
  9. * Accepts a date, a mask, or a date and a mask.
  10. * Returns a formatted version of the given date.
  11. * The date defaults to the current date/time.
  12. * The mask defaults to dateFormat.masks.default.
  13. */
  14. var dateFormat = function () {
  15. var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
  16. timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
  17. timezoneClip = /[^-+\dA-Z]/g,
  18. pad = function (val, len) {
  19. val = String(val);
  20. len = len || 2;
  21. while (val.length < len) val = "0" + val;
  22. return val;
  23. };
  24. // Regexes and supporting functions are cached through closure
  25. return function (date, mask, utc) {
  26. var dF = dateFormat;
  27. // You can't provide utc if you skip other args (use the "UTC:" mask prefix)
  28. if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
  29. mask = date;
  30. date = undefined;
  31. }
  32. // Passing date through Date applies Date.parse, if necessary
  33. date = date ? new Date(date) : new Date;
  34. if (isNaN(date)) throw SyntaxError("invalid date");
  35. mask = String(dF.masks[mask] || mask || dF.masks["default"]);
  36. // Allow setting the utc argument via the mask
  37. if (mask.slice(0, 4) == "UTC:") {
  38. mask = mask.slice(4);
  39. utc = true;
  40. }
  41. var _ = utc ? "getUTC" : "get",
  42. d = date[_ + "Date"](),
  43. D = date[_ + "Day"](),
  44. m = date[_ + "Month"](),
  45. y = date[_ + "FullYear"](),
  46. H = date[_ + "Hours"](),
  47. M = date[_ + "Minutes"](),
  48. s = date[_ + "Seconds"](),
  49. L = date[_ + "Milliseconds"](),
  50. o = utc ? 0 : date.getTimezoneOffset(),
  51. flags = {
  52. d: d,
  53. dd: pad(d),
  54. ddd: dF.i18n.dayNames[D],
  55. dddd: dF.i18n.dayNames[D + 7],
  56. m: m + 1,
  57. mm: pad(m + 1),
  58. mmm: dF.i18n.monthNames[m],
  59. mmmm: dF.i18n.monthNames[m + 12],
  60. yy: String(y).slice(2),
  61. yyyy: y,
  62. h: H % 12 || 12,
  63. hh: pad(H % 12 || 12),
  64. H: H,
  65. HH: pad(H),
  66. M: M,
  67. MM: pad(M),
  68. s: s,
  69. ss: pad(s),
  70. l: pad(L, 3),
  71. L: pad(L > 99 ? Math.round(L / 10) : L),
  72. t: H < 12 ? "a" : "p",
  73. tt: H < 12 ? "am" : "pm",
  74. T: H < 12 ? "A" : "P",
  75. TT: H < 12 ? "AM" : "PM",
  76. Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
  77. o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
  78. S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
  79. };
  80. return mask.replace(token, function ($0) {
  81. return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
  82. });
  83. };
  84. }();
  85. // Some common format strings
  86. dateFormat.masks = {
  87. "default": "ddd mmm dd yyyy HH:MM:ss",
  88. shortDate: "m/d/yy",
  89. mediumDate: "mmm d, yyyy",
  90. longDate: "mmmm d, yyyy",
  91. fullDate: "dddd, mmmm d, yyyy",
  92. shortTime: "h:MM TT",
  93. mediumTime: "h:MM:ss TT",
  94. longTime: "h:MM:ss TT Z",
  95. isoDate: "yyyy-mm-dd",
  96. isoTime: "HH:MM:ss",
  97. isoDateTime: "yyyy-mm-dd'T'HH:MM:ss",
  98. isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
  99. };
  100. // Internationalization strings
  101. dateFormat.i18n = {
  102. dayNames: [
  103. "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
  104. "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
  105. ],
  106. monthNames: [
  107. "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
  108. "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
  109. ]
  110. };
  111. // For convenience...
  112. Date.prototype.FormatEnhance = function (mask, utc) {
  113. return dateFormat(this, mask, utc);
  114. };
  115. Date.prototype.Format = function (fmt) { //author: meizz
  116. var o = {
  117. "M+": this.getMonth() + 1, //月份
  118. "d+": this.getDate(), //日
  119. "h+": this.getHours(), //小时
  120. "m+": this.getMinutes(), //分
  121. "s+": this.getSeconds(), //秒
  122. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  123. "S": this.getMilliseconds() //毫秒
  124. };
  125. if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  126. for (var k in o)
  127. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  128. return fmt;
  129. }
  130. //替换input中的非数字
  131. function rePlaceUnDigital(obj){
  132. if(/[^\d]/g.test(obj.value)){
  133. var pos = getCursorPos(obj);
  134. var array = obj.value.split("");
  135. for(var i in array){
  136. if(/[^\d]/g.test(array[i])){
  137. pos--;
  138. }
  139. }
  140. obj.value = obj.value.replace(/[^\d]/g,'');
  141. setCursorPos(obj,pos);
  142. }
  143. }
  144. //替换input中的空格
  145. function rePlaceSpace(obj){
  146. if(obj.value.indexOf(' ')>-1){
  147. var pos = getCursorPos(obj);
  148. var array = obj.value.split("");
  149. for(var i in array){
  150. if(array[i] == " "){
  151. pos--;
  152. }
  153. }
  154. obj.value = obj.value.replace(new RegExp(' ','gm'),'');
  155. setCursorPos(obj,pos);
  156. }
  157. }
  158. /**
  159. * 设置光标在短连接输入框中的位置
  160. * @param inpObj 输入框
  161. * @param pos
  162. */
  163. function setCursorPos(inpObj, pos){
  164. if(navigator.userAgent.indexOf("MSIE") > -1){
  165. var range = document.selection.createRange();
  166. var textRange = inpObj.createTextRange();
  167. textRange.moveStart('character',pos);
  168. textRange.collapse();
  169. textRange.select();
  170. }else{
  171. inpObj.setSelectionRange(pos,pos);
  172. }
  173. }
  174. /**
  175. * 获取光标在短连接输入框中的位置
  176. * @param inpObj 输入框
  177. */
  178. function getCursorPos(inpObj){
  179. if(navigator.userAgent.indexOf("MSIE") > -1) { // IE
  180. var range = document.selection.createRange();
  181. range.text = '';
  182. range.setEndPoint('StartToStart',inpObj.createTextRange());
  183. return range.text.length;
  184. } else {
  185. return inpObj.selectionStart;
  186. }
  187. }
  188. //获取cookie
  189. function getCookie(name){
  190. var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
  191. if(arr=document.cookie.match(reg))
  192. return unescape(arr[2]);
  193. else
  194. return null;
  195. }
  196. /**
  197. * 正则表达式实现endWith效果函数
  198. * @param str 要判断的字符
  199. **/
  200. String.prototype.endWith = function(str){
  201. var reg = new RegExp(str+"$");
  202. return reg.test(this);
  203. }
  204. /**
  205. * 正则表达式实现startWith效果函数
  206. * @param str 要判断的字符
  207. **/
  208. String.prototype.startWith = function(str){
  209. var reg = new RegExp("^"+str);
  210. return reg.test(this);
  211. }
  212. /* ios input bugs*/
  213. function fixIOSInputBugs () {
  214. var windowHeight = window.innerHeight
  215. function checkHeightForIOS (e) {
  216. var windowFocusHeight = window.innerHeight
  217. if (windowHeight == windowFocusHeight) {
  218. return
  219. }
  220. if(e.target.hasClass('searchinput') || e.currentTarget.hasClass('searchinput')) {
  221. return
  222. }
  223. var currentPosition;
  224. var speed = 1; //页面滚动距离
  225. currentPosition = document.documentElement.scrollTop || document.body.scrollTop;
  226. currentPosition -= speed;
  227. window.scrollTo(0, currentPosition); //页面向上滚动
  228. currentPosition += speed; //speed变量
  229. window.scrollTo(0, currentPosition); //页面向下滚动
  230. }
  231. $("body").on('click', '#recList', function (e) {
  232. checkHeightForIOS(e)
  233. })
  234. $("body").on('click', '.inputDiv', function (e) {
  235. checkHeightForIOS(e)
  236. })
  237. $("body").on('blur', 'input' , function (e) {
  238. // checkHeightForIOS(e)
  239. })
  240. }
  241. //动态加载css
  242. function addCssByLink(url){
  243. var links=document.getElementsByTagName('link')
  244. for(var i=0;i<links.length;i++){
  245. if(links[i].href&&links[i].href.indexOf(url)>-1){
  246. return;
  247. }
  248. }
  249. var doc=document;
  250. var link=doc.createElement("link");
  251. link.setAttribute("rel", "stylesheet");
  252. link.setAttribute("type", "text/css");
  253. link.setAttribute("href", url);
  254. var heads = doc.getElementsByTagName("head");
  255. if(heads.length)
  256. heads[0].appendChild(link);
  257. else
  258. doc.documentElement.appendChild(link);
  259. }
  260. //动态加载js
  261. function loadJS(url, success){
  262. var scripts=document.getElementsByTagName('script')
  263. for(var i=0;i<scripts.length;i++){
  264. if(scripts[i].src&&scripts[i].src.indexOf(url)>-1){
  265. if(success) success();
  266. return;
  267. }
  268. }
  269. var domScript = document.createElement('script');
  270. domScript.src = url;
  271. success = success || function(){};
  272. domScript.onload = domScript.onreadystatechange = function() {
  273. if (!this.readyState || 'loaded' === this.readyState || 'complete' === this.readyState) {
  274. success();
  275. this.onload = this.onreadystatechange = null;
  276. //this.parentNode.removeChild(this);
  277. }
  278. }
  279. document.getElementsByTagName('head')[0].appendChild(domScript);
  280. }
  281. //判断对象是否为空对象{}
  282. function isNullObj(obj){
  283. for(var i in obj){
  284. if(obj.hasOwnProperty(i)){
  285. return false;
  286. }
  287. }
  288. return true;
  289. }
  290. var JyObjMessage = new Object();
  291. $(function(){
  292. if (mySysIsIos()){
  293. window.JyObj = {
  294. //读取复制内容
  295. readRight:function(){
  296. return window.webkit.messageHandlers.readRight.postMessage(JyObjMessage);
  297. },
  298. //写入复制内容
  299. wirteRight:function(txt){
  300. JyObjMessage["txt"]=txt;
  301. window.webkit.messageHandlers.wirteRight.postMessage(JyObjMessage);
  302. JyObj.clearMessage();
  303. },
  304. //清除复制内容
  305. clearRight:function(){
  306. window.webkit.messageHandlers.clearRight.postMessage(JyObjMessage);
  307. },
  308. //拨打电话
  309. callPhone:function(phone){
  310. JyObjMessage["phone"]=phone;
  311. window.webkit.messageHandlers.callPhone.postMessage(JyObjMessage);
  312. JyObj.clearMessage();
  313. },
  314. //抖音or快手其他应用appName:应用名称;appLink:应用链接
  315. openOtherAppLinks:function(appName,appLink){
  316. JyObjMessage["appName"]=appName;
  317. JyObjMessage["appLink"]=appLink;
  318. window.webkit.messageHandlers.openOtherAppLinks.postMessage(JyObjMessage);
  319. JyObj.clearMessage();
  320. },
  321. //调用接口修改消息通知的打开数
  322. openActivityPage:function(url,rectype,openid){
  323. JyObjMessage["url"]=url;
  324. JyObjMessage["rectype"]=rectype;
  325. JyObjMessage["openid"]=openid;
  326. window.webkit.messageHandlers.openActivityPage.postMessage(JyObjMessage);
  327. JyObj.clearMessage();
  328. },
  329. //清除 JyObjMessage
  330. clearMessage:function(){
  331. JyObjMessage = new Object();
  332. },
  333. //隐藏显示底部菜单栏 0:隐藏;1:显示
  334. hiddenBottom:function(val){
  335. JyObjMessage["hidden"]=val;
  336. window.webkit.messageHandlers.hiddenBottom.postMessage(JyObjMessage);
  337. JyObj.clearMessage();
  338. },
  339. //微信登录
  340. loginByWeixin:function(){
  341. window.webkit.messageHandlers.loginByWeixin.postMessage(JyObjMessage);
  342. JyObj.clearMessage();
  343. },
  344. //分享功能
  345. share:function(type,title,content,link){
  346. JyObjMessage["type"]=type
  347. JyObjMessage["title"]=title
  348. JyObjMessage["content"]=content
  349. JyObjMessage["link"]=link
  350. window.webkit.messageHandlers.share.postMessage(JyObjMessage);
  351. JyObj.clearMessage();
  352. },
  353. //保存用户token
  354. saveUserToken:function(val){
  355. JyObjMessage["token"]=val;
  356. window.webkit.messageHandlers.saveUserToken.postMessage(JyObjMessage);
  357. JyObj.clearMessage();
  358. },
  359. //获取用户token
  360. getUserToken:function(){
  361. return JyObj.IosCall("getUserToken")
  362. },
  363. //移除用户token
  364. removeUserToken:function(){
  365. window.webkit.messageHandlers.removeUserToken.postMessage(JyObjMessage);
  366. JyObj.clearMessage();
  367. },
  368. //查看开关状态 是否接受消息
  369. checkNoticePermission:function(){
  370. return JyObj.IosCall("checkNoticePermission")
  371. },
  372. //打开接受消息开关
  373. openSystemNotification:function(){
  374. window.webkit.messageHandlers.openSystemNotification.postMessage(JyObjMessage);
  375. JyObj.clearMessage();
  376. },
  377. //获取极光推送id
  378. getPushRid:function(){
  379. return JyObj.IosCall("getPushRid")
  380. },
  381. //跳转外部链接
  382. openExternalLink:function(url,title){
  383. JyObjMessage["url"]=url
  384. JyObjMessage["title"]=title
  385. window.webkit.messageHandlers.openExternalLink.postMessage(JyObjMessage);
  386. JyObj.clearMessage();
  387. },
  388. //获取当前版本号
  389. getVersion:function(){
  390. return JyObj.IosCall("getVersion")
  391. },
  392. alert:function(content){
  393. JyObjMessage["content"]=content
  394. window.webkit.messageHandlers.alert.postMessage(JyObjMessage);
  395. JyObj.clearMessage();
  396. },
  397. //是否安装了微信
  398. isInstallWeixin:function(){
  399. return JyObj.IosCall("isInstallWeixin")
  400. },
  401. //登录加密
  402. getCipherText:function(val){
  403. JyObjMessage["phone"]=val
  404. return JyObj.IosCall("getCipherText",JyObjMessage)
  405. },
  406. //刷新首页和订阅页面
  407. checkLab:function(){
  408. window.webkit.messageHandlers.checkLab.postMessage(JyObjMessage);
  409. JyObj.clearMessage();
  410. },
  411. //登录成功后向客户端传参
  412. loginSuccess:function(status){
  413. JyObjMessage["status"]=status
  414. window.webkit.messageHandlers.loginSuccess.postMessage(JyObjMessage);
  415. JyObj.clearMessage();
  416. },
  417. //客户端登录页面点击返回 跳转到搜索首页
  418. backUrl:function(val){
  419. JyObjMessage["status"] = val;
  420. window.webkit.messageHandlers.backUrl.postMessage(JyObjMessage);
  421. JyObj.clearMessage();
  422. },
  423. //清空通知栏消息
  424. clearPushMessage:function(){
  425. window.webkit.messageHandlers.clearPushMessage.postMessage(JyObjMessage);
  426. JyObj.clearMessage();
  427. },
  428. //隐藏小红点
  429. hideRedSpotOnMenu:function(menu){
  430. JyObjMessage["menu"] = menu;
  431. window.webkit.messageHandlers.hideRedSpotOnMenu.postMessage(JyObjMessage);
  432. JyObj.clearMessage();
  433. },
  434. //显示小红点
  435. showRedSpotOnMenu:function(menu){
  436. JyObjMessage["menu"] = menu;
  437. window.webkit.messageHandlers.showRedSpotOnMenu.postMessage(JyObjMessage);
  438. JyObj.clearMessage();
  439. },
  440. //微信支付
  441. wxPay:function(order){
  442. JyObjMessage["order"] = order;
  443. window.webkit.messageHandlers.wxPay.postMessage(JyObjMessage);
  444. JyObj.clearMessage();
  445. },
  446. //支付宝支付
  447. aliPay:function(order){
  448. JyObjMessage["order"] = order;
  449. window.webkit.messageHandlers.aliPay.postMessage(JyObjMessage);
  450. JyObj.clearMessage();
  451. },
  452. //获取原生的推送id
  453. getOtherPushRid:function(){
  454. return JyObj.IosCall("getOtherPushRid")
  455. },
  456. //获取手机型号
  457. getPhoneBrand:function(){
  458. return JyObj.IosCall("getPhoneBrand")
  459. },
  460. //获取定位
  461. getLocation:function(){
  462. return JyObj.IosCall("getLocation")
  463. },
  464. //切换菜单
  465. chooseTab:function(indexTab){
  466. JyObjMessage["indexTab"] = indexTab;
  467. window.webkit.messageHandlers.chooseTab.postMessage(JyObjMessage);
  468. JyObj.clearMessage();
  469. },
  470. //打开照相机
  471. skipCamera:function(){
  472. window.webkit.messageHandlers.skipCamera.postMessage(JyObjMessage);
  473. JyObj.clearMessage();
  474. },
  475. //打开相册
  476. skipAlbum:function(){
  477. window.webkit.messageHandlers.skipAlbum.postMessage(JyObjMessage);
  478. JyObj.clearMessage();
  479. },
  480. //点击返回调用
  481. judgeIsHidden:function(referer){
  482. JyObjMessage["referer"] = referer;
  483. window.webkit.messageHandlers.judgeIsHidden.postMessage(JyObjMessage);
  484. JyObj.clearMessage();
  485. },
  486. //返回值 处理
  487. IosCall: function (functionName,args){
  488. if (args!=""&&args!=undefined){
  489. JyObj.clearMessage();
  490. }
  491. var payload = {"jsName": functionName, "arguments": args};
  492. var res = prompt(JSON.stringify(payload));
  493. if (res!=""){
  494. var resObj=JSON.parse(res)
  495. var type = resObj.type
  496. switch (type){
  497. case "int":
  498. return parseInt(resObj.value)
  499. case "string":
  500. return resObj.value
  501. case "bool":
  502. if(resObj.value=="true"){
  503. return true
  504. }
  505. return false
  506. default:
  507. return ""
  508. }
  509. }
  510. return ""
  511. }
  512. }
  513. fixIOSInputBugs()
  514. }
  515. if(isIphoneX()){
  516. // $(".app-layout-header").css("padding-top"," 40px");//标题
  517. $(".app-back.jyapp-icon.jyapp-icon-zuojiantou").css("padding-top"," 40px");//返回
  518. $(".header-share").css("padding-top"," 40px");//分享
  519. // $(".app-layout-content-a, .app-layout-content-b").css("top","64px");//正文
  520. $(".feedback-nav").css("top","85px");//意见反馈
  521. $(".setpage .noticehead").css("top","85px");//关注项目
  522. $(".app-back.jyapp-icon.jyapp-icon-zuojiantou").addClass("jyapp-icon-zuojiantou-x");//登录
  523. $("#header.reg").css("padding-top","50px");//注册
  524. try{
  525. iphoneXInit();
  526. }catch(e){}
  527. }
  528. //自定义tap
  529. $(document).on("touchstart", function(e) {
  530. var $target = $(e.target);
  531. $target.data("isMoved", 0);
  532. $target.data("startTime", Date.now());
  533. });
  534. $(document).on("touchmove", function(e) {
  535. var $target = $(e.target);
  536. $target.data("isMoved", 1);
  537. });
  538. $(document).on("touchend", function(e) {
  539. var $target = $(e.target);
  540. var startTime = $target.data("startTime");
  541. if(Date.now()-startTime>200){
  542. return;
  543. }
  544. if($target.data("isMoved") == 1){
  545. return;
  546. }
  547. $target.trigger("tap",e);
  548. });
  549. $(".app-layout-header .app-back").unbind("click").on("click",function(){
  550. if(typeof(clickBack)=="function"){
  551. clickBack();
  552. }else{
  553. try{
  554. afterClickBack();
  555. }catch(e){}
  556. //可以自定义返回url,不过是跳转的方式
  557. if(typeof(backUrl) != "undefined" && backUrl != null){
  558. if(typeof(backUrl) == "string"){
  559. window.location.href = backUrl;
  560. }else if(typeof(backUrl) == "number"){
  561. window.history.go(backUrl);
  562. }
  563. }else{
  564. window.history.back();
  565. }
  566. }
  567. });
  568. // $(".app-layout-footer li").on("tap",function(){
  569. // if($(this).hasClass("active")){
  570. // return;
  571. // }
  572. // switch(this.id){
  573. // case "navbar-search":
  574. // if(sessionStorage){
  575. // sessionStorage.mainSearchReload = "1";
  576. // }
  577. // autoLogin("/jyapp/jylab/mainSearch");
  578. // break;
  579. // case "navbar-subscribe":
  580. // autoLogin("/jyapp/wxkeyset/keyset/index");
  581. // break;
  582. // case "navbar-laboratory":
  583. // autoLogin("/jyapp/jylab/index");
  584. // break;
  585. // case "navbar-me":
  586. // autoLogin("/jyapp/free/me");
  587. // break;
  588. // }
  589. // });
  590. // if(!mySysIsIos()){
  591. try{
  592. afterPageInit();
  593. //发送渠道统计
  594. sendChannelSign();
  595. }catch(e){}
  596. // }
  597. setInterval(function(){
  598. if(localStorage.chooseTab!=undefined){
  599. try{
  600. JyObj.hiddenBottom("1");
  601. JyObj.chooseTab(parseInt(localStorage.chooseTab));
  602. localStorage.removeItem("chooseTab");
  603. }catch(e){}
  604. }
  605. if(localStorage.reloadTab=="1"&&window.location.pathname=="/jyapp/swordfish/historypush"){
  606. localStorage.removeItem("reloadTab");
  607. window.location.reload();
  608. }
  609. },1000);
  610. });
  611. var EasyAlert = {
  612. timeout: null,
  613. waitTime: 1000,
  614. show: function(text,css,waitTime){
  615. if(this.timeout != null){
  616. clearTimeout(this.timeout);
  617. this.hide();
  618. this.timeout = null;
  619. }
  620. var thisClass = this;
  621. this.timeout = setTimeout(function(){
  622. thisClass.hide();
  623. thisClass.timeout = null;
  624. },waitTime?waitTime:this.waitTime);
  625. $("body").append('<div class="easyalert" id="easyAlert">'+text+'</div>');
  626. if(typeof(css) != "undefined"){
  627. $("#easyAlert").css(css);
  628. }
  629. $("#easyAlert").css({"left":"50%","margin-top":-($("#easyAlert").outerHeight()/2),"margin-left":-($("#easyAlert").outerWidth()/2)}).show();
  630. },
  631. hide: function(){
  632. $("#easyAlert").remove();
  633. }
  634. }
  635. var EasyPopup = function(id){
  636. this.id = id;
  637. var thisClass = this;
  638. document.getElementById(id).onclick = function(e){
  639. if(e.target.id == id){
  640. thisClass.hide();
  641. }
  642. }
  643. this.show = function(){
  644. $("#"+this.id).fadeIn();
  645. var mainObj = $("#"+id+">div:first");
  646. mainObj.css({"margin-top":-(mainObj.outerHeight()/2)});
  647. },
  648. this.hide = function(){
  649. $("#"+this.id).fadeOut();
  650. }
  651. }
  652. var Verification = {
  653. //手机号验证
  654. isPhone: function(value){
  655. return /^[1][3-9][0-9]{9}$/.test(value);
  656. }
  657. }
  658. //计算时差
  659. function timeDiff(date){
  660. var date1 = date;//开始时间
  661. var date2 = new Date();//结束时间
  662. var date3 = date2.getTime()-date1.getTime();//时间差的毫秒数
  663. //计算出相差天数
  664. var days = Math.floor(date3/(24*3600*1000));
  665. //计算出小时数
  666. var leave1 = date3%(24*3600*1000);//计算天数后剩余的毫秒数
  667. var hours = Math.floor(leave1/(3600*1000));
  668. //计算相差分钟数
  669. var leave2 = leave1%(3600*1000);//计算小时数后剩余的毫秒数
  670. var minutes = Math.floor(leave2/(60*1000));
  671. //计算相差秒数
  672. var td = "30秒前";
  673. if(days > 0){
  674. if (days > 10) {
  675. var date1year = date1.getFullYear();
  676. var date2year = date2.getFullYear();
  677. var date1month = date1.getMonth()+1;
  678. var date1day = date1.getDate();
  679. if(date1month < 10){
  680. date1month ="0"+date1month;
  681. }
  682. if(date1day < 10){
  683. date1day ="0"+date1day;
  684. }
  685. if (date1year<date2year){
  686. td = date1.getFullYear()+"-"+date1month+"-"+date1day;
  687. }else{
  688. td = date1month+"-"+date1day;
  689. }
  690. } else {
  691. td = days+"天前"
  692. }
  693. }else if(hours > 0){
  694. td = hours+"小时前";
  695. }else if(minutes > 0){
  696. td = minutes+"分钟前";
  697. }
  698. return td;
  699. }
  700. function newredirect(zbadd,link,sid,sds,index){
  701. if(link != null && typeof(link) != "undefined"){
  702. link = link.replace(/\n/g,"");
  703. if(!/^http/.test(link)){
  704. link="http://"+link
  705. }
  706. }
  707. var pt = ""
  708. if (index==1){
  709. pt="projectMatch=项目匹配"
  710. }
  711. if(sds){
  712. window.location.href=zbadd+"/jyapp/article/content/"+sid+".html?keywords="+encodeURIComponent(sds)+pt;
  713. }else{
  714. window.location.href=zbadd+"/jyapp/article/content/"+sid+".html?"+pt;
  715. }
  716. }
  717. function pcredirect(link,sid){
  718. window.open("/pcdetail/"+sid+".html");
  719. }
  720. function keyWordHighlight(value,oldChars,newChar){
  721. if(typeof(oldChars) == "undefined" || oldChars == null || typeof(newChar) == "undefined" || newChar == null || newChar == ""){
  722. return value;
  723. }
  724. var array = [];
  725. if(oldChars instanceof Array){
  726. array = oldChars.concat();
  727. }else{
  728. array.push(oldChars);
  729. }
  730. try{
  731. var map = {};
  732. for(var i=0;i<array.length;i++){
  733. var oldChar = array[i];
  734. if(oldChar.replace(/\s+/g,"") == "" || map[oldChar]){
  735. continue;
  736. }
  737. map[oldChar] = true;
  738. oldChar = oldChar.replace(/\$/g,"\\$");
  739. oldChar = oldChar.replace(/\(/g,"\\(");
  740. oldChar = oldChar.replace(/\)/g,"\\)");
  741. oldChar = oldChar.replace(/\*/g,"\\*");
  742. oldChar = oldChar.replace(/\+/g,"\\+");
  743. oldChar = oldChar.replace(/\./g,"\\.");
  744. oldChar = oldChar.replace(/\[/g,"\\[");
  745. oldChar = oldChar.replace(/\]/g,"\\]");
  746. oldChar = oldChar.replace(/\?/g,"\\?");
  747. oldChar = oldChar.replace(/\\/g,"\\");
  748. oldChar = oldChar.replace(/\//g,"\\/");
  749. oldChar = oldChar.replace(/\^/g,"\\^");
  750. oldChar = oldChar.replace(/\{/g,"\\{");
  751. oldChar = oldChar.replace(/\}/g,"\\}");
  752. oldChar = oldChar.replace(/\|/g,"\\|");
  753. value = value.replace(new RegExp("("+oldChar+")",'gmi'),newChar);
  754. }
  755. }catch(e){}
  756. return value;
  757. }
  758. function getWxVersion(){
  759. var wechatInfo = navigator.userAgent.match(/MicroMessenger\/([\d\.]+)/i);
  760. if(!wechatInfo) {
  761. return null;
  762. }
  763. return wechatInfo[1];
  764. }
  765. /**
  766. * 设置光标在短连接输入框中的位置
  767. * @param inpObj 输入框
  768. * @param pos
  769. */
  770. function setCursorPos(inpObj, pos){
  771. if(navigator.userAgent.indexOf("MSIE") > -1){
  772. var range = document.selection.createRange();
  773. var textRange = inpObj.createTextRange();
  774. textRange.moveStart('character',pos);
  775. textRange.collapse();
  776. textRange.select();
  777. }else{
  778. inpObj.setSelectionRange(pos,pos);
  779. }
  780. }
  781. /**
  782. * 获取光标在短连接输入框中的位置
  783. * @param inpObj 输入框
  784. */
  785. function getCursorPos(inpObj){
  786. if(navigator.userAgent.indexOf("MSIE") > -1) { // IE
  787. var range = document.selection.createRange();
  788. range.text = '';
  789. range.setEndPoint('StartToStart',inpObj.createTextRange());
  790. return range.text.length;
  791. } else {
  792. return inpObj.selectionStart;
  793. }
  794. }
  795. //获取url中参数
  796. function getUrlParam(name,type){
  797. var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
  798. var r = window.location.search.substr(1).match(reg);
  799. if(r != null)
  800. if(typeof(type) == "function"){
  801. return type(r[2]);
  802. }else{
  803. return unescape(r[2]);
  804. }
  805. return null;
  806. }
  807. //自动登录
  808. function autoLogin(url,callBack){
  809. var sign = "";
  810. try{
  811. sign = JyObj.getUserToken();
  812. }catch(e){}
  813. if(sign == "" || sign == null || typeof(sign) == "undefined"){
  814. if(callBack != null && typeof(callBack) != "undefined"){
  815. callBack(null);
  816. }else if(url != null && typeof(url) != "undefined"){
  817. window.location.href = "/jyapp/free/login?url="+encodeURIComponent(url);
  818. }
  819. return;
  820. }
  821. if(url != null && typeof(url) != "undefined"){
  822. window.location.href = "/jyapp/free/login?sign="+sign+"&url="+encodeURIComponent(url);
  823. return
  824. }
  825. $.ajax({
  826. url: "/jyapp/free/login?t="+new Date().getTime(),
  827. type: "post",
  828. data: {reqType:"signLogin",sign:sign},
  829. dataType: "json",
  830. success: function(r){
  831. //有回调函数不跳转
  832. if(callBack != null && typeof(callBack) != "undefined"){
  833. callBack(r.userInfo);
  834. return;
  835. }
  836. },
  837. error: function(){
  838. //alert("服务器连接超时!");
  839. }
  840. });
  841. }
  842. function loginSuccess(result){
  843. if(sessionStorage){
  844. sessionStorage.removeItem("alertKicked");
  845. }
  846. JyObj.saveUserToken(result.sign);
  847. //
  848. if(getUrlParam("to") == "back"){
  849. // sessionStorage.reloadHomePage=true;
  850. if(sessionStorage){
  851. afterLoginSuccess("",true);
  852. window.history.back();
  853. }else{
  854. afterLoginSuccess("S",false);//提示app定位搜索菜单
  855. //window.location.href = "/jyapp/jylab/mainSearch";
  856. location.replace("/jyapp/jylab/mainSearch");
  857. }
  858. return
  859. }
  860. //分销跳转
  861. if(getUrlParam("appUrl")!=null&&getUrlParam("appUrl").indexOf("distrib/redirectTo")>-1){
  862. location.replace(getUrlParam("appUrl"));
  863. return
  864. }
  865. //
  866. var callBackUrl = getUrlParam("url",decodeURIComponent);
  867. if(callBackUrl != null){
  868. afterLoginSuccess("",true);
  869. //window.location.href = callBackUrl;
  870. locationReplace(callBackUrl);
  871. return
  872. }
  873. //
  874. if(sessionStorage){
  875. sessionStorage.mainSearchReload = "1";
  876. }
  877. afterLoginSuccess("S",false);
  878. //window.location.href = "/jyapp/jylab/mainSearch";
  879. //location.replace("/jyapp/jylab/mainSearch");
  880. }
  881. //2020-05-30 android replace失效
  882. function locationReplace(url){
  883. if(history.replaceState){
  884. history.replaceState(null, document.title, url);
  885. history.go(0);
  886. }else{
  887. location.replace(url);
  888. }
  889. }
  890. function afterLoginSuccess(type,canBack){
  891. if(!canBack){
  892. prohibitBack();
  893. localStorage.reLogin = "1";
  894. }
  895. JyObj.loginSuccess(type);
  896. }
  897. //ios JyObj对象加载完成回调
  898. function afterPageInit(){
  899. setInterval(function(){
  900. redSpotOnMenu();
  901. },600000);
  902. try{
  903. afterJyObjInit();
  904. }catch(e){}
  905. var sign = JyObj.getUserToken();
  906. var rid = JyObj.getPushRid();
  907. var oid = getOtherPushId();
  908. $.post("/jyapp/free/afterPageLoadToCheck?t="+new Date().getTime(),{sign:sign,rid:rid,oid:oid,phoneType:getPhoneType(),version:JyObj.getVersion()},function(r){
  909. if(mySysIsIos()){
  910. if(r.updateflag&&r.update.ios_openUpdate){
  911. var version = JyObj.getVersion();
  912. if(needUpdate(version,r.update.ios_version)){
  913. //以后版本
  914. if(r.update.ios_mustupdate){
  915. JyObj.openExternalLink(r.webdomain+"/jyapp/free/goToUpdate?mustupdate=1","-1");
  916. }else{
  917. if(localStorage.onceTipUpdate != "1"){
  918. sessionStorage.onceTipUpdate = "1";
  919. localStorage.onceTipUpdate = "1";
  920. JyObj.openExternalLink(r.webdomain+"/jyapp/free/goToUpdate?mustupdate=1","去更新");
  921. }
  922. }
  923. return;
  924. }
  925. }
  926. }
  927. if(r.status == -3){
  928. window.location.href = "/jyapp/free/login?flag=kicked";
  929. }else if(r.status == 1){
  930. if(r.sign != ""&& r.sign != "exists"){
  931. JyObj.saveUserToken(r.sign);
  932. }
  933. }
  934. });
  935. //记录推送id
  936. savePushIdMsg();
  937. }
  938. function needUpdate(curVersion,upVersion){
  939. v1=curVersion.split(".");
  940. v2=upVersion.split(".");
  941. var maxlen=v1.length>v2.length?v1.length:v2.length;
  942. for(var i=0;i<maxlen;i++){
  943. if(v1[i]==v2[i]){
  944. continue
  945. }
  946. if(v1[i]==undefined){
  947. v1[i]=-1;
  948. }
  949. if(v2[i]==undefined){
  950. v2[i]=-1;
  951. }
  952. if(parseInt(v1[i])<parseInt(v2[i])){
  953. return true;
  954. }else{
  955. return false;
  956. }
  957. }
  958. return false;
  959. }
  960. function redSpotOnMenu(){
  961. var doAjax = true;
  962. if (localStorage.redSpotLastAjaxTime&&
  963. new Date().getTime()-parseInt(localStorage.redSpotLastAjaxTime)<1000*60){
  964. doAjax = false;
  965. }
  966. if (!doAjax && localStorage.redSpotRes){
  967. try{
  968. var lastAjaxRes = JSON.parse(localStorage.redSpotRes)
  969. redSpotBackFuc(lastAjaxRes,"false")
  970. return
  971. }catch(e){
  972. console.log("redSpotOnMenu",e)
  973. }
  974. }
  975. $.post("/jyapp/free/showRedSpotOnMenu?t="+new Date().getTime(),null,redSpotBackFuc);
  976. }
  977. function redSpotBackFuc(r,flag){
  978. var noticeCount = r.notice;
  979. //try{
  980. //JyObj.getUnReadMessageCount("");
  981. //}catch(e){}
  982. if(noticeCount > 0){
  983. //$("#notice .redspot").show(); //2.8.5 我的页面 改
  984. $(".dot").show();
  985. }else{
  986. //$("#notice .redspot").hide();
  987. $(".dot").hide();
  988. }
  989. if(r.follow_project > 0){
  990. $(".listOne .redspot").show();
  991. }else{
  992. $(".listOne .redspot").hide();
  993. }
  994. if(r.follow_ent > 0){
  995. $(".listTwo .redspot").show();
  996. }else{
  997. $(".listTwo .redspot").hide();
  998. }
  999. try{
  1000. if(r.my == 0){
  1001. JyObj.hideRedSpotOnMenu("my");
  1002. }else{
  1003. JyObj.showRedSpotOnMenu("my");
  1004. }
  1005. if(r.subscribe == 0){
  1006. JyObj.hideRedSpotOnMenu("subscribe");
  1007. }else{
  1008. JyObj.showRedSpotOnMenu("subscribe");
  1009. }
  1010. if(r.my == 0 && r.subscribe == 0){
  1011. //清空通知栏消息
  1012. JyObj.clearPushMessage("");
  1013. }
  1014. }catch(e){}
  1015. if(flag=="success"){
  1016. localStorage.redSpotLastAjaxTime = new Date().getTime();
  1017. localStorage.redSpotRes = JSON.stringify(r);
  1018. }
  1019. }
  1020. //
  1021. function setLiActive(obj){
  1022. $(obj).addClass("jyapp-li-active");
  1023. setTimeout(function(){
  1024. $(obj).removeClass("jyapp-li-active");
  1025. },500);
  1026. }
  1027. function mySysIsIos(){
  1028. //ios终端
  1029. var flag1 = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
  1030. var flag2 = !!navigator.userAgent.match(/\(M[^;]+; Intel Mac OS X/);
  1031. return flag1||flag2
  1032. }
  1033. function appQuit(isKicked){
  1034. //清除小红点缓存
  1035. localStorage.removeItem("redSpotLastAjaxTime"); 
  1036. //清除token
  1037. var sign = JyObj.getUserToken();
  1038. JyObj.removeUserToken();
  1039. //隐藏小红点
  1040. try{
  1041. JyObj.hideRedSpotOnMenu("my");
  1042. JyObj.hideRedSpotOnMenu("subscribe");
  1043. }catch(e){}
  1044. $.ajax({
  1045. url: "/jyapp/free/signOut?t="+new Date().getTime(),
  1046. type: "post",
  1047. data: {isKicked:isKicked,sign:sign},
  1048. dataType: "json",
  1049. success: function(r){
  1050. if(!isKicked){
  1051. window.location.href = "/jyapp/free/login?back=index&flag=quit";
  1052. }
  1053. sessionStorage.removeItem("userMergeFlag");
  1054. },
  1055. error: function(){
  1056. if(!isKicked){
  1057. window.location.href = "/jyapp/free/login?back=index&flag=quit";
  1058. }
  1059. }
  1060. });
  1061. }
  1062. function checkRepeatLogin(){
  1063. try{
  1064. var sign = JyObj.getUserToken();
  1065. if(sign == "" || sign == null || typeof(sign) == "undefined"){
  1066. return;
  1067. }
  1068. $.post("/jyapp/free/timeCheckRepeatLogin?t="+new Date().getTime(),{sign:sign},function(r){
  1069. if(r.status == -3){
  1070. window.location.href = "/jyapp/free/login?flag=kicked";
  1071. }
  1072. });
  1073. }catch(e){}
  1074. }
  1075. //更新极光id
  1076. function checkRid(){
  1077. if(localStorage && localStorage.checkRid == "1"){
  1078. //return;
  1079. }
  1080. if(JyObj.getUserToken()==""){
  1081. return;
  1082. }
  1083. var thisInterval = setInterval(function(){
  1084. var rid = JyObj.getPushRid();
  1085. var oid = getOtherPushId();
  1086. if(!rid&&!oid){
  1087. return;
  1088. }
  1089. clearInterval(thisInterval);
  1090. $.post("/jyapp/free/updateRid?t="+new Date().getTime(),{rid:rid,oid:oid,phoneType:getPhoneType()},function(r){
  1091. if(r.sign == ""){
  1092. return;
  1093. }
  1094. if(localStorage){
  1095. localStorage.checkRid = "1";
  1096. }
  1097. if(r.sign != "exists"){
  1098. JyObj.saveUserToken(r.sign);
  1099. }
  1100. });
  1101. },10000);
  1102. }
  1103. //随机获取分享文案
  1104. var ShareText = [
  1105. "我和投标伙伴都在用剑鱼标讯找项目,推荐你也试试",
  1106. "我用剑鱼标讯免费查到超多招标信息,推荐你也试试",
  1107. "我收到了剑鱼标讯免费推送的招标信息,推荐你也试试",
  1108. "发现了一个投标神器,推荐你也试试"
  1109. ]
  1110. function getShareText(){
  1111. return ShareText[randomNum(0,ShareText.length-1)];
  1112. }
  1113. function randomNum(Min,Max){
  1114. var Range = Max - Min;
  1115. var Rand = Math.random();
  1116. var num = Min + Math.round(Rand * Range);
  1117. return num;
  1118. }
  1119. function getCipherText(phone){
  1120. return encodeURIComponent(JyObj.getCipherText(phone));
  1121. }
  1122. function getChannel(){
  1123. var channel=""
  1124. try{
  1125. channel=JyObj.getChannel();
  1126. }catch(e){}
  1127. return channel
  1128. }
  1129. function getDeviceId(){
  1130. var deviceId=""
  1131. try{
  1132. deviceId=JyObj.getIdentity();
  1133. }catch(e){}
  1134. return deviceId
  1135. }
  1136. function getPhoneType(){
  1137. var phoneType = "";
  1138. try{
  1139. phoneType = JyObj.getPhoneBrand();
  1140. }catch(e){}
  1141. return phoneType;
  1142. }
  1143. function getOtherPushId(){
  1144. var otherPushId = "";
  1145. try{
  1146. otherPushId = JyObj.getOtherPushRid();
  1147. }catch(e){}
  1148. return otherPushId;
  1149. }
  1150. function prohibitBack(){
  1151. try{
  1152. //禁止后退
  1153. JyObj.prohibitBack();
  1154. }catch(e){}
  1155. }
  1156. function sendChannelSign(){
  1157. var first=localStorage.getItem("channelSigned")
  1158. if(first=="1"){
  1159. return
  1160. }
  1161. try{
  1162. var sign=getChannel();
  1163. var id=getDeviceId();
  1164. if (sign==""||id==""){
  1165. return
  1166. }
  1167. $.post("/jyapp/free/channelSign",{"sign":sign,"id":id},function(data){
  1168. if(data.success){
  1169. localStorage.setItem("channelSigned","1")
  1170. }
  1171. })
  1172. }
  1173. catch(err){
  1174. alert(err)
  1175. }
  1176. }
  1177. function savePushIdMsg(){
  1178. var sign = JyObj.getUserToken();
  1179. var save = sessionStorage.getItem("savePush")
  1180. if(!(sign == ""||sign==undefined)||save=="1"){
  1181. sessionStorage.setItem("savePush","1")//每次打开只执行一次
  1182. return;
  1183. }
  1184. sessionStorage.setItem("savePush","1")//每次打开只执行一次
  1185. try{
  1186. var interval = setInterval(function(){
  1187. var id=getDeviceId();
  1188. var phoneType=getPhoneType();
  1189. var rid = JyObj.getPushRid();
  1190. var oid = getOtherPushId();
  1191. var channel = getChannel();
  1192. if(mySysIsIos()){
  1193. phoneType="ios";
  1194. channel="ios";
  1195. }
  1196. if(rid==""||rid==undefined){
  1197. return
  1198. }
  1199. $.post("/jyapp/free/savePushIdMsg",{"id":id,"phoneType":phoneType,"rid":rid,"oid":oid,"channel":channel},function(data){
  1200. if(data.success){
  1201. clearInterval(interval);
  1202. }
  1203. })
  1204. },1000)
  1205. }
  1206. catch(err){
  1207. alert(err)
  1208. }
  1209. }
  1210. function isIphoneX(){
  1211. return /iphone/gi.test(navigator.userAgent) && (screen.height >= 812)
  1212. }
  1213. function myDomain(){
  1214. return window.location.protocol+"//"+window.location.host;
  1215. }
  1216. /******* 获取url参数(正则)********/
  1217. function getParam(name) {
  1218. var search = document.location.search;
  1219. // alert(search);
  1220. var pattern = new RegExp("[?&]" + name + "\=([^&]+)", "g");
  1221. var matcher = pattern.exec(search);
  1222. var items = null;
  1223. if (null != matcher) {
  1224. try {
  1225. items = decodeURIComponent(decodeURIComponent(matcher[1]));
  1226. } catch (e) {
  1227. try {
  1228. items = decodeURIComponent(matcher[1]);
  1229. } catch (e) {
  1230. items = matcher[1];
  1231. }
  1232. }
  1233. }
  1234. return items;
  1235. };
  1236. //分销系统 客户端识别口令 调用
  1237. var tipFlag = true;
  1238. function distribInfo(tt){
  1239. var myHref = window.location.href;
  1240. // alert(myHref+"--:"+tt)
  1241. if (myHref.indexOf("free/login")>-1&&(myHref.indexOf("appUrl=")>-1||myHref.indexOf("url=")>-1)){
  1242. //清除客户端粘贴板
  1243. try{
  1244. JyObj.clearRight();
  1245. }catch(e){}
  1246. return false
  1247. }
  1248. if (tt!=""&&tt.indexOf("复制")>-1&&tt.indexOf("剑鱼标讯")>-1){
  1249. var tt_last = tt.split(":")[1]//汉语:
  1250. var discored = tt_last.split(",")[0]//汉语,获取口令
  1251. if (discored!=""){
  1252. $.ajax({
  1253. url: "/distribution/share/getWordInfo?t="+new Date().getTime(),
  1254. type: "POST",
  1255. data: {copyTxt:tt},
  1256. async:false,
  1257. dataType: "json",
  1258. success: function(r){
  1259. // alert(JSON.stringify(r))
  1260. if(r.error_code==0){
  1261. //清除客户端粘贴板
  1262. try{
  1263. nowTime = new Date(formatDate(nowTime,true)+ " 00:00:00").getTime();
  1264. localStorage.setItem("Active_Vip_Invite",nowTime);
  1265. JyObj.clearRight();
  1266. }catch(e){}
  1267. tipFlag = false;
  1268. var res = r.data
  1269. var imgUrl = res["imgUrl"]=="undefined"?"":res["imgUrl"];//产品头像
  1270. var modular = res["modular"]=="undefined"?"":res["modular"];//产品名称
  1271. var nickName = res["shareNickname"]=="undefined"?"":res["shareNickname"];//分销者昵称
  1272. var appUrl = res["appUrl"]=="undefined"?"":res["appUrl"];//跳转链接
  1273. //日志中转链接
  1274. appUrl = "/jyapp/distrib/redirectTo?url="+encodeURIComponent(appUrl+"&&"+modular)
  1275. if (!res["isLogin"]&&appUrl!=""){
  1276. if (myHref.indexOf("/free/login")>-1){
  1277. var fh = "?"
  1278. if (myHref.indexOf("?")>-1){
  1279. fh="&"
  1280. }
  1281. history.replaceState(null,null,myHref+fh+"appUrl="+encodeURIComponent(appUrl))
  1282. }else{
  1283. appUrl = "/jyapp/free/login?url="+encodeURIComponent(appUrl);
  1284. }
  1285. }
  1286. setTimeout(function(){
  1287. DisWord_Tip_Invite(imgUrl,modular,nickName,appUrl);
  1288. },500)
  1289. }
  1290. },
  1291. error: function(){
  1292. }
  1293. });
  1294. }
  1295. }
  1296. }
  1297. //口令弹窗
  1298. var DisWord_Tip_Invite = function(imgUrl,modular,nickName,appUrl){
  1299. var html = '<div style="background: #fff;border-radius: 7px;">'
  1300. +'<div style="display: flex;padding: 24px">'
  1301. +'<div style="width: 54px;height: 54px;border-radius: 4px;margin-right: 10px;" class="_img">'
  1302. +'<img style="border: 0;vertical-align: middle;max-width: 100%;-webkit-tap-highlight-color: rgba(0, 0, 0, 0);" src="'+imgUrl+'"/>'
  1303. +'</div>'
  1304. +'<div style="padding: 4px 0px;" class="_info">'
  1305. +'<p style="font-family: PingFang SC;font-style: normal;font-weight: normal;font-size: 15px;line-height: 22px;color:#000;">您的好友 '+nickName+'</p>'
  1306. +'<p style="font-family: PingFang SC;font-style: normal;font-weight: normal;font-size: 13px;line-height: 22px;color:#5F5E64;margin-top: 4px;">向您推荐了剑鱼标讯 '+modular+'</p>'
  1307. +'</div>'
  1308. +'</div>'
  1309. +'<div style="background: #2ABED1;border-radius: 4px;text-align: center;height: 40px;color: #F7F9FA;line-height: 40px;margin: 0 24px 10px;font-size: 16px;" class="goToPage">打开</div>'
  1310. +'<div style="font-size: 12px;line-height: 18px;text-align: center;color: #9B9CA3;padding-bottom: 10px;">- 全国招标信息免费看,不遮挡 -</div>'
  1311. +'</div>';
  1312. $("body").append('<div class="modal fade" id="myModal-tap" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="true" style="z-index: 100001;">'
  1313. +'<div class="modal-dialog" style="height:100%;margin:0px;">'
  1314. +'<div style="width: 6rem;height: 7.2rem;position: relative;top: 5.5rem;left:48%;margin-left: -2.8rem;">'
  1315. +'<img src="/jyapp/vipsubscribe/image/close.png?v=51430" style="position: absolute;width: 27px;top:-50.5px;right: 0rem;" onclick="DTIClose()">'
  1316. +html
  1317. +'</div>'
  1318. +'</div>'
  1319. +'</div>');
  1320. $("body").append('<div class="modal-backdrop fade in"></div>')
  1321. $("#myModal-tap").show();
  1322. setTimeout(function(){
  1323. $("#myModal-tap").addClass("in")
  1324. },0);
  1325. $(".modal-backdrop").css("z-index","100000");
  1326. $(".goToPage").on("tap",function(){
  1327. //app分销中转页面
  1328. DTIClose();
  1329. window.location.href = appUrl;
  1330. });
  1331. }
  1332. //分销弹窗 关闭
  1333. function DTIClose(){
  1334. $("#myModal-tap").on('webkitTransitionEnd msTransitionend mozTransitionend transitionend', function(){
  1335. $("#myModal-tap").hide();
  1336. $(".modal-backdrop").remove();
  1337. });
  1338. $("#myModal-tap").removeClass("in");
  1339. }
  1340. //格式化时间
  1341. function formatDate(date,hms) {
  1342. if(date ===null || date==="" || date === 0){
  1343. return "-"
  1344. }
  1345. var date = new Date(date);
  1346. var YY = date.getFullYear() + '-';
  1347. var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
  1348. var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
  1349. var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
  1350. var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
  1351. var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
  1352. if(!hms){
  1353. return YY + MM + DD + " " + hh + mm + ss
  1354. }else{
  1355. return YY + MM + DD
  1356. }
  1357. }