BankInfoTab.vue 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067
  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. @import "@/uni.scss";
  735. .user-form {
  736. margin-top: px2rpx(30);
  737. }
  738. :deep(.uni-row1) {
  739. .uni-col {
  740. padding: 0 0 !important;
  741. }
  742. .uni-forms-item {
  743. min-height: px2rpx(79);
  744. margin-bottom: px2rpx(10);
  745. }
  746. .uni-easyinput__content {
  747. border: none !important;
  748. background-color: var(--bs-secondary-bg) !important;
  749. }
  750. }
  751. .bank-menu {
  752. // background: #fff;
  753. overflow: hidden;
  754. .bank-menu-item {
  755. display: flex;
  756. align-items: center;
  757. gap: px2rpx(12);
  758. padding: px2rpx(10) px2rpx(16);
  759. cursor: pointer;
  760. border: 1px solid var(--bs-border-color);
  761. font-size: px2rpx(16);
  762. font-weight: 500;
  763. color: var(--bs-emphasis-color);
  764. transition: all 0.3s;
  765. height: px2rpx(50);
  766. border-radius: px2rpx(8);
  767. margin-bottom: px2rpx(8);
  768. .bank-icon {
  769. width: px2rpx(50);
  770. }
  771. &.active {
  772. background: var(--bs-secondary);
  773. color: #ffffff;
  774. border-radius: px2rpx(8);
  775. }
  776. &:hover {
  777. background: var(--bs-link-hover-color-rgb);
  778. color: var(--bs-secondary);
  779. }
  780. &.active:hover {
  781. background: #d11920;
  782. }
  783. }
  784. }
  785. .bank-content {
  786. //background: #fff;
  787. border-radius: px2rpx(8);
  788. padding: 0 px2rpx(24);
  789. .bank-info {
  790. .bank-header {
  791. display: flex;
  792. justify-content: space-between;
  793. align-items: center;
  794. margin-bottom: px2rpx(24);
  795. padding-bottom: px2rpx(16);
  796. border-bottom: 1px solid #f3f4f6;
  797. .bank-title {
  798. display: flex;
  799. align-items: center;
  800. font-size: px2rpx(20);
  801. font-weight: 600;
  802. color: #1f2937;
  803. margin-bottom: px2rpx(20);
  804. }
  805. .actions {
  806. display: flex;
  807. flex-direction: column;
  808. }
  809. .bank-actions {
  810. display: flex;
  811. gap: px2rpx(20);
  812. align-items: center;
  813. flex-wrap: wrap;
  814. margin-bottom: px2rpx(10);
  815. justify-content: flex-end;
  816. .action-btn {
  817. padding: px2rpx(8) px2rpx(16);
  818. border: 1px solid #d1d5db;
  819. border-radius: px2rpx(4);
  820. font-size: px2rpx(14);
  821. cursor: pointer;
  822. background: #fff;
  823. transition: all 0.3s;
  824. &:hover {
  825. background: #f3f4f6;
  826. }
  827. &.delete {
  828. background: #ea2027;
  829. color: var(--bs-emphasis-color);
  830. border-color: #ea2027;
  831. &:hover {
  832. background: #d11920;
  833. }
  834. }
  835. }
  836. }
  837. }
  838. }
  839. .photo-upload {
  840. display: flex;
  841. flex-wrap: wrap;
  842. gap: px2rpx(16);
  843. .photo-item {
  844. width: px2rpx(120);
  845. height: px2rpx(120);
  846. border-radius: px2rpx(8);
  847. overflow: hidden;
  848. background: #f3f4f6;
  849. .photo-preview {
  850. width: 100%;
  851. height: 100%;
  852. }
  853. }
  854. }
  855. .add-wallet-btn {
  856. margin-top: px2rpx(24);
  857. height: px2rpx(48);
  858. background: #ea2027;
  859. color: #fff;
  860. border-radius: px2rpx(4);
  861. display: flex;
  862. align-items: center;
  863. justify-content: center;
  864. gap: px2rpx(8);
  865. font-size: px2rpx(16);
  866. font-weight: 600;
  867. cursor: pointer;
  868. transition: all 0.3s;
  869. &:hover {
  870. background: #d11920;
  871. }
  872. }
  873. .bankFront {
  874. width: 100%;
  875. // 上传包装器
  876. .upload-wrapper {
  877. :deep(.uni-file-picker) {
  878. .file-picker__box {
  879. border: none;
  880. background: transparent;
  881. }
  882. // 文件列表容器
  883. .file-picker__box-list {
  884. display: flex;
  885. gap: px2rpx(16);
  886. flex-wrap: wrap;
  887. // 已上传的文件项
  888. .file-picker__box-item {
  889. width: px2rpx(300) !important;
  890. height: px2rpx(300) !important;
  891. margin: 0;
  892. border: 1px solid #e5e7eb;
  893. border-radius: px2rpx(8);
  894. overflow: hidden;
  895. position: relative;
  896. // 图片预览
  897. .file-picker__box-item-image {
  898. width: 100%;
  899. height: 100%;
  900. object-fit: cover;
  901. }
  902. // 删除按钮
  903. .file-picker__box-item-close {
  904. position: absolute;
  905. top: px2rpx(4);
  906. right: px2rpx(4);
  907. width: px2rpx(24);
  908. height: px2rpx(24);
  909. background: rgba(0, 0, 0, 0.5);
  910. border-radius: 50%;
  911. display: flex;
  912. align-items: center;
  913. justify-content: center;
  914. &::before {
  915. content: '×';
  916. color: var(--bs-emphasis-color);
  917. font-size: px2rpx(28);
  918. line-height: 1;
  919. }
  920. .close-icon {
  921. display: none;
  922. }
  923. }
  924. }
  925. }
  926. // 上传按钮
  927. .file-picker__box-add {
  928. width: px2rpx(300) !important;
  929. height: px2rpx(300) !important;
  930. margin: 0;
  931. border: 2rpx dashed #d1d5db;
  932. border-radius: px2rpx(8);
  933. background: #f9fafb;
  934. transition: all 0.3s;
  935. &:hover {
  936. border-color: #ea2027;
  937. background: #fef2f2;
  938. }
  939. // 自定义上传按钮内容
  940. .custom-upload-btn {
  941. width: 100%;
  942. height: 100%;
  943. display: flex;
  944. flex-direction: column;
  945. align-items: center;
  946. justify-content: center;
  947. .plus {
  948. font-size: px2rpx(48);
  949. color: #9ca3af;
  950. line-height: 1;
  951. margin-bottom: px2rpx(8);
  952. }
  953. .tip {
  954. font-size: px2rpx(24);
  955. color: #6b7280;
  956. }
  957. }
  958. // 隐藏默认的加号
  959. .add-icon {
  960. display: none;
  961. }
  962. }
  963. // 上传进度
  964. .file-picker__box-progress {
  965. width: px2rpx(300);
  966. height: px2rpx(300);
  967. border-radius: px2rpx(8);
  968. background: rgba(0, 0, 0, 0.5);
  969. color: var(--bs-emphasis-color);
  970. }
  971. }
  972. }
  973. // 图片预览
  974. .image-preview {
  975. .preview-image {
  976. width: px2rpx(300);
  977. height: px2rpx(300);
  978. border-radius: px2rpx(8);
  979. object-fit: cover;
  980. cursor: pointer;
  981. border: 1px solid #e5e7eb;
  982. }
  983. .no-image {
  984. width: px2rpx(300);
  985. height: px2rpx(300);
  986. display: flex;
  987. align-items: center;
  988. justify-content: center;
  989. background: #f5f5f5;
  990. border-radius: px2rpx(8);
  991. color: var(--bs-heading-color);
  992. font-size: px2rpx(24);
  993. border: 1px solid #e5e7eb;
  994. }
  995. }
  996. }
  997. }
  998. </style>