123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416 |
- <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-row">
- <view class="form-label">卡号</view>
- <view class="form-input">
- <input
- class="card-input"
- v-model="showCardNumber"
- @input="handleInput"
- type="number"
- :maxlength="maxLen"
- placeholder="请输入本人的银行卡号"
- />
- <view class="card-clear" v-if="!showClear" @click="handleClearInput"
- ><text class="iconfont icon-shanchu1"></text
- ></view>
- </view>
- </view>
- <view class="card-row picker">
- <view class="form-label">卡类型</view>
- <view class="form-input">
- <picker @change="handleBindPicker($event)" :value="index" :range="stateActions" range-key="name">
- <input
- class="form-input"
- type="text"
- disabled="false"
- v-model="cardTytpeText"
- placeholder="请选择"
- />
- </picker>
- </view>
- <view class="iconfont icon-xiangyou"></view>
- </view>
- <view class="card-row">
- <view class="form-label">姓名</view>
- <input
- class="form-input"
- type="text"
- name="input"
- v-model="params.quickPayUserName"
- placeholder="请输入您的姓名"
- maxlength="10"
- />
- </view>
- <view class="card-row">
- <view class="form-label">身份证</view>
- <input
- class="form-input"
- type="text"
- name="input"
- v-model="params.idCard"
- placeholder="请输入您的身份证号"
- maxlength="18"
- />
- </view>
- <view class="card-row">
- <view class="form-label">预留手机号</view>
- <input
- class="form-input"
- type="number"
- name="input"
- v-model="params.quickPayMobile"
- placeholder="请输入您的银行预留手机号"
- maxlength="11"
- />
- </view>
- <view class="card-row picker" v-if="pickerIndex === 2">
- <view class="form-label">有效期</view>
- <view class="form-input">
- <picker
- mode="date"
- fields="month"
- :value="date"
- :start="startDate"
- :end="endDate"
- @change="handleDateChange($event)"
- >
- <input
- class="form-input"
- type="text"
- disabled="false"
- :class="handleBankExpireTime === '请选择信用卡有效期' ? 'none' : '' "
- v-model="handleBankExpireTime"
- placeholder="请选择信用卡有效期"
- />
- </picker>
- </view>
- <view class="iconfont icon-xiangyou"></view>
- </view>
- <view class="card-row" v-if="pickerIndex === 2">
- <view class="form-label">CVV2</view>
- <input
- class="form-input"
- type="text"
- name="input"
- v-model="params.cvvCode"
- placeholder="请输入贷记卡背面的安全码"
- maxlength="3"
- />
- </view>
- <view class="card-mains-btn">
- <button
- class="add-btn"
- :disabled="disabled"
- :class="[disabled ? 'disabled' : '']"
- @click="handleAddCard"
- >
- {{ subButtonText }}
- </button>
- </view>
- <view class="card-mains-text" @click="handleGoSusList">查看支持银行 ></view>
- </view>
- </template>
- </view>
- </template>
- <script>
- export default {
- data() {
- const currentDate = this.getDate({
- format: true
- })
- return {
- date: currentDate,
- skeletonShow:true,
- pickerIndex: 1,
- orderId: 0,
- payAmount: '',
- params: {
- userId: 0, //机构UserId
- quickPayBankNumber: '', //快捷支付用户银行卡号/信用卡号
- quickPayMobile: '', //快捷支付银行卡绑定手机号
- quickPayBankExpireTime: '', //快捷支付信用卡过期时间,只包含年月,格式yy-MM
- quickPayUserName: '', //快捷支付用户姓名
- idCard: '', //身份证号
- cvvCode: '' //信用卡安全码
- },
- showCardNumber: '',
- maxLen: 26,
- subType: 0, // 1直接绑卡 2//首次绑卡并支付 3//确认支付
- handleBankExpireTime:'请选择信用卡有效期',
- cardTytpeText: '借记卡',
- subButtonText: '下一步',
- stateActions: [{ name: '借记卡', value: 1 }, { name: '贷记卡', value: 2 }]
- }
- },
- onLoad(option) {
- this.subType = Number(option.type)
- this.initGetStotage(option)
- },
- filters: {},
- computed: {
- startDate() {
- return this.getDate('start')
- },
- endDate() {
- return this.getDate('end')
- },
- showClear() {
- return this.params.quickPayBankNumber.length <= 12
- },
- disabled() {
- if (this.pickerIndex === 1) {
- return !(
- this.params.quickPayBankNumber.length > 12 &&
- this.params.quickPayUserName != '' &&
- this.params.idCard != '' &&
- this.params.quickPayMobile != ''
- )
- } else {
- return !(
- this.params.quickPayBankNumber.length > 12 &&
- this.params.quickPayUserName != '' &&
- this.params.idCard != '' &&
- this.params.quickPayMobile != '' &&
- this.params.quickPayBankExpireTime != '' &&
- this.params.cvvCode != ''
- )
- }
- }
- },
- methods: {
- async initGetStotage(option) {
- const userInfo = await this.$api.getStorage()
- this.params.userId = userInfo.userId ? userInfo.userId : 0
- if (this.subType != 1) {
- const data = JSON.parse(option.data)
- this.params = { ...this.params, ...data.payData }
- this.orderId = data.orderId ? data.orderId : 0
- this.payAmount = data.payAmount ? data.payAmount :0
- }
- console.log('params', this.params)
- setTimeout(()=>{
- this.skeletonShow = false
- },500)
- },
- handleAddCard() {
- //提交卡号
- if (!this.$reg.isIdCard(this.params.idCard)) {
- this.$util.msg('请输入正确的身份证号', 2000)
- return
- }
- if (!this.$reg.isMobile(this.params.quickPayMobile)) {
- this.$util.msg('请输入正确的手机号', 2000)
- return
- }
- if (this.subType === 1) {
- this.orderPayQuickBindCard()
- } else {
- this.orderPayQuickPay()
- }
- },
- async orderPayQuickBindCard() {
- //直接绑卡
- try {
- const res = await this.PayService.orderPayQuickBindCard(this.params)
- console.log('res', res.data)
- const data = JSON.stringify({ params: this.params, payData: res.data })
- this.$api.navigateTo(`/pages/user/pay/card-comfirm-sub?type=${this.subType}&data=${data}`)
- } catch (error) {
- this.$util.msg(error.msg, 2000)
- }
- },
- async orderPayQuickPay() {
- //绑卡并支付
- try {
- const res = await this.PayService.orderPayQuickPay(this.params)
- console.log('res', res.data)
- const data = {
- params: this.params,
- payData: res.data,
- orderId: this.orderId,
- payAmount: this.payAmount
- }
- this.$api.navigateTo(`/pages/user/pay/card-comfirm-sub?type=${this.subType}&data=${JSON.stringify(data)}`)
- } catch (error) {
- this.$util.msg(error.msg, 2000)
- }
- },
- handleDateChange(event) {
- //开始时间
- console.log('event',event)
- this.handleBankExpireTime = this.params.quickPayBankExpireTime = event.detail.value
- },
- handleBindPicker(e) {
- //选择银行卡类型
- this.cardTytpeText = this.stateActions[e.target.value].name
- this.pickerIndex = this.stateActions[e.target.value].value
- },
- handleClearInput() {
- //清空银行卡
- this.params.quickPayBankNumber = this.showCardNumber = ''
- },
- handleInput(e) {
- this.showCardNumber = this.formatAccNo(e.detail.value)
- this.params.quickPayBankNumber = this.showCardNumber.split(/[\t\r\f\n\s]*/g).join('')
- },
- handleGoSusList() {
- // 跳转支持银行
- this.$api.navigateTo(`/pages/user/pay/card-sus-list`)
- },
- formatAccNo(value) {
- const newValue = value.replace(/([^0-9])/g, '') // 只允许输入数字
- const formatValue = newValue.replace(/(\d{4})(?=\d)/g, '$1 ') // 每4个数字后面加一个空格
- const inputLen = this.getOriginValue().length
- if (inputLen > this.maxLen) {
- // 如果输入的字符大于最大输入长度则禁止继续输入
- return
- }
- return formatValue
- },
- getOriginValue() {
- //获取input的原始值
- return this.showCardNumber.split(' ').join('')
- },
- getDate(type) {
- const date = new Date()
- let year = date.getFullYear()
- let month = date.getMonth() + 1
- let day = date.getDate()
- if (type === 'start') {
- year = year - 1
- } else if (type === 'end') {
- year = year + 1
- }
- month = month > 9 ? month : '0' + month
- day = day > 9 ? day : '0' + day
- return `${year}-${month}`
- }
- },
- onShow() {
- // this.beansList = []
- }
- }
- </script>
- <style lang="scss">
- page,
- .container {
- background: #ffffff;
- height: 100%;
- }
- .card-content {
- width: 100%;
- height: auto;
- box-sizing: border-box;
- padding: 32rpx;
- .card-row {
- width: 100%;
- height: 100rpx;
- box-sizing: border-box;
- border-bottom: 1px solid #e1e1e1;
- position: relative;
- float: left;
- &.picker {
- padding-right: 60rpx;
- }
- .form-label {
- float: left;
- height: 100%;
- line-height: 98rpx;
- font-size: $font-size-28;
- text-align: left;
- color: #666666;
- }
- .form-input {
- min-width: 500rpx;
- height: 98rpx;
- line-height: 98rpx;
- font-size: $font-size-28;
- text-align: right;
- color: #333333;
- float: right;
- position: relative;
- &.none{
- color: #999999;
- }
- .card-input {
- width: 568rpx;
- height: 100%;
- line-height: 96rpx;
- padding-left: 20rpx;
- box-sizing: border-box;
- font-size: $font-size-30;
- color: #333;
- padding-right: 60rpx;
- }
- .card-clear {
- width: 60rpx;
- height: 96rpx;
- position: absolute;
- right: 0;
- top: 0;
- line-height: 96rpx;
- text-align: center;
- .icon-shanchu1 {
- font-size: $font-size-32;
- color: #d5d5d5;
- }
- }
- }
- .icon-xiangyou {
- width: 60rpx;
- height: 100rpx;
- position: absolute;
- right: 0;
- top: 0;
- line-height: 100rpx;
- text-align: center;
- color: #b2b2b2;
- }
- }
- .card-mains-btn {
- width: 100%;
- height: auto;
- box-sizing: border-box;
- padding: 0 43rpx;
- margin-top: 180rpx;
- float: left;
- .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;
- }
- }
- }
- .card-mains-text {
- width: 100%;
- line-height: 88rpx;
- box-sizing: border-box;
- padding: 0 56rpx;
- font-size: $font-size-28;
- color: #1890f9;
- text-align: center;
- float: left;
- }
- }
- </style>
|