123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <template>
- <el-dialog
- :visible.sync="visible"
- v-bind="modalOptions"
- append-to-body
- >
- <el-form
- ref="formData"
- :model="formData"
- :rules="formRules"
- size="mini"
- label-suffix=":"
- label-width="150px"
- >
- <el-form-item label="注册手机号" prop="phone">
- <el-input v-model="formData.phone" maxlength="11" placeholder="注册手机号" disabled style="width: 120px;" />
- <el-button style="margin-left: 10px;" type="primary" :loading="codeLoading" @click="handleSendCode(formData.phone)">
- <span v-if="!codeLoading">获取验证码</span>
- <span v-else>{{ codeCount }} s</span>
- </el-button>
- </el-form-item>
- <el-form-item label="验证码" prop="code">
- <el-input
- v-model="formData.code" oninput="value=value.replace(/[^\d]/g,'')" maxlength="6"
- style="width: 120px;"
- />
- </el-form-item>
- </el-form>
- <template #footer>
- <span class="dialog-footer">
- <el-button size="mini" @click="handleClose">取 消</el-button>
- <el-button type="primary" size="mini" @click="handleSubmit">确 定</el-button>
- </span>
- </template>
- </el-dialog>
- </template>
- <script>
- import { getCode, bankDelete } from '@/api/account'
- export default {
- name: 'UnBindBank',
- components: {
- },
- data() {
- return {
- modalOptions: {
- closeOnClickModal: false,
- width: '620px',
- title: ''
- },
- visible: false,
- formData: {
- phone: '',
- code: ''
- },
- formRules: {
- phone: [ { required: true, message: '缺少注册手机号' } ],
- code: [ { required: true, message: '请输入验证码' } ]
- },
- codeTimer: '',
- codeLoading: false,
- codeCount: ''
- }
- },
- methods: {
- handleClose() {
- this.visible = false
- },
- // 获取验证码
- async handleSendCode(phone) {
- if (phone === '') {
- this.$message.error('请填写电话号码')
- return
- } else if (!/^1[3-9]\d{9}$/.test(phone)) {
- this.$message({
- message: '请输入正确手机号',
- type: 'warning'
- })
- return false
- }
- if (!this.codeTimer) {
- const res = await getCode({ phone })
- if (res.code === '') {
- this.$message({
- message: '发送成功,请注意查看手机短信',
- type: 'success'
- })
- }
- this.codeLoading = true
- this.codeCount = 60
- this.codeTimer = setInterval(() => {
- if (this.codeCount > 0 && this.codeCount <= 60) {
- this.codeCount--
- } else {
- clearInterval(this.codeTimer) // 清除定时器
- this.codeTimer = null
- this.codeLoading = false
- }
- }, 1000)
- }
- },
- initList() {
- },
- handleOpen(params = {}) {
- this.modalOptions.title = '解绑银行卡'
- this.formData.phone = params.phone
- // this.formData = Object.assign(this.$options.data().formData, params)
- this.visible = true
- this.initList()
- this.$refs.formData && this.$refs.formData.resetFields()
- },
- handleSubmit() {
- this.$refs.formData.validate(async (valid) => {
- if (valid) {
- const loading = this.$loading({ text: '加载中' })
- try {
- const { ...otps } = this.formData
- const params = {
- ...otps
- }
- await bankDelete(params)
- loading.close()
- this.$message({ message: `解绑成功!`, type: 'success' })
- this.$emit('success')
- this.visible = false
- } catch (e) {
- loading.close()
- } finally {
- loading.close()
- }
- } else {
- this.$message({ message: '请输入相关信息', type: 'warning' })
- return false
- }
- })
- }
- }
- }
- </script>
|