index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <div class="container">
  3. <van-skeleton
  4. v-if="walletData.words.length == 0"
  5. style="width: 100%"
  6. title
  7. :row="8"
  8. />
  9. <div class="tag-container" v-else>
  10. <van-tag
  11. v-for="item in walletData.words"
  12. :key="item"
  13. plain
  14. type="primary"
  15. text-color="#4765DD"
  16. >{{ item }}</van-tag
  17. >
  18. </div>
  19. <div class="button-group">
  20. <a
  21. class="button-group-mnemonic a-link im-copy-btn"
  22. :data-clipboard-text="walletData.words"
  23. >
  24. {{ $t("login.CopyMnemonic") }}</a
  25. >
  26. <van-button
  27. class="btn"
  28. round
  29. block
  30. type="primary"
  31. native-type="submit"
  32. @click="next"
  33. :loading-text="$t('form.Loading')"
  34. :loading="loading"
  35. >
  36. {{ $t("login.BackupComplete") }}
  37. </van-button>
  38. </div>
  39. </div>
  40. </template>
  41. <script setup>
  42. import { createAccent } from "@/api/path/login.api";
  43. import { useWalletStore } from "@/stores/modules/walletStore";
  44. // 一键复制文本
  45. import { useCopy } from "@/hooks/use-copy.js";
  46. useCopy();
  47. const router = useRouter();
  48. const walletStore = useWalletStore();
  49. const loading = ref(false);
  50. const walletData = ref({
  51. words: [],
  52. });
  53. const next = async () => {
  54. // 登录
  55. loading.value = true;
  56. await walletStore.loginWithPrivateKey();
  57. walletStore.$persist();
  58. loading.value = false;
  59. router.push({
  60. path: "/wallet",
  61. });
  62. };
  63. onMounted(async () => {
  64. const { data } = await createAccent({});
  65. walletData.value = JSON.parse(atob(data.content));
  66. walletStore.account = walletData.value.address;
  67. walletStore.privateKey = walletData.value.privateKey;
  68. walletStore.words = walletData.value.words;
  69. });
  70. </script>
  71. <style scoped lang="less">
  72. .tag-container {
  73. margin-top: 3px;
  74. display: grid;
  75. grid-template-columns: repeat(3, 1fr);
  76. grid-gap: 16px;
  77. padding: 27px;
  78. .van-tag {
  79. width: 87px;
  80. height: 33px;
  81. display: flex;
  82. align-items: center;
  83. justify-content: center;
  84. border-radius: 4px;
  85. }
  86. .van-tag--plain {
  87. background: #eceffc;
  88. }
  89. }
  90. .button-group {
  91. margin: 33px 17px 0 17px;
  92. display: flex;
  93. flex-direction: column;
  94. align-items: center;
  95. .button-group-mnemonic {
  96. font-size: 14px;
  97. margin-bottom: 21px;
  98. }
  99. }
  100. .btn {
  101. background: @theme-color1;
  102. border-radius: 70px;
  103. font-family:
  104. PingFang SC,
  105. PingFang SC;
  106. font-weight: 600;
  107. font-size: 19px;
  108. color: #ffffff;
  109. height: 54px !important;
  110. border: none !important;
  111. }
  112. </style>