index.vue 4.2 KB

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