<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>
|