CardAuthDialog.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. <template>
  2. <uni-popup ref="cardRef" type="center" background-color="#fff" style="z-index: 999;">
  3. <view class="dialog-container">
  4. <view class="dialog-header">
  5. <text class="dialog-title" v-t="'PersonalManagement.CardVerify.Title'" />
  6. <view class="dialog-close" @click="close">
  7. <text>×</text>
  8. </view>
  9. </view>
  10. <view class="qrcode-page">
  11. <view class="container">
  12. <view class="title" v-t="'PersonalManagement.CardVerify.UploadTitle'"></view>
  13. <!-- 说明 -->
  14. <uni-file-picker limit="9" :title="t('PersonalManagement.CardVerify.UploadTip')"
  15. @select="fileSelect" @delete="fileDelete"></uni-file-picker>
  16. <!-- 邮箱验证码部分 -->
  17. <view>
  18. <view class="code-input-wrapper">
  19. <view class="code-input">
  20. <cwg-input v-model:value="cardEmailCode" :label="t('newSignup.item9')"
  21. fkey="cardEmailCode" type="text" :required="true" rulesKey="cardEmailCode"
  22. :placeholder="t('newSignup.item10')" @change="handleChange" />
  23. </view>
  24. <view class="get-code-btn1">
  25. <view class="ok-button">
  26. <u-button type="primary" block>{{ getCodeString }}</u-button>
  27. </view>
  28. </view>
  29. <view class="get-code-btn">
  30. <view class="cwg-button">
  31. <button class="btn-gray" block @click="handleGetCode">{{ getCodeString }}</button>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="notice">
  37. <view class="notice-title">
  38. <text class="icon">ⓘ</text>
  39. <text>{{ t('PersonalManagement.CardVerify.NoticeTitle') }}</text>
  40. </view>
  41. <view class="notice-list">
  42. <text v-for="(item, index) in noticeItems" :key="index" class="notice-item">
  43. {{ index + 1 }}. {{ item }}
  44. </text>
  45. </view>
  46. </view>
  47. <!-- 演示视频 -->
  48. <cwg-video-player :video-url="videoUrl"></cwg-video-player>
  49. </view>
  50. </view>
  51. <view class="dialog-footer">
  52. <view class="btn btn-cancel" @click="close">{{ t('Btn.Cancel') }}</view>
  53. <view class="btn btn-confirm" @click="submit">{{ t('Btn.Confirm') }}</view>
  54. </view>
  55. </view>
  56. </uni-popup>
  57. </template>
  58. <script setup lang="ts">
  59. import { ref, computed, nextTick } from 'vue'
  60. import { useI18n } from 'vue-i18n'
  61. import { customApi } from '@/service/custom';
  62. import { showToast } from "@/utils/toast";
  63. import config from '@/config';
  64. import { userToken } from '@/composables/config'
  65. import { useEmailCountdown } from '@/hooks/useEmailCountdown';
  66. const {
  67. time,
  68. text: getCodeString,
  69. canSend,
  70. start,
  71. restore
  72. } = useEmailCountdown()
  73. const { t, locale } = useI18n()
  74. const cardEmailCode = ref('')
  75. const form = ref({
  76. bankId: null,
  77. email: ''
  78. })
  79. const emit = defineEmits(["success"]);
  80. // 发送邮箱验证码
  81. async function sendEmailCode() {
  82. try {
  83. if (!form.value.bankId) {
  84. showToast(t("PersonalManagement.CardVerify.MissingBankId"));
  85. return false;
  86. }
  87. const res = await customApi.customBankCardSendCode({
  88. bankId: form.value.bankId
  89. });
  90. if (res.code === 200) {
  91. if (res.data && (res.data.emailCode || res.data.code)) {
  92. cardEmailCode.value = res.data.emailCode || res.data.code;
  93. }
  94. start()
  95. return true;
  96. } else {
  97. showToast(t("Msg.CodeFail"));
  98. return false;
  99. }
  100. } catch (error: any) {
  101. console.log(error, 12);
  102. showToast(t("Msg.CodeFail"));
  103. return false;
  104. }
  105. }
  106. async function handleGetCode() {
  107. if (!canSend.value) return
  108. await sendEmailCode();
  109. }
  110. // 视频URL
  111. const videoUrl = computed(() => {
  112. const lang = locale.value || 'en'
  113. const videos = {
  114. cn: "https://player.vimeo.com/video/1152417528?badge=0&autopause=0&player_id=0&app_id=58479",
  115. zhHant: "https://player.vimeo.com/video/1152417614?badge=0&autopause=0&player_id=0&app_id=58479",
  116. en: "https://player.vimeo.com/video/1152417671?badge=0&autopause=0&player_id=0&app_id=58479",
  117. }
  118. return videos[lang] || videos.en
  119. })
  120. // uni-file-picker 相关
  121. const selectedFiles = ref([]) // 选择的文件列表
  122. const uploadedFiles = ref([]) // 上传成功的文件列表
  123. // 选择文件
  124. const fileSelect = async (e) => {
  125. selectedFiles.value = e.tempFiles
  126. for (const file of e.tempFiles) {
  127. await uploadFile(file)
  128. }
  129. }
  130. // 上传文件
  131. const uploadFile = (file) => {
  132. return new Promise((resolve, reject) => {
  133. const tempFile = file.path || file.url
  134. uni.uploadFile({
  135. url: config.Host80 + '/custom/bank/upload',
  136. filePath: tempFile,
  137. name: 'file',
  138. header: {
  139. 'Access-Token': userToken.value
  140. },
  141. success: (uploadRes) => {
  142. const data = JSON.parse(uploadRes.data)
  143. console.log(data, 1111);
  144. if (data.code === 200) {
  145. // 保存上传成功后的文件信息
  146. uploadedFiles.value.push(data.data)
  147. resolve(data)
  148. } else {
  149. uni.showToast({
  150. title: data.msg || '上传失败',
  151. icon: 'none'
  152. })
  153. reject(new Error(data.msg))
  154. }
  155. },
  156. fail: (err) => {
  157. uni.showToast({
  158. title: '上传失败',
  159. icon: 'none'
  160. })
  161. reject(err)
  162. }
  163. })
  164. })
  165. }
  166. // 删除文件
  167. const fileDelete = (e) => {
  168. const index = uploadedFiles.value.findIndex(f => f.uuid === e.tempFile.uuid)
  169. if (index !== -1) {
  170. uploadedFiles.value.splice(index, 1)
  171. }
  172. }
  173. // 说明项
  174. const noticeItems = computed(() => [
  175. t('PersonalManagement.CardVerify.NoticeItem1'),
  176. t('PersonalManagement.CardVerify.NoticeItem2'),
  177. t('PersonalManagement.CardVerify.NoticeItem3'),
  178. t('PersonalManagement.CardVerify.NoticeItem4'),
  179. t('PersonalManagement.CardVerify.NoticeItem5'),
  180. t('PersonalManagement.CardVerify.NoticeItem6'),
  181. t('PersonalManagement.CardVerify.NoticeItem7')
  182. ])
  183. const cardRef = ref(null)
  184. // 打开弹窗
  185. const open = async (e, item) => {
  186. form.value = { ...item, bankId: item.id }
  187. console.log(item, 2222);
  188. await nextTick();
  189. restore()
  190. cardRef.value?.open();
  191. };
  192. // 关闭弹窗
  193. const close = () => {
  194. cardRef.value?.close();
  195. };
  196. const submit = async () => {
  197. if (!cardEmailCode.value) {
  198. showToast(t("vaildate.emailCode.empty"));
  199. return;
  200. }
  201. try {
  202. const res = await customApi.customBankCardVerify({
  203. bankId: form.value.bankId,
  204. emailCode: cardEmailCode.value,
  205. fileList: uploadedFiles.value
  206. });
  207. if (res.code === 200) {
  208. showToast(res.msg);
  209. close();
  210. emit("success");
  211. } else {
  212. showToast(res.msg || t("common.error"));
  213. }
  214. } catch (error) {
  215. showToast(t("common.error"));
  216. }
  217. };
  218. // 暴露方法
  219. defineExpose({
  220. open,
  221. close
  222. });
  223. </script>
  224. <style lang="scss" scoped>
  225. @import "@/uni.scss";
  226. .dialog-container {
  227. width: 90vw;
  228. max-width: px2rpx(800);
  229. max-height: 85vh;
  230. background: #fff;
  231. overflow: hidden;
  232. display: flex;
  233. flex-direction: column;
  234. .dialog-header {
  235. display: flex;
  236. justify-content: space-between;
  237. align-items: center;
  238. padding: px2rpx(20) px2rpx(24);
  239. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  240. flex-shrink: 0;
  241. .dialog-title {
  242. font-size: px2rpx(20);
  243. font-weight: 700;
  244. color: #fff;
  245. letter-spacing: 0.5px;
  246. }
  247. .dialog-close {
  248. width: px2rpx(36);
  249. height: px2rpx(36);
  250. display: flex;
  251. align-items: center;
  252. justify-content: center;
  253. font-size: px2rpx(32);
  254. color: rgba(255, 255, 255, 0.9);
  255. cursor: pointer;
  256. transition: all 0.3s;
  257. border-radius: 50%;
  258. background: rgba(255, 255, 255, 0.1);
  259. &:hover {
  260. background: rgba(255, 255, 255, 0.2);
  261. transform: rotate(90deg);
  262. }
  263. &:active {
  264. transform: rotate(90deg) scale(0.9);
  265. }
  266. }
  267. }
  268. .dialog-footer {
  269. display: flex;
  270. gap: px2rpx(150);
  271. justify-content: center;
  272. padding: px2rpx(16);
  273. border-top: 1px solid #f3f4f6;
  274. .btn {
  275. min-width: px2rpx(120);
  276. padding: px2rpx(12) px2rpx(24);
  277. border-radius: px2rpx(6);
  278. font-size: px2rpx(14);
  279. font-weight: 600;
  280. border: none;
  281. box-sizing: border-box;
  282. cursor: pointer;
  283. text-align: center;
  284. transition: all 0.3s;
  285. display: flex;
  286. align-items: center;
  287. justify-content: center;
  288. &.btn-cancel {
  289. background: #f3f4f6;
  290. color: #6b7280;
  291. &:hover {
  292. background: #e5e7eb;
  293. }
  294. &:active {
  295. background: #d1d5db;
  296. }
  297. }
  298. &.btn-confirm {
  299. background: #ea2027;
  300. color: #fff;
  301. &:hover {
  302. background: #d11920;
  303. }
  304. &:active {
  305. background: #c01819;
  306. }
  307. }
  308. }
  309. }
  310. }
  311. .qrcode-page {
  312. flex: 1;
  313. overflow-y: auto;
  314. background: #f8f9fa;
  315. .container {
  316. padding: px2rpx(32);
  317. .title {
  318. font-size: px2rpx(18);
  319. font-weight: 600;
  320. color: #2c3e50;
  321. text-align: center;
  322. margin-bottom: px2rpx(24);
  323. padding-bottom: px2rpx(16);
  324. border-bottom: 2px solid #e9ecef;
  325. }
  326. .qrcode-wrapper {
  327. display: flex;
  328. justify-content: center;
  329. align-items: center;
  330. margin-bottom: px2rpx(32);
  331. padding: px2rpx(24);
  332. background: #fff;
  333. border-radius: px2rpx(12);
  334. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  335. .qrcode {
  336. width: px2rpx(240);
  337. height: px2rpx(240);
  338. }
  339. }
  340. .notice {
  341. background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  342. border-radius: px2rpx(12);
  343. padding: px2rpx(24);
  344. margin-bottom: px2rpx(32);
  345. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  346. border-left: 4px solid #667eea;
  347. .notice-title {
  348. display: flex;
  349. align-items: center;
  350. gap: px2rpx(8);
  351. font-size: px2rpx(16);
  352. font-weight: 700;
  353. color: #2c3e50;
  354. margin-bottom: px2rpx(16);
  355. .icon {
  356. width: px2rpx(24);
  357. height: px2rpx(24);
  358. display: flex;
  359. align-items: center;
  360. justify-content: center;
  361. background: #667eea;
  362. color: var(--bs-emphasis-color);
  363. border-radius: 50%;
  364. font-size: px2rpx(16);
  365. font-weight: bold;
  366. }
  367. }
  368. .notice-list {
  369. .notice-item {
  370. display: block;
  371. font-size: px2rpx(14);
  372. color: #495057;
  373. line-height: 1.8;
  374. margin-bottom: px2rpx(10);
  375. padding-left: px2rpx(8);
  376. position: relative;
  377. &:last-child {
  378. margin-bottom: 0;
  379. }
  380. &::before {
  381. content: '';
  382. position: absolute;
  383. left: 0;
  384. top: px2rpx(10);
  385. width: px2rpx(4);
  386. height: px2rpx(4);
  387. background: #667eea;
  388. border-radius: 50%;
  389. }
  390. }
  391. }
  392. }
  393. .video-section {
  394. background: #fff;
  395. border-radius: px2rpx(12);
  396. padding: px2rpx(24);
  397. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  398. .video-title {
  399. font-size: px2rpx(16);
  400. font-weight: 600;
  401. color: #2c3e50;
  402. margin-bottom: px2rpx(16);
  403. display: flex;
  404. align-items: center;
  405. gap: px2rpx(8);
  406. &::before {
  407. content: '';
  408. width: px2rpx(4);
  409. height: px2rpx(18);
  410. background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
  411. border-radius: px2rpx(2);
  412. }
  413. }
  414. .video-wrapper {
  415. width: 100%;
  416. border-radius: px2rpx(8);
  417. overflow: hidden;
  418. background: #000;
  419. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  420. video {
  421. width: 100%;
  422. height: px2rpx(300);
  423. display: block;
  424. }
  425. }
  426. }
  427. }
  428. }
  429. // 验证码区域
  430. .code-input-label {
  431. font-size: var(--font-size-16);
  432. line-height: px2rpx(44);
  433. letter-spacing: px2rpx(1);
  434. color: #474747;
  435. }
  436. .code-input-wrapper {
  437. position: relative;
  438. display: flex;
  439. align-items: center;
  440. }
  441. .code-input {
  442. flex: 1;
  443. }
  444. .get-code-btn1 {
  445. min-width: px2rpx(100);
  446. margin-left: px2rpx(8);
  447. .ok-button {
  448. .u-button {
  449. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  450. opacity: 0;
  451. }
  452. }
  453. }
  454. .get-code-btn {
  455. position: absolute;
  456. right: 0;
  457. bottom: px2rpx(12);
  458. min-width: px2rpx(100);
  459. z-index: 1;
  460. margin-left: px2rpx(8);
  461. .cwg-button {
  462. margin: 0;
  463. }
  464. .cwg-button .u-button {
  465. border-radius: px2rpx(8);
  466. height: px2rpx(46) !important;
  467. }
  468. .btn-gray{
  469. height: px2rpx(46);
  470. line-height: px2rpx(46);
  471. border-radius: px2rpx(8);
  472. background-color: #102047;
  473. color: #fff;
  474. }
  475. }
  476. /* 移动端优化 */
  477. @media screen and (max-width: 768px) {
  478. .dialog-container {
  479. width: 95vw;
  480. max-height: 90vh;
  481. .dialog-footer {
  482. gap: px2rpx(20);
  483. justify-content: space-around;
  484. }
  485. }
  486. .qrcode-page .container {
  487. padding: px2rpx(20);
  488. .qrcode-wrapper .qrcode {
  489. width: px2rpx(200);
  490. height: px2rpx(200);
  491. }
  492. .video-section .video-wrapper video {
  493. height: px2rpx(240);
  494. }
  495. }
  496. }
  497. /* 滚动条美化 */
  498. .qrcode-page::-webkit-scrollbar {
  499. width: px2rpx(6);
  500. }
  501. .qrcode-page::-webkit-scrollbar-track {
  502. background: #f1f1f1;
  503. }
  504. .qrcode-page::-webkit-scrollbar-thumb {
  505. background: #c1c1c1;
  506. border-radius: px2rpx(3);
  507. &:hover {
  508. background: #a8a8a8;
  509. }
  510. }
  511. </style>