<!--
 * @Author: wangliang
 * @date 20220727
-->
<template>
  <div>
    <div class="rarle">
      <div style="width:100%;height: calc(35vh);background: linear-gradient(90deg, #76befa 0%, #3672f1 99%);">
        <tatle-bar :tatle="titleName" :tatleflag="titleflag" >
        </tatle-bar>
      </div>
      <div class="card">
        <div style="margin-top: 4%; margin-left: 20px"><span style="color: #9e9e9e">贷款利息(元)</span><span v-if="flag" style="margin-left: 130px; color: #3672F1" @click="toSeeRepayPlan">查看还款计划</span></div>
        <div style="margin-top: 0px; margin-left: 20px"><span style="color: #FFA121;font-size: 24px;font-family: '思源黑体 Bold', '思源黑体 Regular', '思源黑体';
    font-weight: 700;
    font-style: normal;">{{result}}</span></div>
        <div style="margin-top: 4%; margin-left: 20px"><span style="color: #9e9e9e">本息合计(元)</span></div>
        <div style="margin-top: 0px; margin-left: 20px"><span style="color: #FFA121;font-size: 24px;font-family: '思源黑体 Bold', '思源黑体 Regular', '思源黑体';
    font-weight: 700;
    font-style: normal;">{{resultPlus}}</span></div>
      </div>
      <div style="margin-top: 50px; margin-left: 30px; margin-right: 30px">
        <van-row>
          <van-col span="12" style="color: #999999">贷款金额(元)</van-col>
          <van-col span="12" style="text-align: right">{{loanAmt}}</van-col>
        </van-row>
      </div>
      <div style="margin-top: 20px; margin-left: 30px; margin-right: 30px">
        <van-row>
          <van-col span="12" style="color: #999999">贷款期限(月)</van-col>
          <van-col span="12" style="text-align: right">{{loanTime}}</van-col>
        </van-row>
      </div>
      <div style="margin-top: 20px; margin-left: 30px; margin-right: 30px">
        <van-row>
          <van-col span="12" style="color: #999999">贷款利率(%)</van-col>
          <van-col span="12" style="text-align: right">{{loanRate}}</van-col>
        </van-row>
      </div>
<!--      <div style="margin-top: 20px; margin-left: 30px; margin-right: 30px">-->
<!--        <van-row>-->
<!--          <van-col span="12" style="color: #999999">计划月还款</van-col>-->
<!--          <van-col span="12" style="text-align: right">{{planMonthRepay}}</van-col>-->
<!--        </van-row>-->
<!--      </div>-->
<!--      <div style="margin-top: 20px; margin-left: 30px; margin-right: 30px">-->
<!--        <van-row>-->
<!--          <van-col span="12" style="color: #999999">贷款种类</van-col>-->
<!--          <van-col span="12" style="text-align: right">{{loanType}}</van-col>-->
<!--        </van-row>-->
<!--      </div>-->
      <div style="margin-top: 20px; margin-left: 30px; margin-right: 30px">
        <van-row>
          <van-col span="12" style="color: #999999">还款方式</van-col>
          <van-col span="12" style="text-align: right">{{repayType}}</van-col>
        </van-row>
      </div>
      <van-button style="width: 90%;margin-left: 5%;background-color: #1890ff;position: absolute;margin-top: 36%;height: 6%;border-radius: 5px;" type="primary" @click="returnCount">确定</van-button>
      <van-button style="width: 90%;margin-left: 5%;position: absolute;margin-top: 50%;height: 6%;border-radius: 5px;border-color: #1890ff" @click="returnCount"><span style="color: #1890ff">重新计算</span></van-button>
    </div>
  </div>
</template>

<script lang="ts">
import {Component, Prop, Vue} from "vue-property-decorator";
import router from "@/router";
import VueRouter, { Route, RouteConfig } from "vue-router";
Vue.use(VueRouter);
@Component({
  name: "CountResult",
})
export default class CountResult extends Vue{
  flag=true;
  resultPlus:any="";
  result:any="";
  loanAmt:any="";
  loanRate:any="";
  planMonthRepay = "";
  loanTime:any="";
  repayType:any = "";
  loanType = "";
  titleName="试算结果";
  titleflag=true;
  mounted() {
    this.result = this.$route.params.result;
    this.loanAmt = this.$route.params.loanAmt;
    this.resultPlus = (parseInt(this.result) + parseInt(this.loanAmt)).toString();
    this.loanRate = this.$route.params.loanRate;
    this.loanTime = this.$route.params.loanTime;
    this.repayType = this.$route.params.repayType;
    //this.planMonthRepay = this.$route.params.planMonthRepay;
    //this.loanType = this.$route.params.loanType;
    if(this.repayType=="利随本清"){
      this.flag=false;
    }
    console.log("@@@@@@@@@@@@@@"+this.$route.redirectedFrom);
  }
  //router.beforeEach((to,from,next) => {});
  //beforeRouteLeave(to:any,from,next){}
  created() {
    this.result = window.localStorage.getItem("result");
    this.loanAmt= window.localStorage.getItem("loanAmt");
    this.resultPlus=window.localStorage.getItem("resultPlus");
    this.loanRate=window.localStorage.getItem("loanRate");
    this.loanTime=window.localStorage.getItem("loanTime");
    this.repayType=window.localStorage.getItem("repayType");
  }
  returnCount() {
    this.$router.back();
  }
  toSeeRepayPlan() {
    window.localStorage.setItem("result",this.result);
    window.localStorage.setItem("loanAmt",this.loanAmt);
    window.localStorage.setItem("resultPlus",this.resultPlus);
    window.localStorage.setItem("loanRate",this.loanRate);
    window.localStorage.setItem("loanTime",this.loanTime);
    window.localStorage.setItem("repayType",this.repayType);
    this.$router.push({
      name: "RepayPlan",
    });
  }
}
</script>

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