12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <template>
- <page-loading class="index-page" :loading="loading">
- <index-logged v-if="isLogin" />
- <index-login v-else />
- </page-loading>
- </template>
- <script>
- import IndexLogged from '../components/Index/Logged'
- import IndexLogin from '../components/Index/Login'
- import PageLoading from '../components/PageLoading'
- export default {
- name: 'Index',
- components: { PageLoading, IndexLogged, IndexLogin },
- data() {
- return {
- isLogin: false,
- loading: true
- }
- },
- computed: {},
- methods: {
- async authorize() {
- this.$loading('小程序授权中...')
- await this.$api.user.authorize().then(async res => {
- this.$hideLoading()
- await this.$store.dispatch('user/authorize')
- })
- }
- },
- async onShow() {
- if (!this.$api.user.isAuthorize()) {
- await this.authorize()
- }
- this.isLogin = this.$api.user.isLogin()
- setTimeout(() => {
- this.loading = false
- }, 500)
- }
- }
- </script>
- <style lang="scss" scoped>
- .index-page {
- }
- </style>
|