App.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <script setup>
  2. import { onHide, onLaunch, onShow } from '@dcloudio/uni-app'
  3. import { usePageAuth } from '@/hooks/usePageAuth'
  4. import { useUserStore } from '@/store'
  5. import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'
  6. import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'
  7. const mtpushModule = uni.requireNativePlugin('EL-MTPush')
  8. usePageAuth()
  9. const userStore = useUserStore()
  10. const isLoggedIn = computed(() => !!userStore.token)
  11. onLaunch(() => {
  12. console.log('App Launch')
  13. if (isLoggedIn.value) {
  14. userStore.getUserInfo()
  15. }
  16. if (uni.getSystemInfoSync().platform === 'ios') {
  17. mtpushModule.requestNotificationAuthorization((result) => {
  18. const status = result.status
  19. if (status < 2) {
  20. uni.showToast({
  21. icon: 'none',
  22. title: '您还没有打开通知权限',
  23. duration: 3000,
  24. })
  25. }
  26. })
  27. }
  28. // mtpushModule.setCountryCode("US");
  29. // mtpushModule.setTcpSSL(true)
  30. mtpushModule.setSiteName('Singapore')
  31. mtpushModule.setLoggerEnable(true)
  32. mtpushModule.initPushService()
  33. mtpushModule.addConnectEventListener((result) => {
  34. const connectEnable = result.connectEnable
  35. uni.$emit('connectStatusChange', connectEnable)
  36. })
  37. mtpushModule.addNotificationListener((result) => {
  38. const notificationEventType = result.notificationEventType
  39. const messageID = result.messageID
  40. const title = result.title
  41. const content = result.content
  42. const extras = result.extras
  43. uni.showToast({
  44. icon: 'none',
  45. title: JSON.stringify(result),
  46. duration: 3000,
  47. })
  48. })
  49. mtpushModule.addCustomMessageListener((result) => {
  50. const type = result.type
  51. const messageType = result.messageType
  52. const content = result.content
  53. uni.showToast({
  54. icon: 'none',
  55. title: JSON.stringify(result),
  56. duration: 3000,
  57. })
  58. })
  59. mtpushModule.addTagAliasListener((result) => {
  60. uni.showToast({
  61. icon: 'none',
  62. title: JSON.stringify(result),
  63. duration: 3000,
  64. })
  65. })
  66. if (uni.getSystemInfoSync().platform === 'ios') {
  67. mtpushModule.addLocalNotificationListener((result) => {
  68. const messageID = result.messageID
  69. const title = result.title
  70. const content = result.content
  71. const extras = result.extras
  72. uni.showToast({
  73. icon: 'none',
  74. title: JSON.stringify(result),
  75. duration: 3000,
  76. })
  77. })
  78. }
  79. // app更新
  80. checkUpdate()
  81. })
  82. onShow(() => {
  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>