index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <van-form @submit="onSubmit">
  3. <van-cell-group inset>
  4. <van-field
  5. v-model="form.userKey"
  6. :label="type == 0 ? $t('form.PrivateKey') : $t('form.MemoryAidWord')"
  7. rows="3"
  8. autosize
  9. type="textarea"
  10. :placeholder="
  11. type == 0
  12. ? $t('form.PleaseEnterThePrivateKey')
  13. : $t('form.PleaseEnterTheMnemonicPhrase')
  14. "
  15. show-word-limit
  16. />
  17. <!-- <van-field
  18. v-model="form.username"
  19. name="username"
  20. :label="$t('form.WalletName')"
  21. :placeholder="$t('form.PleaseFillIn') + $t('form.WalletName')"
  22. :rules="[
  23. {
  24. required: true,
  25. message: $t('form.PleaseFillIn') + $t('form.WalletName'),
  26. },
  27. ]"
  28. /> -->
  29. <van-field
  30. v-model="form.password"
  31. type="password"
  32. name="password"
  33. :label="$t('form.WalletPassword')"
  34. :placeholder="$t('form.PleaseFillIn') + $t('form.WalletPassword')"
  35. :rules="[
  36. {
  37. required: true,
  38. message: $t('form.PleaseFillIn') + $t('form.WalletPassword'),
  39. },
  40. ]"
  41. />
  42. <van-field
  43. v-model="form.confirmPassword"
  44. type="password"
  45. name="confirmPassword"
  46. :label="$t('form.ConfirmPassword')"
  47. :placeholder="$t('form.PleaseFillIn') + $t('form.ConfirmPassword')"
  48. :rules="[
  49. {
  50. required: true,
  51. message: $t('form.PleaseFillIn') + $t('form.ConfirmPassword'),
  52. },
  53. ]"
  54. />
  55. <van-field
  56. v-model="form.promptMessage"
  57. name="promptMessage"
  58. :label="$t('form.PromptMessage')"
  59. :placeholder="$t('form.PleaseFillIn') + $t('form.PromptMessage')"
  60. />
  61. </van-cell-group>
  62. <div class="button-group">
  63. <van-button class="btn" round block type="primary" native-type="submit">
  64. {{ $t("router.ImportWallet") }}
  65. </van-button>
  66. </div>
  67. </van-form>
  68. </template>
  69. <script setup>
  70. import _ from "lodash";
  71. import { useRoute } from "vue-router";
  72. import { useWalletStore } from "@/stores/modules/walletStore";
  73. const router = useRouter();
  74. const route = useRoute();
  75. const walletStore = useWalletStore();
  76. const type = route.query.type;
  77. const form = ref({
  78. userKey: "",
  79. });
  80. const onSubmit = async () => {
  81. if (form.value.password !== form.value.confirmPassword) {
  82. $msg($t("form.InconsistentPasswords"));
  83. return;
  84. }
  85. if(type == 0){
  86. walletStore.privateKey = form.value.userKey;
  87. }else{
  88. walletStore.words = form.value.userKey.trim().split(',');
  89. }
  90. walletStore.accountPassword = form.value.password;
  91. walletStore.accountHint = form.value.promptMessage;
  92. await walletStore.loginWithPrivateKey(type != 0);
  93. router.push({
  94. path: "/wallet",
  95. });
  96. };
  97. </script>
  98. <style scoped lang="less">
  99. .van-cell-group {
  100. margin-top: 16px;
  101. }
  102. .button-group {
  103. width: calc(100% - 32px);
  104. position: absolute;
  105. left: 16px;
  106. bottom: 70px;
  107. .btn {
  108. background: @theme-color1;
  109. border-radius: 70px;
  110. font-family:
  111. PingFang SC,
  112. PingFang SC;
  113. font-weight: 600;
  114. font-size: 19px;
  115. color: #ffffff;
  116. height: 54px !important;
  117. border: none !important;
  118. }
  119. }
  120. </style>