|
@@ -0,0 +1,289 @@
|
|
|
+<template>
|
|
|
+<div class="container card clearfix">
|
|
|
+ <div class="card-content">
|
|
|
+ <div class="card-title" v-if="subType === 2 || subType === 3">
|
|
|
+ <div class="card-pay-text">¥{{ payAmount }}</div>
|
|
|
+ </div>
|
|
|
+ <div class="card-mains">
|
|
|
+ <div class="card-form-text">已发送至手机号 {{ phoneNumbe }}</div>
|
|
|
+ <div class="card-form">
|
|
|
+ <input
|
|
|
+ class="card-input"
|
|
|
+ v-model="codeParams.bindCode"
|
|
|
+ @input="handleInput"
|
|
|
+ type="number"
|
|
|
+ maxlength="6"
|
|
|
+ placeholder="请输入短信验证码"
|
|
|
+ />
|
|
|
+ <div
|
|
|
+ class="card-form-code"
|
|
|
+ :class="isMobileDisabled ? 'disabled' : ''"
|
|
|
+ @click.stop="handleMobileCode"
|
|
|
+ >
|
|
|
+ <text>{{ mobileCodeText }}</text>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="card-mains-btn">
|
|
|
+ <button
|
|
|
+ class="add-btn"
|
|
|
+ :disabled="disabled"
|
|
|
+ :class="[disabled ? 'disabled' : '']"
|
|
|
+ @click="handleAddCard"
|
|
|
+ >
|
|
|
+ {{ suBbtnText }}
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</div>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+import { Toast } from 'vant'
|
|
|
+import { orderPayQuickPay, orderPayQuickBindCard } from '@/api/institutionApi/pay'
|
|
|
+export default {
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ orderId: 0,
|
|
|
+ params: {},
|
|
|
+ payAmount: '',
|
|
|
+ subType: 1, // 1直接绑卡 2//首次绑卡并支付 3//确认支付
|
|
|
+ isMobileDisabled: true, // 手机验证码按钮控制
|
|
|
+ mobilCount: '', // 倒计时
|
|
|
+ mobileCodeText: '重新发送',
|
|
|
+ mobilTime: null,
|
|
|
+ codeParams: {
|
|
|
+ orderId: '',
|
|
|
+ infoId: '',
|
|
|
+ bindCode: '',
|
|
|
+ flag: 1 // 1绑卡 2 付款
|
|
|
+ },
|
|
|
+ skeletonShow: true,
|
|
|
+ suBbtnText: '确认绑定'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted () {
|
|
|
+ this.initOption(this.$route.query.data, this.$route.query.type)
|
|
|
+ },
|
|
|
+ filters: {},
|
|
|
+ computed: {
|
|
|
+ phoneNumbe () {
|
|
|
+ // 手机号仅显示前三位及后四位数字,隐藏信息用*代替
|
|
|
+ return this.params.quickPayMobile.substr(0, 3) + '****' + this.params.quickPayMobile.substring(7)
|
|
|
+ },
|
|
|
+ disabled () {
|
|
|
+ return !(this.codeParams.bindCode.length > 4)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ initOption (option, type) {
|
|
|
+ console.log('option', option)
|
|
|
+ const data = JSON.parse(option)
|
|
|
+ this.subType = Number(type)
|
|
|
+ this.params = data.params
|
|
|
+ this.codeParams = Object.assign(this.codeParams, data.payData)
|
|
|
+ if (this.subType === 1) {
|
|
|
+ this.codeParams.flag = 1
|
|
|
+ } else {
|
|
|
+ this.codeParams.flag = 2
|
|
|
+ this.orderId = data.orderId
|
|
|
+ this.payAmount = this.params.quickPayFlag === 2 ? data.payAmount : this.params.payAmount
|
|
|
+ }
|
|
|
+ this.handleCodeTime()
|
|
|
+ this.handleBbtnText(this.subType)
|
|
|
+ setTimeout(() => {
|
|
|
+ Toast.loading('加载中')
|
|
|
+ }, 500)
|
|
|
+ },
|
|
|
+ handleCodeTime () {
|
|
|
+ // 倒计时
|
|
|
+ const TIME_COUNT = 60
|
|
|
+ if (!this.mobilTime) {
|
|
|
+ this.mobilCount = TIME_COUNT
|
|
|
+ this.isMobileDisabled = true
|
|
|
+ this.mobilTime = setInterval(() => {
|
|
|
+ if (this.mobilCount > 1 && this.mobilCount <= TIME_COUNT) {
|
|
|
+ this.mobilCount--
|
|
|
+ this.mobileCodeText = this.mobilCount + '秒后重发'
|
|
|
+ } else {
|
|
|
+ this.isMobileDisabled = false
|
|
|
+ clearInterval(this.mobilTime)
|
|
|
+ this.mobilTime = null
|
|
|
+ this.mobileCodeText = '重新发送'
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleBbtnText (value) {
|
|
|
+ const textMap = {
|
|
|
+ 1: '确认绑定',
|
|
|
+ 2: '确认绑定支付',
|
|
|
+ 3: '确认支付'
|
|
|
+ }
|
|
|
+ this.suBbtnText = textMap[value]
|
|
|
+ },
|
|
|
+ async handleAddCard () {
|
|
|
+ // 提交绑定或支付
|
|
|
+ try {
|
|
|
+ const loadText = this.subType === 1 ? '绑定中...' : '支付中...'
|
|
|
+ const successMsg = this.subType === 1 ? '绑定成功' : '支付成功'
|
|
|
+ await this.PayService.orderPayQuickBindCode(this.codeParams, loadText)
|
|
|
+ Toast.success(successMsg)
|
|
|
+ setTimeout(() => {
|
|
|
+ this.handleSuccessHref()
|
|
|
+ }, 2000)
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error)
|
|
|
+ Toast.fail(error.msg)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleSuccessHref () {
|
|
|
+ // tiaozhuan
|
|
|
+ if (this.subType === 1) {
|
|
|
+ this.$api.navigateBack(2)
|
|
|
+ } else {
|
|
|
+ if (this.params.quickPayFlag === 1) {
|
|
|
+ const linkData = {
|
|
|
+ payAmount: this.params.payAmount,
|
|
|
+ shopOrderId: this.shopOrderId,
|
|
|
+ orderId: this.orderId,
|
|
|
+ type: 'success'
|
|
|
+ }
|
|
|
+ this.$api.redirectTo(`/pages/user/order/order-success?data=${JSON.stringify({ data: linkData })}`)
|
|
|
+ } else {
|
|
|
+ this.$api.redirectTo('/pages/user/member/member')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleMobileCode () {
|
|
|
+ // 获取短信验证码
|
|
|
+ this.isMobileDisabled = true
|
|
|
+ if (this.subType === 1) {
|
|
|
+ this.orderPayQuickBindCard()
|
|
|
+ } else {
|
|
|
+ this.orderPayQuickPay()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async orderPayQuickBindCard () {
|
|
|
+ // 直只绑卡
|
|
|
+ try {
|
|
|
+ await orderPayQuickBindCard(this.params)
|
|
|
+ this.handleCodeTime()
|
|
|
+ } catch (error) {
|
|
|
+ this.isMobileDisabled = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async orderPayQuickPay () {
|
|
|
+ // 绑卡并支付
|
|
|
+ try {
|
|
|
+ await orderPayQuickPay(this.params)
|
|
|
+ this.handleCodeTime()
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error)
|
|
|
+ this.isMobileDisabled = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onShow () {
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scope>
|
|
|
+.container {
|
|
|
+ background: #ffffff;
|
|
|
+ height: 100%;
|
|
|
+}
|
|
|
+.card-content {
|
|
|
+ width: 100%;
|
|
|
+ height: auto;
|
|
|
+ box-sizing: border-box;
|
|
|
+ padding-top: 70px;
|
|
|
+}
|
|
|
+.card-title {
|
|
|
+ width: 100%;
|
|
|
+ height: auto;
|
|
|
+ box-sizing: border-box;
|
|
|
+ padding: 0 0 70px 0;
|
|
|
+ .card-pay-text {
|
|
|
+ width: 100%;
|
|
|
+ height: 90px;
|
|
|
+ line-height: 90px;
|
|
|
+ text-align: center;
|
|
|
+ font-size: 56px;
|
|
|
+ color: #ff5b00;
|
|
|
+ font-weight: bold;
|
|
|
+ box-sizing: border-box;
|
|
|
+ }
|
|
|
+}
|
|
|
+.card-mains {
|
|
|
+ width: 100%;
|
|
|
+ height: 100px;
|
|
|
+ box-sizing: border-box;
|
|
|
+ padding: 0 50px 0 32px;
|
|
|
+ .card-form-text {
|
|
|
+ width: 100%;
|
|
|
+ height: 40px;
|
|
|
+ line-height: 40px;
|
|
|
+ text-align: left;
|
|
|
+ font-size: $font-size-28;
|
|
|
+ color: #333;
|
|
|
+ box-sizing: border-box;
|
|
|
+ margin-bottom: 16px;
|
|
|
+ }
|
|
|
+ .card-form {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ box-sizing: border-box;
|
|
|
+ border: 1px solid #cccccc;
|
|
|
+ padding: 14px 0;
|
|
|
+ border-radius: 16px;
|
|
|
+ position: relative;
|
|
|
+ .card-input {
|
|
|
+ width: 460px;
|
|
|
+ height: 100%;
|
|
|
+ line-height: 96px;
|
|
|
+ padding-left: 32px;
|
|
|
+ box-sizing: border-box;
|
|
|
+ font-size: $font-size-30;
|
|
|
+ color: #333;
|
|
|
+ border-right: 1px solid #e1e1e1;
|
|
|
+ float: left;
|
|
|
+ }
|
|
|
+ .card-form-code {
|
|
|
+ width: 204px;
|
|
|
+ height: 72px;
|
|
|
+ line-height: 72px;
|
|
|
+ text-align: center;
|
|
|
+ color: $color-system;
|
|
|
+ font-size: $font-size-26;
|
|
|
+ float: left;
|
|
|
+ &.disabled {
|
|
|
+ color: #999;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+.card-mains-btn {
|
|
|
+ width: 100%;
|
|
|
+ height: auto;
|
|
|
+ box-sizing: border-box;
|
|
|
+ padding: 0 75px;
|
|
|
+ margin-top: 180px;
|
|
|
+ .add-btn {
|
|
|
+ width: 100%;
|
|
|
+ height: 90px;
|
|
|
+ font-size: $font-size-30;
|
|
|
+ line-height: 90px;
|
|
|
+ color: #ffffff;
|
|
|
+ text-align: center;
|
|
|
+ background: $btn-confirm;
|
|
|
+ border-radius: 45px;
|
|
|
+ border-radius: 44px;
|
|
|
+ margin-top: 80px;
|
|
|
+ &.disabled {
|
|
|
+ background: #e1e1e1;
|
|
|
+ border-radius: 44px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|