<template>
<!--  石泉单页面打包用-->
  <div class="loadingdata" :class="{'loaderror': show, 'loadsuccess': !show}">
    <!-- <h2 style="margin: 0" v-if="show">{{msg}}</h2> -->
    <h2 style="margin: 0" v-if="show">参数加载失败，请检查网络状态和服务状态...</h2>
  </div>
</template>

<script>
import co from 'co'
import Vue from "vue";

let saveGen = function* (self) {
  try {
    yield self.$login.login()
    yield self.$appdata.load()
  } catch (ret) {
    console.error('登录失败', ret)
  }
}
export default {
  title: '加载参数',
  data () {
    return {
      msg: '',
      show: false
    }
  },
  props: {
    componentName: {}
  },
  ready () {
    if (!this.componentName) {
      this.componentName = Vue.$login.getUrlParames('goto')
    }
    console.log('跳转页面', this.componentName)
    let gen = saveGen(this)
    co(gen).then(() => {
      this.$goto(this.componentName)
    }).catch(() => {
      this.$goto(this.componentName)
    })
  }
}
</script>
<style media="screen">
.loadingdata {
  position: fixed;
  background: #fff;
  opacity: 0.6;
  top: 0;
  width: 100%;
}

.loaderror {
  opacity: 1;
}

.loadsuccess {
  display: none;
}
</style>
