pay-entry.vue 19 KB
Newer Older
李晓兵's avatar
李晓兵 committed
1 2 3 4 5 6 7 8 9 10 11 12 13
<template>
  <h-view id="payment-pay-entry" class="public-style">
    <transition name="trans">
      <div v-show="downNum" class="modal-show">
        <div class="down">
          <p>提示</p>
          <span>您好,当前余额不足,请重新支付!</span>
          <button @click="downNum=false">确定</button>
        </div>
      </div>
    </transition>
    <transition name="trans">
      <div v-show="show" class="modal-show-bank">
李晓兵's avatar
李晓兵 committed
14 15 16 17
        <div class="down">
          <div class="top">
            <img src="@/assets/payment/back.png" @click="show=false" >
            <span>支付方式</span>
李晓兵's avatar
李晓兵 committed
18
          </div>
李晓兵's avatar
李晓兵 committed
19 20
          <scroll>
            <list-item :item-height="56" class="pay-way">
linxin's avatar
linxin committed
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
              <item
                v-for="(item,index) in nongBank"
                :proportion="[7,1,1]"
                :key="item.bank_account_num"
                @click.native="isSelect(`nong${index}`);ischeck(item)"
              >
                <div slot="name" style="flex=3">
                  <img :src="selectImg(item)" alt class="icon" >
                  {{ item.bank_full_name }}({{ selectLast(item) }})
                  <img
                    v-show="item.recommand"
                    class="push"
                    src="@/assets/payment/push.png"
                  >
                </div>
                <section slot="content">
                  <img v-show="select === `nong${index}`" src="@/assets/payment/select.png" alt >
                  <img v-show="select !== `nong${index}`" src="@/assets/payment/unselect.png" alt >
                </section>
              </item>
              <item :proportion="[7,1,1]" @click.native="isSelect('one');ischeck('one')">
                <div slot="name">
                  <img src="@/assets/payment/alipay.png" alt class="icon1" > 支付宝
                </div>
                <section slot="content">
                  <img v-show="select === 'one'" src="@/assets/payment/select.png" alt >
                  <img v-show="select !== 'one'" src="@/assets/payment/unselect.png" alt >
                </section>
              </item>
              <item :proportion="[7,1,1]" @click.native="isSelect('two');ischeck('two')">
                <div slot="name">
                  <img src="@/assets/payment/wx.png" alt class="icon2" > 微信
                </div>
                <section slot="content">
                  <img v-show="select === 'two'" src="@/assets/payment/select.png" alt >
                  <img v-show="select !== 'two'" src="@/assets/payment/unselect.png" alt >
                </section>
              </item>
              <item
                v-for="(item,index) in newList"
                :proportion="[7,1,1]"
                :key="index"
                @click.native="isSelect(`three${index}`);ischeck(item)"
              >
                <div slot="name" style="flex=3">
                  <img :src="selectImg(item)" alt class="icon" >
                  {{ item.bank_full_name }}({{ selectLast(item) }})
                  <img
                    v-show="item.recommand"
                    class="push"
                    src="@/assets/payment/push.png"
                  >
                </div>
                <section slot="content">
                  <img v-show="select === `three${index}`" src="@/assets/payment/select.png" alt >
                  <img v-show="select !== `three${index}`" src="@/assets/payment/unselect.png" alt >
                </section>
              </item>
            </list-item>
李晓兵's avatar
李晓兵 committed
80 81 82
          </scroll>
        </div>
    </div></transition>
