index.vue 9.14 KB
<template>
  <v-layout column justify-center align-center>
    <v-flex>
      <InfoCard :info="infoCard"/>
      <div id="tabBlock">
        <div id="isBorrowing" :class="tabChoose === 'borrow' ? 'isChoosing' : ''" @click="tabChange('borrow')">正在借款</div>
        <span id="tabDivider"></span>
        <div id="isLending" :class="tabChoose === 'lend' ? 'isChoosing' : ''" @click="tabChange('lend')">正在出借</div>
      </div>
      <v-flex class="cardContainer">
        <v-card v-for="(item, index) in listInfo" :key="index" class="infoCards" flat height="6rem">
          <v-card-title class="infoCardsTitle" >
            <div class="infoCardsAvatar">
              <img v-if="item.avatar" :src="item.avatar" alt="" />
              <i v-if="!item.avatar" class="material-icons icon iconfont icon-face"></i>
            </div>
            <div class="infoCardsName">{{item.name}}</div>
            <div class="infoCardsTitleButton">补借条</div>
            <div class="infoCardsCornerMark">
              <div class="infoCardsCornerMarkString">剩余{{item.timeRemain}}</div>
            </div>
          </v-card-title>
          <v-card-text class="infoCardsContent" >
            <div class="infoCardsContentBlock amount">
              <div class="infoCardsContentKey">筹款金额</div>
              <div class="infoCardsContentValue">{{item.amount}}元</div>              
            </div>
            <div class="infoCardsContentBlock time">
              <div class="infoCardsContentKey">借款时长</div>
              <div class="infoCardsContentValue">{{item.time}}天</div>                            
            </div>
            <div class="infoCardsContentBlock rate">
              <div class="infoCardsContentKey">年利率</div>
              <div class="infoCardsContentValue">{{item.rate}}%</div>                            
            </div>
          </v-card-text>
        </v-card>
      </v-flex>
    </v-flex>
    <v-bottom-nav id="bottomNav" fixed color="toolbar-grey" >
      <v-btn class="bottomNavBtn" flat color="gold" value="buJieTiao" @click="fillIOU">
        <span>补借条</span>
          <svg class='material-icons icon iconfont' width="1.6rem" height="1.6rem"  version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 566.9 566.9" style="enable-background:new 0 0 566.9 566.9;" xml:space="preserve">
            <g>
              <path d="M299.2,204.7h157.6v31.5H299.2V204.7z M299.2,267.7h157.6v31.5H299.2V267.7z M110.1,330.7h346.7v31.5H110.1V330.7z
                M110.1,393.8h346.7v31.5H110.1V393.8z M299.2,141.6h157.6v31.5H299.2V141.6z M525.7,525.3H41.3V41.6h484.4V525.3z M60.5,506h445.9
                V60.9H60.5V506z M60.5,506"/>
              <g>
                <path d="M157.8,147.6c-4.4,11.8-9.9,24-16.3,35.6v116h-23.2v-80.5c-2.4,3-4.9,5.9-7.2,8.4c-2.2-6.1-8.7-19.7-12.8-25.7
                  c14.5-14.6,28.4-37.8,36.5-61L157.8,147.6z M256.1,191.3V213H153.1v-21.7h19.7v-12.4h-16v-21.2h16v-18h23.4v18h15.5v-18h23.7v18
                  h17v21.2h-17v12.4H256.1z M164.7,220.2H246v79H221v-5.5h-32.4v5.5h-23.9V220.2z M188.5,240.1v7.7H221v-7.7H188.5z M221,274.5v-7.7
                  h-32.4v7.7H221z M196.1,191.3h15.5v-12.4h-15.5V191.3z"/>
              </g>
            </g>
          </svg>
      </v-btn>
      <v-btn class="bottomNavBtn" :disabled="true" flat color="gold" value="chaXinYong">
        <span>查信用</span>
        <i aria-hidden="true" class="material-icons icon iconfont icon-xinyongqia"></i> 
      </v-btn>
      <v-btn class="bottomNavBtn" :disabled="true" flat color="gold" value="qiuJieKuan">
        <span>求借款</span>
        <i aria-hidden="true" class="material-icons icon iconfont icon-dkw_jiekuan"></i> 
      </v-btn>
      <v-btn class="bottomNavBtn" to="/userCenter" flat color="gold" value="geRenZhongXin">
        <span>个人中心</span>
        <i aria-hidden="true" class="material-icons icon iconfont icon-gerenzhongxin"></i> 
      </v-btn>
    </v-bottom-nav>
    <v-dialog  v-model="dialogDisplay" persistent max-width="290">
      <v-card id="bindHintDialog">
        <v-card-title class="headline">提示</v-card-title>
        <v-card-text>为正常使用各项功能,您需要先验证手机号码</v-card-text>
        <v-card-actions>
          <v-spacer></v-spacer>
          <v-btn color="gold" flat @click.native="dialogDisplay = false">知道了</v-btn>
          <v-btn color="gold" flat @click.native="$router.push('/login')">去验证</v-btn>
        </v-card-actions>
      </v-card>
    </v-dialog>
    <v-dialog  v-model="idDialogDisplay" persistent max-width="290">
      <v-card id="bindHintDialog">
        <v-card-title class="headline">提示</v-card-title>
        <v-card-text>为正常使用补借条等功能,您需要先绑定身份信息</v-card-text>
        <v-card-actions>
          <v-spacer></v-spacer>
          <v-btn color="gold" flat @click.native="idDialogDisplay = false">知道了</v-btn>
          <v-btn color="gold" flat @click.native="$router.push('/idBind')">去绑定</v-btn>
        </v-card-actions>
      </v-card>
    </v-dialog>
  </v-layout>
