confirmedCredit.vue 17.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552
<template>
	<v-layout id="confirmedCredit" column justify-center align-center>
    <v-flex>
      <v-card class="infoCards" flat height="6rem">
        <v-card-title class="infoCardsTitle" >
          <div class="infoCardsName">借款人:{{creditor}}</div>
          <div class="infoCardsDetail" @click="$router.push(`/borrowContent?id=${info.id}`)">查看详情<v-icon>keyboard_arrow_right</v-icon></div>          
        </v-card-title>
        <v-card-text class="infoCardsContent" >
          <div class="infoCardsContentBlock total">
            <div class="infoCardsContentKey">待收总额</div>
            <div class="infoCardsContentValue">{{total}}元</div>              
          </div>
          <div class="infoCardsContentBlock amount">
            <div class="infoCardsContentKey">出借本金</div>
            <div class="infoCardsContentValue">{{info.amount}}元</div>                            
          </div>
          <div class="infoCardsContentBlock interest">
            <div class="infoCardsContentKey">利息</div>
            <div class="infoCardsContentValue">{{interest}}元</div>                            
          </div>
        </v-card-text>
      </v-card>
      <v-card class="BorrowList" id="BorrowListContent" flat >
        <v-tabs v-model="active" color="toolbarGrey" centered grow dark slider-color="gold">
          <v-tab :key="1" ripple>待收金额</v-tab>
          <v-tab :key="2" ripple>
            <v-badge color="red" :value="!!badgeNumber">
              <span slot="badge">{{badgeNumber}}</span>
              收款记录
            </v-badge>
          </v-tab>
          <v-tab :key="3" ripple>展期记录</v-tab>
          <v-tab-item :key="1">
            <v-card id='waitToPay' class="itemsCard">
              <div class="waitToPayInfo">
                <v-progress-circular
                  id="progress"
                  :size="cycleSize"
                  :width="10"
                  :rotate="270"
                  :value="circularValue"
                  :color="circularValueColor"
                >
                  <div class="InfoBlock">
                    <div class="InfoBlockTitle">待收金额</div>
                    <div class="total">{{total}}元</div>
                    <div class="timeRemain">
                      <span v-if="info.status === '已生效'">剩余{{info.timeRemain}}天</span>
                      <span class="orange--text text--darken-3" v-if="info.status === '已逾期'">已逾期{{info.timeRemain}}天</span>                    
                    </div>
                  </div>
                </v-progress-circular>
                <v-btn depressed class="btn-deep" v-if="info.status !== '已还清'" @click="writeOffsConfirm">销账</v-btn>
                <v-btn depressed class="btn-deep" v-if="info.status !== '已还清'" @click="$router.push(`/extensionPreiod?id=${info.id}`)">展期</v-btn>
                <v-btn depressed class="btn-light" @click="$router.push(`/report?id=${info.id}`)">举报违法</v-btn>  
              </div>
            </v-card>
          </v-tab-item>
          <v-tab-item :key="2">
            <v-card id='payRecordTitle' class="itemsCard">
              <v-list class="list">
                <v-list-tile class="listTitle listLine">
                  <v-list-tile-content class="BorrowListTitle">收款日期</v-list-tile-content>
                  <v-list-tile-content class="BorrowListTitle">还款人姓名</v-list-tile-content>
                  <v-list-tile-content class="BorrowListTitle">收款金额</v-list-tile-content>
                  <v-list-tile-content class="BorrowListTitle">收款状态</v-list-tile-content>                  
                </v-list-tile>
              </v-list>
            </v-card>
            <v-card id='payRecord' class="itemsCard" height="60vh">
              <v-list class="list">
                <v-list-tile class="listLine" v-if="!repayments.length">
                  <v-list-tile-content class="BorrowListTitle noData">暂无数据</v-list-tile-content>               
                </v-list-tile>
                  <v-list-tile class="listLine" v-for="(item, index) in repayments" :key="index" @click="showRepaymentPopUp(item)">
                    <v-list-tile-content class="BorrowListTitle">{{dateParse(item.repayment_date)}}</v-list-tile-content>
                    <v-list-tile-content class="BorrowListTitle">{{borrower}}</v-list-tile-content>
                    <v-list-tile-content class="BorrowListTitle">{{item.amount}}</v-list-tile-content>
                    <v-list-tile-content class="BorrowListTitle" :class="item.status === '待确认' ? 'orange--text' : ''">{{item.status}}</v-list-tile-content>                  
                  </v-list-tile>
              </v-list>
            </v-card>
          </v-tab-item>
          <v-tab-item :key="3">
            <v-card id='payRecordTitle' class="itemsCard">
              <v-list class="list">
                <v-list-tile class="listTitle listLine">
                  <v-list-tile-content class="BorrowListTitle">金额</v-list-tile-content>
                  <v-list-tile-content class="BorrowListTitle">利率</v-list-tile-content>
                  <v-list-tile-content class="BorrowListTitle">时间</v-list-tile-content>
                  <v-list-tile-content class="BorrowListTitle">状态</v-list-tile-content>                  
                </v-list-tile>
              </v-list>
            </v-card>
            <v-card id='payRecord' class="itemsCard" height="60vh">
              <v-list class="list">
                <v-list-tile class="listLine" v-if="!extendPreiod.length">
                  <v-list-tile-content class="BorrowListTitle noData">暂无数据</v-list-tile-content>               
                </v-list-tile>
                <v-list-tile class="listLine" v-for="(period, index) in extendPreiod" :key="index">
                  <v-list-tile-content class="BorrowListTitle">{{period.amount}}</v-list-tile-content>
                  <v-list-tile-content class="BorrowListTitle">{{Math.floor(period.rate* 100)}}%</v-list-tile-content>
                  <v-list-tile-content class="BorrowListTitle">{{dateParse(period.start_date)}}<br/>-{{dateParse(period.end_date)}}</v-list-tile-content>
                  <v-list-tile-content class="BorrowListTitle">{{period.status}}</v-list-tile-content>                  
                </v-list-tile>
              </v-list>
            </v-card>
          </v-tab-item>
        </v-tabs>
      </v-card>
      <v-card id="ConfirmBlock" >
        <div class="repaymentConfirm" v-show="active === '1' && !!badgeNumber">
          <v-btn depressed :loading="isLoading" class="btn-deep" @click="repaymentConfirmHint()">确认收款</v-btn>                            
          <v-btn depressed :loading="isLoading" class="btn-light" @click="passwordCheck('repaymentReject')">驳回收款</v-btn>
        </div>
      </v-card>
      <div id="FuckIphoneX"></div>
    </v-flex>
    <v-dialog  v-model="dialogDisplay" persistent max-width="290">
      <v-card class="hintDialog">
        <v-card-title class="headline">提示</v-card-title>
        <v-card-text class='dialogContent'>
          <p>{{dialogContent}}</p>
          </v-card-text>          
        <v-card-actions>
          <v-spacer></v-spacer>
          <v-btn color="black" flat @click.native="dialogDisplay = false">取消</v-btn>
          <v-btn color="black" flat @click.native="passwordCheck('')">确认</v-btn>            
        </v-card-actions>
      </v-card>
    </v-dialog>
    <v-bottom-sheet v-model="passwordPannelDisplay" full-width>
       <PasswordInputer :display="passwordPannelDisplay" @passwordSubmit="passwordSubmit"/>
    </v-bottom-sheet>
  </v-layout>
