App.vue 4.3 KB

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