timer.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. parent.postMessage(
  67. {
  68. type: 'exit',
  69. },
  70. '*',
  71. );
  72. uni.postMessage({
  73. data: {
  74. type: 'exit'
  75. }
  76. });
  77. quit();
  78. } else {
  79. $.toast(res.msg, 'text');
  80. }
  81. },
  82. });
  83. }
  84. function residueTimeStamp(value) {
  85. let theTime = value;//秒
  86. let middle = 0;//分
  87. let hour = 0;//小时
  88. if (theTime > 59) {
  89. middle = parseInt(theTime / 60);
  90. theTime = parseInt(theTime % 60);
  91. }
  92. if (middle > 59) {
  93. hour = parseInt(middle / 60);
  94. middle = parseInt(middle % 60);
  95. }
  96. theTime < 10 ? theTime = '0' + theTime : theTime = theTime
  97. middle < 10 ? middle = '0' + middle : middle = middle
  98. hour < 10 ? hour = '0' + hour : hour = hour
  99. return hour + ':' + middle + ':' + theTime
  100. }
  101. function handleclose() {
  102. $.ajax({
  103. url: baseUrl + '/api/resources/yearMember/closeRemind?userCardId=' + userCardId,
  104. headers: {
  105. Authorization: token,
  106. },
  107. type: 'get',
  108. dataType: 'json',
  109. async: false,
  110. success: function (res) {
  111. if (res.status === 0) {
  112. clearInterval(residueTimer);
  113. $("#countView").hide();
  114. } else {
  115. $.toast(res.msg, 'text');
  116. }
  117. },
  118. });
  119. }
  120. $.toast.prototype.defaults.duration = 4000