App.uvue 3.0 KB

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