timer.js 2.5 KB

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