<template>
  <div class="tabs-body">
		<div style="margin:50px;" v-if="!chenzhen.isLogin">
      <el-form :model="ruleForm2" status-icon  ref="ruleForm2"  class="demo-ruleForm">
        <el-form-item prop="pass">
          <el-input type="text" placeholder="登录名" v-model="ruleForm2.account" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item  prop="checkPass">
          <el-input type="password" placeholder="密码" v-model="ruleForm2.passwd" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm()">登录</el-button>
        </el-form-item>
      </el-form>  
    </div>
    <baozheng v-if="chenzhen.isLogin&&user.userInfo.type==3"/>   
    <chenzheng v-if="chenzhen.isLogin&&user.userInfo.type==1"/>
  </div>  
</template>

<script>
import { mapGetters, mapState, mapActions } from 'vuex'
import baozheng from './baozheng'
import chenzheng from './chenzheng'
import { mainPanel } from '@/utils/common'
export default{
    data(){
      return {
        activeName:'second',
        ruleForm2:{
          account:'13521750803',
          passwd:'baozheng0618'
        }
      }    
    },
    components: {
        baozheng,
        chenzheng,
    },
    computed: {
      ...mapState([
        'chenzhen',
        'user',
      ])
    },
    mounted() {
      this.init()
      // if(this.chenzhen.isLogin&&this.user.userInfo.type==1){
      //   this.init()
      // }
    },
    methods: {
      ...mapActions('chenzhen',[
          'login',
          'init'
      ]),
      submitForm(){
        let parm = this.ruleForm2
        this.login(parm).then(()=>{
          this.$message({
            message: '登录成功！',
            type: 'success'
          });
          this.isLogin = true
        }).catch((error)=>{
           this.$message.error(error);
        })
      },
      handleClick(){
        console.log()
        console.log(43434)
      }
    }
}
</script>

<style lang="stylus" scoped>
.tabs-body
  height:700px;
  width:100%;
  .tool-body
    width:100%;
    height:729px;
    overflow-y: auto;
</style>