|
|
@@ -0,0 +1,226 @@
|
|
|
+<template>
|
|
|
+ <div class="page">
|
|
|
+ <page-bar>
|
|
|
+ 添加银行卡
|
|
|
+ <template #sub>成功绑定应行卡后</template>
|
|
|
+ <template #sub-prim>不能修改</template>
|
|
|
+ </page-bar>
|
|
|
+ <van-form @submit="onSubmit" class="form">
|
|
|
+ <van-field
|
|
|
+ type="digit"
|
|
|
+ name="卡号"
|
|
|
+ label="卡号"
|
|
|
+ :maxlength="23"
|
|
|
+ placeholder="点击输入银行卡号"
|
|
|
+ :formatter="bankFormatter"
|
|
|
+ v-model="form.bankNo"
|
|
|
+ clearable
|
|
|
+ :rules="[{ required: true, message: '请填写银行卡号' }]"
|
|
|
+ />
|
|
|
+ <van-field
|
|
|
+ type="tel"
|
|
|
+ name="银行预留手机号"
|
|
|
+ label="银行预留手机号"
|
|
|
+ placeholder="请输入银行预留手机号"
|
|
|
+ v-model="form.phone"
|
|
|
+ :rules="[
|
|
|
+ { required: true, message: '请填写银行预留手机号' },
|
|
|
+ {
|
|
|
+ pattern: phonePattern,
|
|
|
+ message: '手机号码格式错误'
|
|
|
+ }
|
|
|
+ ]"
|
|
|
+ />
|
|
|
+ <div class="sub">
|
|
|
+ <van-button type="primary" :disabled="!canNext" round block native-type="submit">下一步</van-button>
|
|
|
+ </div>
|
|
|
+ </van-form>
|
|
|
+
|
|
|
+ <van-popup class="popup-content" v-model:show="show" teleport="body" position="bottom">
|
|
|
+ <div class="popup">
|
|
|
+ <div class="cancel" @click="show = false">取消</div>
|
|
|
+ <div class="title">输入验证码</div>
|
|
|
+ <div class="phone">已发送到您{{ phoneText }}手机</div>
|
|
|
+ <van-password-input :value="form.code" :length="4" />
|
|
|
+ <!-- 数字键盘 -->
|
|
|
+ <van-number-keyboard
|
|
|
+ maxlength="4"
|
|
|
+ theme="custom"
|
|
|
+ v-model="form.code"
|
|
|
+ :show="show"
|
|
|
+ close-button-text="完成"
|
|
|
+ @close="bind"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </van-popup>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import phone from '../../mixins/phone';
|
|
|
+export default {
|
|
|
+ mixins: [phone],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ form: {},
|
|
|
+ show: false
|
|
|
+ };
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ canNext() {
|
|
|
+ return this.form.bankNo && this.form.phone;
|
|
|
+ },
|
|
|
+ phoneText() {
|
|
|
+ let phone = this.form.phone || '';
|
|
|
+ if (phone.length === 11) {
|
|
|
+ return phone.substr(0, 3) + '****' + phone.substr(-4, 4);
|
|
|
+ }
|
|
|
+
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ onSubmit() {
|
|
|
+ this.sendMsg(this.form.phone);
|
|
|
+ this.form.code = '';
|
|
|
+ this.show = true;
|
|
|
+ },
|
|
|
+ bind() {
|
|
|
+ if (!this.form.code || this.form.code.length < 4) {
|
|
|
+ this.$toast('请输入验证码');
|
|
|
+ } else {
|
|
|
+ this.$toast.loading({
|
|
|
+ message: '加载中...',
|
|
|
+ forbidClick: true
|
|
|
+ });
|
|
|
+ let bankNo = this.form.bankNo.replace(/ /g, '');
|
|
|
+ this.$http
|
|
|
+ .post(`/user/addBankCard?bankNo=${bankNo}&phone=${this.form.phone}&code=${this.form.code}`)
|
|
|
+ .then(res => {
|
|
|
+ this.$toast.success('添加成功');
|
|
|
+ setTimeout(() => {
|
|
|
+ this.$router.go(-1);
|
|
|
+ }, 1000);
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ if (e) {
|
|
|
+ this.$toast(e.error);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ bankFormatter(val) {
|
|
|
+ let _val = val.replace(/ /g, '');
|
|
|
+ _val = _val.split('');
|
|
|
+ let vals = [];
|
|
|
+ _val.forEach((item, index) => {
|
|
|
+ vals.push(item);
|
|
|
+ if ((index - 2) % 4 === 0 && index !== _val.length - 1) {
|
|
|
+ vals.push(' ');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return vals.join('');
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+/deep/.form {
|
|
|
+ .van-cell {
|
|
|
+ .flex-col();
|
|
|
+
|
|
|
+ .van-field__label {
|
|
|
+ width: auto;
|
|
|
+ }
|
|
|
+
|
|
|
+ .van-field__body {
|
|
|
+ line-height: 48px;
|
|
|
+ border-radius: 8px;
|
|
|
+ border: 1px solid #494a4d;
|
|
|
+ padding: 0 16px;
|
|
|
+ margin-top: 6px;
|
|
|
+
|
|
|
+ .van-field__control {
|
|
|
+ font-size: @font1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .van-field__error-message {
|
|
|
+ margin-top: 6px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+.sub {
|
|
|
+ margin: 60px 48px;
|
|
|
+}
|
|
|
+@bottom: 280px;
|
|
|
+@gray3: #c8c9cc;
|
|
|
+.popup {
|
|
|
+ color: #000;
|
|
|
+ position: relative;
|
|
|
+ padding-bottom: calc(@bottom+ constant(safe-area-inset-bottom));
|
|
|
+ padding-bottom: calc(@bottom + env(safe-area-inset-bottom));
|
|
|
+ .title {
|
|
|
+ text-align: center;
|
|
|
+ font-size: @font3;
|
|
|
+ padding: 20px 0;
|
|
|
+ border-bottom: 1px solid #c8c9cc;
|
|
|
+ }
|
|
|
+
|
|
|
+ .cancel {
|
|
|
+ position: absolute;
|
|
|
+ font-size: @font1;
|
|
|
+ font-family: PingFangSC-Regular, PingFang SC;
|
|
|
+ font-weight: 400;
|
|
|
+ color: #939599;
|
|
|
+ line-height: 22px;
|
|
|
+ padding: 21px 20px;
|
|
|
+ left: 0;
|
|
|
+ top: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .phone {
|
|
|
+ padding: 12px 0 20px;
|
|
|
+ text-align: center;
|
|
|
+ font-size: 12px;
|
|
|
+ color: #aaabad;
|
|
|
+ line-height: 24px;
|
|
|
+ }
|
|
|
+
|
|
|
+ /deep/.van-password-input {
|
|
|
+ margin: 0 80px;
|
|
|
+ }
|
|
|
+
|
|
|
+ /deep/.van-key {
|
|
|
+ &:hover {
|
|
|
+ background-color: @gray3;
|
|
|
+ }
|
|
|
+ &:focus {
|
|
|
+ background-color: @gray3;
|
|
|
+ }
|
|
|
+ &:active {
|
|
|
+ background-color: @gray3;
|
|
|
+ }
|
|
|
+ &:link {
|
|
|
+ background-color: @gray3;
|
|
|
+ }
|
|
|
+ &:visited {
|
|
|
+ background-color: @gray3;
|
|
|
+ }
|
|
|
+
|
|
|
+ &.van-key--active {
|
|
|
+ background-color: @gray3;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /deep/[class*='van-hairline']::after {
|
|
|
+ border-color: @gray3;
|
|
|
+ }
|
|
|
+
|
|
|
+ /deep/.van-key--blue {
|
|
|
+ background: linear-gradient(135deg, #fdfb60 0%, #ff8f3e 100%);
|
|
|
+ color: #333230;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|