李晓兵's avatar
李晓兵 committed
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
    <transition name="trans">
      <div v-show="confirm" class="modal-show-confirm">
        <div class="down">
          <div class="top">
            <img src="@/assets/payment/back.png" @click="confirm=false" >
            <span>确认付款</span>
          </div>
          <div class="info">
            <div class="info-item">
              <span>还款金额</span>
              <span>¥{{ money |currency }}</span>
            </div>
            <div class="interest">
              <span>本次交易收取{{ rate }}%服务费</span>
            </div>
            <div class="info-item">
              <span>服务费</span>
              <span>{{ serviceCharge |currency }}</span>
            </div>
            <div class="info-item" @click="show=true">
              <span>付款方式</span>
              <span>
                <img :src="checkType.img" >
                <span>{{ checkType.bank_full_name }}</span>
                <span v-if="sectctNong">({{ selectLast(checkType) }})</span>
                <img class="arrow" src="@/assets/payment/go.png" >
              </span>
            </div>
          </div>
          <bottom-tab>
            <tab-button class="footer" @click.native="pay">立即支付</tab-button>
          </bottom-tab>
        </div>
      </div>
    </transition>
    <h-header :proportion="[5,1,1]" class="bar-custom">
      <div slot="left" class="h-header-btn">
        <img src="@/assets/userBind/arrow.png" @click="changePage" >
        <span>支付中心</span>
      </div>
    </h-header>

    <h-content class="entry-content">
      <div class="amount">
        <p>{{ userName }}</p>
        <div>{{ sumMoney |currency }}</div>
      </div>
      <div class="info">
        <div class="info-item">
          <span>还款金额</span>
          <span>¥{{ parseFloat(money).toFixed(2) |currency }}</span>
        </div>
        <div class="interest">
linxin's avatar
linxin committed
136
          <span>本次交易收取{{ rate }}%手续费</span>
李晓兵's avatar
李晓兵 committed
137 138
        </div>
        <div class="info-item">
linxin's avatar
linxin committed
139
          <span>手续费</span>
李晓兵's avatar
李晓兵 committed
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
          <span>{{ serviceCharge }}</span>
        </div>
        <div class="info-item" @click="show=true">
          <span>付款方式</span>
          <span>
            <img :src="checkType.img" >
            <span>{{ checkType.bank_full_name }}</span>
            <span v-if="sectctNong">({{ selectLast(checkType) }})</span>
            <img class="arrow" src="@/assets/payment/go.png" >
          </span>
        </div>
      </div>
    </h-content>
    <bottom-tab>
      <tab-button class="footer" @click.native="affirm">确认支付</tab-button>
    </bottom-tab>
  </h-view>
</template>

