Nav apraksta

fund_h5_api.js 28KB

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