top-head.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <view class="head-box" :class="{'top-two':topType!==1}">
  3. <view class="top-head">
  4. <view class="head-item head-left" @click="goToUrl">
  5. <view class="left-img">
  6. <image src="@/static/img/index/logo1.png" mode="aspectFill"></image>
  7. </view>
  8. <view class="left-text">
  9. <view class="item-item">BNBDAO</view>
  10. <view class="item-item">WEB3 DATA</view>
  11. </view>
  12. </view>
  13. <view class="head-item head-right">
  14. <view class="right-img" @click.stop="setShowLang">
  15. <image src="@/static/img/index/yy.svg" mode="aspectFill"></image>
  16. </view>
  17. <view class="right-text">{{ babAddress }}</view>
  18. </view>
  19. </view>
  20. <view class="top-lang" :class="{'show-lang':showLang}">
  21. <view class="lang-item" v-for="langItem in langList" @click.stop="setLocaleLang(langItem.name)">
  22. {{ langItem.value }}
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import tokenpocketBnb from "@/common/wallet/tokenpocket-wallet/tokenpocket-bnb";
  29. export default {
  30. name: "top-head",
  31. components: {},
  32. props: {
  33. topType:{
  34. default:1
  35. }
  36. },
  37. data() {
  38. return {
  39. langList: [
  40. {'name': 'zh-Hans', 'value': '简体中文'},
  41. {'name': 'en', 'value': 'English'},
  42. // { 'name': 'ja', 'value': '日本語' },
  43. {'name': 'ko', 'value': '한국어'}],
  44. babAddress: '',
  45. showLang:false
  46. }
  47. },
  48. watch: {},
  49. async mounted() {
  50. this.applicationLocale = uni.getLocale();
  51. this.babAddress =await tokenpocketBnb.getAccounts()
  52. },
  53. methods: {
  54. goToUrl() {
  55. uni.navigateTo({
  56. 'url': 'pages/index/index'
  57. })
  58. },
  59. setLocaleLang(code) {
  60. uni.setLocale(code);
  61. this.$i18n.locale = code;
  62. this.applicationLocale = code;
  63. this.showLang = false
  64. },
  65. setShowLang() {
  66. this.showLang = !this.showLang
  67. },
  68. }
  69. }
  70. </script>
  71. <style scoped lang="scss">
  72. .head-box {
  73. .top-head {
  74. display: flex;
  75. justify-content: space-between;
  76. height: 84rpx;
  77. padding-left: 20rpx;
  78. .head-item {
  79. display: flex;
  80. justify-content: left;
  81. }
  82. .head-left {
  83. .left-img {
  84. margin-top: 1rpx;
  85. image {
  86. width: 80rpx;
  87. height: 80rpx;
  88. }
  89. }
  90. .left-text {
  91. padding-top: 5px;
  92. margin-left: 10px;
  93. .item-item {
  94. font-size: 22rpx;
  95. color: #fff;
  96. }
  97. .item-item:nth-of-type(1) {
  98. font-size: 32rpx;
  99. font-weight: bold;
  100. }
  101. }
  102. }
  103. .head-right {
  104. justify-content: right;
  105. .right-img {
  106. width: 70rpx;
  107. height: 70rpx;
  108. image {
  109. width: 70rpx;
  110. height: 70rpx;
  111. }
  112. }
  113. .right-text {
  114. margin-left: 20rpx;
  115. height: 70rpx;
  116. line-height: 70rpx;
  117. width: 200rpx;
  118. overflow: hidden;
  119. text-overflow: ellipsis;
  120. color: rgb(116, 132, 164);
  121. }
  122. }
  123. }
  124. .top-lang{
  125. border-radius: 0 0 0 20rpx;
  126. z-index: 1000;
  127. position: absolute;
  128. top:120rpx ;
  129. right: 0;
  130. width: 300rpx;
  131. transition: 0.5s ease;
  132. height: 0;
  133. overflow: hidden;
  134. background-color: rgba(0, 0, 0, 0.8);
  135. .lang-item{
  136. height: 100rpx;
  137. display: flex;
  138. align-items: center;
  139. color: #fff;
  140. font-size: 32rpx;
  141. padding-left: 40rpx;
  142. box-sizing: border-box;
  143. }
  144. }
  145. .show-lang{
  146. height: auto;
  147. transition: 0.5s ease;
  148. }
  149. }
  150. .top-two{
  151. z-index: 1000;
  152. background: #fff;
  153. top: 0;
  154. position: fixed;
  155. width: 100vw;
  156. padding: 20rpx 0;
  157. box-shadow: 0 0 24rpx 0 rgba(0,0,0,0.16);
  158. .item-item{
  159. color: #222 !important;
  160. }
  161. .right-text{
  162. color: rgb(0, 87, 255) !important;
  163. }
  164. }
  165. </style>