App.uvue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. },
  26. // #endif
  27. onExit: function () {
  28. console.log('App Exit')
  29. },
  30. methods:{
  31. startTimer() {
  32. console.log("==========")
  33. timer = setInterval(() => {
  34. console.log('定时器运行');
  35. // 这里写你的定时任务
  36. }, 10000); // 每1000毫秒运行一次
  37. },
  38. stopTimer() {
  39. if (timer > 0) {
  40. clearInterval(timer);
  41. timer = 0;
  42. }
  43. }
  44. }
  45. }
  46. </script>
  47. <style lang="scss">
  48. @import './static/css/form.scss';
  49. /*每个页面公共css */
  50. /* 布局 */
  51. .uni-row {
  52. flex-direction: row;
  53. }
  54. .uni-column {
  55. flex-direction: column;
  56. }
  57. /* 文字颜色 */
  58. .text-primary {
  59. color: #333333;
  60. }
  61. .text-secondary {
  62. color: #666666;
  63. }
  64. .text-placeholder {
  65. color: #999999;
  66. }
  67. /* 背景色 */
  68. .bg-white {
  69. background-color: #ffffff;
  70. }
  71. .bg-gray {
  72. background-color: #f5f5f5;
  73. }
  74. /* 间距 */
  75. .padding-sm {
  76. padding: 15rpx;
  77. }
  78. .padding-md {
  79. padding: 20rpx;
  80. }
  81. .padding-lg {
  82. padding: 30rpx;
  83. }
  84. .margin-sm {
  85. margin: 15rpx;
  86. }
  87. .margin-md {
  88. margin: 20rpx;
  89. }
  90. .margin-lg {
  91. margin: 30rpx;
  92. }
  93. /* 圆角 */
  94. .radius-sm {
  95. border-radius: 4rpx;
  96. }
  97. .radius-md {
  98. border-radius: 8rpx;
  99. }
  100. .radius-lg {
  101. border-radius: 12rpx;
  102. }
  103. </style>
  104. <style>
  105. /* #ifdef APP-HARMONY */
  106. /* 鸿蒙平台全局样式 */
  107. .l-input__placeholder {
  108. font-weight: 400 !important;
  109. font-size: 28rpx !important;
  110. color: #999999 !important;
  111. }
  112. .l-textarea__placeholder {
  113. font-weight: 400 !important;
  114. font-size: 28rpx !important;
  115. color: #999999 !important;
  116. }
  117. .l-input__control {
  118. font-weight: 400 !important;
  119. font-size: 28rpx !important;
  120. color: #131415 !important;
  121. }
  122. .l-textarea__control {
  123. font-weight: 400 !important;
  124. font-size: 28rpx !important;
  125. color: #131415 !important;
  126. }
  127. .uni-input-input {
  128. font-weight: 400 !important;
  129. font-size: 28rpx !important;
  130. color: #131415 !important;
  131. }
  132. .uni-textarea-textarea {
  133. font-weight: 400 !important;
  134. font-size: 28rpx !important;
  135. color: #131415 !important;
  136. }
  137. .uni-input-placeholder,
  138. .uni-textarea-placeholder {
  139. font-weight: 400 !important;
  140. font-size: 28rpx !important;
  141. color: #999999 !important;
  142. }
  143. /* #endif */
  144. </style>