revenue.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. <template>
  2. <view class="revenue">
  3. <view class="top-jg">
  4. </view>
  5. <view class="nav-wrapper">
  6. <view class="nav-item" v-for="(item, index) in navList" :key="index" :class="{ active: currentIndex === index }" @click="navClick(index)">{{ item.title }}</view>
  7. </view>
  8. <view class="list">
  9. <view class="list-item flex">
  10. <view class="item-tpl">
  11. <view class="tpl name">有效算力</view>
  12. <view class="tpl num">{{list.doing}}{{navList[currentIndex].slUnit}}</view>
  13. </view>
  14. <view class="item-tpl">
  15. <view class="tpl name">待生效算力</view>
  16. <view class="tpl num">{{list.stand}}{{navList[currentIndex].slUnit}}</view>
  17. </view>
  18. </view>
  19. <view class="list-item">
  20. <view class="item-tpl tols">
  21. <view class="tpl name">累计挖币</view>
  22. <view class="tpl num">{{list.all_mining}}{{navList[currentIndex].unit}}</view>
  23. </view>
  24. <!-- <view class="item-tpl">
  25. <view class="tpl name">当前锁仓</view>
  26. <view class="tpl num">{{list.all_lock}}FIL</view>
  27. </view> -->
  28. </view>
  29. </view>
  30. <view class="all-num">
  31. <view class="">
  32. <view class="title">总收益</view>
  33. <view class="num">{{allIncome}}{{navList[currentIndex].unit}}</view>
  34. </view>
  35. <view class="">
  36. <view class="title">累计释放</view>
  37. <view class="num">{{ljIncome}}{{navList[currentIndex].unit}}</view>
  38. </view>
  39. <view class="">
  40. <view class="title">待释放</view>
  41. <view class="num">{{wait}}{{navList[currentIndex].unit}}</view>
  42. </view>
  43. </view>
  44. <view class="tip">
  45. <view class="line"></view>
  46. <view class="title">每日收益记录</view>
  47. <view class="line"></view>
  48. </view>
  49. <scroll-view :style="{ height: height }" class="days" scroll-y>
  50. <empty v-if="navList[currentIndex].loaded === true && navList[currentIndex].list.length === 0"></empty>
  51. <view class="day-item" v-for="(item,index) in navList[currentIndex].list" :key="index">
  52. <view class="item">
  53. <view class="item-title">结算日期:</view>
  54. <view class="item-value">2021-07-04</view>
  55. </view>
  56. <view class="item">
  57. <view class="item-title">今日可用<text>25%</text></view>
  58. <view class="item-value">0.09{{navList[currentIndex].unit}}</view>
  59. </view>
  60. <view class="item">
  61. <view class="item-title">今日冻结<text>25%</text></view>
  62. <view class="item-value">0.09{{navList[currentIndex].unit}}</view>
  63. </view>
  64. <view class="item">
  65. <view class="item-title">今日释放<text>1/150</text></view>
  66. <view class="item-value">0.09{{navList[currentIndex].unit}}</view>
  67. </view>
  68. <uni-load-more :status="item.loadingType"></uni-load-more>
  69. </view>
  70. </scroll-view>
  71. </view>
  72. </template>
  73. <script>
  74. import empty from '@/components/empty';
  75. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  76. import { mining,miningIndex } from '@/api/calculation.js';
  77. export default {
  78. components:{
  79. empty,
  80. uniLoadMore
  81. },
  82. data() {
  83. return {
  84. list: '',
  85. navList: [
  86. {
  87. title: 'Fil',
  88. unit: 'FIL',
  89. slUnit:'T',
  90. list: [],
  91. page: 1,
  92. limit: 10,
  93. loadingType: 'more',
  94. },
  95. {
  96. title: 'Chia',
  97. unit: 'XCH',
  98. slUnit:'T',
  99. list: [],
  100. page: 1,
  101. limit: 10,
  102. loadingType: 'more',
  103. },
  104. {
  105. title: 'Bzz',
  106. unit: 'BZZ',
  107. slUnit:'节点',
  108. list: [],
  109. page: 1,
  110. limit: 10,
  111. loadingType: 'more',
  112. }
  113. ],
  114. currentIndex: 0,
  115. height: 0,
  116. allIncome: 0,//总收益
  117. ljIncome: 0,//累计收益
  118. wait: 0//待释放
  119. };
  120. },
  121. onReady(res) {
  122. var _this = this;
  123. uni.getSystemInfo({
  124. success: resu => {
  125. const query = uni.createSelectorQuery();
  126. query.select('.days').boundingClientRect();
  127. query.exec(function(res) {
  128. console.log(res, 'ddddddddddddd');
  129. _this.height = resu.windowHeight - res[0].top + 'px';
  130. console.log('打印页面的剩余高度', _this.height);
  131. });
  132. },
  133. fail: res => {}
  134. });
  135. },
  136. onLoad() {
  137. let userInfo = uni.getStorageSync('userInfo') || '';
  138. this.level = userInfo.level;
  139. this.loadData();
  140. this.loadTopDate('FIL')
  141. },
  142. methods: {
  143. async loadTopDate(type) {
  144. uni.showLoading({
  145. title: '加载中...'
  146. })
  147. let obj = this;
  148. miningIndex({
  149. type: type
  150. }).then(({ data }) => {
  151. obj.list = data;
  152. uni.hideLoading()
  153. console.log(obj.list)
  154. });
  155. },
  156. //切换币种
  157. navClick(index) {
  158. if(index !== this.currentIndex ){
  159. this.currentIndex = index;
  160. this.loadTopDate(this.navList[index].unit)
  161. this.loadData('tabChange')
  162. }
  163. },
  164. loadData(source) {
  165. //这里是将list挂载到nav列表下
  166. let index = this.currentIndex;
  167. let navItem = this.navList[index];
  168. // let state = navItem.state;
  169. if (source === 'tabChange' && navItem.loaded === true) {
  170. //tab切换只有第一次需要加载数据
  171. return;
  172. }
  173. if (navItem.loadingType === 'loading') {
  174. //防止重复加载
  175. return;
  176. }
  177. if (navItem.loadingType === 'noMore') {
  178. //防止重复加载
  179. return;
  180. }
  181. // 修改当前对象状态为加载中
  182. navItem.loadingType = 'loading';
  183. // orderList({
  184. // type: state,
  185. // page: navItem.page,
  186. // limit: navItem.limit
  187. // })
  188. // .then(({ data }) => {
  189. // let arr = data.map(e => {
  190. // return e;
  191. // });
  192. // navItem.list = navItem.list.concat(arr);
  193. // // console.log(navItem.orderList);
  194. // navItem.page++;
  195. // if (navItem.limit == data.length) {
  196. // //判断是否还有数据, 有改为 more, 没有改为noMore
  197. // navItem.loadingType = 'more';
  198. // return;
  199. // } else {
  200. // //判断是否还有数据, 有改为 more, 没有改为noMore
  201. // navItem.loadingType = 'noMore';
  202. // }
  203. // this.$set(navItem, 'loaded', true);
  204. // })
  205. // .catch(e => {
  206. // console.log(e);
  207. // });
  208. //假数据
  209. let arr = []
  210. navItem.list = navItem.list.concat(arr)
  211. navItem.page++
  212. navItem.loadingType = 'noMore'
  213. this.$set(navItem, 'loaded', true)
  214. console.log(this.navList)
  215. }
  216. }
  217. };
  218. </script>
  219. <style lang="scss" scoped>
  220. page {
  221. width: 100%;
  222. }
  223. .top-jg {
  224. height: 55rpx;
  225. }
  226. .nav-wrapper {
  227. margin: 0rpx auto 10rpx;
  228. width: 627rpx;
  229. height: 60rpx;
  230. border: 2px solid #5771df;
  231. border-radius: 5rpx;
  232. display: flex;
  233. .nav-item {
  234. width: 209rpx;
  235. text-align: center;
  236. line-height: 60rpx;
  237. font-size: 28rpx;
  238. font-family: PingFang SC;
  239. font-weight: bold;
  240. color: #5771df;
  241. }
  242. .active {
  243. background: #5771df;
  244. color: #fff;
  245. }
  246. }
  247. .all-num {
  248. width: 627rpx;
  249. margin: 0 auto;
  250. display: flex;
  251. justify-content: space-between;
  252. font-size: 30rpx;
  253. font-family: PingFang SC;
  254. font-weight: bold;
  255. color: #333333;
  256. view {
  257. display: flex;
  258. flex-direction: column;
  259. justify-content: center;
  260. align-items: center;
  261. .title {
  262. padding-bottom: 20rpx;
  263. }
  264. .num {
  265. font-weight: 500;
  266. }
  267. }
  268. }
  269. .tip {
  270. width: 627rpx;
  271. margin: 80rpx auto 70rpx;
  272. display: flex;
  273. justify-content: space-between;
  274. align-items: center;
  275. .line {
  276. width: 193rpx;
  277. height: 2rpx;
  278. background: #5771df;
  279. }
  280. .title {
  281. font-size: 28rpx;
  282. font-family: PingFang SC;
  283. font-weight: bold;
  284. color: #5771df;
  285. }
  286. }
  287. .days {
  288. // background-color: red;
  289. padding: 0 65rpx;
  290. .day-item {
  291. height: 230rpx;
  292. border-bottom: 1px solid #F3F4F6;
  293. background-color: #fff;
  294. font-size: 24rpx;
  295. font-family: PingFang SC;
  296. font-weight: bold;
  297. color: #333333;
  298. display: flex;
  299. flex-direction: column;
  300. justify-content: space-around;
  301. padding: 20rpx 0;
  302. .item {
  303. display: flex;
  304. justify-content: space-between;
  305. text {
  306. display: inline-block;
  307. margin-left: 10rpx;
  308. }
  309. }
  310. }
  311. }
  312. .list {
  313. padding:10rpx 65rpx 0;
  314. .list-item{
  315. // padding: 90rpx 118rpx 0 118rpx;
  316. margin-bottom: 15rpx;
  317. .item-tpl{
  318. background-color: #f7f6fb;
  319. text-align: center;
  320. // background-color: #FFFFFF;
  321. padding: 41rpx 0;
  322. width: 48%;
  323. .name{
  324. color: #666666;
  325. font-size: 24rpx;
  326. }
  327. .num{
  328. font-size: 32rpx;
  329. color: #333333;
  330. font-weight: bold;
  331. padding-top: 10rpx;
  332. }
  333. }
  334. }
  335. .tols{
  336. width: 100% !important;
  337. }
  338. }
  339. </style>