BankInfoTab.vue 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119
  1. <template>
  2. <view class="user-form crm-form">
  3. <uni-row class="demo-uni-row uni-row1">
  4. <uni-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  5. <view class="card">
  6. <view class="bank-menu card-header">
  7. <view v-for="item in bankTypes" :key="item.key" class="bank-menu-item"
  8. :class="{ active: selectedBankType === item.key }" @click="selectedBankType = item.key">
  9. <!-- <image class="bank-icon" :src="item.icon" mode="widthFix" />-->
  10. <text>{{ item.label }}</text>
  11. </view>
  12. </view>
  13. <view class="card-body">
  14. <view class="bank-content" v-if="selectedBankType === 'crypto'">
  15. <view class="d-flex flex-wrap align-items-center header-title mb-3 card-header">
  16. <view class="h4">
  17. {{ t('blockchain.item2') }}
  18. </view>
  19. <view class="add-wallet-btn" @click="addBank()" v-if="cryptoWallets.length < 2">
  20. <text>+</text>
  21. <text>{{ `${t('Btn.New')}${t('blockchain.item2')}` }}</text>
  22. </view>
  23. </view>
  24. <view class="bank-info bg-gray bg-opacity-05 card" v-for="(item, index) in cryptoWallets" :key="item.id">
  25. <view class="bank-header card-header">
  26. <uni-row style="width: 100%;">
  27. <uni-col :xs="24" :sm="24" :md="24" :lg="8" :xl="8">
  28. <view class="bank-title">
  29. <text>{{ currentBankType?.label }} {{ index + 1 }}</text>
  30. </view>
  31. </uni-col>
  32. <uni-col :xs="24" :sm="24" :md="16" :lg="16" :xl="16">
  33. <view class="actions">
  34. <view class="bank-actions">
  35. <view class="action-btn bg-secondary btn-dark" v-if="item.authStatus == 0"
  36. type="primary" v-t="'State.ToCertified'"
  37. @click="doReady(item.id, item)" />
  38. <view class="action-btn bg-secondary btn-dark" v-if="item.authStatus == 0"
  39. type="primary" @click="openCardDialog(item.id, item)"
  40. v-t="'PersonalManagement.CardVerify.Title'" />
  41. <view class="action-btn bg-secondary btn-dark"
  42. v-if="!editingId && item.authStatus !== 1" @tap="startEdit(item)"
  43. v-t="'Btn.Editor'" />
  44. <template v-if="editingId === item.id">
  45. <view class="action-btn bg-secondary btn-dark" @tap="saveBank(item)"
  46. v-t="'Btn.Save'" />
  47. <view class="action-btn bg-secondary btn-dark" @tap="cancelEdit()"
  48. v-t="'Btn.Cancel'" />
  49. </template>
  50. <view class="action-btn bg-secondary btn-dark" @tap="confirmDelete(item)"
  51. v-t="'Btn.Delete'" />
  52. </view>
  53. </view>
  54. </uni-col>
  55. </uni-row>
  56. </view>
  57. <uni-forms :model="item" labelWidth="200" label-position="top">
  58. <uni-row class="card-body custom-row" :gutter="20">
  59. <uni-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
  60. <uni-forms-item :label="t('blockchain.item3')">
  61. <uni-easyinput :clearable="false" v-model="item.addressName"
  62. :disabled="editingId !== item.id"
  63. :placeholder="locale == 'es' ? 'Introduzca el nombre de la red' : t('placeholder.input')" />
  64. </uni-forms-item>
  65. </uni-col>
  66. <uni-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
  67. <uni-forms-item :label="t('blockchain.item4')">
  68. <uni-easyinput :clearable="false" v-model="item.address"
  69. :disabled="editingId !== item.id"
  70. :placeholder="locale == 'es' ? 'Introduzca la dirección de la billetera' : t('placeholder.input')" />
  71. </uni-forms-item>
  72. </uni-col>
  73. <uni-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24"
  74. v-if="item.cardFiles && item.cardFiles.length">
  75. <uni-forms-item :label="t('PersonalManagement.Label.CertificationPhoto')">
  76. <view class="photo-upload">
  77. <view v-for="(file, idx) in item.cardFiles" :key="idx" class="photo-item">
  78. <image class="photo-preview" :src="updateUrl + file.path"
  79. mode="aspectFill" />
  80. </view>
  81. </view>
  82. </uni-forms-item>
  83. </uni-col>
  84. <uni-col :xs="24">
  85. <uni-forms-item class="checkbox-item">
  86. <uni-data-checkbox :disabled="editingId !== item.id" v-model="item.defaultBank1" multiple
  87. :localdata="hobbys" />
  88. </uni-forms-item>
  89. </uni-col>
  90. </uni-row>
  91. </uni-forms>
  92. </view>
  93. </view>
  94. <view class="bank-content" v-if="selectedBankType === 'unionpay'">
  95. <view class="d-flex flex-wrap align-items-center header-title card-header mb-3">
  96. <view class="h4">
  97. {{ t('PersonalManagement.Title.ChinaUnionPayCard') }}
  98. </view>
  99. <view class="add-wallet-btn" @click="addBank()" v-if="unionpayCards.length < 2">
  100. <text>+</text>
  101. <text>{{ `${t('Btn.New')}${t('PersonalManagement.Title.ChinaUnionPayCard')}` }}</text>
  102. </view>
  103. </view>
  104. <view class="bank-info bg-gray bg-opacity-05 card" v-for="(item, index) in unionpayCards" :key="item.id">
  105. <view class="bank-header card-header">
  106. <uni-row style="width: 100%;">
  107. <uni-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
  108. <view class="bank-title">
  109. <text>{{ currentBankType?.label }}{{ index + 1 }}</text>
  110. </view>
  111. </uni-col>
  112. <uni-col :xs="24" :sm="24" :md="16" :lg="16" :xl="16">
  113. <view class="bank-actions">
  114. <view class="action-btn bg-secondary btn-dark"
  115. v-if="!editingId && item.authStatus !== 1" @tap="startEdit(item)"
  116. v-t="'Btn.Editor'" />
  117. <template v-if="editingId === item.id">
  118. <view class="action-btn bg-secondary btn-dark" @tap="saveBank(item)"
  119. v-t="'Btn.Save'" />
  120. <view class="action-btn bg-secondary btn-dark" @tap="cancelEdit()"
  121. v-t="'Btn.Cancel'" />
  122. </template>
  123. <view class="action-btn delete btn-dark" @tap="confirmDelete(item)"
  124. v-t="'Btn.Delete'" />
  125. </view>
  126. </uni-col>
  127. </uni-row>
  128. </view>
  129. <uni-forms :model="item" labelWidth="200" label-position="top">
  130. <uni-row class="card-body custom-row" :gutter="20">
  131. <uni-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
  132. <uni-forms-item :label="t('PersonalManagement.Label.BankAccountName')">
  133. <uni-easyinput :clearable="false" v-model="item.bankUname" :disabled="true"
  134. :placeholder="locale == 'es' ? 'Introduzca el nombre de la red' : t('placeholder.input')" />
  135. </uni-forms-item>
  136. </uni-col>
  137. <uni-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
  138. <uni-forms-item :label="t('PersonalManagement.Label.BankName')">
  139. <cwg-combox :clearable="false" :filterable="true" v-model:value="item.bankName"
  140. :options="bankOptions" :placeholder="t('placeholder.choose')"
  141. :disabled="editingId !== item.id" @change="onStateChange" />
  142. </uni-forms-item>
  143. </uni-col>
  144. <uni-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
  145. <uni-forms-item :label="t('PersonalManagement.Label.BankAccount')">
  146. <uni-easyinput :clearable="false" v-model="item.bankCardNum"
  147. :disabled="editingId !== item.id"
  148. :placeholder="locale == 'es' ? 'Introduzca la dirección de la billetera' : t('placeholder.input')" />
  149. </uni-forms-item>
  150. </uni-col>
  151. <uni-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
  152. <uni-forms-item :label="t('PersonalManagement.Label.AccountOpeningBranch')">
  153. <uni-easyinput :clearable="false" v-model="item.bankBranchName"
  154. :disabled="editingId !== item.id"
  155. :placeholder="locale == 'es' ? 'Introduzca la dirección de la billetera' : t('placeholder.input')" />
  156. </uni-forms-item>
  157. </uni-col>
  158. <uni-col :xs="24" :sm="24" :md="16" :lg="16" :xl="16">
  159. <uni-forms-item :label="t('PersonalManagement.Label.CertificationPhoto')">
  160. <cwg-file-picker-wrapper
  161. v-model="item.bankFront"
  162. :delIcon="editingId === item.id"
  163. :limit="1"
  164. uploadUrl="/custom/bank/upload"
  165. :baseUrl="updateUrl"
  166. :imageWidth="120"
  167. :imageHeight="120"
  168. uploadText="点击上传"
  169. replaceText="点击替换" noImageText="暂无图片"
  170. :showPreviewDelete="editingId === item.id"
  171. @update:modelValue="(val) => handleFileUpdate(val, item, 'bankFront')" />
  172. </uni-forms-item>
  173. </uni-col>
  174. <uni-col :xs="24">
  175. <uni-forms-item class="checkbox-item">
  176. <uni-data-checkbox :disabled="editingId !== item.id" v-model="item.defaultBank1"
  177. multiple :localdata="hobbys" />
  178. </uni-forms-item>
  179. </uni-col>
  180. </uni-row>
  181. </uni-forms>
  182. </view>
  183. </view>
  184. <view class="bank-content" v-if="selectedBankType === 'bank'">
  185. <view class="d-flex flex-wrap align-items-center card-header header-title mb-3">
  186. <view class="h4">
  187. {{ t('PersonalManagement.Title.BankWireTransfer') }}
  188. </view>
  189. <view class="add-wallet-btn" @click="addBank()" v-if="wireTransfers.length < 2">
  190. <text>+</text>
  191. <text>{{ `${t('Btn.New')}${t('PersonalManagement.Title.BankWireTransfer')}` }}</text>
  192. </view>
  193. </view>
  194. <view class="bank-info bg-gray bg-opacity-05 card" v-for="(item, index) in wireTransfers" :key="item.id">
  195. <view class="bank-header card-header ">
  196. <uni-row style="width: 100%;">
  197. <uni-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
  198. <view class="bank-title">
  199. <text>{{ currentBankType?.label }} {{ index + 1 }}</text>
  200. </view>
  201. </uni-col>
  202. <uni-col :xs="24" :sm="24" :md="16" :lg="16" :xl="16">
  203. <view class="bank-actions">
  204. <view class="action-btn bg-secondary btn-dark"
  205. v-if="!editingId && item.authStatus !== 1" @tap="startEdit(item)"
  206. v-t="'Btn.Editor'" />
  207. <template v-if="editingId === item.id">
  208. <view class="action-btn bg-secondary btn-dark" @tap="saveBank(item)"
  209. v-t="'Btn.Save'" />
  210. <view class="action-btn bg-secondary btn-dark" @tap="cancelEdit()"
  211. v-t="'Btn.Cancel'" />
  212. </template>
  213. <view class="action-btn delete btn-dark" @tap="confirmDelete(item)"
  214. v-t="'Btn.Delete'" />
  215. </view>
  216. </uni-col>
  217. </uni-row>
  218. </view>
  219. <uni-forms :model="item" labelWidth="200" label-position="top">
  220. <uni-row class="card-body custom-row" :gutter="20">
  221. <uni-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8" >
  222. <uni-forms-item :label="t('PersonalManagement.Label.BankAccountName')">
  223. <uni-easyinput :clearable="false" v-model="item.bankUname" :disabled="true"
  224. :placeholder="locale == 'es' ? 'Introduzca el nombre de la red' : t('placeholder.input')" />
  225. </uni-forms-item>
  226. </uni-col>
  227. <uni-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
  228. <uni-forms-item :label="t('PersonalManagement.Label.BankAccount')">
  229. <uni-easyinput :clearable="false" v-model="item.bankCardNum"
  230. :disabled="editingId !== item.id"
  231. :placeholder="locale == 'es' ? 'Introduzca la dirección de la billetera' : t('placeholder.input')" />
  232. </uni-forms-item>
  233. </uni-col>
  234. <uni-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
  235. <uni-forms-item :label="t('PersonalManagement.Label.BankName')">
  236. <uni-easyinput :clearable="false" v-model="item.bankName"
  237. :disabled="editingId !== item.id"
  238. :placeholder="locale == 'es' ? 'Introduzca el nombre del banco' : t('placeholder.input')" />
  239. </uni-forms-item>
  240. </uni-col>
  241. <uni-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
  242. <uni-forms-item :label="t('PersonalManagement.Label.BankAddress')">
  243. <uni-easyinput :clearable="false" v-model="item.bankAddr"
  244. :placeholder="locale == 'es' ? 'Introduzca la dirección del banco' : t('placeholder.input')"
  245. :disabled="editingId !== item.id" />
  246. </uni-forms-item>
  247. </uni-col>
  248. <uni-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
  249. <uni-forms-item :label="t('PersonalManagement.Label.SwiftBIC')">
  250. <uni-easyinput :clearable="false" v-model="item.swiftCode"
  251. :placeholder="locale == 'es' ? 'Introduzca el SWIFT/BIC' : t('placeholder.input')"
  252. :disabled="editingId !== item.id" />
  253. </uni-forms-item>
  254. </uni-col>
  255. <uni-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
  256. <uni-forms-item :label="t('PersonalManagement.Label.BankCode')">
  257. <uni-easyinput :clearable="false" v-model="item.bankCode"
  258. :placeholder="locale == 'es' ? 'Introduzca el código del banco' : t('placeholder.input')"
  259. :disabled="editingId !== item.id" />
  260. </uni-forms-item>
  261. </uni-col>
  262. <uni-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
  263. <uni-forms-item
  264. :label="locale == 'es' ? 'Número de sucursal (opcional)' : 'Account Agency NO'">
  265. <uni-easyinput :clearable="false" v-model="item.agencyNo"
  266. :placeholder="locale == 'es' ? 'Introduzca el número de sucursal' : t('placeholder.input')"
  267. :disabled="editingId !== item.id" />
  268. </uni-forms-item>
  269. </uni-col>
  270. <uni-col :xs="24">
  271. <uni-forms-item class="checkbox-item">
  272. <uni-data-checkbox :disabled="editingId !== item.id" v-model="item.defaultBank1"
  273. multiple :localdata="hobbys" />
  274. </uni-forms-item>
  275. </uni-col>
  276. </uni-row>
  277. </uni-forms>
  278. </view>
  279. </view>
  280. <view class="bank-content" v-if="selectedBankType === 'credit'">
  281. <view class="d-flex flex-wrap align-items-center header-title card-header mb-3">
  282. <view class="h4">
  283. {{ t('PersonalManagement.Label.CreditCard') }}
  284. </view>
  285. <view class="add-wallet-btn" @click="addBank()" v-if="creditCards.length < 2">
  286. <text>+</text>
  287. <text>{{ `${t('Btn.New')}${t('PersonalManagement.Label.CreditCard')}` }}</text>
  288. </view>
  289. </view>
  290. <view class="bank-info bg-gray bg-opacity-05 card" v-for="(item, index) in creditCards" :key="item.id">
  291. <view class="bank-header card-header">
  292. <uni-row style="width: 100%;">
  293. <uni-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
  294. <view class="bank-title">
  295. <text>{{ currentBankType?.label }} {{ index + 1 }}</text>
  296. </view>
  297. </uni-col>
  298. <uni-col :xs="24" :sm="24" :md="16" :lg="16" :xl="16">
  299. <view class="bank-actions">
  300. <view class="action-btn bg-secondary btn-dark"
  301. v-if="!editingId && item.authStatus !== 1" @tap="startEdit(item)"
  302. v-t="'Btn.Editor'" />
  303. <template v-if="editingId === item.id">
  304. <view class="action-btn bg-secondary btn-dark" @tap="saveBank(item)"
  305. v-t="'Btn.Save'" />
  306. <view class="action-btn bg-secondary btn-dark" @tap="cancelEdit()"
  307. v-t="'Btn.Cancel'" />
  308. </template>
  309. <view class="action-btn delete btn-dark" @tap="confirmDelete(item)"
  310. v-t="'Btn.Delete'" />
  311. </view>
  312. </uni-col>
  313. </uni-row>
  314. </view>
  315. <uni-forms :model="item" labelWidth="200" label-position="top">
  316. <uni-row class="card-body custom-row" :gutter="20">
  317. <uni-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
  318. <uni-forms-item :label="t('PersonalManagement.Label.CreditCardAccountName')">
  319. <uni-easyinput :clearable="false" v-model="item.bankUname" :disabled="true"
  320. :placeholder="t('placeholder.input')" />
  321. </uni-forms-item>
  322. </uni-col>
  323. <uni-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
  324. <uni-forms-item :label="t('PersonalManagement.Label.CreditCardAccount')">
  325. <uni-easyinput :clearable="false" v-model="item.bankCardNum"
  326. :disabled="editingId !== item.id"
  327. :placeholder="locale == 'es' ? 'Introduzca el número de tarjeta' : t('placeholder.input')" />
  328. </uni-forms-item>
  329. </uni-col>
  330. <uni-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
  331. <uni-forms-item :label="t('PersonalManagement.Label.ExpirationYear')">
  332. <uni-easyinput :clearable="false" v-model="item.expiryYearMonth"
  333. :disabled="editingId !== item.id"
  334. :placeholder="locale == 'es' ? 'Introduzca MM/AA' : t('placeholder.input')" />
  335. </uni-forms-item>
  336. </uni-col>
  337. <uni-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
  338. <uni-forms-item :label="t('CVV')">
  339. <uni-easyinput :clearable="false" v-model="item.cvv"
  340. :disabled="editingId !== item.id"
  341. :placeholder="locale == 'es' ? 'Introduzca el CVV' : t('placeholder.input')" />
  342. </uni-forms-item>
  343. </uni-col>
  344. <uni-col :xs="24">
  345. <uni-forms-item class="checkbox-item">
  346. <uni-data-checkbox :disabled="editingId !== item.id" v-model="item.defaultBank1"
  347. multiple :localdata="hobbys" />
  348. </uni-forms-item>
  349. </uni-col>
  350. </uni-row>
  351. </uni-forms>
  352. </view>
  353. </view>
  354. </view>
  355. </view>
  356. </uni-col>
  357. </uni-row>
  358. </view>
  359. <!-- 删除确认弹窗 -->
  360. <uni-popup ref="deletePopup" type="dialog">
  361. <uni-popup-dialog :title="t('Msg.SystemPrompt')" :content="t('Msg.Delete')" @confirm="deleteBank"
  362. @close="closeDeletePopup" />
  363. </uni-popup>
  364. <!-- 新增银行弹窗 -->
  365. <add-bank-dialog ref="addBankDialogRef" @success="addSuccess" />
  366. <!-- kyc认证弹窗 -->
  367. <kyc-auth-dialog ref="kycDialogRef" />
  368. <!-- 证件认证弹窗 -->
  369. <card-auth-dialog ref="cardDialogRef" />
  370. </template>
  371. <script setup lang="ts">
  372. import { computed, ref, onMounted } from 'vue'
  373. import { useI18n } from 'vue-i18n'
  374. import { personalApi } from '@/service/personal'
  375. import KycAuthDialog from './KycAuthDialog.vue'
  376. import CardAuthDialog from './CardAuthDialog.vue'
  377. import AddBankDialog from '@/components/AddBankDialog.vue'
  378. import config from '@/config'
  379. import { BankType } from './bank'
  380. const { t, locale } = useI18n()
  381. interface BankListType {
  382. key: string;
  383. label: string;
  384. icon: string;
  385. }
  386. interface BankInfo {
  387. id?: string;
  388. type: number;
  389. defaultBank: boolean;
  390. approveStatus?: number;
  391. authStatus?: number;
  392. blockchainName: string;
  393. walletAddress: string;
  394. photos?: string[];
  395. expiryYearMonth?: string;
  396. expiryYear?: string;
  397. expiryMonth?: string;
  398. [key: string]: any;
  399. }
  400. const selectedBankType = ref<string>('crypto')
  401. const bankTypes = computed<BankListType[]>(() => [
  402. { key: 'crypto', label: t('blockchain.item2'), icon: '/static/images/info/bank-info_1.png' },
  403. {
  404. key: 'unionpay',
  405. label: t('PersonalManagement.Title.ChinaUnionPayCard'),
  406. icon: '/static/images/info/bank-info_2.png',
  407. },
  408. { key: 'bank', label: t('PersonalManagement.Title.BankWireTransfer'), icon: '/static/images/info/bank-info_3.png' },
  409. { key: 'credit', label: t('PersonalManagement.Label.CreditCard'), icon: '/static/images/info/bank-info_4.png' },
  410. ])
  411. const currentBankType = computed(() => bankTypes.value.find((item: BankListType) => item.key === selectedBankType.value))
  412. const hobbys = computed(() => {
  413. switch (selectedBankType.value) {
  414. case 'crypto':
  415. return [{ value: 1, text: t('blockchain.item8') }]
  416. case 'unionpay':
  417. return [{ value: 1, text: t('PersonalManagement.Title.DefaultBank') }]
  418. case 'bank':
  419. return [{ value: 1, text: t('PersonalManagement.Title.DefaultWire') }]
  420. case 'credit':
  421. return [{ value: 1, text: t('PersonalManagement.Title.DefaultCredit') }]
  422. }
  423. })
  424. // 状态
  425. const updateUrl = config.Host80
  426. const editingId = ref(null)
  427. const bankList = ref([])
  428. const isZh = computed(() => ['cn', 'zh', 'zhHant'].includes(locale.value))
  429. const getLangName = (item: any) => (isZh.value ? item.name : item.enName)
  430. const createOptions = (list: any[], valueKey = 'code') => {
  431. return list.map((item) => ({
  432. text: getLangName(item),
  433. value: getLangName(item),
  434. }))
  435. }
  436. const bankOptions = computed(() => createOptions(bankList.value, 'name'))
  437. // 银行数据
  438. const bankData = ref({
  439. [BankType.CRYPTO]: [],
  440. [BankType.UNIONPAY]: [],
  441. [BankType.WIRE_TRANSFER]: [],
  442. [BankType.CREDIT_CARD]: [],
  443. })
  444. // 计算属性 - 各类型银行列表
  445. const cryptoWallets = computed(() => bankData.value[BankType.CRYPTO] || [])
  446. const unionpayCards = computed(() => bankData.value[BankType.UNIONPAY] || [])
  447. const wireTransfers = computed(() => bankData.value[BankType.WIRE_TRANSFER] || [])
  448. const creditCards = computed(() => bankData.value[BankType.CREDIT_CARD] || [])
  449. // 弹出层ref
  450. const deletePopup = ref(null)
  451. const deleteTarget = ref(null)
  452. // 开始编辑
  453. const startEdit = (item) => {
  454. editingId.value = item.id
  455. }
  456. // 取消编辑
  457. const cancelEdit = () => {
  458. editingId.value = null
  459. getBankInfo() // 重新加载数据
  460. }
  461. // 保存银行信息
  462. const saveBank = async (item) => {
  463. if (selectedBankType.value === 'crypto' && item.approveStatus == 1) {
  464. uni.showToast({
  465. title: '加密钱包认证审核中',
  466. icon: 'none',
  467. })
  468. return
  469. }
  470. try {
  471. const params = { ...item }
  472. params.defaultBank = params.defaultBank1[0] ? 1 : 0
  473. if (params.type === BankType.CREDIT_CARD && params.expiryYearMonth) {
  474. const [year, month] = params.expiryYearMonth.split('/')
  475. params.expiryYear = year
  476. params.expiryMonth = month
  477. }
  478. const res = await personalApi.customBankUpdate(params)
  479. if (res.code === 200) {
  480. uni.hideLoading()
  481. uni.showToast({
  482. title: t('Msg.Success'),
  483. icon: 'success',
  484. })
  485. editingId.value = null
  486. getBankInfo()
  487. } else {
  488. throw new Error(res.msg)
  489. }
  490. } catch (error) {
  491. uni.hideLoading()
  492. uni.showToast({
  493. title: error.message || t('Msg.Fail'),
  494. icon: 'none',
  495. })
  496. }
  497. }
  498. // 删除
  499. const confirmDelete = (item) => {
  500. if (selectedBankType.value === 'crypto' && item.approveStatus == 1) {
  501. uni.showToast({
  502. title: '加密钱包认证审核中',
  503. icon: 'none',
  504. })
  505. return
  506. }
  507. deleteTarget.value = item
  508. deletePopup.value.open()
  509. }
  510. // 关闭删除弹窗
  511. const closeDeletePopup = () => {
  512. deletePopup.value.close()
  513. deleteTarget.value = null
  514. }
  515. // 执行删除
  516. const deleteBank = async () => {
  517. if (!deleteTarget.value) return
  518. try {
  519. const res = await personalApi.customBankDelete({
  520. ids: [deleteTarget.value.id],
  521. })
  522. if (res.code === 200) {
  523. uni.hideLoading()
  524. uni.showToast({
  525. title: t('Msg.DeleteSuccess'),
  526. icon: 'success',
  527. })
  528. deletePopup.value.close()
  529. deleteTarget.value = null
  530. getBankInfo()
  531. } else {
  532. uni.showToast({
  533. title: res.msg,
  534. icon: 'none',
  535. })
  536. }
  537. } catch (error) {
  538. uni.hideLoading()
  539. uni.showToast({
  540. title: error.msg,
  541. icon: 'none',
  542. })
  543. deletePopup.value.close()
  544. }
  545. }
  546. // 新增银行信息
  547. const addBankDialogRef = ref(null)
  548. function addBank() {
  549. switch (selectedBankType.value) {
  550. case 'crypto':
  551. openAddCrypto()
  552. break
  553. case 'unionpay':
  554. openAddUnionpay()
  555. break
  556. case 'bank':
  557. openAddBank()
  558. break
  559. case 'credit':
  560. openAddCredit()
  561. break
  562. }
  563. }
  564. function openAddCrypto() {
  565. const wallets = cryptoWallets.value || []
  566. // 1️⃣ 没有钱包
  567. if (wallets.length === 0) {
  568. addBankDialogRef.value?.open(4)
  569. return
  570. }
  571. // 2️⃣ 是否存在未认证钱包
  572. const hasUnAuth = wallets.some(
  573. item => item.authStatus === 0 || item.approveStatus === 1,
  574. )
  575. if (hasUnAuth) {
  576. uni.showToast({
  577. title: '加密钱包未认证',
  578. icon: 'none',
  579. })
  580. return
  581. }
  582. // 3️⃣ 是否达到上限
  583. if (wallets.length >= 2) {
  584. uni.showToast({
  585. title: t('blockchain.item9'),
  586. icon: 'none',
  587. })
  588. return
  589. }
  590. // 4️⃣ 正常打开
  591. addBankDialogRef.value?.open(4)
  592. }
  593. function openAddUnionpay() {
  594. const wallets = unionpayCards.value || []
  595. if (wallets.length === 0) {
  596. addBankDialogRef.value?.open(1)
  597. return
  598. }
  599. if (wallets.length >= 2) {
  600. uni.showToast({
  601. title: t('Msg.UnionPayCARDS'),
  602. icon: 'none',
  603. })
  604. return
  605. }
  606. addBankDialogRef.value?.open(1)
  607. }
  608. function openAddBank() {
  609. const wallets = wireTransfers.value || []
  610. if (wallets.length === 0) {
  611. addBankDialogRef.value?.open(2)
  612. return
  613. }
  614. if (wallets.length >= 2) {
  615. uni.showToast({
  616. title: t('Msg.WireTransfers'),
  617. icon: 'none',
  618. })
  619. return
  620. }
  621. addBankDialogRef.value?.open(2)
  622. }
  623. function openAddCredit() {
  624. const wallets = creditCards.value || []
  625. if (wallets.length === 0) {
  626. addBankDialogRef.value?.open(3)
  627. return
  628. }
  629. addBankDialogRef.value?.open(3)
  630. }
  631. // 新增银行信息成功回调
  632. const addSuccess = (e) => {
  633. if (selectedBankType.value === 'crypto') {
  634. openKycDialog(e)
  635. }
  636. getBankInfo()
  637. }
  638. // kyc认证和证件认证
  639. const kycDialogRef = ref(null)
  640. const cardDialogRef = ref(null)
  641. // kyc认证
  642. const doReady = (bankId, item) => {
  643. if (item.approveStatus == 1) {
  644. uni.showToast({
  645. title: '加密钱包认证审核中',
  646. icon: 'none',
  647. })
  648. return
  649. }
  650. if (item.authStatus == 1) {
  651. uni.showToast({
  652. title: '加密钱包已认证',
  653. icon: 'none',
  654. })
  655. return
  656. }
  657. openKycDialog(bankId)
  658. }
  659. // 打开kyc认证弹窗
  660. function openKycDialog(e) {
  661. kycDialogRef.value?.open(e)
  662. }
  663. // 打开证件认证弹窗
  664. function openCardDialog(e, item) {
  665. if (item.approveStatus == 1) {
  666. uni.showToast({
  667. title: '加密钱包认证审核中',
  668. icon: 'none',
  669. })
  670. return
  671. }
  672. if (item.authStatus == 1) {
  673. uni.showToast({
  674. title: '加密钱包已认证',
  675. icon: 'none',
  676. })
  677. return
  678. }
  679. cardDialogRef.value?.open(e, item)
  680. }
  681. // 掩码卡号
  682. const maskCardNumber = (num) => {
  683. if (!num) return '--'
  684. if (num.length <= 4) return num
  685. return '**** **** **** ' + num.slice(-4)
  686. }
  687. // 获取银行列表
  688. const getBankList = async () => {
  689. const res = await personalApi.BankList({})
  690. if (res.code === 200) {
  691. bankList.value = res.data
  692. }
  693. }
  694. // 文件更新处理
  695. const handleFileUpdate = (newValue, item, field) => {
  696. item[field] = newValue
  697. }
  698. // 或者如果你需要在上传成功后做其他操作
  699. const handleUploadComplete = (result, item, field) => {
  700. if (result.success) {
  701. console.log('上传完成:', result.paths)
  702. // 可以在这里做其他操作,比如保存到服务器
  703. }
  704. }
  705. // 获取银行信息
  706. const getBankInfo = async () => {
  707. try {
  708. const res = await personalApi.customBankList({})
  709. if (res.code === 200) {
  710. // 清空数据
  711. bankData.value = {
  712. [BankType.CRYPTO]: [],
  713. [BankType.UNIONPAY]: [],
  714. [BankType.WIRE_TRANSFER]: [],
  715. [BankType.CREDIT_CARD]: [],
  716. }
  717. // 分类数据
  718. res.data.forEach(item => {
  719. item.defaultBank1 = item.defaultBank == 1 ? [1] : []
  720. if (item.type === BankType.UNIONPAY) {
  721. bankData.value[BankType.UNIONPAY].push(item)
  722. } else if (item.type === BankType.WIRE_TRANSFER) {
  723. bankData.value[BankType.WIRE_TRANSFER].push(item)
  724. } else if (item.type === BankType.CREDIT_CARD) {
  725. item.expiryYearMonth = item.expiryYear && item.expiryMonth
  726. ? `${item.expiryYear}/${item.expiryMonth}`
  727. : ''
  728. bankData.value[BankType.CREDIT_CARD].push(item)
  729. } else if (item.type === BankType.CRYPTO) {
  730. bankData.value[BankType.CRYPTO].push(item)
  731. }
  732. })
  733. }
  734. } catch (error) {
  735. uni.showToast({
  736. title: error.message || t('Msg.Fail'),
  737. icon: 'none',
  738. })
  739. }
  740. }
  741. // 获取银行信息
  742. onMounted(() => {
  743. getBankList()
  744. getBankInfo()
  745. })
  746. </script>
  747. <style scoped lang="scss">
  748. @import "@/uni.scss";
  749. .user-form {
  750. margin-top: px2rpx(30);
  751. }
  752. :deep(.uni-row1) {
  753. .uni-col {
  754. }
  755. .uni-forms-item {
  756. min-height: px2rpx(79);
  757. margin-bottom: px2rpx(10);
  758. }
  759. .uni-easyinput__content {
  760. background-color: var(--bs-secondary-bg) !important;
  761. }
  762. }
  763. .bank-menu {
  764. // background: #fff;
  765. display: flex;
  766. flex-wrap: wrap;
  767. overflow: hidden;
  768. &.card-header {
  769. padding: px2rpx(10) px2rpx(20);
  770. }
  771. .bank-menu-item {
  772. flex: 1;
  773. min-width: px2rpx(260);
  774. display: flex;
  775. align-items: center;
  776. justify-content: center;
  777. //gap: px2rpx(12);
  778. padding: 0 px2rpx(16);
  779. cursor: pointer;
  780. font-size: px2rpx(16);
  781. font-weight: bold;
  782. color: var(--bs-emphasis-color);
  783. transition: all 0.3s;
  784. height: px2rpx(36);
  785. border-radius: px2rpx(8);
  786. .bank-icon {
  787. width: px2rpx(50);
  788. }
  789. &.active {
  790. background: var(--bs-secondary);
  791. color: #ffffff;
  792. border-radius: px2rpx(8);
  793. &:hover {
  794. background: var(--bs-link-hover-color-rgb);
  795. color: #ffffff;
  796. }
  797. }
  798. &:hover {
  799. background: var(--bs-link-hover-color-rgb);
  800. color: var(--bs-secondary);
  801. }
  802. &.active:hover {
  803. background: #d11920;
  804. }
  805. }
  806. }
  807. .bank-content {
  808. //border-radius: px2rpx(8);
  809. .bank-info {
  810. .bank-header {
  811. display: flex;
  812. justify-content: space-between;
  813. align-items: center;
  814. //border-bottom: 1px solid #f3f4f6;
  815. .bank-title {
  816. display: flex;
  817. align-items: center;
  818. font-size: px2rpx(20);
  819. font-weight: 600;
  820. line-height: px2rpx(32);
  821. color: #1f2937;
  822. //margin-bottom: px2rpx(20);
  823. }
  824. .actions {
  825. display: flex;
  826. flex-direction: column;
  827. }
  828. @media screen and (max-width: 992px) {
  829. .bank-actions {
  830. justify-content: flex-start !important;
  831. }
  832. }
  833. .bank-actions {
  834. display: flex;
  835. gap: px2rpx(20);
  836. align-items: center;
  837. flex-wrap: wrap;
  838. //margin-bottom: px2rpx(10);
  839. justify-content: flex-end;
  840. .action-btn {
  841. padding: px2rpx(8) px2rpx(16);
  842. border: 1px solid #d1d5db;
  843. border-radius: px2rpx(4);
  844. font-size: px2rpx(14);
  845. cursor: pointer;
  846. background: #fff;
  847. transition: all 0.3s;
  848. &:hover {
  849. background: #f3f4f6;
  850. }
  851. &.delete {
  852. background: var(--bs-btn-bg);
  853. color: #fff;
  854. border-color: var(--bs-btn-bg);
  855. &:hover {
  856. background: var(--bs-btn-hover-bg);
  857. }
  858. }
  859. }
  860. }
  861. }
  862. }
  863. .photo-upload {
  864. display: flex;
  865. flex-wrap: wrap;
  866. gap: px2rpx(16);
  867. .photo-item {
  868. width: px2rpx(120);
  869. height: px2rpx(120);
  870. border-radius: px2rpx(8);
  871. overflow: hidden;
  872. background: #f3f4f6;
  873. .photo-preview {
  874. width: 100%;
  875. height: 100%;
  876. }
  877. }
  878. }
  879. .header-title {
  880. justify-content: space-between;
  881. padding: 0 0 px2rpx(20) 0;
  882. }
  883. .add-wallet-btn {
  884. height: px2rpx(40);
  885. background: var(--bs-secondary);
  886. color: #fff;
  887. border-radius: px2rpx(20);
  888. padding: 0 px2rpx(20);
  889. display: flex;
  890. align-items: center;
  891. justify-content: center;
  892. gap: px2rpx(8);
  893. font-size: px2rpx(16);
  894. font-weight: 600;
  895. cursor: pointer;
  896. transition: all 0.3s;
  897. &:hover {
  898. background: #d11920;
  899. }
  900. }
  901. .bankFront {
  902. width: 100%;
  903. // 上传包装器
  904. .upload-wrapper {
  905. :deep(.uni-file-picker) {
  906. .file-picker__box {
  907. border: none;
  908. background: transparent;
  909. }
  910. // 文件列表容器
  911. .file-picker__box-list {
  912. display: flex;
  913. gap: px2rpx(16);
  914. flex-wrap: wrap;
  915. // 已上传的文件项
  916. .file-picker__box-item {
  917. width: px2rpx(300) !important;
  918. height: px2rpx(300) !important;
  919. margin: 0;
  920. border: 1px solid #e5e7eb;
  921. border-radius: px2rpx(8);
  922. overflow: hidden;
  923. position: relative;
  924. // 图片预览
  925. .file-picker__box-item-image {
  926. width: 100%;
  927. height: 100%;
  928. object-fit: cover;
  929. }
  930. // 删除按钮
  931. .file-picker__box-item-close {
  932. position: absolute;
  933. top: px2rpx(4);
  934. right: px2rpx(4);
  935. width: px2rpx(24);
  936. height: px2rpx(24);
  937. background: rgba(0, 0, 0, 0.5);
  938. border-radius: 50%;
  939. display: flex;
  940. align-items: center;
  941. justify-content: center;
  942. &::before {
  943. content: '×';
  944. color: var(--bs-emphasis-color);
  945. font-size: px2rpx(28);
  946. line-height: 1;
  947. }
  948. .close-icon {
  949. display: none;
  950. }
  951. }
  952. }
  953. }
  954. // 上传按钮
  955. .file-picker__box-add {
  956. width: px2rpx(300) !important;
  957. height: px2rpx(300) !important;
  958. margin: 0;
  959. border: 2rpx dashed #d1d5db;
  960. border-radius: px2rpx(8);
  961. background: #f9fafb;
  962. transition: all 0.3s;
  963. &:hover {
  964. border-color: #ea2027;
  965. background: #fef2f2;
  966. }
  967. // 自定义上传按钮内容
  968. .custom-upload-btn {
  969. width: 100%;
  970. height: 100%;
  971. display: flex;
  972. flex-direction: column;
  973. align-items: center;
  974. justify-content: center;
  975. .plus {
  976. font-size: px2rpx(48);
  977. color: #9ca3af;
  978. line-height: 1;
  979. margin-bottom: px2rpx(8);
  980. }
  981. .tip {
  982. font-size: px2rpx(24);
  983. color: #6b7280;
  984. }
  985. }
  986. // 隐藏默认的加号
  987. .add-icon {
  988. display: none;
  989. }
  990. }
  991. // 上传进度
  992. .file-picker__box-progress {
  993. width: px2rpx(300);
  994. height: px2rpx(300);
  995. border-radius: px2rpx(8);
  996. background: rgba(0, 0, 0, 0.5);
  997. color: var(--bs-emphasis-color);
  998. }
  999. }
  1000. }
  1001. // 图片预览
  1002. .image-preview {
  1003. .preview-image {
  1004. width: px2rpx(300);
  1005. height: px2rpx(300);
  1006. border-radius: px2rpx(8);
  1007. object-fit: cover;
  1008. cursor: pointer;
  1009. border: 1px solid #e5e7eb;
  1010. }
  1011. .no-image {
  1012. width: px2rpx(300);
  1013. height: px2rpx(300);
  1014. display: flex;
  1015. align-items: center;
  1016. justify-content: center;
  1017. background: #f5f5f5;
  1018. border-radius: px2rpx(8);
  1019. color: var(--bs-heading-color);
  1020. font-size: px2rpx(24);
  1021. border: 1px solid #e5e7eb;
  1022. }
  1023. }
  1024. }
  1025. }
  1026. .custom-row {
  1027. gap: px2rpx(20); // 使用 gap 替代 gutter
  1028. }
  1029. </style>