timer.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // function handleQuit() {
  2. // if (userCardType === 1) {
  3. // $.actions({
  4. // actions: [{
  5. // text: "退出",
  6. // onClick: function () {
  7. // decodeWoker.postMessage('close');
  8. // decodeWoker.terminate();
  9. // quit();
  10. // }
  11. // }, {
  12. // text: "退出并下机",
  13. // onClick: function () {
  14. // downline();
  15. // }
  16. // }]
  17. // });
  18. // } else {
  19. // decodeWoker.postMessage('close');
  20. // decodeWoker.terminate();
  21. // quit();
  22. // }
  23. // }
  24. function handleQuit(action = "quit") {
  25. switch (action) {
  26. case 'quit':
  27. return exit();
  28. case 'dormant':
  29. return downline();
  30. }
  31. }
  32. // 退出
  33. function exit() {
  34. decodeWoker.postMessage('close');
  35. decodeWoker.terminate();
  36. quit();
  37. }
  38. // 退出并下机
  39. function downline() {
  40. $.ajax({
  41. url: baseUrl + '/api/resources/yearMember/downline?userCardId=' + userCardId,
  42. headers: {
  43. Authorization: token
  44. },
  45. type: 'get',
  46. dataType: 'json',
  47. success: function (res) {
  48. if (res.status === 0) {
  49. decodeWoker.postMessage('close');
  50. decodeWoker.terminate();
  51. deleteDB(db, storeName, userCardId)
  52. quit();
  53. } else {
  54. $.toast(res.msg, 'text');
  55. }
  56. },
  57. });
  58. }
  59. function residueTimeStamp(value) {
  60. let theTime = value;//秒
  61. let middle = 0;//分
  62. let hour = 0;//小时
  63. if (theTime > 59) {
  64. middle = parseInt(theTime / 60);
  65. theTime = parseInt(theTime % 60);
  66. }
  67. if (middle > 59) {
  68. hour = parseInt(middle / 60);
  69. middle = parseInt(middle % 60);
  70. }
  71. theTime < 10 ? theTime = '0' + theTime : theTime = theTime
  72. middle < 10 ? middle = '0' + middle : middle = middle
  73. hour < 10 ? hour = '0' + hour : hour = hour
  74. return hour + ':' + middle + ':' + theTime
  75. }
  76. function handleclose() {
  77. $.ajax({
  78. url: baseUrl + '/api/resources/yearMember/closeRemind?userCardId=' + userCardId,
  79. headers: {
  80. Authorization: token,
  81. },
  82. type: 'get',
  83. dataType: 'json',
  84. async: false,
  85. success: function (res) {
  86. if (res.status === 0) {
  87. clearInterval(residueTimer);
  88. $("#countView").hide();
  89. } else {
  90. $.toast(res.msg, 'text');
  91. }
  92. },
  93. });
  94. }
  95. $.toast.prototype.defaults.duration = 4000