index.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <div class="container">
  3. <van-search
  4. v-model="value"
  5. shape="round"
  6. :placeholder="$t('login.SearchMainnet')"
  7. class="search"
  8. />
  9. </div>
  10. <van-skeleton avatar title :row="2" :loading="loading" />
  11. <div class="network-list">
  12. <div class="network-item" v-for="item in networkComputed" :key="item.id" @click="selectNetwork(item)">
  13. <van-image loading-icon="wechat-moments" lazy-load class="network-item-icon" :src="item.icon" />
  14. <div class="network-item-name">{{ item.name }}</div>
  15. </div>
  16. </div>
  17. </template>
  18. <script setup>
  19. import { getNetwork } from '@/api/path/login.api'
  20. import { useSystemStore } from "@/stores/modules/systemStore";
  21. import { useWalletStore } from "@/stores/modules/walletStore";
  22. import { useRouter } from 'vue-router'
  23. const router = useRouter()
  24. const systemStore = useSystemStore();
  25. const walletStore = useWalletStore();
  26. const value = ref('')
  27. const networkList = ref([])
  28. const loading = ref(true)
  29. const initNetwork = async () => {
  30. const { data } = await getNetwork({})
  31. loading.value = false
  32. networkList.value = data
  33. }
  34. const networkComputed = computed(() => {
  35. if (!value.value) return networkList.value
  36. let arr = [];
  37. arr = networkList.value.filter((item) => {
  38. return JSON.stringify(item).includes(value.value);
  39. });
  40. return arr;
  41. })
  42. const selectNetwork = (item) => {
  43. walletStore.accountName = item.name
  44. walletStore.accountIcon = item.icon
  45. walletStore.rpcUrl = item.url
  46. router.push({
  47. path: systemStore.getISCREATE?'/createWallet':'/importMethod',
  48. })
  49. }
  50. onMounted(() =>{
  51. initNetwork()
  52. })
  53. </script>
  54. <style scoped lang="less">
  55. .search{
  56. background-color: transparent;
  57. }
  58. :deep(.van-search__content){
  59. background: @bg-color1;
  60. }
  61. .network-list{
  62. display: flex;
  63. flex-direction: column;
  64. margin: 20px 20px 0 20px;
  65. .network-item{
  66. display: flex;
  67. align-items: center;
  68. margin-bottom: 17px;
  69. .network-item-icon{
  70. width: 30px;
  71. height: 30px;
  72. }
  73. .network-item-name{
  74. margin-left: 10px;
  75. font-size: 15px;
  76. color: @font-color2;
  77. }
  78. }
  79. }
  80. </style>