BorrowUsage.vue 4.04 KB
<template>
  <transition name="picker-fade">
    <v-layout v-show="componentDisplay" column justify-center align-center id="BorrowUsage">
      <v-flex>
        <div class="label">借款用途</div>
        <v-card flat class="ButtonBlock">
          <div class="ButtonContainer">
            <v-btn 
              depressed
              v-for="(item, index) in buttons" 
              :key="index"
              :class="chosenBtnIndex === index ? 'isChosen' : ''"
              @click="usageChosen(item, index)"
              class="BorrowUsageBtn">
              {{item.text}}
            </v-btn>
          </div>
        </v-card>
        <div class="label">补充说明(不超过300字)</div>
        <v-card flat class="ExplanationBlock" >
          <textarea 
            v-model="form.explanation"
            name="ExplanationTextarea" 
            placeholder="具体说明您的借贷用途或者证明您的还款能力" 
            maxlength="300"
            id="ExplanationTextarea" cols="30" rows="5"></textarea>
        </v-card>
        <div class="label">图片说明(不超过20张)</div>
        <v-card flat class="ImgBlock">
          <ImgUploader :limit="9"/>
        </v-card>
        <div class="ConfirmButtonBlock">
          <v-btn depressed id="ConfirmButton" @click="confirm">确  定</v-btn>
        </div>
      </v-flex>
    </v-layout>
  </transition>
</template>

<script>
import ImgUploader from "@/components/ImgUploader"
export default {
  name: 'BorrowUsage',
  data: () => ({
    componentDisplay: false,
    buttons: [{text: '个体经营'}, {text: '消费'},{text: '助学'},
      {text: '创业'},{text: '租房'},{text: '旅游'},
      {text: '装修'},{text: '医疗'},{text: '其他'},
    ],
    chosenBtnIndex: 8,
    form: {
      type: '其他',
      explanation: ''
    }
  }),
  watch: {
    display: function (val, oldVal) {
      if (val) {
        this.componentDisplay = true
      }
    },
    componentDisplay: function (val, oldVal) {
      if (!val) {
        this.$emit('close')
      }
    }
  },
  props: {
    display: {
      type: Boolean,
      default: true
    }
  },
  components: {
    ImgUploader
  },
  methods: {
    usageChosen(item, index) {
      this.chosenBtnIndex = index
      this.form.type = item.text
    },
    confirm() {
      this.$emit('change', this.form)
      this.componentDisplay = false
    }
  }
}
</script>

<style lang="scss" scoped>
  #BorrowUsage {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background-color: $light-background-grey;
    z-index: 1000;

    .label {
      width: 100vw;
      height: 2.3rem;
      line-height: 2.3rem;
      font-size: 0.75rem;
      color: #B9B9BA;
      padding-left: 0.9rem;
      box-sizing: border-box;
    }

    .ButtonBlock {
      width: 100vw;
      background-color: #fff;
      padding: 0 1.3rem;

      .ButtonContainer {
        display: flex;
        width: 100%;
        justify-content: space-around;
        align-items: center;
        flex-direction: row;
        flex-wrap: wrap;

        .BorrowUsageBtn {
          width: 6.2rem;
          height: 2rem;
          margin: 0.6rem 0;
          color: #fff;
          background-color: #ccc;

          &.isChosen {
            background-image: linear-gradient(-229deg, #DAB269 37%, #E7C78C 87%);
          }
        }
      }
    }
    .ExplanationBlock {
      width: 100vw;
      
      #ExplanationTextarea {
        width: 100%;
        outline: none;
        padding: 1rem;
      }
    }
    .ImgBlock {
      min-height: 7rem;
      padding: 1rem 0.8rem;
    }
    .ConfirmButtonBlock {
      width: 90vw;
      margin: 2.5rem auto;

      #ConfirmButton {
        color: #484646;
        background-image: linear-gradient(-213deg, #DAB269 0%, #E7C78C 92%);
        border-radius: 2px;
        width: 100%;
        height: 2.8rem;
        font-size: 18px;
        margin: auto;
      }
    }
  }
  .picker-fade-enter, .picker-fade-leave-active {
    opacity: 0;
  }
  .picker-fade-enter-active, .picker-fade-leave-active {
    transition: all .3s ease-in-out;
  }
</style>