timer.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. $.confirm({
  30. title: '提示',
  31. text: '确定退出云手机并下机',
  32. onOK: function () {
  33. //点击确认
  34. downline();
  35. },
  36. });
  37. // return
  38. }
  39. }
  40. // 退出
  41. function exit() {
  42. decodeWoker.postMessage('close');
  43. decodeWoker.terminate();
  44. quit();
  45. }
  46. // 退出并下机
  47. function downline() {
  48. $.ajax({
  49. url: baseUrl + '/api/resources/yearMember/downline?userCardId=' + userCardId,
  50. headers: {
  51. Authorization: token
  52. },
  53. type: 'get',
  54. dataType: 'json',
  55. success: function (res) {
  56. if (res.status === 0) {
  57. decodeWoker.postMessage('close');
  58. decodeWoker.terminate();
  59. deleteDB(db, storeName, userCardId)
  60. quit();
  61. } else {
  62. $.toast(res.msg, 'text');
  63. }
  64. },
  65. });
  66. }
  67. function residueTimeStamp(value) {
  68. let theTime = value;//秒
  69. let middle = 0;//分
  70. let hour = 0;//小时
  71. if (theTime > 59) {
  72. middle = parseInt(theTime / 60);
  73. theTime = parseInt(theTime % 60);
  74. }
  75. if (middle > 59) {
  76. hour = parseInt(middle / 60);
  77. middle = parseInt(middle % 60);
  78. }
  79. theTime < 10 ? theTime = '0' + theTime : theTime = theTime
  80. middle < 10 ? middle = '0' + middle : middle = middle
  81. hour < 10 ? hour = '0' + hour : hour = hour
  82. return hour + ':' + middle + ':' + theTime
  83. }
  84. function handleclose() {
  85. $.ajax({
  86. url: baseUrl + '/api/resources/yearMember/closeRemind?userCardId=' + userCardId,
  87. headers: {
  88. Authorization: token,
  89. },
  90. type: 'get',
  91. dataType: 'json',
  92. async: false,
  93. success: function (res) {
  94. if (res.status === 0) {
  95. clearInterval(residueTimer);
  96. $("#countView").hide();
  97. } else {
  98. $.toast(res.msg, 'text');
  99. }
  100. },
  101. });
  102. }
  103. $.toast.prototype.defaults.duration = 4000