</template>

<script>
import InfoCard from '@/components/InfoCard'
export default {
  data:() => ({
    navTarget: 'buJieTiao',
    tabChoose: 'borrow',
    listInfo: [],
    infoCard: {},
    dialogDisplay: false,
    idDialogDisplay: false,
  }),
  computed: {
    userInfo () {
      return this.$store.state.user
    }
  },
  components: {
    InfoCard
  },
  beforeRouteLeave (to, from, next) {
    if (to.path === '/login') next()
    if (this.userInfo.needPhoneBind) {
      this.dialogDisplay = true
      next(false)
    } else {
      next()
    }
  },
  created() {
  },
  methods: {
    fillIOU() {
      if (this.userInfo.needPhoneBind) {
        this.dialogDisplay = true
      } else if (this.userInfo.needIdBind) {
        this.idDialogDisplay = true
      } else {
        console.log('pass')
      }
    },
    tabChange(tab) {
      this.tabChoose = tab
    }
  }
}
</script>

<style lang="scss" scoped>
  body {
    height: 100%;
    overflow: hidden;
  }
  #tabBlock {
    width: 100%;
    padding-top: 1.5rem;
    
    div {
      width: calc(50% - 2px);
      display: inline-block;
      text-align: center;
      height: 18px;
      font-size: 18px;
      transition: color 0.3s ease-in-out;
      -webkit-transition: color 0.3s ease-in-out;
    }

    #tabDivider:before {
      content: "";
      height: 18px;
      width: 0;
      border: 2px solid $gold;
    }
    .isChoosing {
      color: $gold;
    }
  }
  .cardContainer {
    width: 92vw;
    overflow: auto;
    height: 50vh;
    margin-top: 1.5rem;

    .infoCards {
      background-color: #fff;
      color: #000;
      border-radius: 2px;
      margin-bottom: 1rem;
      position: relative;
      overflow:hidden;      

      .infoCardsTitle {
        padding:0.5rem 1.3rem 0.2rem 1.3rem; 
        

        .infoCardsAvatar {
          width: 2.5rem;
          height: 2.5rem;
          border-radius: 1.3rem;
          overflow:hidden;

          img {
            width: 100%;
            vertical-align: bottom;
          }
          
          .icon {
            color: $avatar-grey;
            font-size: 2.5rem;
          }
        }

        .infoCardsName {
          margin-left: 0.8rem;
          font-size: 16px;
        }

        .infoCardsTitleButton {
          width: 3.2rem;
          height: 1.2rem;
          line-height: 1.35rem;
          font-size: 10px;
          text-align: center;
          background-image: linear-gradient(-229deg, #DAB269 37%, #E7C78C 87%);
          border-radius: 32px;
          margin-left: 0.9rem;
        }
        .infoCardsCornerMark {
          font-size: 10px;
          width: 6rem;
          height: 2.8rem;
          background-image: linear-gradient(-229deg, #DAB269 37%, #E7C78C 87%);
          border-radius: 26px;
          position: absolute;
          top: -1.6rem;
          right: -1rem;
          z-index: 1;

          .infoCardsCornerMarkString {
            position: absolute;
            bottom: 0;
            left: 1rem;
          }
        }
      }

      .infoCardsContent {
        width: 100%;
        padding: 0;

          .infoCardsContentBlock {
            width: 33%;
            display: inline-block;
            text-align: center;

            .infoCardsContentKey {
              font-size: 0.8rem;
              color: #898989;
            }

            .infoCardsContentValue {
              font-size: 0.8rem;
              color: $gold;
              margin: auto;
            }
          }
      }
    }
  }
  #bottomNav {
    height: 42pt;
    box-sizing: border-box;
    background-color: $toolbar-grey;
    transform: translate3D(0,0,0);
    -webkit-transform: translate3D(0,0,0);
    
    .bottomNavBtn {
      color: #fff;
      opacity: 1;
      svg {
        fill: #fff;
        width: 1.8rem;
        height: 1.8rem;
      }
    }
    
    .bottomNavBtn.btn--active {
      color: $gold;
      svg {
        fill: $gold;
      }
    }
  }
  #bindHintDialog {
      background-color: #fff;
      color: #000;
    .headline {
      justify-content: center;
      font-weight: bold;
      padding-bottom: 0;
    }
    .btn {
      width: 50%;
    }
  }
</style>