App.vue 3.9 KB

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