index.vue 4.3 KB

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