index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <script>
  2. import homeIndex from "@/pages/home/home-index.vue";
  3. import myIndex from "@/pages/my/my-index.vue";
  4. import convertIndex from "@/pages/convert/convert-index.vue";
  5. import tokenpocketBnb from "@/common/wallet/tokenpocket-wallet/tokenpocket-bnb";
  6. import tools from "@/common/js/tools";
  7. export default {
  8. components: { homeIndex, myIndex, convertIndex },
  9. data() {
  10. return {
  11. tab_index: 1,
  12. address:''
  13. };
  14. },
  15. mounted() {
  16. this.getMyData()
  17. this.getAccount()
  18. // this.handlerDateDurationCurrent()
  19. },
  20. methods: {
  21. abbreviateString(str ){
  22. let startLength=4;
  23. let endLength=4;
  24. if (str.length <= startLength + endLength + 1) {
  25. return str; // 如果字符串长度不足以被截断,则返回原字符串
  26. }
  27. return str.slice(0, startLength) + '...' + str.slice(-endLength);
  28. },
  29. async getAccount(){
  30. tokenpocketBnb.getAccounts().then(async (Address) => {
  31. console.log(Address)
  32. if (Address) {
  33. this.address=Address
  34. } else {
  35. tools.error("地址信息获取失败")
  36. }
  37. }).catch((e)=>{
  38. console.log(e)
  39. // tools.goToError(2)
  40. })
  41. },
  42. getMyData() {
  43. // let token = uni.getStorageSync('token')
  44. // if (token) {
  45. // getMemberInfo().then((res) => {
  46. // if (res.code === 1) {
  47. // this.memberData = res.data
  48. // tokenpocketBnb.getAccounts().then((babAddress)=>{
  49. // if(babAddress && this.memberData.address.toLocaleLowerCase()!==babAddress.toLocaleLowerCase()){
  50. // // uni.clearStorageSync()
  51. // // uni.reLaunch({
  52. // // 'url': 'pages/login/index'
  53. // // })
  54. // }
  55. // })
  56. // }
  57. // })
  58. // }
  59. },
  60. tabClick(num) {
  61. if(num) {
  62. this.tab_index = num
  63. }
  64. }
  65. },
  66. }
  67. </script>
  68. <template>
  69. <view class="flex-common-css">
  70. <view class="top-b bgc-f plr-20 box-sizing-border align-items-center flex-justify-space">
  71. <image
  72. class="img-box"
  73. src="@/static/img/logo/logo.png"
  74. ></image>
  75. <view class="fs-30">
  76. {{abbreviateString(address)}}
  77. </view>
  78. </view>
  79. <view class="content-b p-20 box-sizing-border">
  80. <view class="scroll-view-css">
  81. <homeIndex v-if="tab_index === 1" :address="address"></homeIndex>
  82. <convertIndex v-else-if="tab_index === 2"></convertIndex>
  83. <myIndex v-else></myIndex>
  84. </view>
  85. <view class="tab-b align-items-center flex-justify-space b-rad-10 bgc-f">
  86. <view @click="tabClick(1)" class="flex-1 flex-direction-column align-items-center flex-justify-center">
  87. <image
  88. class="tab-img mb-4"
  89. v-if="tab_index === 1"
  90. :src="require('@/static/img/tab/index.svg')"
  91. ></image>
  92. <image
  93. class="tab-img mb-4"
  94. v-else
  95. :src="require('@/static/img/tab/index-two.svg')"
  96. ></image>
  97. <view class="fs-28" :class="tab_index === 1?'fc-f78820':''">首页</view>
  98. </view>
  99. <view @click="tabClick(2)" class="flex-1 flex-direction-column align-items-center flex-justify-center">
  100. <image
  101. class="tab-img mb-4"
  102. :src="require('@/static/img/tab/jh.svg')"
  103. ></image>
  104. <view class="fs-28" :class="tab_index === 2?'fc-f78820':''">兑换</view>
  105. </view>
  106. <view @click="tabClick(3)" class="flex-1 flex-direction-column align-items-center flex-justify-center">
  107. <image
  108. v-if="tab_index === 3"
  109. class="tab-img mb-4"
  110. :src="require('@/static/img/tab/my-two.svg')"
  111. ></image>
  112. <image
  113. v-else
  114. class="tab-img mb-4"
  115. :src="require('@/static/img/tab/my.svg')"
  116. ></image>
  117. <view class="fs-28" :class="tab_index === 3?'fc-f78820':''">我的</view>
  118. </view>
  119. </view>
  120. </view>
  121. </view>
  122. </template>
  123. <style scoped lang="scss">
  124. .content-b{
  125. width: 100%;
  126. height: calc(100vh - 98rpx);
  127. display: flex;
  128. flex-direction: column;
  129. }
  130. .top-b{
  131. width: 100%;
  132. height: 98rpx;
  133. line-height: 98rpx;
  134. }
  135. .img-box{
  136. width: 78rpx;
  137. height: 60rpx;
  138. }
  139. .tab-img{
  140. width: 50rpx;
  141. height: 50rpx;
  142. }
  143. .tab-b{
  144. width: 100%;
  145. height: 138rpx;
  146. padding: 20rpx 0;
  147. box-sizing: border-box;
  148. }
  149. </style>