UnBindBank.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <el-dialog
  3. :visible.sync="visible"
  4. v-bind="modalOptions"
  5. append-to-body
  6. >
  7. <el-form
  8. ref="formData"
  9. :model="formData"
  10. :rules="formRules"
  11. size="mini"
  12. label-suffix=":"
  13. label-width="150px"
  14. >
  15. <el-form-item label="注册手机号" prop="phone">
  16. <el-input v-model="formData.phone" maxlength="11" placeholder="注册手机号" disabled style="width: 120px;" />
  17. </el-form-item>
  18. <el-form-item label="验证码" prop="code">
  19. <GraphicVerificationCode
  20. :phone="formData.phone"
  21. @input="(e) => formData.code = e"
  22. ></GraphicVerificationCode>
  23. </el-form-item>
  24. </el-form>
  25. <template #footer>
  26. <span class="dialog-footer">
  27. <el-button size="mini" @click="handleClose">取 消</el-button>
  28. <el-button type="primary" size="mini" @click="handleSubmit">确 定</el-button>
  29. </span>
  30. </template>
  31. </el-dialog>
  32. </template>
  33. <script>
  34. import GraphicVerificationCode from '@/components/GraphicVerificationCode/index.vue'
  35. import { bankDelete } from '@/api/account'
  36. export default {
  37. name: 'UnBindBank',
  38. components: {
  39. GraphicVerificationCode
  40. },
  41. data() {
  42. return {
  43. modalOptions: {
  44. closeOnClickModal: false,
  45. width: '620px',
  46. title: ''
  47. },
  48. visible: false,
  49. formData: {
  50. phone: '',
  51. code: ''
  52. },
  53. formRules: {
  54. phone: [ { required: true, message: '缺少注册手机号' } ],
  55. code: [ { required: true, message: '请输入验证码' } ]
  56. }
  57. }
  58. },
  59. methods: {
  60. handleClose() {
  61. this.visible = false
  62. },
  63. initList() {
  64. },
  65. handleOpen(params = {}) {
  66. this.modalOptions.title = '解绑银行卡'
  67. this.formData.phone = params.phone
  68. // this.formData = Object.assign(this.$options.data().formData, params)
  69. this.visible = true
  70. this.initList()
  71. this.$refs.formData && this.$refs.formData.resetFields()
  72. },
  73. handleSubmit() {
  74. this.$refs.formData.validate(async (valid) => {
  75. if (valid) {
  76. const loading = this.$loading({ text: '加载中' })
  77. try {
  78. const { ...otps } = this.formData
  79. const params = {
  80. ...otps
  81. }
  82. await bankDelete(params)
  83. loading.close()
  84. this.$message({ message: `解绑成功!`, type: 'success' })
  85. this.$emit('success')
  86. this.visible = false
  87. } catch (e) {
  88. loading.close()
  89. } finally {
  90. loading.close()
  91. }
  92. } else {
  93. this.$message({ message: '请输入相关信息', type: 'warning' })
  94. return false
  95. }
  96. })
  97. }
  98. }
  99. }
  100. </script>