Index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <app-view class="bank-sign g-form">
  3. <template #header>
  4. <app-navbar title="签约账户管理" />
  5. </template>
  6. <div class="bank-sign__container" v-if="bankInfo">
  7. <CellGroup>
  8. <Cell title="开户银行" :value="bankInfo.bankname" />
  9. <Cell title="银行卡号" :value="bankInfo.bankaccountno" />
  10. <template v-if="bankInfo.signstatus === SignStatus.Signed">
  11. <Cell title="姓名" :value="bankInfo.bankaccountname" />
  12. <Cell title="手机号码" :value="bankInfo.mobilephone" v-if="bankInfo.mobilephone" />
  13. </template>
  14. <Cell title="支行名称" v-if="bankInfo.branchbankname != ''" :value="bankInfo.branchbankname" />
  15. <Cell title="状态" :value="getSignStatusName(bankInfo.signstatus)" />
  16. </CellGroup>
  17. </div>
  18. <div class="bank-sign__empty" v-else>
  19. <Empty description="您还未添加签约账户" />
  20. <Button type="danger" @click="showComponent(false)" round>添加签约账户</Button>
  21. </div>
  22. <template #footer>
  23. <div class="g-form__footer inset" v-if="bankInfo">
  24. <Button type="danger" round block @click="showComponent(true)"
  25. v-if="[SignStatus.Unsigned, SignStatus.Refuse].includes(bankInfo.signstatus)">重新签约</Button>
  26. <Button type="warning" round block @click="formSubmit"
  27. v-if="bankInfo.signstatus === SignStatus.Signed && cusBank?.canrelease === 1">解约</Button>
  28. <Button type="danger" round block @click="beforeShowComponent"
  29. v-if="bankInfo.signstatus === SignStatus.Signed && cusBank?.canmodifysigninfo === 1">修改</Button>
  30. </div>
  31. </template>
  32. <component ref="componentRef" v-bind="{ isedit }" :is="componentMap.get(componentId)" @closed="closeComponent"
  33. v-if="componentId" />
  34. </app-view>
  35. </template>
  36. <script lang="ts" setup>
  37. import { onActivated, defineAsyncComponent, ref } from 'vue'
  38. import { CellGroup, Cell, Button, Empty, showFailToast } from 'vant'
  39. import { fullloading, dialog } from '@/utils/vant'
  40. import { useComponent } from '@/hooks/component'
  41. import { getSignStatusName, SignStatus } from '@/constants/bank'
  42. import { useDoCancelBankSign } from '@/business/bank'
  43. import { useNavigation } from '@mobile/router/navigation'
  44. import { useRequest } from '@/hooks/request'
  45. import { queryCusBankSignBank } from '@/services/api/bank'
  46. import { useUserStore } from '@/stores'
  47. import { shallowRef } from 'vue'
  48. const componentMap = new Map<string, unknown>([
  49. ['edit', defineAsyncComponent(() => import('./components/edit/Index.vue'))],
  50. ])
  51. const useStore = useUserStore()
  52. const cusBank = shallowRef<Model.CusBankSignBankRsp>()
  53. const { componentRef, componentId, openComponent, closeComponent } = useComponent(() => formRefresh())
  54. const { cancelSubmit, formRefresh, bankInfo } = useDoCancelBankSign()
  55. const { router } = useNavigation()
  56. /// 是否修改
  57. const isedit = ref(false)
  58. /// 查询托管银行信息
  59. useRequest(queryCusBankSignBank, {
  60. onSuccess: (res) => {
  61. /// 签约状态
  62. if (res.data.length != 0) {
  63. cusBank.value = res.data[0]
  64. }
  65. }
  66. })
  67. const formSubmit = () => {
  68. dialog({
  69. message: '确认解约?',
  70. showCancelButton: true
  71. }).then(() => {
  72. fullloading((hideLoading) => {
  73. cancelSubmit().then(() => {
  74. hideLoading()
  75. dialog('解约提交成功,请稍后确认结果。').then(() => {
  76. router.back()
  77. })
  78. }).catch((err) => {
  79. showFailToast(err)
  80. })
  81. })
  82. })
  83. }
  84. const showComponent = (isEdit: boolean) => {
  85. isedit.value = isEdit
  86. openComponent('edit')
  87. }
  88. const beforeShowComponent = () => {
  89. if (bankInfo.value?.cusbankid === 'jdjs') {
  90. dialog('请先发函到结算中心修改信息后再修改,否则将会影响充值、提现。').then(() => {
  91. showComponent(true)
  92. })
  93. } else {
  94. showComponent(true)
  95. }
  96. }
  97. onActivated(() => {
  98. useStore.getUserData()
  99. formRefresh()
  100. })
  101. </script>
  102. <style lang="less">
  103. @import './index.less';
  104. </style>