1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <template>
- <div id="app" v-if="showPage">
- <router-view/>
- </div>
- </template>
-
- <script>
- import './assets/css/reset.css'
- import { createNamespacedHelpers } from 'vuex'
- const { mapActions: mapIndexActions } = createNamespacedHelpers('user')
- const { mapState: mapUserState } = createNamespacedHelpers('user')
- export default {
- name: 'App',
- data () {
- return {
- showPage: false, // 不控制显示时机
- code: ''
- }
- },
- created () {
- this.init()
- },
- computed: {
- ...mapUserState({
- userInfo: item => item.userInfo,
- appid: item => item.appid
- })
- },
- methods: {
- ...mapIndexActions(['getAppId', 'getUser', 'getShare']),
- async init () {
- // this.showPage = true
- try {
- await this.getAppId()
- await this.getCode()
- await this.getUser({ code: this.code })
- this.showPage = true
- // this.getShare()
- } catch (err) {
- console.log(err)
- }
- },
- getCode () {
- return new Promise((resolve, reject) => {
- if (location.search && this.toolClass.UrlSearch(location.search).code) {
- this.code = this.toolClass.UrlSearch(location.search).code
- let oldCode = localStorage.getItem('code')
- if (this.code === oldCode) {
- localStorage.setItem('code', this.code)
- this.toolClass.getCode(this.appid)
- } else {
- localStorage.setItem('code', this.code)
- resolve()
- }
- } else {
- this.toolClass.getCode(this.appid)
- }
- })
- }
- }
- }
- </script>
-
- <style>
- #app {
- width: 100%;
- height: 100%;
- position: relative;
- overflow: hidden;
- }
- </style>
|