This commit is contained in:
@@ -1,12 +1,31 @@
|
||||
import { PropsWithChildren } from 'react'
|
||||
import { useLaunch } from '@tarojs/taro'
|
||||
import Taro, { useLaunch } from '@tarojs/taro'
|
||||
import { login } from './utils/request'
|
||||
import './app.scss'
|
||||
|
||||
function App({ children }: PropsWithChildren<any>) {
|
||||
|
||||
useLaunch(() => {
|
||||
console.log('App launched.')
|
||||
useLaunch((options) => {
|
||||
console.log('App launched.', options)
|
||||
|
||||
// 捕获邀请码 (场景值或直接参数)
|
||||
const { query } = options
|
||||
if (query) {
|
||||
let inviteCode = ''
|
||||
if (query.scene) {
|
||||
// 扫码进入,scene 需要解码
|
||||
inviteCode = decodeURIComponent(query.scene)
|
||||
} else if (query.invite_code) {
|
||||
// 链接分享进入
|
||||
inviteCode = query.invite_code
|
||||
}
|
||||
|
||||
if (inviteCode && inviteCode !== 'undefined') {
|
||||
console.log('Captured invite code:', inviteCode)
|
||||
Taro.setStorageSync('invite_code', inviteCode)
|
||||
}
|
||||
}
|
||||
|
||||
// Auto login
|
||||
login().then(res => {
|
||||
console.log('Logged in as:', res?.nickname)
|
||||
|
||||
Reference in New Issue
Block a user