|
@@ -0,0 +1,144 @@
|
|
|
+<template>
|
|
|
+ <van-form @submit="onSubmit" >
|
|
|
+ <van-cell-group inset>
|
|
|
+ <van-field
|
|
|
+ v-model="form.userKey"
|
|
|
+ :label="type == 0?$t('form.PrivateKey'):$t('form.MemoryAidWord')"
|
|
|
+ rows="2"
|
|
|
+ autosize
|
|
|
+ type="textarea"
|
|
|
+ :placeholder="type == 0?$t('form.PleaseEnterThePrivateKey'):$t('form.PleaseEnterTheMnemonicPhrase')"
|
|
|
+ show-word-limit
|
|
|
+ />
|
|
|
+ <van-field
|
|
|
+ v-model="form.username"
|
|
|
+ name="username"
|
|
|
+ :label="$t('form.WalletName')"
|
|
|
+ :placeholder="$t('form.PleaseFillIn') + $t('form.WalletName')"
|
|
|
+ :rules="[
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: $t('form.PleaseFillIn') + $t('form.WalletName'),
|
|
|
+ },
|
|
|
+ ]"
|
|
|
+ />
|
|
|
+ <van-field
|
|
|
+ v-model="form.password"
|
|
|
+ type="password"
|
|
|
+ name="password"
|
|
|
+ :label="$t('form.WalletPassword')"
|
|
|
+ :placeholder="$t('form.PleaseFillIn') + $t('form.WalletPassword')"
|
|
|
+ :rules="[
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: $t('form.PleaseFillIn') + $t('form.WalletPassword'),
|
|
|
+ },
|
|
|
+ ]"
|
|
|
+ />
|
|
|
+
|
|
|
+ <van-field
|
|
|
+ v-model="form.confirmPassword"
|
|
|
+ type="password"
|
|
|
+ name="confirmPassword"
|
|
|
+ :label="$t('form.ConfirmPassword')"
|
|
|
+ :placeholder="$t('form.PleaseFillIn') + $t('form.ConfirmPassword')"
|
|
|
+ :rules="[
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: $t('form.PleaseFillIn') + $t('form.ConfirmPassword'),
|
|
|
+ },
|
|
|
+ ]"
|
|
|
+ />
|
|
|
+
|
|
|
+ <van-field
|
|
|
+ v-model="form.promptMessage"
|
|
|
+ name="promptMessage"
|
|
|
+ :label="$t('form.PromptMessage')"
|
|
|
+ :placeholder="$t('form.PleaseFillIn') + $t('form.PromptMessage')"
|
|
|
+ />
|
|
|
+ </van-cell-group>
|
|
|
+ <div class="button-group" >
|
|
|
+ <van-button class="btn" round block type="primary" native-type="submit">
|
|
|
+ {{ $t("router.ImportWallet") }}
|
|
|
+ </van-button>
|
|
|
+ </div>
|
|
|
+ </van-form>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <script setup>
|
|
|
+ import _ from "lodash";
|
|
|
+ import { cryptoEncode } from "@/utils/crypto.js"
|
|
|
+ import { useRoute } from 'vue-router'
|
|
|
+ import { useSystemStore } from "@/stores/modules/systemStore";
|
|
|
+ import { useWalletAuth } from "@/composables/useWalletAuth";
|
|
|
+ const {
|
|
|
+ authState,
|
|
|
+ loginWithPrivateKey,
|
|
|
+ loginWithStorage,
|
|
|
+ logout,
|
|
|
+ hasStoredWallet,
|
|
|
+ getBalance,
|
|
|
+} = useWalletAuth();
|
|
|
+ const router = useRouter();
|
|
|
+ const route = useRoute();
|
|
|
+ const systemStore = useSystemStore();
|
|
|
+ const network = JSON.parse(route.query.network);
|
|
|
+ const type = route.query.type;
|
|
|
+
|
|
|
+ const form = ref({});
|
|
|
+
|
|
|
+ const onSubmit = async ()=>{
|
|
|
+ if(form.value.password !== form.value.confirmPassword){
|
|
|
+ $msg($t("form.InconsistentPasswords"));
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let data = _.cloneDeep(form.value)
|
|
|
+ data.password = cryptoEncode(data.password)
|
|
|
+ data.confirmPassword = cryptoEncode(data.confirmPassword)
|
|
|
+ // 将网络和钱包信息保存
|
|
|
+ data.networkName = network.name;
|
|
|
+ data.networkUrl = network.url;
|
|
|
+ data.networkImg = network.icon;
|
|
|
+
|
|
|
+ systemStore.setStateValue({
|
|
|
+ key: "wallet",
|
|
|
+ value: {
|
|
|
+ address: '',
|
|
|
+ privateKey: type == 0? data.userKey :"",
|
|
|
+ words: type == 1? data.userKey :"",
|
|
|
+ walletInfo:data
|
|
|
+ },
|
|
|
+ localStorage: true,
|
|
|
+ });
|
|
|
+ await loginWithPrivateKey(
|
|
|
+ systemStore.getWallet.privateKey.trim()
|
|
|
+ );
|
|
|
+ router.push({
|
|
|
+ path:"/wallet"
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ </script>
|
|
|
+
|
|
|
+ <style scoped lang="less">
|
|
|
+ .van-cell-group{
|
|
|
+ margin-top: 16px;
|
|
|
+ }
|
|
|
+ .button-group{
|
|
|
+ width: calc(100% - 32px);
|
|
|
+ position: absolute;
|
|
|
+ left: 16px;
|
|
|
+ bottom: 70px;
|
|
|
+ .btn{
|
|
|
+ background: @theme-color1;
|
|
|
+ border-radius: 70px;
|
|
|
+ font-family: PingFang SC, PingFang SC;
|
|
|
+ font-weight: 600;
|
|
|
+ font-size: 19px;
|
|
|
+ color: #FFFFFF;
|
|
|
+ height: 54px !important;
|
|
|
+ border:none !important;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+
|