top-head.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. 'babAddress':function (){
  50. this.$emit('setBabAddress',this.babAddress)
  51. }
  52. },
  53. async mounted() {
  54. this.applicationLocale = uni.getLocale();
  55. if(this.$Route.query==='/pages/index/index'){
  56. setTimeout(()=>{
  57. this.getBabAddress()
  58. },100)
  59. }else {
  60. await this.getBabAddress()
  61. }
  62. },
  63. methods: {
  64. async getBabAddress(){
  65. this.babAddress =await tokenpocketBnb.getAccounts()
  66. },
  67. goToUrl() {
  68. uni.navigateTo({
  69. 'url': 'pages/index/index'
  70. })
  71. },
  72. setLocaleLang(code) {
  73. uni.setLocale(code);
  74. this.$i18n.locale = code;
  75. this.applicationLocale = code;
  76. this.showLang = false
  77. },
  78. setShowLang() {
  79. this.showLang = !this.showLang
  80. },
  81. }
  82. }
  83. </script>
  84. <style scoped lang="scss">
  85. .head-box {
  86. .top-head {
  87. display: flex;
  88. justify-content: space-between;
  89. height: 84rpx;
  90. padding-left: 20rpx;
  91. .head-item {
  92. display: flex;
  93. justify-content: left;
  94. }
  95. .head-left {
  96. .left-img {
  97. margin-top: 1rpx;
  98. image {
  99. width: 80rpx;
  100. height: 80rpx;
  101. }
  102. }
  103. .left-text {
  104. padding-top: 5px;
  105. margin-left: 10px;
  106. .item-item {
  107. font-size: 22rpx;
  108. color: #fff;
  109. }
  110. .item-item:nth-of-type(1) {
  111. font-size: 32rpx;
  112. font-weight: bold;
  113. }
  114. }
  115. }
  116. .head-right {
  117. justify-content: right;
  118. .right-img {
  119. width: 70rpx;
  120. height: 70rpx;
  121. image {
  122. width: 70rpx;
  123. height: 70rpx;
  124. }
  125. }
  126. .right-text {
  127. margin-left: 20rpx;
  128. height: 70rpx;
  129. line-height: 70rpx;
  130. width: 200rpx;
  131. overflow: hidden;
  132. text-overflow: ellipsis;
  133. color: rgb(116, 132, 164);
  134. }
  135. }
  136. }
  137. .top-lang{
  138. border-radius: 0 0 0 20rpx;
  139. z-index: 1000;
  140. position: absolute;
  141. top:120rpx ;
  142. right: 0;
  143. width: 300rpx;
  144. transition: 0.5s ease;
  145. height: 0;
  146. overflow: hidden;
  147. background-color: rgba(0, 0, 0, 0.8);
  148. .lang-item{
  149. height: 100rpx;
  150. display: flex;
  151. align-items: center;
  152. color: #fff;
  153. font-size: 32rpx;
  154. padding-left: 40rpx;
  155. box-sizing: border-box;
  156. }
  157. }
  158. .show-lang{
  159. height: auto;
  160. transition: 0.5s ease;
  161. }
  162. }
  163. .top-two{
  164. z-index: 1000;
  165. background: #fff;
  166. top: 0;
  167. position: fixed;
  168. width: 100vw;
  169. padding: 20rpx 0;
  170. box-shadow: 0 0 24rpx 0 rgba(0,0,0,0.16);
  171. .item-item{
  172. color: #222 !important;
  173. }
  174. .right-text{
  175. color: rgb(0, 87, 255) !important;
  176. }
  177. }
  178. </style>