123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300 |
- <template>
- <view class="container card clearfix">
- <tui-skeleton
- v-if="skeletonShow"
- backgroundColor="#fafafa"
- borderRadius="10rpx"
- :isLoading="true"
- :loadingType="5"
- ></tui-skeleton>
- <template v-else>
- <view class="card-content">
- <view class="card-title" v-if="subType === 2 || subType === 3">
- <view class="card-pay-text">¥{{ payAmount }}</view>
- </view>
- <view class="card-mains">
- <view class="card-form-text">已发送至手机号 {{ phoneNumbe }}</view>
- <view class="card-form">
- <input
- class="card-input"
- v-model="codeParams.bindCode"
- @input="handleInput"
- type="number"
- maxlength="6"
- placeholder="请输入短信验证码"
- />
- <view
- class="card-form-code"
- :class="isMobileDisabled ? 'disabled' : ''"
- @click.stop="handleMobileCode"
- >
- <text>{{ mobileCodeText }}</text>
- </view>
- </view>
- </view>
- <view class="card-mains-btn">
- <button
- class="add-btn"
- :disabled="disabled"
- :class="[disabled ? 'disabled' : '']"
- @click="handleAddCard"
- >
- {{ suBbtnText }}
- </button>
- </view>
- </view>
- </template>
- </view>
- </template>
- <script>
- 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: '确认绑定'
- }
- },
- onLoad(option) {
- this.initOption(option)
- },
- 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) {
- console.log('option', option)
- const data = JSON.parse(option.data)
- this.subType = Number(option.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(() => {
- this.skeletonShow = false
- }, 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 ? '绑定成功' : '支付成功'
- const res = await this.PayService.orderPayQuickBindCode(this.codeParams, loadText)
- if(this.subType === 1){
- this.$util.msg(successMsg, 2000, true, 'success')
- setTimeout(() => {
- this.handleSuccessHref()
- }, 2000)
- }else{
- this.handleSuccessHref()
- }
- } catch (error) {
- console.log(error)
- this.$util.msg(error.msg, 2000)
- }
- },
- handleSuccessHref() {
- // tiaozhuan
- if (this.subType === 1) {
- this.$api.navigateBack(2)
- } else {
- if (this.params.quickPayFlag === 1) {
- const linkData = {
- payAmount: this.params.payAmount,
- orderId: this.orderId,
- type: 'success'
- }
- this.$api.redirectTo(`/pages/user/pay/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 {
- const res = await this.PayService.orderPayQuickBindCard(this.params)
- this.handleCodeTime()
- } catch (error) {
- this.isMobileDisabled = false
- }
- },
- async orderPayQuickPay() {
- //绑卡并支付
- try {
- const res = await this.PayService.orderPayQuickPay(this.params)
- this.handleCodeTime()
- } catch (error) {
- console.log(error)
- this.isMobileDisabled = false
- }
- }
- },
- onShow() {
- }
- }
- </script>
- <style lang="scss">
- page,
- .container {
- background: #ffffff;
- height: 100%;
- }
- .card-content {
- width: 100%;
- height: auto;
- box-sizing: border-box;
- padding-top: 70rpx;
- }
- .card-title {
- width: 100%;
- height: auto;
- box-sizing: border-box;
- padding: 0 0 70rpx 0;
- .card-pay-text {
- width: 100%;
- height: 90rpx;
- line-height: 90rpx;
- text-align: center;
- font-size: 56rpx;
- color: #F3B574;
- font-weight: bold;
- box-sizing: border-box;
- }
- }
- .card-mains {
- width: 100%;
- height: 100rpx;
- box-sizing: border-box;
- padding: 0 50rpx 0 32rpx;
- .card-form-text {
- width: 100%;
- height: 40rpx;
- line-height: 40rpx;
- text-align: left;
- font-size: $font-size-28;
- color: #333;
- box-sizing: border-box;
- margin-bottom: 16rpx;
- }
- .card-form {
- width: 100%;
- height: 100%;
- box-sizing: border-box;
- border: 1px solid #cccccc;
- padding: 14rpx 0;
- border-radius: 16rpx;
- position: relative;
- .card-input {
- width: 460rpx;
- height: 100%;
- line-height: 96rpx;
- padding-left: 32rpx;
- box-sizing: border-box;
- font-size: $font-size-30;
- color: #333;
- border-right: 1px solid #e1e1e1;
- float: left;
- }
- .card-form-code {
- width: 204rpx;
- height: 72rpx;
- line-height: 72rpx;
- 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 75rpx;
- margin-top: 180rpx;
- .add-btn {
- width: 100%;
- height: 90rpx;
- font-size: $font-size-30;
- line-height: 90rpx;
- color: #ffffff;
- text-align: center;
- background: $btn-confirm;
- border-radius: 45rpx;
- border-radius: 44rpx;
- margin-top: 80rpx;
- &.disabled {
- background: #e1e1e1;
- border-radius: 44rpx;
- }
- }
- }
- </style>
|