BankInfoTab.vue 45 KB

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