index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <view class="receiving-account-container">
  3. <JHeader title="收款账户" width="50" height="50" style="padding: 24upx 0 0;"></JHeader>
  4. <view v-if="!bankMessage.cardNumber">
  5. <tui-no-data :fixed="false" style="margin-top: 60upx;">暂未绑定收款账户</tui-no-data>
  6. <view style="width: 70%;margin: 14upx auto;">
  7. <tui-button
  8. type="blue" bold shape="circle" width="100%"
  9. @click="go('/another-tf/another-user/receiving-account/receiving-account-form')"
  10. >
  11. 立即绑定
  12. </tui-button>
  13. </view>
  14. </view>
  15. <view v-else style="padding: 45upx 0;">
  16. <tui-card
  17. :title="{ text: `账号:${bankMessage.cardNumber}` }"
  18. >
  19. <template #body>
  20. <view style="padding: 10upx 32upx;">
  21. <view>持卡人:{{ bankMessage.cardName }}</view>
  22. </view>
  23. </template>
  24. <template #footer>
  25. <view style="padding: 0 20rpx 20rpx;text-align: right;">
  26. <tui-button
  27. type="warning" width="120rpx" height="50rpx" margin="0 20upx 0"
  28. style="border-radius: 50rpx;display: inline-block;"
  29. @click="go('/another-tf/another-user/receiving-account/receiving-account-form?isEdit=1')"
  30. >
  31. 编辑
  32. </tui-button>
  33. <tui-button
  34. type="danger" width="120rpx" height="50rpx" style="border-radius: 50rpx;display: inline-block;"
  35. @click="isShowUnbindBankDialog = true"
  36. >
  37. 解绑
  38. </tui-button>
  39. </view>
  40. </template>
  41. </tui-card>
  42. </view>
  43. <tui-dialog
  44. style="position: relative;z-index: 888;"
  45. :buttons="[{ text: '取消' }, { text: '确定', color: '#586c94' }]" :show="isShowUnbindBankDialog" title="解绑银行卡"
  46. @click="handleUnbindBank"
  47. >
  48. <template #content>
  49. <tui-input v-model="unbindForm.phone" label="手机号" type="number" placeholder="请输入手机号">
  50. <template #right>
  51. <tui-countdown-verify ref="refUnbindBankVerify" width="144upx" @send="handleSendVerify"></tui-countdown-verify>
  52. </template>
  53. </tui-input>
  54. <tui-input v-model="unbindForm.code" label="验证码" type="number" placeholder="请输入验证码"></tui-input>
  55. </template>
  56. </tui-dialog>
  57. </view>
  58. </template>
  59. <script>
  60. import { getByIdBankApi, deleteBankDeleteApi, getCodeBusinessApi } from '../../../api/anotherTFInterface'
  61. export default {
  62. name: 'ReceivingAccount',
  63. components: {
  64. },
  65. data() {
  66. return {
  67. bankMessage: {
  68. cardNumber: '',
  69. cardName: ''
  70. },
  71. unbindForm: {
  72. phone: '',
  73. code: ''
  74. },
  75. isShowUnbindBankDialog: false
  76. }
  77. },
  78. onLoad() {
  79. this.getBankMessage()
  80. },
  81. methods: {
  82. getBankMessage() {
  83. uni.showLoading({
  84. title: '加载中'
  85. })
  86. getByIdBankApi({})
  87. .then((res) => {
  88. this.bankMessage = res.data || {}
  89. uni.hideLoading()
  90. })
  91. .catch(() => {
  92. uni.hideLoading()
  93. })
  94. },
  95. handleUnbindBank(e) {
  96. if (e.index === 0) {} else if (e.index === 1) {
  97. if (!this.unbindForm.phone) return this.$showToast('请填写手机号')
  98. if (!this.unbindForm.code) return this.$showToast('请填写验证码')
  99. uni.showLoading({
  100. title: '操作中'
  101. })
  102. deleteBankDeleteApi({ ...this.unbindForm })
  103. .then(({ data }) => {
  104. uni.hideLoading()
  105. this.$showToast('解绑成功')
  106. this.getBankMessage()
  107. })
  108. .catch(() => {
  109. uni.hideLoading()
  110. })
  111. }
  112. this.unbindForm.phone = ''
  113. this.unbindForm.code = ''
  114. this.isShowUnbindBankDialog = false
  115. },
  116. handleSendVerify() {
  117. if (!this.unbindForm.phone) {
  118. this.$refs.refUnbindBankVerify.reset()
  119. return this.$showToast('请填写手机号')
  120. }
  121. if (!/^1[3-9]\d{9}$/.test(this.unbindForm.phone)) {
  122. this.$refs.refUnbindBankVerify.reset()
  123. return this.$showToast('请输入正确的手机号')
  124. }
  125. getCodeBusinessApi({ phone: this.unbindForm.phone })
  126. .then((res) => {
  127. this.$refs.refUnbindBankVerify.success()
  128. this.$showToast('发送成功,请注意查看手机短信')
  129. })
  130. .catch(() => {
  131. this.$refs.refUnbindBankVerify.reset()
  132. })
  133. }
  134. }
  135. }
  136. </script>
  137. <style lang="less" scoped>
  138. .receiving-account-container {
  139. width: 100%;
  140. min-height: 100vh;
  141. background-color: #f5f4f9;
  142. }
  143. </style>