<script>
import zfb from '@/assets/payment/alipay.png'
import wx from '@/assets/payment/wx.png'
import js from '@/assets/payment/js.png'
import ny from '@/assets/payment/ly.png'
import pf from '@/assets/payment/pf.png'
import gd from '@/assets/payment/gd.png'
import gf from '@/assets/payment/gf.png'
import jt from '@/assets/payment/jt.png'
import gs from '@/assets/payment/gs.png'
import ms from '@/assets/payment/ms.png'
import pa from '@/assets/payment/pa.png'
import xy from '@/assets/payment/xy.png'
import yzcx from '@/assets/payment/yzcx.png'
import zg from '@/assets/payment/zg.png'
import zs from '@/assets/payment/zs.png'
import zx from '@/assets/payment/zx.png'
export default {
  name: 'PaymentPayEntry',
  components: {},
  data () {
    return {
      money: '',
      select: 'one',
      name: '',
      sectctNong: false,
      checkType: {
        img: '',
        bank_full_name: '',
        bank_account_num: '',
      },
      confirm: false,
      show: false,
      downNum: false,
      userName: window.sessionStorage.getItem('bp_name'),
      nongBank: [], // 存农行卡
      flag: false, // 用于判断是否有农业银行卡
      lists: [],
    }
  },
  computed: {
    serviceCharge () {
      return (this.money * (this.rate / 100)).toFixed(2)
    },
linxin's avatar
linxin committed
203 204 205
    rate () {
      return this.checkType.bank_full_name.indexOf('农业') !== -1 ? 0.00 : 0.18
    },
李晓兵's avatar
李晓兵 committed
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
    sumMoney () {
      return (parseFloat(this.serviceCharge) + parseFloat(this.money)).toFixed(
        2
      )
    },
    newList () {
      let vm = this
      vm.nongBank = []
      vm.lists.forEach((item, i) => {
        if (item.bank_full_name.indexOf('农业') !== -1) {
          vm.nongBank.push(vm.lists[i])
          vm.flag = true
        }
      })
      let notNong = vm.lists.filter(i => {
        return i.bank_full_name.indexOf('农业') === -1
      })
      if (vm.flag) {
        vm.select = 'nong0'
        vm.checkType.bank_full_name = '农业银行'
        vm.checkType.img = ny
        vm.checkType.bank_account_num = this.nongBank[0].bank_account_num
        vm.sectctNong = true
      } else {
        vm.select = 'one'
        vm.checkType.bank_full_name = '支付宝'
        vm.checkType.img = zfb
        vm.sectctNong = false
      }
      return notNong
    },
  },
  watch: {},
  beforeRouteEnter (to, from, next) {
    next(vm => {
      vm.confirm = false
      vm.show = false
      vm.downNum = false
      if (from.name === 'NewList') {
        vm.money = vm.$route.params.money
      } else if (from.name === 'PaymentContractRecord') {
        vm.money = vm.$route.params.sumMoney
      }
      vm.getType()
      // vm.nongBank = []
    })
  },
  methods: {
    affirm () {
      this.confirm = true
    },
    pay () {
      let vm = this
      hlsPopup.showLoading('请稍候')
      setTimeout(() => {
        vm.hlsPopup.hideLoading()
        if (vm.money === 0) {
          vm.downNum = true
        } else {
          vm.goSuccess()
        }
      }, 2000)
    },
    ischeck (way) {
      if (way === 'one') {
        this.checkType.bank_full_name = '支付宝'
        this.checkType.img = zfb
        this.sectctNong = false
      } else if (way === 'two') {
        this.checkType.bank_full_name = '微信'
        this.checkType.img = wx
        this.sectctNong = false
      } else {
        this.checkType.bank_full_name = way.bank_full_name
        this.checkType.bank_account_num = way.bank_account_num
        this.checkType.img = this.selectImg(way)
        this.sectctNong = true
      }
      this.show = false
    },
    selectLast (item) {
      let num = item.bank_account_num
      return num.substring(num.length - 4)
    },
    selectImg (e) {
      if (e.bank_full_name.indexOf('建设') !== -1) {
        return js
      } else if (e.bank_full_name.indexOf('农业') !== -1) {
        e.recommand = true
        return ny
      } else if (e.bank_full_name.indexOf('光大') !== -1) {
        return gd
      } else if (e.bank_full_name.indexOf('广发') !== -1) {
        return gf
      } else if (e.bank_full_name.indexOf('浦') !== -1) {
        return pf
      } else if (e.bank_full_name.indexOf('工商') !== -1) {
        return gs
      } else if (e.bank_full_name.indexOf('交通') !== -1) {
        return jt
      } else if (e.bank_full_name.indexOf('民生') !== -1) {
        return ms
      } else if (e.bank_full_name.indexOf('平安') !== -1) {
        return pa
      } else if (e.bank_full_name.indexOf('兴业') !== -1) {
        return xy
      } else if (e.bank_full_name.indexOf('邮') !== -1) {
        return yzcx
      } else if (e.bank_full_name.indexOf('中国') !== -1) {
        return zg
      } else if (e.bank_full_name.indexOf('招商') !== -1) {
        return zs
      } else if (e.bank_full_name.indexOf('中信') !== -1) {
        return zx
      }
    },
    goSuccess () {
      this.$router.push({
        name: 'Success',
        params: {
          userName: this.userName,
          money: this.money,
        },
      })
    },
    isSelect (way) {
      this.select = way
    },
    getType () {
      let vm = this
      let url = process.env.basePath + 'payment_method_query'
      let param = {
        bp_id: window.sessionStorage.getItem('bp_id'),
      }
      hlsPopup.showLoading('请稍候')
      vm.$post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          vm.lists = res.lists
        } else {
          hlsPopup.showLongCenter(res.message)
        }
      })
    },
    changePage () {
      this.$router.replace({
        name: 'NewList',
        params: {
          money: this.$route.params.money,
        },
      })
      this.$router.go(-1)
    },
  },
}
</script>
<style lang='less' >
#payment-pay-entry {
李晓兵's avatar
李晓兵 committed
364 365 366
  .vue-better-scroll__wrapper{
    padding: 0;
  }