</template>


<script>
import PasswordInputer from '@/components/PasswordInputer'
import {wechatShareSetting, dateParse, interestWithDamage, interest } from '@/helper'

export default {
  async asyncData({store, query, app, redirect}) {
    let {data} = await app.$axios.get(`/confirmedInfo?kind=credit&id=${query.id}&userId=${store.state.user.id}`)
    if (data.success) {
      return {info: data.info, active: query.active || '0'}
    } else {
      store.dispatch('displayMessage', data.msg)
      redirect(301, '/')
      return
    }
  },
  data:() => ({
    dialogDisplay: false,
    passwordPannelDisplay: false,
    repaymentPopUpDisplay: false,
    isLoading: false,
    passwordSubmit: {},
    dialogContent: '',
    redirect: '',
    cycleSize: 250,
    active: null,
    targetRepaymentId: '',
  }),
  watch: {
    '$route' (to, from) {
      this.active = to.query.active || '0'
    }
  },
  computed: {
    userInfo() {
      return this.$store.state.user
    },
    extendPreiod() {
      return (this.info.periods || [])
    },
    repayments() {
      return (this.info.repayment_records || [])
    },
    borrower() {
      return (this.info.Borrower ? this.info.Borrower.name : '')
    },
    creditor() {
      return (this.info.Creditor ? this.info.Creditor.name : '')
    },
    badgeNumber() {
      return this.repayments.filter((item) => (item.status === '待确认')).length
    },
    circularValue() {
      if (this.info.status === '已生效') {
        return (this.info.timeRemain / this.info.duration) * 100
      }
      return 100
    },
    circularValueColor() {
      if (this.info.status === '已逾期') {
        return 'red'
      }
      if (this.info.status === '已还清') {
        return 'blue'
      }
      return 'gold'
    },
    interest() {
      if (this.info.status === '已逾期') {
        return interestWithDamage(this.info.amount, this.info.rate, this.info.startDate, this.info.endDate)
      }
      return interest(this.info.amount, this.info.rate, this.info.startDate, this.info.endDate)
    },
    total() {
      if (this.info.status === '已还清') return 0
      return Math.floor((this.info.amount + this.interest) * 100) / 100
    }
  },
  head:() => ({
    title: '借出详情'
  }),
  components: {
    PasswordInputer
  },
  mounted() {
    let windowHeight = document.body.offsetHeight 
    if (windowHeight < 600) {
      this.cycleSize = 210
    }
    wechatShareSetting(this.$axios, this.$store)
  },
  methods: {
    async getData() {
      let {data} = await this.$axios.get(`/confirmedInfo?kind=credit&id=${this.info.id}&userId=${this.$store.state.user.id}`)
      if (data.success) {
        this.info = data.info
      } else {
        store.dispatch('displayMessage', data.msg)
      }
    },
    dateParse: dateParse,
    showRepaymentPopUp(item) {
      if (item.status === '待确认') {
        this.targetRepaymentId = item.id        
        this.repaymentPopUpDisplay = true
      }
    },
    passwordCheck(type = '') {
      this.dialogDisplay = false
      switch (type) {
        case 'repaymentConfirm':
          this.passwordSubmit = this.repaymentConfirm
          break
        case 'repaymentReject':
          this.passwordSubmit = this.repaymentReject          
          break
        case 'writeOffs':
          this.passwordSubmit = this.writeOffs          
          break
      }
      this.passwordPannelDisplay = true      
    },
    writeOffsConfirm() {
      this.dialogContent = '销账之后该借条不可恢复,且默认借款人已经还款,确认要销账吗?'
      this.passwordSubmit = this.writeOffs
      this.dialogDisplay = true
    },
    repaymentConfirmHint() {
      this.dialogContent = '确认收款之后该借条不可恢复,请确保借款人已还款!'
      this.passwordSubmit = this.repaymentConfirm
      this.dialogDisplay = true
    },
    async writeOffs(password) {
      this.passwordPannelDisplay = false
      this.isLoading = true
      const {data} = await this.$axios.post('/iou/writeOffs', {
        userId: this.userInfo.id,
        id: this.info.id,
        password: password,
      })
      this.isLoading = false
      if (data.success) {
        this.$store.dispatch('displayMessage', '销账成功')        
        this.getData()
      } else {
        this.$store.dispatch('displayMessage', data.msg)
      }
    },
    async repaymentConfirm(password) {
      this.passwordPannelDisplay = false
      this.isLoading = true
      const {data} = await this.$axios.post('/iou/repaymentConfirm', {
        userId: this.userInfo.id,
        id: this.info.id,
        password: password,
      })
      this.isLoading = false
      if (data.success) {
        this.$store.dispatch('displayMessage', '确认收款成功')  
        return this.getData()
      } else {
        this.$store.dispatch('displayMessage', data.msg)
      }
    },
    async repaymentReject(password) {
      this.passwordPannelDisplay = false
      this.isLoading = true
      const {data} = await this.$axios.post('/iou/repaymentReject', {
        userId: this.userInfo.id,
        id: this.info.id,
        password: password,
      })
      this.isLoading = false
      if (data.success) {
        this.$store.dispatch('displayMessage', '驳回收款成功')
        return this.getData()            
      } else {
        this.$store.dispatch('displayMessage', data.msg)
      }
    }
  }
}
</script>

