App.uvue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <script lang="uts">
  2. export default {
  3. onLaunch: function (options: OnLaunchOptions) {
  4. console.log('App Launch')
  5. console.log('启动参数:', options)
  6. uni.onPushMessage((res) => {
  7. console.log("收到推送消息:",res) //监听推送消息
  8. if(res.type =='receive'){
  9. uni.setAppBadgeNumber(0);
  10. // 安全取出推送数据并强转类型
  11. const pushData = res.data as UTSJSONObject
  12. const title = pushData["title"] as string
  13. const content = pushData["content"] as string
  14. if (title!=null && content!=null) {
  15. uni.createPushMessage({
  16. title: title,
  17. content: content,
  18. when: Date.now() + 10000,
  19. icon: "/static/login/2.png",
  20. sound: "system",
  21. success: (res) => {
  22. console.log('创建推送消息成功', res);
  23. },
  24. fail: (err) => {
  25. console.error('创建推送消息失败', err);
  26. }
  27. });
  28. }
  29. }
  30. })
  31. uni.setStorageSync("notify_key", "0")
  32. },
  33. onShow: function (options: OnShowOptions) {
  34. console.log('App Show')
  35. },
  36. onHide: function () {
  37. console.log('App Hide')
  38. // this.startTimer();
  39. },
  40. // #ifdef APP-ANDROID
  41. onLastPageBackPress: function () {
  42. console.log('App LastPageBackPress')
  43. // #ifdef APP-ANDROID
  44. UTSAndroid.getUniActivity()?.moveTaskToBack(true)
  45. // #endif
  46. // #ifdef APP-HARMONY
  47. UTSHarmony.getUIAbilityContext().moveAbilityToBackground()
  48. // #endif
  49. },
  50. // #endif
  51. onExit: function () {
  52. console.log('App Exit')
  53. },
  54. methods:{
  55. }
  56. }
  57. </script>
  58. <style lang="scss">
  59. @import './static/css/form.scss';
  60. /*每个页面公共css */
  61. /* 布局 */
  62. .uni-row {
  63. flex-direction: row;
  64. }
  65. .uni-column {
  66. flex-direction: column;
  67. }
  68. /* 文字颜色 */
  69. .text-primary {
  70. color: #333333;
  71. }
  72. .text-secondary {
  73. color: #666666;
  74. }
  75. .text-placeholder {
  76. color: #999999;
  77. }
  78. /* 背景色 */
  79. .bg-white {
  80. background-color: #ffffff;
  81. }
  82. .bg-gray {
  83. background-color: #f5f5f5;
  84. }
  85. /* 间距 */
  86. .padding-sm {
  87. padding: 15rpx;
  88. }
  89. .padding-md {
  90. padding: 20rpx;
  91. }
  92. .padding-lg {
  93. padding: 30rpx;
  94. }
  95. .margin-sm {
  96. margin: 15rpx;
  97. }
  98. .margin-md {
  99. margin: 20rpx;
  100. }
  101. .margin-lg {
  102. margin: 30rpx;
  103. }
  104. /* 圆角 */
  105. .radius-sm {
  106. border-radius: 4rpx;
  107. }
  108. .radius-md {
  109. border-radius: 8rpx;
  110. }
  111. .radius-lg {
  112. border-radius: 12rpx;
  113. }
  114. </style>
  115. <style>
  116. /* #ifdef APP-HARMONY */
  117. /* 鸿蒙平台全局样式 */
  118. .l-input__placeholder {
  119. font-weight: 400 !important;
  120. font-size: 28rpx !important;
  121. color: #999999 !important;
  122. }
  123. .l-textarea__placeholder {
  124. font-weight: 400 !important;
  125. font-size: 28rpx !important;
  126. color: #999999 !important;
  127. }
  128. .l-input__control {
  129. font-weight: 400 !important;
  130. font-size: 28rpx !important;
  131. color: #131415 !important;
  132. }
  133. .l-textarea__control {
  134. font-weight: 400 !important;
  135. font-size: 28rpx !important;
  136. color: #131415 !important;
  137. }
  138. .uni-input-input {
  139. font-weight: 400 !important;
  140. font-size: 28rpx !important;
  141. color: #131415 !important;
  142. }
  143. .uni-textarea-textarea {
  144. font-weight: 400 !important;
  145. font-size: 28rpx !important;
  146. color: #131415 !important;
  147. }
  148. .uni-input-placeholder,
  149. .uni-textarea-placeholder {
  150. font-weight: 400 !important;
  151. font-size: 28rpx !important;
  152. color: #999999 !important;
  153. }
  154. /* #endif */
  155. </style>