CardAuthDialog.vue 16 KB

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