<template>
    <view class=""><tui-skeleton v-if="true" :loadingType="3" :isLoading="true"></tui-skeleton></view>
</template>

<script>
import { mapActions } from 'vuex'
import shareEntry from './mixins/share-entry.js'

// 页面初始化
export default {
    mixins: [shareEntry],
    data() {
        return {
            scene: '',
            state_str: ''
        }
    },
    onLoad(options) {
        this.scene = options.scene
        this.state_str = options.state_str
    },
    onShow() {
        this.init()
    },
    methods: {
        ...mapActions('user', ['wxAutoLogin']),

        // 初始化页面数据
        async init() {
            try {
                await this.wxAutoLogin()
            } catch (e) {
                console.log('初始化用户信息时出现了错误')
            } finally {
                this.redirectToEntry()
            }
        },

        // 跳转入口页面
        redirectToEntry() {
            if (this.scene) {
                // 处理分享信息 二维码
                this.shareHandle(this.scene, 'scene')
            } else if (this.state_str) {
                this.shareHandle(this.state_str, 'state_str')
            } else {
                // 默认跳转首页
                this.$router.switchTab('home')
            }
        }
    }
}
</script>
