説明なし

fund_h5_api.js 21KB

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