BankInfoTab.vue 45 KB

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