<template>
  <div class="main">
    <div class="container">
      <h3 class="title">测试平台</h3>
      <el-select v-model="namespace" placeholder="请选择环境" @change="handleSelectChange" style="width: 100%; margin-top: 20px">
        <el-option v-for="item in nsOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
      </el-select>
      <el-button type="primary" style="width: 100%; margin-top: 40px;" @click="login">登录</el-button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      namespace: '',
      nsOptions: [
        { label: 'dev1', value: 'dev1' },
        { label: 'pre', value: 'pre' },
        { label: 'qa', value: 'qa' },
        { label: 'qa2', value: 'qa2' },
        { label: 'qa3', value: 'qa3' },
        { label: 'test1', value: 'test1' },
        { label: 'xjfq', value: 'xjfq' },
        { label: 'xyqb', value: 'xyqb' },
        { label: 'vcc', value: 'vcc' },
        { label: 'vcc2', value: 'vcc2' },
        { label: 'vcc3', value: 'vcc3' }
      ]
    }
  },
  methods: {
    //   给store.state.env赋值
    handleSelectChange() {
      window.sessionStorage.setItem('env', this.namespace)
    },
    login() {
      if (this.namespace === '') {
        return this.$message.error('请先选择环境')
      }
      this.$router.push('/main')
    }
  }
}
</script>

<style lang="less" scoped>
.main {
  position: fixed;
  height: 100%;
  width: 100%;
  background-color: #2d3a4b;
  .container {
    height: 300px;
    width: 500px;
    margin: 200px auto;
    padding: 20px;
  }
}
.title {
  text-align: center;
  font-size: 26px;
  color: #ffffff;
}

.area {
  margin-top: 40px;
}
</style>