<style lang="scss" scoped>
  #confirmedCredit {

    /deep/ .toolbarGrey {
      background-color: #3A424A !important;
    }

    /deep/ .gold {
      background-color: #dabb84 !important;
    }

    .infoCards {
      background-color: $toolbar-grey;
      color: $gold;
      border-radius: 2px;
      margin-bottom: 1rem;
      position: relative;
      overflow:hidden;      

      .infoCardsTitle {
        height: 3rem;
        box-sizing: border-box;
        line-height: 3rem;
        padding: 0;
        border-bottom: 1px solid $gold;

        .infoCardsName {
          width: 50%;
          padding-left: 0.8rem;
          font-size: 16px;
        }

        .infoCardsDetail {
          width: 50%;
          padding-right: 0.8rem;
          font-size: 16px;
          text-align: right;
          i {
            color: $gold;
          }
        }  
      }

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

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


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

            .infoCardsContentValue {
              font-size: 0.8rem;
              color: $gold;
              margin: auto;
            }
          }
      }
    }
    /deep/ .tabs__items {
      background-color: $background-black;
    }

    .itemsCard {
      // height: 50vh;
      width: 100vw;
      // margin: 3vh auto 0 auto;
      background-color: $background-black;
    }

    #waitToPay {
      
      .waitToPayInfo {
        width: 100%;
        text-align: center;
        padding-top: 3vh;

        #progress {
          width: 100% !important;
        }

        .InfoBlockTitle {
          color: #fff;
          font-size: 2rem;
          font-weight: 400;
        }

        .total {
          font-size: 2rem;
          color: $light-gold;
        }

        .timeRemain {
          color: #fff;
        }

        .btn-deep {
          width: 42%;
          margin-top: 2rem;
          height: 3rem;
          background-image: linear-gradient(-229deg, #DAB269 37%, #E7C78C 87%);
          color: $toolbar-grey;
        }

        .btn-light {
          background-color: $toolbar-grey;
          width: 90%;
          margin-top: 1rem;
          height: 3rem;
          color: $light-gold;
          border: 1px solid $light-gold;
        }

      }
    }

    #payRecord {
      overflow: auto;
      height: 100%;
    }

    .BorrowList {
      width: 100vw;
      margin-top: 1.1rem;
      border-top: 1px solid #666;

      .list {
        padding: 0;
        background-color: $toolbar-grey;

        .listLine.listTitle {
          background-color: $background-black;
          color: #fff;
        }

        .listLine {
          background-color: $light-background-grey;
          color: $background-black;
          border-bottom: 1px solid #ccc;
        }

        .BorrowListTitle {
          font-size: 0.8rem;
          width: 25%;
          align-items: center;
        }
      }
    }

    #ConfirmBlock {
      width: 100vw;
      border-top: 1px solid #979797;
      background-color: $toolbar-grey;
      position: fixed;
      bottom: 0;
      text-align: right;
      margin-bottom: constant(safe-area-inset-bottom);
      margin-bottom: env(safe-area-inset-bottom);

      button {
        height: 2.5rem;
      }
      .btn-light {
        background-color: $toolbar-grey;
        color: $light-gold;
        border: 1px solid $light-gold;
      }

      .btn-deep {
        background-image: linear-gradient(-229deg, #DAB269 37%, #E7C78C 87%);
        color: $toolbar-grey;
      }
      
    }

    #FuckIphoneX {
      position: fixed;
      bottom: 0;
      width: 100%;
      height: constant(safe-area-inset-bottom);
      height: env(safe-area-inset-bottom);
      background-color: #39424a;
    }
  }
  .hintDialog {
    background-color: #fff;
    color: #000;
    .headline {
      justify-content: center;
      font-weight: bold;
      padding-bottom: 0;
    }
    .dialogContent {
      justify-content: center;  
      text-align: center;

      .warningIcon {
        margin-bottom: 0.5rem;
        color: red;
        font-size: 5rem;
      }
      .bold {
        font-weight: bold;
      }

      p {
        margin-bottom: 0;
      }
    }
    .btn {
      width: 100%;
    }

    
  }
  .popUpItem {
    width: 100%;
    height: 3.5rem;
    line-height: 3.5rem;
    font-size: 1.2rem;
    border-bottom: 1px solid #eee;
  }
</style>