App.uvue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <script lang="uts">
  2. let firstBackTime = 0
  3. let timer = 0;
  4. export default {
  5. onLaunch: function () {
  6. console.log('App Launch')
  7. uni.setStorageSync("notify_key", "0")
  8. },
  9. onShow: function () {
  10. console.log('App Show')
  11. },
  12. onHide: function () {
  13. console.log('App Hide')
  14. // this.startTimer();
  15. },
  16. // #ifdef APP-ANDROID
  17. onLastPageBackPress: function () {
  18. console.log('App LastPageBackPress')
  19. // #ifdef APP-ANDROID
  20. UTSAndroid.getUniActivity()?.moveTaskToBack(true)
  21. // #endif
  22. // #ifdef APP-HARMONY
  23. UTSHarmony.getUIAbilityContext().moveAbilityToBackground()
  24. // #endif
  25. // if (firstBackTime == 0) {
  26. // uni.showToast({
  27. // title: '再按一次退出应用',
  28. // position: 'bottom',
  29. // })
  30. // firstBackTime = Date.now()
  31. // setTimeout(() => {
  32. // firstBackTime = 0
  33. // }, 2000)
  34. // } else if (Date.now() - firstBackTime < 2000) {
  35. // firstBackTime = Date.now()
  36. // uni.exit()
  37. // }
  38. },
  39. // #endif
  40. onExit: function () {
  41. console.log('App Exit')
  42. },
  43. methods:{
  44. startTimer() {
  45. console.log("==========")
  46. timer = setInterval(() => {
  47. console.log('定时器运行');
  48. // 这里写你的定时任务
  49. }, 10000); // 每1000毫秒运行一次
  50. },
  51. stopTimer() {
  52. if (timer > 0) {
  53. clearInterval(timer);
  54. timer = 0;
  55. }
  56. }
  57. }
  58. }
  59. </script>
  60. <style lang="scss">
  61. @import './static/css/form.scss';
  62. /*每个页面公共css */
  63. /* 布局 */
  64. .uni-row {
  65. flex-direction: row;
  66. }
  67. .uni-column {
  68. flex-direction: column;
  69. }
  70. /* 文字颜色 */
  71. .text-primary {
  72. color: #333333;
  73. }
  74. .text-secondary {
  75. color: #666666;
  76. }
  77. .text-placeholder {
  78. color: #999999;
  79. }
  80. /* 背景色 */
  81. .bg-white {
  82. background-color: #ffffff;
  83. }
  84. .bg-gray {
  85. background-color: #f5f5f5;
  86. }
  87. /* 间距 */
  88. .padding-sm {
  89. padding: 15rpx;
  90. }
  91. .padding-md {
  92. padding: 20rpx;
  93. }
  94. .padding-lg {
  95. padding: 30rpx;
  96. }
  97. .margin-sm {
  98. margin: 15rpx;
  99. }
  100. .margin-md {
  101. margin: 20rpx;
  102. }
  103. .margin-lg {
  104. margin: 30rpx;
  105. }
  106. /* 圆角 */
  107. .radius-sm {
  108. border-radius: 4rpx;
  109. }
  110. .radius-md {
  111. border-radius: 8rpx;
  112. }
  113. .radius-lg {
  114. border-radius: 12rpx;
  115. }
  116. </style>
  117. <style>
  118. /* #ifdef APP-HARMONY */
  119. /* 鸿蒙平台全局样式 */
  120. .l-input__placeholder {
  121. font-weight: 400 !important;
  122. font-size: 28rpx !important;
  123. color: #999999 !important;
  124. }
  125. .l-textarea__placeholder {
  126. font-weight: 400 !important;
  127. font-size: 28rpx !important;
  128. color: #999999 !important;
  129. }
  130. .l-input__control {
  131. font-weight: 400 !important;
  132. font-size: 28rpx !important;
  133. color: #131415 !important;
  134. }
  135. .l-textarea__control {
  136. font-weight: 400 !important;
  137. font-size: 28rpx !important;
  138. color: #131415 !important;
  139. }
  140. .uni-input-input {
  141. font-weight: 400 !important;
  142. font-size: 28rpx !important;
  143. color: #131415 !important;
  144. }
  145. .uni-textarea-textarea {
  146. font-weight: 400 !important;
  147. font-size: 28rpx !important;
  148. color: #131415 !important;
  149. }
  150. .uni-input-placeholder,
  151. .uni-textarea-placeholder {
  152. font-weight: 400 !important;
  153. font-size: 28rpx !important;
  154. color: #999999 !important;
  155. }
  156. /* #endif */
  157. </style>