index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <view class="nav-bar">
  3. <view class="back-box" v-if="back"></view>
  4. <view class="nav-title" @click="changeLinkAddress">
  5. ACC <span style="padding: 0 12rpx">|</span>{{address}}
  6. </view>
  7. <view class="nav-right">
  8. <!-- <view class="nav-right-network">
  9. <image
  10. src="@/static/image/home/network.png"
  11. mode="scaleToFill"
  12. />
  13. </view> -->
  14. <view class="nav-right-logo">
  15. <image
  16. src="@/static/image/home/logo.png"
  17. mode="scaleToFill"
  18. />
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script setup>
  24. import { ref,defineProps,defineEmits,onMounted } from "vue";
  25. import { getWalletAddress } from "@/utils/utils";
  26. const props = defineProps({
  27. back: {
  28. type: Boolean,
  29. default: () => false,
  30. },
  31. });
  32. const emit = defineEmits(['update:address']);
  33. const address = ref("");
  34. const getAddress = async () =>{
  35. // const addr = await getWalletAddress();
  36. let addr = '0x01Ce8d3Ae9240B029E0868f811dfF77a4F5320f2';
  37. if (addr) {
  38. console.log(addr);
  39. emit('update:address', addr);
  40. address.value = `${addr.slice(0, 4)}...${addr.slice(-4)}`;
  41. } else {
  42. address.value = "未连接钱包";
  43. }
  44. }
  45. const changeLinkAddress = () =>{
  46. if(address.value == '未连接钱包'){
  47. getAddress();
  48. }
  49. }
  50. onMounted(async () => {
  51. getAddress();
  52. });
  53. </script>
  54. <style lang="scss">
  55. .nav-bar {
  56. height: 116rpx;
  57. background: rgba(0,0,0,0.1);
  58. position: fixed;
  59. display: flex;
  60. justify-content: center;
  61. align-items: center;
  62. left: 0;
  63. top: 0;
  64. right: 0;
  65. z-index: 100;
  66. .back-box{
  67. position: absolute;
  68. left: 32rpx;
  69. top: 0;
  70. height: 100%;
  71. width: 90rpx;
  72. }
  73. .nav-title{
  74. color: #fff;
  75. font-weight: 600;
  76. font-size: 36rpx;
  77. }
  78. .nav-right{
  79. position: absolute;
  80. top: 0;
  81. right: 32rpx;
  82. bottom: 0;
  83. margin: auto;
  84. display: flex;
  85. align-items: center;
  86. .nav-right-network{
  87. height: 102rpx;
  88. width: 102rpx;
  89. image{
  90. width: 100%;
  91. height: 100%;
  92. }
  93. }
  94. .nav-right-logo{
  95. height: 80rpx;
  96. width: 80rpx;
  97. background: #283082;
  98. border-radius: 8rpx;
  99. image{
  100. width: 100%;
  101. height: 100%;
  102. }
  103. }
  104. }
  105. }
  106. </style>