暫無描述

fund_h5_api.js 26KB

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