BankInfoTab.vue 41 KB

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