cloudroam
7 天以前 c31a8def0ac90d86b8e8e345441bd28002a9ef2f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<script setup lang="ts">
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
import { useUserStore } from '@/store/user'
const userStore = useUserStore()
onLaunch(async (options: any) => {
 
  // 初始化用户状态
  userStore.initLoginState()
 
  const query = options.q ? decodeURIComponent(options.q) : ''
  const querydto: Record<string, string> = {}
 
  if (query) {
    try {
      const keyvalues = query.split("?")[1].split("&")
      for (const item of keyvalues) {
        const tarr = item.split("=")
        querydto[tarr[0]] = tarr[1]
      }
    } catch (e) {
      console.error('error', e)
    }
  }
 
  try {
    if (!querydto.partnerUserId && options.query?.scene) {
      // 特殊小程序二维码扫码跳转
      const keyvalues = decodeURIComponent(options.query.scene).split("&")
      for (const item of keyvalues) {
        const tarr = item.split("=")
        querydto[tarr[0]] = tarr[1]
      }
    }
  } catch (e) {
    console.error('error2', e)
  }
 
  console.log('app query222', options, query, '\n@@\n ', querydto)
 
  console.warn('当前组件仅支持 uni_modules 目录结构 ,请升级 HBuilderX 到 3.1.0 版本以上!')
  console.log('App Launch')
 
  uni.getSystemSetting({
    success: (e: any) => {
      try {
        const custom = uni.getMenuButtonBoundingClientRect()
        uni.setStorageSync('StatusBar', e.statusBarHeight)
        uni.setStorageSync('CustomBar', (custom.bottom + custom.top - e.statusBarHeight))
       
        console.log('custom.bottom', custom.bottom)
        console.log('custom.top',  custom.top)
        console.log('StatusBar', e.statusBarHeight)
        console.log('CustomBar', (custom.bottom + custom.top - e.statusBarHeight))
      } catch (e) {
        console.error('e', e)
      }
    }
  })
 
  // 初始化主题为 light(也可以切换成 dark)
  uni.setStorageSync('theme', 'light')
})
 
onShow(() => {
    console.log('App Show')
})
 
onHide(() => {
    console.log('App Hide')
})
</script>
 
<style lang="scss">
@import "uview-plus/index.scss";
</style>