李晓兵's avatar
李晓兵 committed
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
  .trans-enter-active,
  .trans-leave-active {
    transition: opacity 0.5s;
  }
  .trans-enter,
  .trans-leave-active {
    opacity: 0;
  }
  .modal-show-confirm {
    width: 100%;
    height: 100%;
    position: absolute;
    display: flex;
    z-index: 900;
    background-color: rgba(56, 63, 69, 0.3);
    justify-content: center;
    align-items: center;
    .down {
      height: 466px;
      width: 100%;
linxin's avatar
linxin committed
387
     position: relative;
李晓兵's avatar
李晓兵 committed
388
      top:16%;
李晓兵's avatar
李晓兵 committed
389 390 391 392
      background: #fff;
      border-radius: 12px 12px 0 0;
      overflow: scroll;
      display: flex;
李晓兵's avatar
李晓兵 committed
393 394
      align-items: center;
      flex-direction: column;
李晓兵's avatar
李晓兵 committed
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413
      .top {
        width: 330px;
        height: 54px;
        display: flex;
        align-items: center;
        background-color: #fff;
        img {
          width: 20px;
        }
        span {
          margin-left: 38%;
          font-family: PingFangSC-Semibold;
          font-size: 16px;
          color: #656464;
          letter-spacing: 0.49px;
          text-align: center;
        }
      }
      .info {
李晓兵's avatar
李晓兵 committed
414
        //margin-top: 60px;
李晓兵's avatar
李晓兵 committed
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429
      }
    }
  }
  .modal-show-bank {
    width: 100%;
    height: 100%;
    position: absolute;
    display: flex;
    z-index: 910;
    background-color: rgba(56, 63, 69, 0.3);
    justify-content: center;
    align-items: center;
    .down {
      height: 466px;
      width: 100%;
linxin's avatar
linxin committed
430
     position: relative;
李晓兵's avatar
李晓兵 committed
431
      top:16%;
李晓兵's avatar
李晓兵 committed
432 433 434 435
      background: #fff;
      border-radius: 12px 12px 0 0;
      overflow: scroll;
      display: flex;
李晓兵's avatar
李晓兵 committed
436 437
      align-items: center;
      flex-direction: column;
李晓兵's avatar
李晓兵 committed
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
      .top {
        left: 24px;
        width: 330px;
        height: 54px;
        display: flex;
        align-items: center;
        background-color: #fff;
        img {
          width: 20px;
        }
        span {
          margin-left: 38%;
          font-family: PingFangSC-Semibold;
          font-size: 16px;
          color: #656464;
          letter-spacing: 0.49px;
          text-align: center;
        }
      }
      .pay-way {
        //width: 350px;
        //margin: 0 auto;
李晓兵's avatar
李晓兵 committed
460 461
        width: 100%;
       padding: 0 4% 0 4%;
李晓兵's avatar
李晓兵 committed
462 463 464 465 466 467 468 469 470
        background: #fff;
        .hls-item {
          padding-left: 12px;
          .add-name {
            flex: 3;
            line-height: 56px;
            font-family: PingFangSC-Regular;
            font-size: 14px;
            color: #656464;
李晓兵's avatar
李晓兵 committed
471 472 473 474 475
            div{
              display: flex;
              justify-content: center;
              align-items: center;
            }
李晓兵's avatar
李晓兵 committed
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495
            .icon1 {
              width: 34px;
              height: 34px;
              display: block;
              float: left;
              margin-top: 10px;
              margin-right: 5px;
            }
            .icon2 {
              width: 32px;
              display: block;
              float: left;
              margin-top: 12px;
              margin-right: 8px;
            }
            .icon {
              width: 30px;
              display: block;
              float: left;
              position: relative;
李晓兵's avatar
李晓兵 committed
496
              margin: 0 8px 0 3px;
李晓兵's avatar
李晓兵 committed
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 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579
            }
          }

          .add-content {
            img {
              width: 21px;
            }
          }
        }
      }
    }
  }
  .info {
    width: 100%;
    height: 226px;
    background-color: #fff;
    .info-item {
      height: 46px;
      width: 335px;
      margin: 0 auto;
      position: relative;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .arrow {
        margin-right: -10px;
      }
      img {
        width: 17px;
        margin-right: 10px;
      }
      span:first-child {
        font-family: PingFangSC-Regular;
        font-size: 14px;
        color: rgba(56, 63, 69, 0.6);
        letter-spacing: 0;
        line-height: 18px;
      }
      span:last-child {
        font-family: Verdana;
        font-size: 14px;
        color: #383f45;
        letter-spacing: 0;
        line-height: 18px;
        display: flex;
        align-items: center;
      }
    }
    .info-item:nth-of-type(1)::after {
      content: "";
      display: block;
      position: absolute;
      right: 20px;
      top: 25px;
      border: 10px solid #fff;
      border-left-color: transparent;
      border-right-color: transparent;
      border-top-color: transparent;
      border-bottom-color: rgba(75, 74, 75, 0.1);
    }
    .info-item:nth-of-type(1) {
      border-top: 1px solid #d9dbdf;
    }
    .interest {
      width: 100%;
      height: 37px;
      line-height: 37px;
      font-family: PingFangSC-Medium;
      font-size: 11px;
      color: #4b4a4b;
      letter-spacing: 0;
      text-indent: 215px;
      background-color: rgba(75, 74, 75, 0.1);
    }
  }
  .icon {
    width: 30px;
    display: block;
    float: left;
    position: relative;
    margin: 12px 8px 0 3px;
  }
  .push {
李晓兵's avatar
李晓兵 committed
580
   /* position: absolute;
李晓兵's avatar
李晓兵 committed
581
    top: 10px;
李晓兵's avatar
李晓兵 committed
582
    margin-left: 10px;*/
李晓兵's avatar
李晓兵 committed
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698
    width: 35px;
  }
  .modal-show {
    width: 100%;
    height: 100%;
    position: absolute;
    display: flex;
    z-index: 900;
    background-color: rgba(56, 63, 69, 0.3);
    justify-content: center;
    align-items: center;
    .down {
      position: relative;
      width: 301px;
      height: 162px;
      display: flex;
      justify-content: center;
      flex-flow: column wrap;
      align-items: center;
      background-size: 301px 24.7px;
      background-color: #fff;
      border-radius: 8px;
      p {
        font-family: PingFangSC-Semibold;
        font-size: 16px;
        color: #1d3fff;
        margin-top: 16px;
        flex: 2;
      }
      span {
        font-family: PingFangSC-Regular;
        font-size: 14px;
        color: #383f45;
        flex: 3;
        letter-spacing: 0;
        margin-top: 16px;
      }
      button {
        width: 159px;
        flex: 2;
        margin-bottom: 16px;
        height: 40px;
        background-color: @headerColor;
        font-family: PingFangSC-Semibold;
        font-size: 15px;
        color: #fafafa;
        line-height: 20px;
      }
    }
  }
  .entry-content {
    .amount {
      height: 166px;
      background-color: #fff;
      padding-top: 55px;
      text-align: center;
      border-bottom: 1px solid #d9dbdf;

      p {
        font-family: PingFangSC-Regular;
        font-size: 14px;
        color: #656464;
        letter-spacing: 0;
      }

      div {
        font-family: PingFangSC-Semibold;
        font-size: 24px;
        color: #383f45;
        letter-spacing: 0.86px;
        font-weight: 700;
        margin-top: 10px;
      }
    }

    .pay-way {
      .hls-item {
        padding-left: 12px;
        .add-name {
          flex: 3;
          line-height: 56px;
          font-family: PingFangSC-Regular;
          font-size: 14px;
          color: #656464;

          .icon1 {
            width: 34px;
            height: 34px;
            display: block;
            float: left;
            margin-top: 10px;
            margin-right: 5px;
          }
          .icon2 {
            width: 32px;
            display: block;
            float: left;
            margin-top: 12px;
            margin-right: 8px;
          }
        }

        .add-content {
          img {
            width: 21px;
          }
        }
      }
    }
  }
  .footer {
    color: #fff;
    background-color: @headerColor;
  }
}
</style>