12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <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', 'putShare']),
- async init () {
- try {
- await this.getAppId()
- await this.getCode()
- await this.getUser({ code: this.code })
- this.showPage = true
- this.putShare()
- } 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>
|