App.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <script setup>
  2. import { onHide, onLaunch, onShow } from '@dcloudio/uni-app'
  3. import { usePageAuth } from '@/hooks/usePageAuth'
  4. import { t } from '@/locale'
  5. import { useUserStore } from '@/store'
  6. import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'
  7. import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'
  8. const mtpushModule = uni.requireNativePlugin('EL-MTPush')
  9. usePageAuth()
  10. const userStore = useUserStore()
  11. const isLoggedIn = computed(() => !!userStore.token)
  12. onLaunch(() => {
  13. console.log('App Launch')
  14. if (isLoggedIn.value) {
  15. userStore.getUserInfo()
  16. }
  17. if (uni.getSystemInfoSync().platform === 'ios') {
  18. mtpushModule.requestNotificationAuthorization((result) => {
  19. const status = result.status
  20. if (status < 2) {
  21. uni.showToast({
  22. icon: 'none',
  23. title: t('app.notificationPermission'),
  24. duration: 3000,
  25. })
  26. }
  27. })
  28. }
  29. // mtpushModule.setCountryCode("US");
  30. // mtpushModule.setTcpSSL(true)
  31. mtpushModule.setSiteName('Singapore')
  32. mtpushModule.setLoggerEnable(true)
  33. mtpushModule.initPushService()
  34. mtpushModule.addConnectEventListener((result) => {
  35. const connectEnable = result.connectEnable
  36. uni.$emit('connectStatusChange', connectEnable)
  37. })
  38. // mtpushModule.addNotificationListener((result) => {
  39. // const notificationEventType = result.notificationEventType
  40. // const messageID = result.messageID
  41. // const title = result.title
  42. // const content = result.content
  43. // const extras = result.extras
  44. // uni.showToast({
  45. // icon: 'none',
  46. // title: JSON.stringify(result),
  47. // duration: 3000,
  48. // })
  49. // })
  50. // mtpushModule.addCustomMessageListener((result) => {
  51. // const type = result.type
  52. // const messageType = result.messageType
  53. // const content = result.content
  54. // uni.showToast({
  55. // icon: 'none',
  56. // title: JSON.stringify(result),
  57. // duration: 3000,
  58. // })
  59. // })
  60. // mtpushModule.addTagAliasListener((result) => {
  61. // uni.showToast({
  62. // icon: 'none',
  63. // title: JSON.stringify(result),
  64. // duration: 3000,
  65. // })
  66. // })
  67. // if (uni.getSystemInfoSync().platform === 'ios') {
  68. // mtpushModule.addLocalNotificationListener((result) => {
  69. // const messageID = result.messageID
  70. // const title = result.title
  71. // const content = result.content
  72. // const extras = result.extras
  73. // uni.showToast({
  74. // icon: 'none',
  75. // title: JSON.stringify(result),
  76. // duration: 3000,
  77. // })
  78. // })
  79. // }
  80. })
  81. onShow(() => {
  82. checkUpdate()
  83. console.log('App Show')
  84. })
  85. onHide(() => {
  86. console.log('App Hide')
  87. })
  88. </script>
  89. <style lang="scss">
  90. button::after {
  91. border: none;
  92. }
  93. swiper,
  94. scroll-view {
  95. flex: 1;
  96. height: 100%;
  97. overflow: hidden;
  98. }
  99. image {
  100. width: 100%;
  101. height: 100%;
  102. vertical-align: middle;
  103. }
  104. // ==================== 认证页面公共样式 ====================
  105. // 包含登录、注册、忘记密码等页面的通用样式
  106. // 背景图片区域样式
  107. .auth-bg-section {
  108. background-image: url('/static/login-bg.png');
  109. background-size: cover;
  110. background-position: top;
  111. background-repeat: no-repeat;
  112. min-height: 28vh; /* 占据上半部分屏幕 */
  113. }
  114. // 输入框样式 - 使用特殊化命名避免冲突
  115. :deep(.bandhu-auth-input-field) {
  116. box-sizing: border-box;
  117. height: 72rpx !important;
  118. background: #ffffff !important;
  119. border-radius: 8rpx !important;
  120. border: 2rpx solid rgba(166, 166, 166, 0.65) !important;
  121. padding: 0 24rpx !important;
  122. font-size: 28rpx !important;
  123. display: flex !important;
  124. align-items: center !important;
  125. &.is-disabled {
  126. background: #efefef !important;
  127. .wd-input__inner {
  128. color: #000000 !important;
  129. }
  130. }
  131. }
  132. // 主要按钮样式
  133. :deep(.bandhu-auth-primary-btn) {
  134. box-sizing: border-box;
  135. height: 88rpx !important;
  136. border-radius: 44rpx !important;
  137. font-size: 32rpx !important;
  138. font-weight: bold !important;
  139. }
  140. // 次要按钮样式(如获取验证码按钮)
  141. :deep(.bandhu-auth-secondary-btn) {
  142. box-sizing: border-box;
  143. width: 160rpx !important;
  144. height: 72rpx !important;
  145. border-radius: 12rpx !important;
  146. font-size: 24rpx !important;
  147. }
  148. </style>