tuil.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. // import { runtime } from "webpack";
  2. /**
  3. * 初始化加载
  4. */
  5. $(function() {
  6. postini();
  7. ncode = false;
  8. curCount = 0; //初始化验证码走动时间
  9. SetRemainTime(); //初始化验证码按钮
  10. fes = getUrlParam("fes");
  11. sou = getUrlParam("sou");
  12. $("#useraccount_tt").attr("value", getUrlParam("freeflow_token"));
  13. if (sou != 29 & sou != 33) {
  14. $("#jh").remove();
  15. }
  16. });
  17. var fes;
  18. var sou;
  19. var uidc;
  20. var product = {};
  21. var products = {};
  22. var user = {};
  23. var userid = {}
  24. var usermob = {}
  25. /**
  26. * 页面统一工具
  27. */
  28. var derice = "";
  29. var pattern = /^1[345678]\d{9}$/; //判断联通号码正则表达式
  30. var ncode = false; //用于页面判断验证码超时
  31. //------------------获取页面数据----------------------------
  32. /**
  33. * 获取当前url中参数信息
  34. * @param urlprm url中参数名称
  35. * @returns
  36. */
  37. function getUrlParam(urlprm) {
  38. var reg = new RegExp("(^|&)" + urlprm + "=([^&]*)(&|$)");
  39. var r = window.location.search.substr(1).match(reg);
  40. if (r != null) {
  41. return r[2];
  42. } else { //当获取链接中必须要参数未获取到时标示链接错误直接跳转至统一404页面
  43. //if(urlprm=="con"){
  44. // return "1";
  45. // //获取强制页面跳转标示,不跳转至404.
  46. //}else {
  47. // var url = getRootPath()+"/404.html";
  48. // $(location).attr('href', url);
  49. //}
  50. switch (urlprm) {
  51. case "con":
  52. return "1";
  53. break;
  54. case "freeflow_token":
  55. return "";
  56. break;
  57. default:
  58. var url = getRootPath() + "/404.html";
  59. $(location).attr('href', url);
  60. }
  61. }
  62. }
  63. /**
  64. * 获取项目根目录
  65. * @returns
  66. */
  67. function getRootPath() {
  68. //获取当前网址,如: http://localhost:8080/ems/Pages/Basic/Person.jsp
  69. var curWwwPath = window.document.location.href;
  70. //获取主机地址之后的目录,如: /ems/Pages/Basic/Person.jsp
  71. var pathName = window.document.location.pathname;
  72. var pos = curWwwPath.indexOf(pathName);
  73. //获取主机地址,如: http://localhost:8080
  74. var localhostPath = curWwwPath.substring(0, pos);
  75. //获取带"/"的项目名,如:/ems
  76. var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
  77. return (localhostPath + projectName);
  78. }
  79. /**
  80. * 获取项目根目录
  81. * @returns
  82. */
  83. function getHref() {
  84. //获取当前网址,如: http://localhost:8080/ems/Pages/Basic/Person.jsp
  85. var curWwwPath = window.document.location.href;
  86. //获取主机地址之后的目录,如: /ems/Pages/Basic/Person.jsp
  87. var pathName = window.document.location.pathname;
  88. var pos = curWwwPath.indexOf(pathName);
  89. //获取主机地址,如: http://localhost:8080
  90. var localhostPath = curWwwPath.substring(0, pos);
  91. //获取带"/"的项目名,如:/ems
  92. var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
  93. return (localhostPath + pathName);
  94. }
  95. /**
  96. * 获取对应标签中value
  97. * @param memoid
  98. * @param type
  99. * @returns
  100. */
  101. function getMemoValbyId(product, type) {
  102. var val = "";
  103. switch (type) {
  104. case "phone":
  105. val = $("#input_100_" + product).val();
  106. break;
  107. case "code":
  108. val = $("#input_50_" + product).val();
  109. break;
  110. case "fog":
  111. val = $("#fog_" + product).val();
  112. break;
  113. case "useraccount":
  114. val = $("#useraccount_" + product).val();
  115. break;
  116. case "sendsmsorder":
  117. val = $("#sendsms_order_" + product).val();
  118. break;
  119. case "sendsmscancel":
  120. val = $("#sendsms_cancel_" + product).val();
  121. break;
  122. case "sendsmsyuyue":
  123. val = $("#sendsms_yuyue_" + product).val();
  124. break;
  125. case "sendsmsacti":
  126. val = $("#sendsms_acti_" + product).val();
  127. break;
  128. }
  129. if (val == null) {
  130. return "";
  131. } else {
  132. return val;
  133. }
  134. }
  135. //------------------修改页面样式----------------------------
  136. /**
  137. * 验证码走动
  138. * @param product 对应产品名称缩写
  139. */
  140. var InterValObj;
  141. var curCount = 0;
  142. function coderun(product) {
  143. curCount = 59;
  144. //验证码走码
  145. $(".again_send_btn").removeAttr("style");
  146. $(".send_btn").attr("style", "display:none;");
  147. InterValObj = window.setInterval(SetRemainTime, 1000);
  148. }
  149. //timer处理函数
  150. function SetRemainTime() {
  151. if (curCount == 0) {
  152. ncode = false;
  153. window.clearInterval(InterValObj); // 停止计时器
  154. $(".again_send_btn").removeAttr("disabled"); //启用按钮
  155. $(".send_btn").removeAttr("style");
  156. $(".again_send_btn").attr("style", "display:none;");
  157. $(".again_send_btn").text("重新发送(60S)");
  158. } else {
  159. //提示
  160. $(".again_send_btn").text("请在" + curCount + "秒内输入");
  161. curCount--;
  162. }
  163. }
  164. /**
  165. * 根据页面加载函数初始化页面图标,页面主题
  166. * 页面中必须有对应标签ID
  167. * @param iniJson 后台获取到的页面加载函数
  168. */
  169. function theme(title, icon) {
  170. //加载页面主题文字
  171. $("title").text(title);
  172. //加载页面图标
  173. $("#icon").attr("href", icon + ".ico");
  174. var sou = getUrlParam("sou");
  175. var fes = getUrlParam("fes");
  176. if (fes == "9om" && sou == "2e") {
  177. $("title").text("免流量看皮皮虾");
  178. }
  179. }
  180. /**
  181. * 页面中样式提醒
  182. * @param inc 事件名称
  183. * @param product 对应产品
  184. * @param message
  185. */
  186. function hint(inc, product, message) {
  187. $("#warning_" + inc + "_" + product).removeAttr("style");
  188. $("#warning_" + inc + "_" + product).text(message);
  189. }
  190. /**
  191. * 跳转至404页面
  192. */
  193. function goto404() {
  194. var url = getRootPath() + "/404.html";
  195. $(location).attr('href', url);
  196. }
  197. /**
  198. * 页面弹框提示
  199. */
  200. function pro_bounced(headmg, textmg, buttonmg, state) {
  201. emptyM();
  202. $(".layer").removeAttr("style");
  203. $(".head").append("<h2>" + headmg + "</h2>");
  204. $(".coupon").append("<p>" + textmg + "</p>");
  205. if (state) {
  206. $(".coupon").append("<input type='button' value='" + buttonmg + "' class='red_btn' onclick='closeSe()'>");
  207. } else {
  208. $(".coupon").append("<input type='button' value='" + buttonmg + "' class='red_btn' onclick='closeSe()'>");
  209. }
  210. }
  211. /**
  212. * 去往成功页面
  213. */
  214. function gotosucc() {
  215. var url = getRootPath() + "/tt/orderSucc.html" +
  216. "?fes=" + getUrlParam("fes") + "&sou=" + getUrlParam("sou") +
  217. "&phone=" + getMemoValbyId('tt', 'phone') + "&fog=" + getMemoValbyId('tt', 'fog') + "&fog=" + getMemoValbyId('tt', 'fog') + "&use=" + getMemoValbyId('tt', 'useraccount');
  218. $(location).attr('href', url);
  219. }
  220. /**
  221. * 为查询到订购关系时强制跳转至订购页面
  222. */
  223. function gotorder() {
  224. var url = getRootPath() + "/tt/order.html" +
  225. "?fes=" + getUrlParam("fes") + "&sou=" + getUrlParam("sou") +
  226. "&con=0";
  227. $(location).attr('href', url);
  228. }
  229. /**
  230. * 跳转至对应页面
  231. */
  232. function gotoUrl(html) {
  233. var url = getRootPath() + "/" + html + ".html?fes=" + getUrlParam("fes") + "&sou=" + getUrlParam("sou") + "&use=" + getMemoValbyId('tt', 'useraccount');
  234. $(location).attr('href', url);
  235. }
  236. function gotoUrlC(html) {
  237. var url = getRootPath().replace(/https/ig, "http") + "/" + html + ".html?fes=" + getUrlParam("fes") + "&sou=" + getUrlParam("sou") + "&use=" + getMemoValbyId('tt', 'useraccount');
  238. $(location).attr('href', url);
  239. }
  240. //刷新弹层文本框
  241. function emptyM() {
  242. $(".head").empty();
  243. $(".coupon").empty();
  244. }
  245. // 关闭所有弹层
  246. function closeSe() {
  247. $(".warning").attr("style", "display:none;");
  248. $(".layer").attr("style", "display:none;");
  249. }
  250. /**
  251. * 百度统计组件
  252. */
  253. // var _hmt = _hmt || [];
  254. // (function () {
  255. // var hm = document.createElement("script");
  256. // hm.src = "https://hm.baidu.com/hm.js?0ece85510b3306c074204023de4e49dc";
  257. // var s = document.getElementsByTagName("script")[0];
  258. // s.parentNode.insertBefore(hm, s);
  259. // })();
  260. //------------------请求----------------------------
  261. /*--页面初始化加载--*/
  262. /**
  263. * 消息发送获取Josn数据
  264. * @param method 方法名称
  265. * @param data 发送数据
  266. * @returns 返回的json数据
  267. * 此方法需加载页面头信息与页面显示图标:
  268. * 页面必须有 title 标签
  269. * id = "icon" 链接地址
  270. * <link id="icon" rel="shortcut icon" type="image/x-icon" href=""/>
  271. * 加载页面基本信息:
  272. * XX 为活动对应产品表中配置标示
  273. * <input type="hidden" id="fog_XX"/>
  274. */
  275. function postini() {
  276. $.ajax({
  277. url: getRootPath() + "-s1api" + '/ini/getstyle',
  278. type: "POST", // 用POST方式传输
  279. contentType: "application/json; charset=utf-8",
  280. dataType: "Json",
  281. data: JSON.stringify(postiniDate()),
  282. success: function(msg) {
  283. var resCode = msg["resultCode"];
  284. if (resCode == "0000") {
  285. var festival = msg["festival"];
  286. theme(festival["title"], festival["icon"]); //加载页面信息头,图标
  287. var productlist = msg["product"];
  288. for (var i = 0, l = productlist.length; i < l; i++) {
  289. $("#fog_" + productlist[i].url).attr("value", productlist[i].fog);
  290. var smslist = productlist[i].icon.split(",");
  291. for (var int = 0; int < smslist.length; int++) {
  292. if (int == 0) {
  293. $("#sendsms_order_" + productlist[i].url).attr("value", smslist[int]);
  294. }
  295. if (int == 1) {
  296. $("#sendsms_cancel_" + productlist[i].url).attr("value", smslist[int]);
  297. }
  298. if (int == 2) {
  299. $("#sendsms_yuyue_" + productlist[i].url).attr("value", smslist[int]);
  300. }
  301. }
  302. }
  303. } else { //未取出对应渠道与活动组数据
  304. goto404();
  305. }
  306. if (location.href.indexOf('/cancel') >= 0) {
  307. burypointLogId('110002'); // 退订页面pv, pv去重得到uv
  308. } else if (location.href.indexOf('/draw') >= 0) {
  309. burypointLogId('110003'); // 领取页面pv, pv去重得到uv
  310. } else if (location.href.indexOf('/flow') >= 0) {
  311. burypointLogId('110004'); // 流量查询pv, pv去重得到uv
  312. } else if (location.href.indexOf('/active') >= 0 || location.href.indexOf('/activate') >= 0) {
  313. burypointLogId('110005'); // 激活页面pv, pv去重得到uv
  314. } else {
  315. // location.href.indexOf('/index') >= 0
  316. // location.href.indexOf('/order') >= 0
  317. burypointLogId('110001'); // 订购页面pv, pv去重得到uv
  318. }
  319. },
  320. error: function(XMLHttpRequest, textStatus, errorThrown) { //加载请求失败
  321. goto404();
  322. },
  323. });
  324. }
  325. /**
  326. * 验证码发送
  327. * @param product
  328. */
  329. function sendSms(product, mode) {
  330. //限制验证码在为获取到结果前重复提交
  331. $(".send_btn").removeAttr("onclick");
  332. if (getMemoValbyId("tt", "phone") != "") { //判断号码是否输入
  333. if (pattern.test(getMemoValbyId("tt", "phone"))) { //判断号码格式
  334. $.ajax({
  335. type: "POST",
  336. contentType: "application/json; charset=utf-8",
  337. dataType: "Json",
  338. url: getRootPath() + "-s1api" + '/smsc', //目标地址
  339. data: JSON.stringify(sendSmsDate(product, mode)),
  340. success: function(msg) {
  341. $(".send_btn").attr("onclick", "sendSms('" + product + "','" + mode + "')");
  342. var resCode = eval(msg["resultCode"]);
  343. if (resCode == "0000") {
  344. ncode = true;
  345. coderun("");
  346. } else {
  347. hint("code", product, msg["errorInfo"]);
  348. }
  349. },
  350. error: function(XMLHttpRequest, textStatus, errorThrown) {
  351. $(".send_btn").attr("onclick", "sendSms('" + product + "','" + mode + "')");
  352. hint("code", product, "数据提交失败");
  353. },
  354. });
  355. } else {
  356. $(".send_btn").attr("onclick", "sendSms('" + product + "','" + mode + "')");
  357. hint("phone", product, "请输入正确的中国联通手机号码");
  358. }
  359. } else {
  360. $(".send_btn").attr("onclick", "sendSms('" + product + "','" + mode + "')");
  361. hint("phone", product, "手机号码未输入");
  362. }
  363. if ('acti' == mode) {
  364. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'active_click_send_sms_code_btn' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(getUrlParam("sou"), 32) })
  365. } else {
  366. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'cancel_click_send_sms_code_btn' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(getUrlParam("sou"), 32) })
  367. }
  368. try {
  369. window.HtmlPageVisitor && window.HtmlPageVisitor.setMp(getMemoValbyId("tt", "phone"));
  370. } catch (e) {}
  371. }
  372. /**
  373. * 数据加载发送信息包装.
  374. */
  375. function postiniDate() {
  376. var data = {
  377. fes: getUrlParam("fes"),
  378. sou: getUrlParam("sou"),
  379. };
  380. return data;
  381. }
  382. /**
  383. * 短信发送信息包装.
  384. */
  385. function sendSmsDate(product, mode) {
  386. var data = {
  387. "fog": getMemoValbyId(product, "fog"),
  388. "usermob": getMemoValbyId(product, "phone"),
  389. "smstype": getMemoValbyId(product, "sendsms" + mode),
  390. "sou": getUrlParam("sou"),
  391. };
  392. return data;
  393. }
  394. /**
  395. * 订购发送信息包装
  396. * @param product
  397. * @returns {___anonymous5356_5582}
  398. */
  399. function GetMasData(product, canceltype, cancelmsg) {
  400. var data = {
  401. "code": getMemoValbyId(product, "code"),
  402. "fog": getMemoValbyId(product, "fog"),
  403. "usermob": getMemoValbyId(product, "phone"),
  404. "useraccount": getMemoValbyId(product, "useraccount"),
  405. "canceltype": canceltype,
  406. "cancelmsg": cancelmsg,
  407. "fes": getUrlParam("fes"),
  408. "sou": getUrlParam("sou"),
  409. };
  410. return data;
  411. }
  412. /**
  413. * 获取流量
  414. */
  415. function GetFlowJsonData(product) {
  416. var data = {
  417. "fog": fog,
  418. "usermob": phone,
  419. };
  420. return data;
  421. }
  422. /**
  423. * 订购发送信息包装
  424. * @param product
  425. * @returns {___anonymous5356_5582}
  426. */
  427. function GetDevData(device) {
  428. var data = {
  429. "device_id": device,
  430. };
  431. return data;
  432. }
  433. var se = 0;
  434. function seuid() {
  435. se = se + 1;
  436. if (se == 5) {
  437. se = 0;
  438. alert(getMemoValbyId("tt", "useraccount"));
  439. }
  440. }
  441. function getDecice() {
  442. getDeviceId(function(device_id) {
  443. return device_id;
  444. })
  445. }
  446. function getDeviceId(cb) {
  447. var client_id = '7376a4d6da8df222';
  448. window.ToutiaoJSBridge.call('config', {
  449. client_id: client_id,
  450. }, function() {
  451. toutiao.appInfo({
  452. success: function(res) {
  453. if (cb) {
  454. cb(res.device_id || '')
  455. }
  456. },
  457. fail: function(res) {
  458. return "4001";
  459. },
  460. error: function(res) {
  461. return "4001";
  462. },
  463. });
  464. });
  465. }
  466. (function() {
  467. Date.prototype.from = function(dateString) {
  468. var pattern2 = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/
  469. var str = dateString.replace(/-/g, '/');
  470. str = str.replace(pattern2, '$1/$2/$3 $4:$5:$6')
  471. return new Date(str)
  472. }
  473. // 对Date的扩展,将 Date 转化为指定格式的String
  474. // 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符,
  475. // 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
  476. // 例子:
  477. // (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
  478. // (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
  479. Date.prototype.format = function(fmt) { //author: meizz
  480. var o = {
  481. "M+": this.getMonth() + 1, //月份
  482. "d+": this.getDate(), //日
  483. "h+": this.getHours(), //小时
  484. "m+": this.getMinutes(), //分
  485. "s+": this.getSeconds(), //秒
  486. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  487. "S": this.getMilliseconds() //毫秒
  488. };
  489. if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  490. for (var k in o)
  491. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  492. return fmt;
  493. }
  494. })();
  495. function getTodaySurplusMillis() {
  496. var time1 = new Date();
  497. var time2 = time1.from(time1.getFullYear() + '-' + (time1.getMonth() + 1) + '-' + time1.getDate() + ' 23:59:59');
  498. console.log(time2.getTime() - time1)
  499. return time2.getTime() - time1.getTime();
  500. }
  501. function burypointLogId(operid, remark, url) {
  502. var uuid = getCookie('uuid'); // uv
  503. var vvid = getCookie('vvid'); // vv
  504. if (uuid == null || uuid.trim() == '') {
  505. uuid = guid();
  506. setCookie('uuid', uuid, getTodaySurplusMillis());
  507. }
  508. if (vvid == null || vvid.trim() == '') {
  509. vvid = guid();
  510. setCookie('vvid', vvid, -1);
  511. }
  512. if (operid == null || operid == '') {
  513. // 页面的埋点不通过/burypoint/logid接口实现,通过文件日志入库方式
  514. return;
  515. }
  516. var param = {
  517. operid: operid,
  518. uuid: uuid,
  519. vvid: vvid,
  520. fog: getMemoValbyId('tt', 'fog'),
  521. userid: '',
  522. fes: getUrlParam("fes"),
  523. sou: getUrlParam("sou"),
  524. url: encodeURIComponent(url || window.location.href),
  525. remark: encodeURIComponent(remark || '')
  526. }
  527. $.ajax({
  528. type: "POST",
  529. contentType: "application/json; charset=utf-8",
  530. dataType: "Json",
  531. url: getRootPath() + "-s1api" + '/burypoint/logid', //目标地址
  532. data: JSON.stringify(param),
  533. success: function() {},
  534. error: function() {},
  535. });
  536. }
  537. function getCookie(name) {
  538. var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
  539. if (arr = document.cookie.match(reg))
  540. return unescape(arr[2]);
  541. else
  542. return null;
  543. }
  544. /**
  545. * 如果没有设置时间
  546. */
  547. function setCookie(name, value, millis) {
  548. millis = (millis == undefined ? 0 : millis);
  549. var exp = new Date();
  550. if (millis < 0) {
  551. document.cookie = name + "=" + escape(value);
  552. } else {
  553. exp.setTime(exp.getTime() + millis);
  554. document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
  555. }
  556. }
  557. function guid() {
  558. return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
  559. var r = Math.random() * 16 | 0,
  560. v = c == 'x' ? r : (r & 0x3 | 0x8);
  561. return v.toString(16);
  562. });
  563. }
  564. $('#tiu').unbind('click').on('click', function() {
  565. showCancelReasonPage().done(function(cancelReason) {
  566. doShowCancelPage(cancelReason)
  567. })
  568. })
  569. function showCancelReasonPage() {
  570. var reasonUrl;
  571. var baseUrl;
  572. if (window.location.href.indexOf("https://800.wo.cn/orderchannel") >= 0) {
  573. reasonUrl = "https://800.wo.cn/orderchannel/public/libs/cancelreason/index.html";
  574. baseUrl = "https://800.wo.cn/";
  575. } else if (window.location.href.indexOf("https://800.wo.cn/festivalchannel") >= 0) {
  576. reasonUrl = "https://800.wo.cn/festivalchannel/public/libs/cancelreason/index.html";
  577. baseUrl = "https://800.wo.cn/";
  578. } else if (window.location.href.indexOf("http://localhost") >= 0) {
  579. reasonUrl = "http://localhost:8088/orderchannel/public/libs/cancelreason/index.html";
  580. baseUrl = "http://localhost:8088/";
  581. } else if (window.location.href.indexOf("http://127.0.0.1") >= 0) {
  582. reasonUrl = "http://127.0.0.1:8088/orderchannel/public/libs/cancelreason/index.html";
  583. baseUrl = "http://127.0.0.1:8088/";
  584. } else if (window.location.href.indexOf("http://100.0.4.69:3344") >= 0) {
  585. reasonUrl = "http://100.0.4.69:3344/orderchannel/public/libs/cancelreason/index.html";
  586. baseUrl = "http://100.0.4.69:3344/";
  587. } else if (window.location.href.indexOf("http://100.0.4.69:8282") >= 0) {
  588. reasonUrl = "http://100.0.4.69:8282/orderchannel/public/libs/cancelreason/index.html";
  589. baseUrl = "http://100.0.4.69:8282/";
  590. } else {
  591. reasonUrl = "https://800.wo.cn/orderchannel/public/libs/cancelreason/index.html";
  592. baseUrl = "https://800.wo.cn/";
  593. }
  594. window.$capoverlay = $('<div class="overlay" style="z-index: 0; background-color: rgba(0,0,0,0.4);"></div>');
  595. $capoverlay.appendTo($(document.body));
  596. $("body").css("overflow", "hidden");
  597. var $iframe;
  598. if ($('#reasonIframe').length >= 1) {
  599. $iframe = $('#reasonIframe').attr('src', reasonUrl);
  600. } else {
  601. $iframe = $('<iframe id="reasonIframe" src="' + reasonUrl + '"></iframe>');
  602. $('body').append($iframe);
  603. }
  604. $iframe.css({
  605. width: "100%",
  606. height: "100%",
  607. position: "fixed",
  608. top: 0,
  609. left: 0,
  610. margin: 0,
  611. padding: 0,
  612. "-webkit-overflow-scrolling": "touch",
  613. border: "0px",
  614. "z-index": 111,
  615. });
  616. var def = $.Deferred();
  617. function messageListener(event) {
  618. var data = JSON.parse(event.data);
  619. $iframe.remove();
  620. $capoverlay.remove();
  621. $("body").css("overflow", "auto");
  622. window.removeEventListener('message', messageListener);
  623. if (data.eventtype != 'close') {
  624. def.resolve(data)
  625. } else {
  626. def.reject(data)
  627. }
  628. }
  629. window.addEventListener('message', messageListener);
  630. return def;
  631. }
  632. function doShowCancelPage(cancelReason) {
  633. var k = JSON.stringify(cancelReason)
  634. window.localStorage.setItem('kye', k)
  635. gotoUrl('tt/cancel')
  636. }