<template>
  <div>
    <div class="login">
      <van-form @submit="onSubmit1" style="width: 100%;">
        <van-field v-model="username" name="username" label="用户名" placeholder="请输入用户名"
          :rules="[{ required: true, message: '请输入用户名' }]" />
        <!-- <van-field
          v-model="password"
          type="password"
          name="password"
          label="密码"
          placeholder="请输入密码"
          :rules="[{ required: true, message: '请输入密码' }]"
        /> -->
        <!-- <div class="agent-box">
          <div class="left-label">应用入口：</div>
          <el-select v-model="agentValue" placeholder="请选择" size="small">
            <el-option
                    v-for="item in agentOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
            </el-option>
          </el-select>
        </div> -->
        <div style="margin: 16px;">
          <van-button round block type="info" native-type="submit">
            虚拟登录
          </van-button>
        </div>
      </van-form>
    </div>
  </div>
</template>
<script lang="ts">
import { Component, Vue, Watch, Prop } from "vue-property-decorator";
import { initGuidInfo, doWecomLogin } from '@/utils/wecomLogin.ts';


@Component
export default class extends Vue {
  username: string = "";
  password: string = "";
  wxUserId: string = "";
  agentValue: string = "hbs";
  agentOptions: any = [{
    value: 'hbs',
    label: '好邦手'
  }, {
    value: 'ssb',
    label: '随身邦'
  }, {
    value: 'stoneLikePaint',
    label: '服务商随身邦'
  }, {
    value: 'goldShop',
    label: '金牌店随身邦'
  }]
  async created() {
    let that = this;
    that.wxUserId = that.$route.query.wxUserId as string;
  }
  onSubmit1() {
    window.localStorage.clear();
    window.localStorage.setItem('loginMode', 'codeLogin');
    initGuidInfo();
    doWecomLogin('QWert!@345', this.username)
      .then(() => {
        debugger
        this.$router.push('/');
        console.log(`模拟登录成功`);
      }).catch((err) => {
        console.log("err=", err);
      })
  }
}
</script>
<style lang="scss" scoped>
.login {
  width: 100%;
  padding-right: 15px;
  box-sizing: border-box;
}

.agent-box {
  flex-direction: row;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
  padding: 10px 16px;
  overflow: hidden;
  color: #323233;
  font-size: 14px;
  line-height: 24px;
  background-color: #fff;

  .left-label {
    -webkit-box-flex: 0;
    -webkit-flex: none;
    flex: none;
    box-sizing: border-box;
    width: 6.2em;
    margin-right: 12px;
    color: #646566;
    text-align: left;
    word-wrap: break-word;
  }
}
</style>
