暫無描述

fund_h5_api.js 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  1. var token = '';
  2. var tid = '';
  3. var returnUrl = '';
  4. var cityInfo = '';
  5. var retrievePwd = '';
  6. var appName = '';
  7. var qs = parseQueryString(window.location.href);
  8. var httpStr=location.href.substr(0,location.href.indexOf("?") + 1); //str得到?之前的字符串
  9. $().ready(function() {
  10. if (qs.returnUrl) {
  11. returnUrl = qs.returnUrl;
  12. }
  13. if (qs.appName) {
  14. appName = qs.appName;
  15. }
  16. if (qs.token) {
  17. token = qs.token;
  18. } else {
  19. showMsg('未提供token!')
  20. }
  21. if (qs.name && qs.code) {
  22. $('.city-name').text(qs.name).attr('data-code', qs.code);
  23. }
  24. var agreementLink = $('.agreement-wrapper a');
  25. agreementLink.attr('href', agreementLink.attr('href') + '?appName=' + appName);
  26. httpStr += "returnUrl=" + returnUrl + "&appName=" + appName;
  27. httpStr = encodeURIComponent(httpStr)
  28. $("nav p span").html(qs.name+"公积金查询")
  29. getLoginInfo();
  30. //头部切换公积金类型
  31. switchingType();
  32. });
  33. //头部切换公积金类型
  34. function switchingType() {
  35. var btn = $("nav p");
  36. btn.click(function () {
  37. console.log(cityInfo)
  38. if(cityInfo !='' && cityInfo){
  39. window.location.href = './typeChoice.html?name=' + cityInfo.region + '&code=' + cityInfo.regionCode + (token ? ('&token=' + token) : '') + '&httpStr=' + httpStr;
  40. }else{
  41. showMsg('获取城市信息失败:' + cityInfo.region + '公积金查询');
  42. }
  43. })
  44. }
  45. /**
  46. * [showMsg 提示各种错误信息,3s后消失]
  47. */
  48. function showMsg(msg) {
  49. var msgBox = $('.alert-info');
  50. msgBox.children('p').text(msg);
  51. msgBox.show();
  52. setTimeout(function() {
  53. msgBox.hide();
  54. }, 3000);
  55. }
  56. /**
  57. * [showDialog 弹窗提示,传不同的参数提示不同的内容以及按钮的内容和点击之后的作用]
  58. * failed 任务失败,点击关闭弹窗
  59. * maintain 当前城市维护中,点击关闭弹窗
  60. * timeout token过期,点击关闭页面
  61. */
  62. function showDialog(type) {
  63. var mask = $('.mask');
  64. mask.show();
  65. $('.dialog-wrapper input').val('确定');
  66. $('.dialog-wrapper div').hide();
  67. if (type === 'failed') {
  68. $('.dialog-failed').show();
  69. $('.mask').siblings().hide();
  70. } else if (type === 'maintain') {
  71. $('.dialog-maintain').show();
  72. } else if (type === 'timeout') {
  73. $('.dialog-timeout').show();
  74. $('.dialog-wrapper input').val('关闭').click(function() {
  75. redirectToFailedReturnUrl(tid, 'failed', 1020, '无效的token, 会话不存在或已过期');
  76. })
  77. } else if (type === 'forget') {
  78. var html = '如果您忘记密码,需前往' + qs.name+ '公积金官网<br>重置密码'
  79. $('.dialog-forget').show();
  80. // $('.dialog-forget').find('p').html(html)
  81. cituInfoData();
  82. $('.dialog-wrapper input').val('立即前往').click(function() {
  83. tips.find(function(item, index) {
  84. if(item.region == cityInfo.region){
  85. if(item.URL.password){
  86. retrievePwd = item.URL.password;
  87. // window.location.href=retrievePwd;
  88. window.webkit.messageHandlers.OutPushMessageHandler.postMessage({'name':qs.name,'url':retrievePwd});
  89. }else if(item.URL.web){
  90. retrievePwd = item.URL.web;
  91. // window.location.href=retrievePwd;
  92. window.webkit.messageHandlers.OutPushMessageHandler.postMessage({'name':qs.name,'url':retrievePwd});
  93. }
  94. }
  95. })
  96. })
  97. }
  98. }
  99. /**
  100. * [enableCommitButton 启用/禁用提交按钮]
  101. * @param {Boolean} isEnableButton [是否启用提交按钮]
  102. */
  103. function enableCommitButton(isEnableButton) {
  104. var commitButton = $('#submitButton');
  105. if (isEnableButton) {
  106. commitButton.attr('disabled', false).removeClass('disable-commit').addClass('enable-commit');
  107. } else {
  108. commitButton.attr('disabled', true).removeClass('enable-commit').addClass('disable-commit');
  109. }
  110. }
  111. /**
  112. * [isInputReady 检查参数是否输入完毕]
  113. * @return {Boolean} [参数是否输入完毕]
  114. */
  115. function isInputReady() {
  116. var isInputReady = true;
  117. var activeID = $('.tab-tab-active').attr('data-id');
  118. $('.tab-content [data-id="' + activeID + '"]')
  119. .find('input')
  120. .each(
  121. function(index, item) {
  122. if ($(item).val().trim() === '') {
  123. isInputReady = false;
  124. }
  125. if (!$('.check').hasClass('check-active')) {
  126. isInputReady = false;
  127. }
  128. })
  129. return isInputReady;
  130. }
  131. /**
  132. * [initEvent 初始化各种事件]
  133. */
  134. function initEvent() {
  135. var tabs = $('.tab-tab');
  136. var activeID = $('.tab-tab-active').attr('data-id');
  137. // tab页切换
  138. tabs.click(function(event) {
  139. var currItem = $(this);
  140. var currId = currItem.attr('data-id');
  141. $('.tab-tab[data-id="' + currId + '"]').addClass('tab-tab-active').siblings().removeClass('tab-tab-active');
  142. $('.tab-content div[data-id=' + currId + ']').show().siblings().hide();
  143. enableCommitButton(isInputReady());
  144. })
  145. // 监测用户输入来设置提交按钮的状态
  146. $('.tab-content').on('keyup', function() {
  147. enableCommitButton(isInputReady());
  148. })
  149. // 确定按钮点击事件
  150. $('#closeMask').click(function(event) {
  151. $('.mask').removeClass('bg-white').hide().siblings().show();
  152. $('#tid').hide();
  153. $('.alert-info').hide();
  154. $('.loading-wrapper').hide();
  155. })
  156. //阻止冒泡
  157. $(".dialog-wrapper").click(function (){
  158. return false
  159. })
  160. //点击mask阴影
  161. $(".mask").click(function() {
  162. $('.mask').removeClass('bg-white').hide().siblings().show();
  163. $('#tid').hide();
  164. $('.alert-info').hide();
  165. $('.loading-wrapper').hide();
  166. })
  167. // 解析协议checkBox选中/取消选中事件
  168. $('.check').click(function() {
  169. var currentItem = $(this);
  170. if (currentItem.hasClass('check-active')) {
  171. enableCommitButton(false);
  172. currentItem.removeClass('check-active');
  173. } else {
  174. currentItem.addClass('check-active');
  175. enableCommitButton(isInputReady());
  176. }
  177. })
  178. // 提交按钮点击事件
  179. $('#submitButton').click(function() {
  180. if (isInputValid()) {
  181. submitTask();
  182. }
  183. });
  184. // 导航栏左上角退出H5的点击事件
  185. $('#back').click(function() {
  186. // redirectToFailedReturnUrl(tid, 'failed', 1020, '退出公积金查询页');
  187. // window.history.go(-1)
  188. window.webkit.messageHandlers.PopRootMessageHandler.postMessage({name:"1"});
  189. })
  190. }
  191. /**
  192. * [getLoginInfo 获取城市登录信息]
  193. */
  194. function getLoginInfo() {
  195. var regionCode = $('.city-name').attr('data-code');
  196. $.ajax({
  197. type: "GET",
  198. url: BASEURL + 'city_list?type=fund&token=' + token + '&regionCode=' + regionCode + '&time=' + Math.round(Date.now() / 1000),
  199. // url: '../../city_list?type=fund&token=' + token + '&regionCode=' + regionCode + '&time=' + Math.round(Date.now() / 1000),
  200. contentType: 'application/json;charset=utf-8',
  201. success: function(data) {
  202. cityInfo = data;
  203. return renderLoginInfo(data);
  204. },
  205. error: function(err) {
  206. // return showMsg('获取城市信息失败:' + JSON.stringify(err));
  207. return showMsg('获取城市信息失败:' + qs.name + '公积金查询');
  208. }
  209. });
  210. }
  211. /**
  212. * [renderLoginInfo 渲染城市登录信息]
  213. * @param {[type]} cityInfo [城市登录信息]
  214. */
  215. function renderLoginInfo(cityInfo) {
  216. var tabWrapper = $('.tab-tab-wrapper');
  217. var tabConWrapper = $('.tab-content');
  218. var tabsHtmlStr = '';
  219. var tabConHtmlStr = '';
  220. $('.city-name').text(cityInfo.region).attr('data-code', cityInfo.regionCode);
  221. // $('.choose-city a').attr('href', './choose_city.html?name=' + cityInfo.region + '&code=' + cityInfo.regionCode + (token ? ('&token=' + token) : ''));
  222. $('nav span a').attr('href', './choose_city.html?name=' + cityInfo.region + '&code=' + cityInfo.regionCode + (token ? ('&token=' + token) : ''));
  223. $('.obtainPwd a').attr('href', './queryHelp.html?name=' + cityInfo.region + '&code=' + cityInfo.regionCode + (token ? ('&token=' + token) : '') + '&httpStr=' + httpStr);
  224. for (var index in cityInfo.loginTypes) {
  225. var loginType = cityInfo.loginTypes[index];
  226. // if(cityInfo.loginTypes.length != 1){
  227. if (index === '0') {
  228. tabsHtmlStr += '<div class="tab-tab tab-tab-active" data-id ="' + loginType.loginTypeId + '"><p class="tab-title">' + loginType.loginLabel + '</p><i class="hr-active"></i></div>';
  229. tabConHtmlStr += '<div data-id="' + loginType.loginTypeId + '" style="display:block">';
  230. } else {
  231. tabsHtmlStr += '<div class="tab-tab" data-id ="' + loginType.loginTypeId + '"><p class="tab-title">' + loginType.loginLabel + '</p><i class="hr-active"></i></div>';
  232. tabConHtmlStr += '<div data-id="' + loginType.loginTypeId + '" style="display:none">';
  233. }
  234. // }
  235. for (var loginField of loginType.loginFields) {
  236. var type = '';
  237. var placeStr = '';
  238. if (loginField.name.includes('联名卡')) {
  239. placeStr = '请输入公积金联名卡号';
  240. } else if (loginField.name.includes('身份证')) {
  241. placeStr = '请输入身份证';
  242. } else if (loginField.name.includes('手机号')) {
  243. placeStr = '请输入手机号';
  244. } else if (loginField.name.includes('用户名')) {
  245. placeStr = '请输入用户名';
  246. } else if (loginField.name.includes('账号')) {
  247. placeStr = '请输入账号';
  248. } else if (loginField.name.includes('姓名')) {
  249. placeStr = '请输入姓名';
  250. } else if (loginField.name.includes('存折账号')) {
  251. placeStr = '请输入存折账号';
  252. } else if (loginField.name.includes('密码')) {
  253. placeStr = '请输入密码';
  254. type = 'password';
  255. }
  256. if(qs.name == "北京"){
  257. if (loginField.name.includes('身份证')) {
  258. placeStr = '首次查询请选择联名卡号';
  259. }
  260. }
  261. if(loginField.name.includes('密码')){
  262. tabConHtmlStr += '<div class="input-wrapper inputForget" ><label for="">' + loginField.name + ':</label><input id="' + loginField.code + '" type="' + type + '" placeholder="' + placeStr + '"><div class="forget" onclick="forgetEvent()">忘记密码</div></div>';
  263. }else{
  264. tabConHtmlStr += '<div class="input-wrapper" ><label for="">' + loginField.name + ':</label><input id="' + loginField.code + '" type="' + type + '" placeholder="' + placeStr + '"></div>';
  265. }
  266. }
  267. tabConHtmlStr += '</div>';
  268. }
  269. tabWrapper.html(tabsHtmlStr);
  270. tabConWrapper.html(tabConHtmlStr);
  271. if(cityInfo.loginTypes !=undefined){
  272. if(cityInfo.loginTypes.length == 1){
  273. $(".tab-tab").css({
  274. 'position':'absolute',
  275. 'left':'-5000px'
  276. })
  277. }
  278. }
  279. renderTips($('.city-name').text());
  280. initEvent(); // 各种事件绑定
  281. checkToken();
  282. }
  283. //点击忘记密码按钮
  284. function forgetEvent () {
  285. showDialog('forget')
  286. }
  287. /**
  288. * [isInputValid 校验输入信息是否合法]
  289. * @return {Boolean} [输入信息是否合法]
  290. */
  291. function isInputValid() {
  292. var isInputValid = true;
  293. var activeID = $('.tab-tab-active').attr('data-id');
  294. $('.tab-content [data-id="' + activeID + '"]')
  295. .find('input')
  296. .each(
  297. function(index, item) {
  298. var currentEle = $(item);
  299. // 通过label标签里面的文本来判断输入项的类型
  300. // 例如:
  301. // 身份证号:
  302. var labelText = currentEle.parent().find('label').text().replace(':', '');
  303. var value = currentEle.val();
  304. var reg = null;
  305. if (labelText && labelText.includes('身份证')) {
  306. reg = /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/;
  307. if (!reg.test(value)) {
  308. showMsg('身份证输入格式不正确');
  309. isInputValid = false;
  310. return false;
  311. }
  312. }
  313. if (labelText && (labelText.includes('电话') || labelText.includes('手机'))) {
  314. reg = /^1[3456879]\d{9}$/;
  315. if (!reg.test(value)) {
  316. showMsg('电话(手机)号码输入格式不正确')
  317. isInputValid = false;
  318. return false;
  319. }
  320. }
  321. if (labelText && labelText.includes('公积金')) {
  322. reg = /^\d+$/;
  323. if (!reg.test(value)) {
  324. showMsg('公积金账号输入格式不正确')
  325. isInputValid = false;
  326. return false;
  327. }
  328. }
  329. if (labelText && labelText.includes('联名卡')) {
  330. reg = /^\d+$/;
  331. if (!reg.test(value)) {
  332. showMsg('联名卡输入格式不正确')
  333. isInputValid = false;
  334. return false;
  335. }
  336. }
  337. })
  338. return isInputValid;
  339. }
  340. /**
  341. * [checkToken 校验token信息]
  342. */
  343. function checkToken() {
  344. var getTokenInfo = $.ajax({
  345. type: 'GET',
  346. url: BASEURL + 'token?token=' + token + '&time=' + Math.round(Date.now() / 1000),
  347. // url: '../../token?token=' + token + '&time=' + Math.round(Date.now() / 1000),
  348. timeout: 30000,
  349. contentType: 'application/json;charset=utf-8'
  350. });
  351. getTokenInfo.done(function(data) {
  352. if (data.returnUrl && !returnUrl) {
  353. window.sessionStorage.isTokenValid = true;
  354. returnUrl = data.returnUrl;
  355. }
  356. if (data.appName) {
  357. var agreementLink = $('.agreement-wrapper a');
  358. agreementLink.attr('href', agreementLink.attr('href') + '?appName=' + data.appName);
  359. }
  360. if (data.region && data.loginLabel && data.inputData) {
  361. // 防止每次刷新都提交任务
  362. if (!window.sessionStorage.tid) {
  363. var task = {
  364. type: 'fund',
  365. region: data.region,
  366. loginLabel: data.loginLabel,
  367. inputData: JSON.parse(data.inputData),
  368. }
  369. return submitTask(task);
  370. }
  371. }
  372. if (data.tid) {
  373. $("#tid").val(data.tid);
  374. tid = data.tid;
  375. autoInputTaskInfo();
  376. // checkTaskStatus(data.tid);
  377. }
  378. });
  379. getTokenInfo.fail(function(error) {
  380. window.sessionStorage.isTokenValid = false;
  381. enableCommitButton(false);
  382. if (error.responseJSON.code === 1020) {
  383. showDialog('timeout');
  384. } else {
  385. showMsg(error.responseJSON.error);
  386. }
  387. });
  388. }
  389. /**
  390. * [submitTask 提交查询任务]
  391. * @param {[type]} data [查询任务相关参数]
  392. */
  393. function submitTask(data) {
  394. showLoading(true);
  395. var url = BASEURL + "task?token=" + token + "&time=" + Math.round(Date.now() / 1000);
  396. // var url = "../../task?token=" + token + "&time=" + Math.round(Date.now() / 1000);
  397. var task = data || getTaskInfo();
  398. data ? null : saveTaskInfo();
  399. var posting = $.ajax({
  400. type: "POST",
  401. url: url,
  402. data: JSON.stringify(task),
  403. timeout: 30000,
  404. contentType: 'application/json;charset=utf-8'
  405. });
  406. posting.done(function(task) {
  407. tid = task.tid;
  408. $("#tid").val(task.tid); // for next submit
  409. window.sessionStorage.tid = tid;
  410. checkTaskStatus(task.tid);
  411. });
  412. posting.fail(function(error) {
  413. showLoading(false);
  414. if (error.responseJSON.code === 1029) {
  415. showDialog('maintain');
  416. } else if (error.responseJSON.code === 1011) {
  417. showMsg('身份证输入不正确');
  418. } else if (error.responseJSON.code === 1020) {
  419. showDialog('timeout');
  420. } else {
  421. showDialog('failed');
  422. }
  423. });
  424. }
  425. /**
  426. * [getTaskInfo 获取提交任务所需参数]
  427. * @return {[Object]} [提交任务所需参数]
  428. */
  429. function getTaskInfo() {
  430. var task = {};
  431. var activeID = $('.tab-tab-active').attr('data-id');
  432. task.region = $('.city-name').attr('data-code');
  433. task.loginLabel = $(".tab-tab-active").text().trim();
  434. task.inputData = []; // 完整记录用户输入信息
  435. $("div[data-id='" + activeID + "'] input").each(function(index, item) {
  436. var currEle = $(item);
  437. task.inputData.push({
  438. key: currEle.attr('id'),
  439. value: currEle.val()
  440. })
  441. })
  442. if ($("#tid").val()) {
  443. task.tid = $("#tid").val();
  444. } else {
  445. task.type = 'fund';
  446. }
  447. return task;
  448. }
  449. /**
  450. * [saveTaskInfo 保存提交用户输入的信息在sessionStorage中,用于用户刷新后数据回填]
  451. */
  452. function saveTaskInfo() {
  453. var ss = window.sessionStorage;
  454. var activeID = $('.tab-tab-active').attr('data-id');
  455. ss.activeID = activeID;
  456. var inputList = $('div [data-id="' + activeID + '"] input');
  457. inputList.each(function(index, item) {
  458. var currentEle = $(item);
  459. ss[currentEle.attr('id')] = currentEle.val();
  460. })
  461. }
  462. /**
  463. * [autoInputTaskInfo 用于用户刷新后从sessionStorage中拿到数据数据回填]
  464. */
  465. function autoInputTaskInfo() {
  466. var ss = window.sessionStorage;
  467. var activeID = $('.tab-tab-active').attr('data-id');
  468. if (ss.activeID && (activeID !== ss.activeID)) {
  469. $('.tab-tab[data-id="' + ss.activeID + '"]').addClass('tab-tab-active').siblings().removeClass('tab-tab-active');
  470. $('.tab-content div[data-id=' + ss.activeID + ']').show().siblings().hide();
  471. }
  472. $("#tid").val(ss.tid);
  473. tid = ss.tid;
  474. for (var key in ss) {
  475. var currentEle = $("div [data-id='" + ss.activeID + "'] #" + key);
  476. currentEle.length > 0 ? currentEle.val(ss[key]) : null;
  477. }
  478. enableCommitButton(isInputReady());
  479. }
  480. /**
  481. * [checkTaskStatus 轮询任务状态]
  482. * @param {[type]} tid [tid]
  483. */
  484. function checkTaskStatus(tid) {
  485. var url = BASEURL + 'task?tid=' + tid + '&token=' + token + '&time=' + Math.round(Date.now() / 1000);
  486. // var url = '../../task?tid=' + tid + '&token=' + token + '&time=' + Math.round(Date.now() / 1000);
  487. var getting = $.get(url);
  488. getting.fail(function(error) {
  489. showMsg(error.responseJSON.error);
  490. });
  491. getting.done(function(task) {
  492. if (task.status === 'done') {
  493. process.stop(100);
  494. $("#tid").val('');
  495. showLoading(false);
  496. redirectToSucsessReturnUrl(task.tid, 'success');
  497. return;
  498. }
  499. if (task.status === "processing") {
  500. if ($('.loading-wrapper').css('display') === 'none') {
  501. showLoading(true);
  502. }
  503. setTimeout(function() {
  504. checkTaskStatus(tid);
  505. }, 1000);
  506. return;
  507. }
  508. if (task.status === "failed") {
  509. process.stop(100);
  510. tid = '';
  511. $("#tid").val('');
  512. showLoading(false);
  513. window.sessionStorage.clear();
  514. if (task.failCode === 1029) {
  515. showDialog('maintain');
  516. } else {
  517. showDialog('failed');
  518. }
  519. return;
  520. }
  521. console.log(task.status)
  522. if (task.status == "suspended") {
  523. process.stop(0);
  524. showLoading(false);
  525. enableCommitButton(false);
  526. console.log(task)
  527. switch (task.need) {
  528. case 'changeLoginType': // 无记录,请尝试切换登录类型
  529. case 'regionOrLogintype': // 请选择地区信息 | 请选择登录类型 | 请选择补充地区信息 | 该地区不支持公积金 | 发送的fundId或loginTypeId错误
  530. // 你不是本地用户,请选择所属地区进行登录 | 所选的城市暂不支持,请选择其它城市登录
  531. showMsg('你不是本地用户,请选择所属地区进行登录');
  532. break;
  533. case 'accountOrpassword':
  534. showMsg('账号或密码输入错误');
  535. break;
  536. case 'parameterError':
  537. showMsg('输入的信息有误');
  538. break;
  539. default:
  540. showMsg(task.need);
  541. break;
  542. }
  543. }
  544. });
  545. }
  546. /**
  547. * [showLoading 显示loading界面]
  548. * @param {Boolean} isShow [description]
  549. */
  550. function showLoading(isShow) {
  551. if (isShow) {
  552. // 防止页面刷新之后进度从0开始
  553. if (window.sessionStorage.processRate) {
  554. process.start(parseInt(window.sessionStorage.processRate));
  555. } else {
  556. process.start(0);
  557. }
  558. $('.loading-wrapper').show().siblings().hide();
  559. $('html').addClass('bg-white');
  560. } else {
  561. process.stop(0);
  562. $('html').removeClass('bg-white');
  563. $('.loading-wrapper').hide().siblings().show();
  564. }
  565. }
  566. /**
  567. * [redirectToFailedReturnUrl 跳到redirectURL]
  568. */
  569. function redirectToFailedReturnUrl(tid, result, failCode, reason) {
  570. if (returnUrl.indexOf('?') < 0) {
  571. returnUrl += "?result=" + result + "&tid=" + tid + "&token=" + token + "&failCode=" + failCode + "&reason=" + reason;
  572. } else {
  573. returnUrl += "&result=" + result + "&tid=" + tid + "&token=" + token + "&failCode=" + failCode + "&reason=" + reason;
  574. }
  575. window.sessionStorage.clear();
  576. window.location.href = returnUrl;
  577. }
  578. /**
  579. * [redirectToSucsessReturnUrl 跳到redirectURL]
  580. */
  581. function redirectToSucsessReturnUrl(tid, result) {
  582. if (returnUrl.indexOf('?') < 0) {
  583. returnUrl += "?result=" + result + "&tid=" + tid + "&token=" + token;
  584. } else {
  585. returnUrl += "&result=" + result + "&tid=" + tid + "&token=" + token;
  586. }
  587. window.sessionStorage.clear();
  588. window.location.href = returnUrl;
  589. }
  590. /**
  591. * [renderTips 渲染常见问题]
  592. * @param {[type]} region [description]
  593. */
  594. function renderTips(region) {
  595. var tipStr = "<p>常见问题</p>";
  596. var defaultTip = null;
  597. var defaultRegion = '北京';
  598. var tipContent = tips.find(function(item, index) {
  599. if (item.region === defaultRegion) {
  600. defaultTip = item;
  601. }
  602. return item.region === region;
  603. });
  604. if (!tipContent) {
  605. tipContent = defaultTip; // 默认北京
  606. }
  607. tipContent = tipContent.tip;
  608. for (var list of tipContent) {
  609. tipStr += "<p>" + list.title + "</p>";
  610. if (list.content) {
  611. for (var tip of list.content) {
  612. tipStr += "<p>" + tip + "</p>"
  613. }
  614. }
  615. }
  616. $('.tips').html(tipStr);
  617. }
  618. /**
  619. * [Process 任务进度显示]
  620. */
  621. function Process(opt) {
  622. this.ele = opt.ele;
  623. this.rate = 0;
  624. this.afterStart = opt.afterStart;
  625. this.afterStop = opt.afterStop;
  626. this.timer = null;
  627. this.step = null;
  628. this._getInterval = function() {
  629. return Math.round((Math.random() * 100) + 300);
  630. };
  631. this._getStep = function() {
  632. return Math.round(Math.random() * 3);
  633. };
  634. }
  635. Process.prototype.start = function(rate) {
  636. this.rate = rate == undefined ? this.rate : rate;
  637. let _this = this;
  638. let interval = this._getInterval();
  639. this.timer = setInterval(function() {
  640. interval = _this._getInterval();
  641. _this.step = _this._getStep();
  642. _this.afterStart && _this.afterStart.call(_this);
  643. }, interval);
  644. }
  645. Process.prototype.stop = function(rate) {
  646. this.rate = rate == undefined ? this.rate : rate;
  647. clearInterval(this.timer);
  648. this.afterStop && this.afterStop();
  649. }
  650. var process = new Process({
  651. ele: $('.process'),
  652. interval: 1000,
  653. afterStart: function() {
  654. this.rate += this.step;
  655. if (this.rate >= 97) {
  656. this.rate = 99;
  657. this.stop(this.rate);
  658. }
  659. this.ele.text(this.rate + '%');
  660. window.sessionStorage.processRate = this.rate;
  661. },
  662. afterStop: function() {
  663. this.ele.text(this.rate + '%');
  664. window.sessionStorage.processRate = this.rate;
  665. }
  666. })
  667. //忘记密码文案
  668. function cituInfoData () {
  669. $.ajax({
  670. type:"POST",
  671. url: "/api/city/listinfo",
  672. data:{
  673. 'region': qs.name
  674. },
  675. dataType:'json',
  676. success: function (res) {
  677. console.log(res)
  678. if(res.errno == 0 && res.rst.city && res.rst.city.city){
  679. var data = res.rst.city.city;
  680. if(data.pwd_info){
  681. $(".dialog-forget").find("p").html(data.pwd_info);
  682. }else{
  683. $(".dialog-forget").find("p").html(`如果您忘记密码,需前往${qs.name}公积金官网重置密码.`)
  684. }
  685. }else{
  686. showMsg(res.err)
  687. }
  688. }
  689. });
  690. }