lib.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817
  1. import $ from 'jquery';
  2. import BDY from 'BDY';
  3. import WjySdk from 'extSdk';
  4. import _ from 'underscore'
  5. import Indicator from 'mint-ui/lib/indicator';
  6. import Toast from 'mint-ui/lib/toast';
  7. import MessageBox from 'mint-ui/lib/message-box';
  8. import 'mint-ui/lib/indicator/style.css';
  9. import 'mint-ui/lib/toast/style.css';
  10. import 'mint-ui/lib/message-box/style.css';
  11. import PhotoSwipe from 'photoswipe';
  12. import PhotoSwipeUI_Default from 'photoswipe/dist/photoswipe-ui-default';
  13. const isAndroid = navigator.userAgent.indexOf('Android') > -1 || navigator.userAgent.indexOf('Adr') > -1; //android终端
  14. const isiOS = navigator.userAgent.match(/(iPhone|iPod|iPad);?/i); //ios终端
  15. var lib = {};
  16. // require('../artDialog/artDialog');
  17. //+++++++++++++++++++++++++++ hash 参数控制 +++++++++++++++++++++++++++++++++++++
  18. /**
  19. * js获取url参数的值,(函数内部decodeURIComponent值)
  20. * @author benzhan
  21. * @param {string} name 参数名
  22. * @return {string} 参数值
  23. */
  24. function getParam(name) {
  25. //先获取#后面的参数
  26. var str = document.location.hash.substr(2);
  27. var value = getParam2(name, str);
  28. if (value == null) {
  29. str = document.location.search.substr(1);
  30. value = getParam2(name, str);
  31. }
  32. return value;
  33. };
  34. function getParam2(name, str) {
  35. //获取参数name的值
  36. var reg = new RegExp("(^|!|&|\\?)" + name + "=([^&]*)(&|$)");
  37. //再获取?后面的参数
  38. var r = str.match(reg);
  39. if (r != null) {
  40. try {
  41. return decodeURIComponent(r[2]);
  42. } catch (e) {
  43. return null;
  44. }
  45. }
  46. return null;
  47. };
  48. /**
  49. * js设置url中hash参数的值, (函数内部encodeURIComponent传入的value参数)
  50. * @author benzhan
  51. * @param {string} name 参数名
  52. * @return {string} value 参数值
  53. */
  54. function setParam(name, value, causeHistory) {
  55. var search = document.location.search.substr(1);
  56. if ($.type(name) === "object") {
  57. // 支持 setParam(value, causeHistory)的写法
  58. causeHistory = value;
  59. value = name;
  60. for (var key in value) {
  61. search = setParam2(key, value[key], search);
  62. }
  63. } else {
  64. search = setParam2(name, value, search);
  65. }
  66. if (causeHistory) {
  67. if (history.pushState) {
  68. history.pushState({}, null, "?" + search);
  69. } else {
  70. document.location.search = search;
  71. }
  72. } else {
  73. if (history.replaceState) {
  74. history.replaceState({}, null, "?" + search);
  75. } else {
  76. console.error("history.replaceState:" + history.replaceState);
  77. }
  78. }
  79. };
  80. function setParam2(name, value, str) {
  81. if ($.type(name) === "object") {
  82. // 支持 setParam(value, causeHistory)的写法
  83. str = value;
  84. value = name;
  85. for (var key in value) {
  86. str = setParam2(key, value[key], str);
  87. }
  88. return str;
  89. } else {
  90. var prefix = str ? "&" : "";
  91. var reg = new RegExp("(^|!|&|\\?)" + name + "=([^&]*)(&|$)");
  92. var r = str.match(reg);
  93. value = encodeURIComponent(value);
  94. if (r) {
  95. if (r[2]) {
  96. var newValue = r[0].replace(r[2], value);
  97. str = str.replace(r[0], newValue);
  98. } else {
  99. var newValue = prefix + name + "=" + value + "&";
  100. str = str.replace(r[0], newValue);
  101. }
  102. } else {
  103. var newValue = prefix + name + "=" + value;
  104. str += newValue;
  105. }
  106. return str;
  107. }
  108. };
  109. function removeParam(name, causeHistory) {
  110. var search = document.location.search.substr(1);
  111. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  112. r = search.match(reg);
  113. if (r) {
  114. if (r[1] && r[3]) {
  115. search = search.replace(r[0], '&');
  116. } else {
  117. search = search.replace(r[0], '');
  118. }
  119. }
  120. if (causeHistory) {
  121. document.location.search = search;
  122. } else {
  123. if (history.replaceState) {
  124. history.replaceState({}, null, "?" + search);
  125. } else {
  126. console.error("history.replaceState:" + history.replaceState);
  127. }
  128. }
  129. };
  130. function parseHash(strUrl) {
  131. strUrl = strUrl ? strUrl : document.location.search.substr(1);
  132. //获取参数name的值
  133. var reg = new RegExp("(^|!|#|&|\\?)(\\w*)=([^&]*)", "g");
  134. //先获取#后面的参数
  135. var r = reg.exec(strUrl);
  136. var datas = {};
  137. var i = 0;
  138. while (r != null) {
  139. datas[r[2]] = decodeURIComponent(r[3]);
  140. r = reg.exec(strUrl);
  141. }
  142. return datas;
  143. };
  144. // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  145. // +++++++++++++++++++++++++++ get 和 post +++++++++++++++++++++++++++++++++++++
  146. function _getDefaultData(data) {
  147. data = data || {};
  148. var ouid = getCookie('ouid');
  149. ouid && (data.ouid = ouid);
  150. var defaultKeys = ['gym_id'];
  151. for (var i in defaultKeys) {
  152. var key = defaultKeys[i];
  153. var value = getLocalData(key);
  154. if (value && value != "undefined") {
  155. data[key] = value;
  156. }
  157. }
  158. for (var k in data) {
  159. var v = data[k];
  160. if (v == null || typeof v === 'undefined') {
  161. delete data[k];
  162. } else {
  163. if (typeof v === 'string') {
  164. data[k] = $.trim(v);
  165. }
  166. }
  167. }
  168. return data;
  169. }
  170. /**
  171. * option object {'cache', 'loading', 'onTimeout'}
  172. * cache为every、once
  173. */
  174. function post(url, data, callback, option) {
  175. option = option || {};
  176. // 支持postCross(url, callback)的写法;
  177. if ( typeof data == 'function') {
  178. option = callback || {};
  179. callback = data;
  180. data = {};
  181. }
  182. data = _getDefaultData(data);
  183. var xhr = new XMLHttpRequest();
  184. BDY.xhrs.push(xhr);
  185. BDY.xhrCount++;
  186. xhr.index = BDY.xhrs.length;
  187. xhr.open("POST", url);
  188. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  189. xhr.withCredentials = true;
  190. // 兼容ios6.0会缓存
  191. if (window.KalaGame) {
  192. xhr.setRequestHeader("Cache-Control", "no-cache");
  193. }
  194. data = $.param(data);
  195. //获取cache的key
  196. if (option['cache']) {
  197. var cacheKey = 'ajaxCache-' + url + '?' + data;
  198. //如果有cache则不出现loading
  199. var isCached = _loadAjaxCache(cacheKey, callback);
  200. if (isCached) {
  201. option['loading'] = false;
  202. if (option['cache'] == "must") {
  203. return;
  204. }
  205. }
  206. }
  207. if (option['loading']) {
  208. xhr.timeout = 15000;
  209. showLoading();
  210. }
  211. xhr.send(data);
  212. xhr.ontimeout = option['onTimeout'] || function () {
  213. callback && callback({result:0, code:-11, msg:"网络超时,请重试"});
  214. };
  215. // 响应处理
  216. xhr.onload = function() {
  217. BDY.xhrs[xhr.index] = null;
  218. BDY.xhrCount--;
  219. option['loading'] && hideLoading();
  220. var objResult = _getAjaxResult(xhr.responseText);
  221. if (objResult['result'] && option['cache']) {
  222. var cache = localStorage.getItem(cacheKey);
  223. if (cache && cache == xhr.responseText) {
  224. // 网络返回跟缓存一致
  225. return;
  226. } else {
  227. localStorage.setItem(cacheKey, xhr.responseText);
  228. }
  229. }
  230. _handleResult(callback, objResult);
  231. };
  232. }
  233. function get(url, callback, option) {
  234. option = option || {};
  235. var xhr = new XMLHttpRequest();
  236. BDY.xhrs.push(xhr);
  237. BDY.xhrCount++;
  238. var data = {};
  239. _getDefaultData(data);
  240. for (var key in data) {
  241. if (!getParam2(key, url)) {
  242. url += url.indexOf('?') >= 0 ? '&' : '?';
  243. url += key + '=' + data[key];
  244. }
  245. }
  246. xhr.url = url;
  247. option['loading'] && showLoading();
  248. xhr.onreadystatechange = function() {
  249. if (xhr.readyState != 4) {
  250. return;
  251. }
  252. BDY.xhrs[xhr.index] = null;
  253. BDY.xhrCount--;
  254. if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304 || (xhr.status == 0 && location.protocol == 'file:')) {
  255. option['loading'] && hideLoading();
  256. if (option['type'] == 'text') {
  257. callback(xhr.responseText);
  258. } else {
  259. callback(_getAjaxResult(xhr.responseText));
  260. }
  261. }
  262. };
  263. xhr.open("GET", url);
  264. // xhr.withCredentials = true;
  265. xhr.send();
  266. }
  267. function _getAjaxResult(text) {
  268. var objResult = {};
  269. var objError = {
  270. result : 0,
  271. msg : "系统繁忙,请稍后再试!"
  272. };
  273. try {
  274. objResult = JSON.parse(text);
  275. if (typeof objResult !== 'object' || objResult === null) {
  276. objResult = objError;
  277. }
  278. } catch (ex) {
  279. //非json的处理
  280. objResult = objError;
  281. }
  282. return objResult;
  283. }
  284. function _loadAjaxCache(cacheKey, callback) {
  285. var cache = localStorage.getItem(cacheKey);
  286. if (cache) {
  287. var objResult = JSON.parse(cache);
  288. objResult._fromCache = true;
  289. _handleResult(callback, objResult);
  290. return true;
  291. } else {
  292. return false;
  293. }
  294. }
  295. function _handleResult(callback, objResult) {
  296. //session_id失效,重新验证登录
  297. if(!objResult.result && objResult.code == -5) {
  298. openLogin();
  299. } else {
  300. callback && callback(objResult);
  301. }
  302. }
  303. function _deserialize(value){
  304. if (typeof value != 'string') {
  305. return undefined
  306. }
  307. try {
  308. return JSON.parse(value)
  309. }catch(e) {
  310. return value || undefined
  311. }
  312. }
  313. function getLocalData(key) {
  314. return getParam(key) || _deserialize(localStorage.getItem(key));
  315. }
  316. function setLocalData(key, val) {
  317. localStorage.setItem(key, JSON.stringify(val))
  318. }
  319. function getCookie(name) {
  320. var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
  321. if(arr=document.cookie.match(reg))
  322. return unescape(arr[2]);
  323. else
  324. return null;
  325. }
  326. function _setTimeout(callback, timeout) {
  327. var timer = setTimeout(callback, timeout);
  328. BDY.timeout.push(timer);
  329. return timer;
  330. }
  331. function _setInterval(callback, timeout) {
  332. var timer = setInterval(callback, timeout);
  333. BDY.interval.push(timer);
  334. return timer;
  335. }
  336. function _clearRes() {
  337. var len;
  338. var timeout = BDY.timeout;
  339. var interval = BDY.interval;
  340. len = timeout.length;
  341. for (var i = 0; i < len; i++) {
  342. clearTimeout(timeout[i]);
  343. }
  344. len = interval.length;
  345. for (var i = 0; i < len; i++) {
  346. clearInterval(interval[i]);
  347. }
  348. // 重置timer
  349. BDY.timeout = [];
  350. BDY.interval = [];
  351. for (var i in BDY.xhrs) {
  352. BDY.xhrs[i] && BDY.xhrs[i].abort();
  353. }
  354. BDY.xhrs = [];
  355. BDY.xhrCount = 0;
  356. }
  357. // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  358. var loadingDelayHandler = 0;
  359. var loadingTimeoutHandler = 0;
  360. var loadDialog;
  361. function showLoading(text, timeout, cancelable, delay) {
  362. // 超时时间为15s
  363. timeout = timeout || 15000;
  364. // 0.2s后才显示loading
  365. delay = delay || 200;
  366. if (cancelable == null) {
  367. cancelable = true;
  368. } else {
  369. cancelable = !!cancelable;
  370. }
  371. if (loadingDelayHandler) {
  372. return;
  373. }
  374. loadingDelayHandler = setTimeout(function() {
  375. if (!WjySdk.showLoading(text, timeout, cancelable)) {
  376. Indicator.open(text);
  377. loadingTimeoutHandler = setTimeout(function(){
  378. hideLoading();
  379. showTip("加载超时,请稍后再试");
  380. }, timeout);
  381. }
  382. }, delay);
  383. }
  384. function hideLoading() {
  385. loadingDelayHandler && clearTimeout(loadingDelayHandler);
  386. loadingDelayHandler = 0;
  387. loadingTimeoutHandler && clearTimeout(loadingTimeoutHandler);
  388. loadingTimeoutHandler = 0;
  389. try {
  390. Indicator.close();
  391. } catch(e) {}
  392. }
  393. function showErrorTip(msg, timeout) {
  394. if (!msg) { return; }
  395. timeout = timeout || 3000;
  396. if (!WjySdk.showErrorTip(msg, timeout)) {
  397. Toast({
  398. message : msg,
  399. position: 'middle',
  400. duration: timeout
  401. });
  402. }
  403. }
  404. function showTip(msg, timeout) {
  405. if (!msg) { return; }
  406. timeout = timeout || 2000;
  407. if (!WjySdk.showTip(msg, timeout)) {
  408. Toast({
  409. message : msg,
  410. position: 'bottom',
  411. duration: timeout
  412. });
  413. }
  414. }
  415. function showDialog(msg, callback, title, buttonLabels) {
  416. title = title || "提示";
  417. buttonLabels = buttonLabels || "确定";
  418. MessageBox({
  419. title: title,
  420. message: msg,
  421. confirmButtonText: buttonLabels
  422. }).then(action => {
  423. callback && callback(action);
  424. });
  425. }
  426. function confirm(msg, callback, title, buttonLabels) {
  427. title = title || "提示";
  428. buttonLabels = buttonLabels || "确定,取消";
  429. if (!WjySdk.confirm(msg, callback, title, buttonLabels)) {
  430. MessageBox.confirm(msg, title).then(action => {
  431. callback && callback(true);
  432. }).catch(err => {
  433. callback && callback(false);
  434. });
  435. }
  436. }
  437. function setTitle(title) {
  438. document.title = title;
  439. if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
  440. WjySdk.run2('setTitle',[title]);
  441. }
  442. // WjySdk.setTitle(title);
  443. //解决在IOS微信内置浏览器内无法通过document.title修改页面标题的hack
  444. if(checkWXAgent()) {
  445. var $body = $('body');
  446. var $iframe = $('<iframe src="/favicon.ico" style="display:none;"></iframe>');
  447. $iframe.on('load',function() {
  448. setTimeout(function() {
  449. $iframe.off('load').remove();
  450. }, 0);
  451. }).appendTo($body);
  452. }
  453. }
  454. function closeWebView() {
  455. if (!WjySdk.closeWebView()) {
  456. historyBack();
  457. }
  458. }
  459. function openUrl(url, title, needTopBar) {
  460. if (!WjySdk.openUrl(url, title, needTopBar)) {
  461. window.open(url);
  462. }
  463. }
  464. function tryAutoLogin() {
  465. if (window.Wjy) {
  466. var flag = WjySdk.openLogin();
  467. historyBack();
  468. return flag;
  469. } else {
  470. return false;
  471. }
  472. }
  473. function openLogin() {
  474. var flag = tryAutoLogin();
  475. //调用微信登录接口
  476. if (!flag) {
  477. var fromUrl = encodeURIComponent(document.location.href);
  478. var url = BDY.mHiydUrl + 'user/login?fromUrl=' + fromUrl;
  479. location.href = url;
  480. return false;
  481. }
  482. }
  483. function initWxSdk() {
  484. if(!checkWXAgent()) {
  485. return;
  486. }
  487. let url = BDY.mHiydUrl + "weixin/getJsSign";
  488. let data = {
  489. url : location.href,
  490. appid: 6
  491. };
  492. post(url, data, function(ret) {
  493. ret.data.debug = /test\.|webdev/.test(document.location.href) ? true : false;
  494. ret.data.jsApiList = [
  495. "chooseImage",
  496. "previewImage",
  497. "uploadImage",
  498. ];
  499. wx.config(ret.data);
  500. });
  501. }
  502. function handleTime(timeStamp,type){
  503. if(!timeStamp) return "--"
  504. var date = new Date(timeStamp)
  505. var year = date.getFullYear()
  506. var month = date.getMonth()+1
  507. var day = date.getDate()
  508. var hour = date.getHours()
  509. var minute = date.getMinutes()
  510. month = month >= 10 ? month : "0"+month
  511. day = day >= 10 ? day : "0"+day
  512. hour = hour >= 10 ? hour : "0"+hour
  513. minute = minute >= 10 ? minute : "0"+minute
  514. if(type==2) {
  515. return year+"-"+month+"-"+day+" "+hour+":"+minute
  516. } else {
  517. return year+"年"+month+"月"+day+"日 "+hour+":"+minute
  518. }
  519. }
  520. function checkWXAgent() {
  521. var ua = navigator.userAgent.toLowerCase();
  522. if (ua.match(/micromessenger/i) == "micromessenger") {
  523. return true;
  524. } else {
  525. return false;
  526. }
  527. }
  528. function checkWjyAgent() {
  529. var ua = navigator.userAgent.toLowerCase();
  530. if (ua.match(/wjy/i) == "wjy") {
  531. return true;
  532. } else {
  533. return false;
  534. }
  535. }
  536. function getDomain(){
  537. var host = location.host;
  538. if (host.indexOf("127.0.0.1") > -1 || host.indexOf("test.h5-glance.duowan.com") > -1) {
  539. lib.apiUrl = "//test.api.glance.oxzj.net";
  540. lib.upAdminDomain = "//test.up.admin.duowan.com";
  541. } else {
  542. lib.apiUrl = "//api-glance.duowan.com";
  543. lib.upAdminDomain = "//phpadmin-up.duowan.com";
  544. }
  545. }
  546. function getDownloadUrl(){
  547. var downloadUrl = "#";
  548. if(checkWXAgent()) {
  549. downloadUrl = "http://a.app.qq.com/o/simple.jsp?pkgname=com.ouj.movietv";
  550. } else {
  551. if (isiOS) {
  552. downloadUrl = "https://itunes.apple.com/us/app/%E5%BE%AE%E5%89%A7%E9%99%A2-5%E5%88%86%E9%92%9F%E7%9C%8B%E7%89%87/id1268549279?l=zh&ls=1&mt=8";
  553. } else {
  554. downloadUrl = "http://www.hiyd.com/static/apkDownload?appid=13"
  555. }
  556. }
  557. return downloadUrl;
  558. }
  559. function getSchemaUrl(){
  560. return isAndroid ? 'glance://' : 'movietv://'
  561. }
  562. function getAppName() {
  563. let appName;
  564. if(lib.getParam("appid") == 1008 || lib.getParam("appid") == 17) {
  565. appName = '知了电影'
  566. } else {
  567. appName = '微剧院'
  568. }
  569. return appName;
  570. }
  571. //设置微信分享的参数
  572. function setWxShare(data,sCallback,cCallBack){ //分享数据,success回调,cancel回调
  573. if (!checkWXAgent()) return;
  574. var checkWxInterval = setInterval(function(){
  575. if(wx) {
  576. clearInterval(checkWxInterval);
  577. // 适配https
  578. if(!data.imgUrl.match(/http\:\/\/|https\:\/\//)) {
  579. data.imgUrl = "https:" + data.imgUrl
  580. }
  581. wx.ready(function(){
  582. wx.onMenuShareTimeline({
  583. title: data.title, // 分享标题
  584. link: data.link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
  585. imgUrl: data.imgUrl, // 分享图标
  586. success: function () {
  587. sCallback && sCallback(); // 用户确认分享后执行的回调函数
  588. },
  589. cancel: function () {
  590. cCallBack && cCallBack(); // 用户取消分享后执行的回调函数
  591. }
  592. });
  593. wx.onMenuShareAppMessage({
  594. title: data.title, // 分享标题
  595. desc: data.desc, // 分享描述
  596. link: data.link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
  597. imgUrl: data.imgUrl, // 分享图标
  598. success: function () {
  599. sCallback && sCallback(); // 用户确认分享后执行的回调函数
  600. },
  601. cancel: function () {
  602. cCallBack && cCallBack(); // 用户取消分享后执行的回调函数
  603. }
  604. });
  605. });
  606. }
  607. },200);
  608. }
  609. //图片预览
  610. function setPreviewImage(imgList, curIndex,w,h) {
  611. let handleImgList = []
  612. if (checkWXAgent()) { //微信客户端
  613. _.each(imgList,(img,i)=>{
  614. if(img.indexOf("http")> -1){
  615. handleImgList.push(img)
  616. } else {
  617. handleImgList.push(`https:${img}`)
  618. }
  619. })
  620. wx.ready(function() {
  621. wx.previewImage({
  622. current: handleImgList[curIndex],
  623. urls: handleImgList
  624. });
  625. });
  626. } else {
  627. _.each(imgList,(pic,i)=>{
  628. handleImgList.push({
  629. src: pic,
  630. w: w || 1242,
  631. h: h || 1080
  632. })
  633. })
  634. let options = {
  635. index: curIndex
  636. };
  637. let gallery = new PhotoSwipe($('.pswp').get(0), PhotoSwipeUI_Default, handleImgList, options);
  638. gallery.init();
  639. }
  640. }
  641. function formatHttpProtocol(object) {
  642. let fData = JSON.stringify(object);
  643. fData = fData.replace(/http\:\/\//g, "//");
  644. return JSON.parse(fData);
  645. }
  646. /**
  647. * APP协议跳转
  648. * @param {String} schemaUrl
  649. */
  650. function goSchema(schemaUrl) {
  651. var url = getDownloadUrl();
  652. if(isAndroid) {
  653. $('body').append(`<iframe src='${schemaUrl}' style='display:none' target='' ></iframe>`);
  654. } else {
  655. window.location = schemaUrl
  656. }
  657. setTimeout(() => {
  658. window.location = url
  659. },25);
  660. }
  661. function init(){
  662. getDomain();
  663. }
  664. init();
  665. lib.getParam = getParam;
  666. lib.getParam2 = getParam2;
  667. lib.setParam = setParam;
  668. lib.setParam2 = setParam2;
  669. lib.removeParam = removeParam;
  670. lib.parseHash = parseHash;
  671. lib.post = post;
  672. lib.get = get;
  673. lib.getLocalData = getLocalData;
  674. lib.setLocalData = setLocalData;
  675. lib.getCookie = getCookie;
  676. lib.setTimeout = _setTimeout;
  677. lib.setInterval = _setInterval;
  678. lib.clearRes = _clearRes;
  679. lib.setTitle = setTitle;
  680. lib.closeWebView = closeWebView;
  681. lib.openUrl = openUrl;
  682. lib.showLoading = showLoading;
  683. lib.hideLoading = hideLoading;
  684. lib.showErrorTip = showErrorTip;
  685. lib.showTip = showTip;
  686. lib.showDialog = showDialog;
  687. lib.confirm = confirm;
  688. lib.checkWXAgent = checkWXAgent;
  689. lib.checkWjyAgent = checkWjyAgent;
  690. lib.handleTime = handleTime;
  691. lib.setWxShare = setWxShare;
  692. lib.setPreviewImage = setPreviewImage;
  693. lib.formatHttpProtocol = formatHttpProtocol;
  694. lib.goSchema = goSchema;
  695. lib.downloadUrl = getDownloadUrl()
  696. lib.schemaUrl = getSchemaUrl()
  697. lib.appName = getAppName()
  698. export default lib;