LoanTrial.vue 3.3 KB
<template>
  <div>
    <div class="card" :model="test2">
      <div class="d-flex" style="margin-top: 6%;margin-left: 5%">贷款金额(元)<van-field v-model="test2.loanAmt" placeholder="请输入贷款金额" style="width: 50%;margin-top: -4%;margin-left: auto;"></van-field></div>
      <div class="d-flex" style="margin-top: 6%;margin-left: 5%">贷款期限(月)<van-field v-model="test2.loanTime" placeholder="请输入贷款期限" style="width: 50%;margin-top: -4%;margin-left: auto"></van-field></div>
      <div class="d-flex" style="margin-top: 6%;margin-left: 5%">计划月还款(元)<van-field v-model="test2.planMonthRepay" placeholder="请输入计划月还款" style="width: 50%;margin-top: -4%;margin-left: auto"></van-field></div>
      <div class="d-flex" style="margin-top: 6%;margin-left: 5%">贷款利率(%)<van-field v-model="test2.loanRate" placeholder="请输入贷款利率" style="width: 50%;margin-top: -4%;margin-left: auto;"></van-field></div>
      <div class="d-flex" style="margin-top: 6%;margin-left: 5%">贷款种类
        <a-select v-model:value="test2.loanType" :options="loanTypes" placeholder="请选择贷款种类" style="width: 50%;margin-top: -2%;margin-left: auto">
        </a-select>
      </div>
      <div class="d-flex" style="margin-top: 6%;margin-left: 5%;margin-bottom: 6%">还款方式<a-select :v-model="test2.repayType" @change="handleChoiceChange" placeholder="请选择还款方式" style="width: 50%;margin-top: -2%;margin-left: auto">
        <a-select-option v-for="(item, index) in choices" :key="index" :value="item">
          {{item}}
        </a-select-option>
      </a-select></div>
    </div>
    <div>
      <van-button style="width: 90%;margin-left: 5%;background-color: #1890ff;position: absolute;margin-top: 86%;height: 6%;border-radius: 5px;" type="primary" @click="countB">计算</van-button>
      <van-button style="width: 90%;margin-left: 5%;position: absolute;margin-top: 102%;height: 6%;border-radius: 5px;border-color: #1890ff"><span style="color: #1890ff">清除</span></van-button>
    </div>
  </div>
</template>

<script lang="ts">
import {Component, Vue} from "vue-property-decorator";

@Component({
  name: "LoanTrial"
})
export default class LoanTrial extends Vue {
  choices: string[] = ["利随本清","等额本金","等额本息"];
  test2: any = {
    loanAmt: "",
    loanTime: "",
    planMonthRepay : "",
    loanRate: "",
    loanType: undefined,
    repayType: "",
  };
  loanTypes: any[] = [
    {
      value : "有抵押",
      label : "有抵押",
    },{
      value : "无抵押",
      label : "无抵押",
    }
  ];
  handleChoiceChange(value:any) {
    this.test2.repayType = value;
  }
  countB() {
    let result = 0;
    result = parseInt(this.test2.loanAmt)*parseInt(this.test2.loanRate)/100*parseInt(this.test2.loanTime)/12;
    this.$router.push({
      name: "CountResult",
      params: {
        loanAmt: this.test2.loanAmt,
        loanTime: this.test2.loanTime,
        planMonthRepay: this.test2.planMonthRepay,
        loanRate: this.test2.loanRate,
        loanType: this.test2.loanType,
        repayType: this.test2.repayType,
        result: result.toString(),
      }
    })
  }
}
</script>

<style scoped lang="scss">
.card{
  position: absolute;
  background-color: #ffffff;
  width: 90%;
  margin-left: 5%;
  margin-top: -30%;
}
</style>