revenue.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. <template>
  2. <view class="revenue">
  3. <view class="top-jg"></view>
  4. <view class="nav-wrapper">
  5. <view class="nav-item" v-for="(item, index) in navList" :key="index" :class="{ active: currentIndex === index }" @click="navClick(index)">{{ item.title }}</view>
  6. </view>
  7. <view class="list">
  8. <view class="list-item flex">
  9. <view class="item-tpl">
  10. <view class="tpl name">有效算力</view>
  11. <view class="tpl num">{{ list.doing }}{{ navList[currentIndex].slUnit }}</view>
  12. </view>
  13. <view class="item-tpl">
  14. <view class="tpl name">待生效算力</view>
  15. <view class="tpl num">{{ list.stand }}{{ navList[currentIndex].slUnit }}</view>
  16. </view>
  17. </view>
  18. <view class="list-item">
  19. <view class="item-tpl tols">
  20. <view class="tpl name">可用</view>
  21. <view class="tpl num">{{ list.all_mining | four }}{{ navList[currentIndex].unit }}</view>
  22. </view>
  23. <!-- <view class="item-tpl">
  24. <view class="tpl name">当前锁仓</view>
  25. <view class="tpl num">{{list.all_lock}}FIL</view>
  26. </view> -->
  27. </view>
  28. </view>
  29. <scroll-view scroll-x="true" style="width: 750rpx; padding-top: 20rpx;">
  30. <view class="flex">
  31. <view class="info-cell">
  32. <view class="cell">总收益</view>
  33. <view class="cell-title">
  34. <!-- {{
  35. (navList[currentIndex].all_unlock * 1 + navList[currentIndex].all_lock + list.all_mining + navList[currentIndex].all_recommend)| four
  36. }}{{ navList[currentIndex].unit }} -->
  37. {{ navList[currentIndex].all_get | four }}{{ navList[currentIndex].unit }}
  38. </view>
  39. </view>
  40. <view class="info-cell">
  41. <view class="cell">分享收益</view>
  42. <view class="cell-title">{{ navList[currentIndex].all_recommend | four }}{{ navList[currentIndex].unit }}</view>
  43. </view>
  44. <view class="info-cell">
  45. <view class="cell">今日分享收益</view>
  46. <view class="cell-title">{{ navList[currentIndex].today_recommend | four }}{{ navList[currentIndex].unit }}</view>
  47. </view>
  48. <!-- <view class="info-cell" v-if="navList[currentIndex].all_recommend != 0">
  49. <view class="cell">累计推荐</view>
  50. <view class="cell-title">{{navList[currentIndex].all_recommend | four}}{{ navList[currentIndex].unit }}</view>
  51. </view> -->
  52. <!-- <view class="info-cell" v-if="navList[currentIndex].today_recommend != 0">
  53. <view class="cell">今日推荐</view>
  54. <view class="cell-title">{{navList[currentIndex].today_recommend | four}}{{ navList[currentIndex].unit }}</view>
  55. </view> -->
  56. </view>
  57. </scroll-view>
  58. <!-- <view class="all-num">
  59. <view class="num-item">
  60. <view class="title">总收益</view>
  61. <view class="num">{{ (+navList[currentIndex].all_unlock + navList[currentIndex].all_lock + list.all_mining) == 0 ? 0 : (+navList[currentIndex].all_unlock + navList[currentIndex].all_lock + list.all_mining).toFixed(6) }}{{ navList[currentIndex].unit }}</view>
  62. </view>
  63. <view class="num-item">
  64. <view class="title">累计释放</view>
  65. <view class="num">{{ navList[currentIndex].all_unlock }}{{ navList[currentIndex].unit }}</view>
  66. </view>
  67. <view class="num-item">
  68. <view class="title">待释放</view>
  69. <view class="num">{{ navList[currentIndex].all_lock }}{{ navList[currentIndex].unit }}</view>
  70. </view>
  71. </view> -->
  72. <view class="tip">
  73. <view class="line"></view>
  74. <view class="title">每日收益记录</view>
  75. <view class="line"></view>
  76. </view>
  77. <scroll-view :style="{ height: height }" class="days" scroll-y @scrolltolower="loadData()">
  78. <empty v-if="navList[currentIndex].loaded === true && navList[currentIndex].list.length === 0"></empty>
  79. <view class="day-item" v-for="(item, index) in navList[currentIndex].list" :key="index">
  80. <view v-if="item.step == 1 || item.step == 0">
  81. <view class="item">
  82. <view class="item-title">结算日期:</view>
  83. <view class="item-value">{{ item.add_date }}</view>
  84. </view>
  85. <view class="item">
  86. <view class="item-title">
  87. 今日可用
  88. <!-- <text>{{ +item.machine.first_step_get_ratio }}</text> -->
  89. </view>
  90. <view class="item-value">{{ item.get_money | four }}{{ item.get_money_type }}</view>
  91. </view>
  92. <!-- <view class="item" v-if="((item.get_money * 1) / (item.machine.first_step_get_ratio * 1)) * 100 - item.get_money * 1 != 0">
  93. <view class="item-title">
  94. 今日质押
  95. <text>{{ 100 - item.machine.second_step_get_ratio * 1 }}%</text>
  96. </view>
  97. <view class="item-value">{{ (((item.get_money * 1) / (item.machine.first_step_get_ratio * 1)) * 100 - item.get_money * 1) | four }}{{ item.get_money_type }}</view>
  98. </view> -->
  99. </view>
  100. <view v-if="item.step == 2">
  101. <!-- <view class=""> -->
  102. <view class="item">
  103. <view class="item-title">结算日期:</view>
  104. <view class="item-value">{{ item.add_date }}</view>
  105. </view>
  106. <view class="item">
  107. <view class="item-title">
  108. 今日获得:
  109. <text>{{ +item.machine.second_step_get_ratio }}%</text>
  110. </view>
  111. <view class="item-value">{{ (item.get_money*1 - item.unlock*1) | four }}{{ item.get_money_type }}</view>
  112. </view>
  113. <view class="item" v-if="item.all_lock*1 != 0">
  114. <view class="item-title">
  115. 今日冻结:
  116. <text>{{ 100 - item.machine.second_step_get_ratio }}%</text>
  117. </view>
  118. <view class="item-value">
  119. <text>{{ (+item.all_lock) | four }}{{ item.get_money_type }}</text>
  120. </view>
  121. </view>
  122. <view class="item" v-if="+item.unlock != 0">
  123. <view class="item-title">
  124. 今日释放:
  125. <text>1/{{ item.machine.third_step_time }}</text>
  126. </view>
  127. <view class="item-value">
  128. <text>{{ (+item.unlock) | four}}{{ item.get_money_type }}</text>
  129. </view>
  130. </view>
  131. </view>
  132. <view v-if="item.step == 3">
  133. <view class="item">
  134. <view class="item-title">结算日期:</view>
  135. <view class="item-value">{{ item.add_date }}{{ item.get_money_type }}</view>
  136. </view>
  137. <view class="item">
  138. <view class="item-title">
  139. 今日释放:
  140. <text>1/{{ item.machine.third_step_time }}</text>
  141. </view>
  142. <view class="item-value">{{ item.unlock | four}}{{ item.get_money_type }}</view>
  143. </view>
  144. <view class="item">
  145. <view class="item-title">
  146. 解除质押:
  147. <text>1/{{ item.machine.third_step_time }}</text>
  148. </view>
  149. <view class="item-value">{{ item.unstand | four }}{{ item.get_money_type }}</view>
  150. </view>
  151. </view>
  152. </view>
  153. <uni-load-more :status="navList[currentIndex].loadingType" v-if="navList[currentIndex].list !=0"></uni-load-more>
  154. </scroll-view>
  155. </view>
  156. </template>
  157. <script>
  158. import empty from '@/components/empty';
  159. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  160. import { mining, miningIndex, myMiningGet } from '@/api/calculation.js';
  161. export default {
  162. components: {
  163. empty,
  164. uniLoadMore
  165. },
  166. data() {
  167. return {
  168. list: '',
  169. navList: [
  170. {
  171. title: 'BTC',
  172. unit: 'BTC',
  173. slUnit: 'T',
  174. list: [],
  175. page: 1,
  176. limit: 10,
  177. loadingType: 'more',
  178. all_lock: 0, //待释放
  179. all_get: 0, //总收益
  180. all_unlock: 0 //累计释放
  181. },
  182. // {
  183. // title: 'Chia',
  184. // unit: 'XCH',
  185. // slUnit: 'T',
  186. // list: [],
  187. // page: 1,
  188. // limit: 10,
  189. // loadingType: 'more',
  190. // all_lock: 0, //待释放
  191. // all_get: 0, //总收益
  192. // all_unlock: 0 //累计释放
  193. // },
  194. {
  195. title: 'ETH',
  196. unit: 'ETH',
  197. slUnit: 'T',
  198. list: [],
  199. page: 1,
  200. limit: 10,
  201. loadingType: 'more',
  202. all_lock: 0, //待释放
  203. all_get: 0, //总收益
  204. all_unlock: 0 //累计释放
  205. }
  206. ],
  207. currentIndex: 0,
  208. height: 0,
  209. allIncome: 0, //总收益
  210. ljIncome: 0, //累计收益
  211. wait: 0, //待释放,
  212. all_lock: 0, //待释放
  213. all_get: 0, //总收益
  214. all_unlock: 0 //累计释放
  215. };
  216. },
  217. filters: {
  218. four(val) {
  219. if (val) {
  220. val = val.toString();
  221. let index = val.indexOf('.');
  222. if (index !== -1) {
  223. val = val.substring(0, 4 + index + 1);
  224. } else {
  225. val = val.substring(0);
  226. }
  227. return parseFloat(val).toFixed(4);
  228. }
  229. return '0.0000';
  230. }
  231. },
  232. onReady(res) {
  233. var _this = this;
  234. uni.getSystemInfo({
  235. success: resu => {
  236. const query = uni.createSelectorQuery();
  237. query.select('.days').boundingClientRect();
  238. query.exec(function(res) {
  239. console.log(res, 'ddddddddddddd');
  240. _this.height = resu.windowHeight - res[0].top + 'px';
  241. console.log('打印页面的剩余高度', _this.height);
  242. });
  243. },
  244. fail: res => {}
  245. });
  246. },
  247. onLoad() {
  248. let userInfo = uni.getStorageSync('userInfo') || '';
  249. this.level = userInfo.level;
  250. this.loadData();
  251. this.loadTopDate('BTC');
  252. },
  253. methods: {
  254. async loadTopDate(type) {
  255. uni.showLoading({
  256. title: '加载中...'
  257. });
  258. let obj = this;
  259. miningIndex({
  260. type: type
  261. }).then(({ data }) => {
  262. obj.list = data;
  263. uni.hideLoading();
  264. console.log(obj.list);
  265. });
  266. },
  267. //切换币种
  268. navClick(index) {
  269. if (index !== this.currentIndex) {
  270. this.currentIndex = index;
  271. this.loadTopDate(this.navList[index].unit);
  272. this.loadData('tabChange');
  273. }
  274. },
  275. loadData(source) {
  276. console.log('loadnoe');
  277. //这里是将list挂载到nav列表下
  278. let index = this.currentIndex;
  279. let navItem = this.navList[index];
  280. // let state = navItem.state;
  281. if (source === 'tabChange' && navItem.loaded === true) {
  282. //tab切换只有第一次需要加载数据
  283. return;
  284. }
  285. if (navItem.loadingType === 'loading') {
  286. //防止重复加载
  287. return;
  288. }
  289. if (navItem.loadingType === 'noMore') {
  290. //防止重复加载
  291. return;
  292. }
  293. // 修改当前对象状态为加载中
  294. navItem.loadingType = 'loading';
  295. myMiningGet({
  296. type: navItem.unit,
  297. page: navItem.page,
  298. limit: navItem.limit
  299. })
  300. .then(({ data }) => {
  301. console.log(data, '888888888888888888888');
  302. navItem.all_lock = data.all_lock;
  303. navItem.all_get = data.all_get;
  304. navItem.all_unlock = data.all_unlock;
  305. navItem.all_recommend = data.all_recommend*1
  306. navItem.today_recommend = data.today_recommend*1
  307. let arr = data.list.data.map(e => {
  308. return e;
  309. });
  310. navItem.list = navItem.list.concat(arr);
  311. console.log(arr);
  312. navItem.page++;
  313. if (navItem.limit == data.list.data.length) {
  314. //判断是否还有数据, 有改为 more, 没有改为noMore
  315. navItem.loadingType = 'more';
  316. console.log('more');
  317. return;
  318. } else {
  319. //判断是否还有数据, 有改为 more, 没有改为noMore
  320. navItem.loadingType = 'noMore';
  321. console.log('noMore');
  322. }
  323. this.$set(navItem, 'loaded', true);
  324. })
  325. .catch(e => {
  326. console.log(e);
  327. });
  328. }
  329. }
  330. };
  331. </script>
  332. <style lang="scss" scoped>
  333. page {
  334. width: 100%;
  335. }
  336. .top-jg {
  337. height: 55rpx;
  338. }
  339. .nav-wrapper {
  340. margin: 0rpx auto 10rpx;
  341. width: 627rpx;
  342. height: 60rpx;
  343. border: 2px solid #141E47;
  344. border-radius: 5rpx;
  345. display: flex;
  346. .nav-item {
  347. width: 50%;
  348. text-align: center;
  349. line-height: 60rpx;
  350. font-size: 28rpx;
  351. font-family: PingFang SC;
  352. font-weight: bold;
  353. color: #141E47;
  354. }
  355. .active {
  356. background: #141E47;
  357. color: #fff;
  358. }
  359. }
  360. .all-num {
  361. width: 627rpx;
  362. margin: 0 auto;
  363. display: flex;
  364. justify-content: space-between;
  365. font-size: 30rpx;
  366. font-family: PingFang SC;
  367. font-weight: bold;
  368. color: #333333;
  369. .num-item {
  370. width: 33.3%;
  371. flex-shrink: 0;
  372. display: flex;
  373. flex-direction: column;
  374. justify-content: center;
  375. align-items: center;
  376. .title {
  377. padding-bottom: 20rpx;
  378. }
  379. .num {
  380. font-weight: 500;
  381. }
  382. }
  383. }
  384. .tip {
  385. width: 627rpx;
  386. margin: 30rpx auto 30rpx;
  387. display: flex;
  388. justify-content: space-between;
  389. align-items: center;
  390. .line {
  391. width: 193rpx;
  392. height: 2rpx;
  393. background: #FF6600;
  394. }
  395. .title {
  396. font-size: 28rpx;
  397. font-family: PingFang SC;
  398. font-weight: bold;
  399. color: #FF6600;
  400. }
  401. }
  402. .days {
  403. // background-color: red;
  404. padding: 0 65rpx;
  405. .day-item {
  406. // height: 230rpx;
  407. border-bottom: 1px solid #f3f4f6;
  408. background-color: #fff;
  409. font-size: 24rpx;
  410. font-family: PingFang SC;
  411. font-weight: bold;
  412. color: #333333;
  413. display: flex;
  414. flex-direction: column;
  415. justify-content: space-around;
  416. padding: 20rpx 0;
  417. .item {
  418. display: flex;
  419. justify-content: space-between;
  420. text {
  421. display: inline-block;
  422. margin-left: 10rpx;
  423. }
  424. }
  425. }
  426. }
  427. .list {
  428. padding: 10rpx 65rpx 0;
  429. .list-item {
  430. // padding: 90rpx 118rpx 0 118rpx;
  431. margin-bottom: 15rpx;
  432. .item-tpl {
  433. background-color: #f7f6fb;
  434. text-align: center;
  435. // background-color: #FFFFFF;
  436. padding: 20rpx 0;
  437. width: 48%;
  438. .name {
  439. color: #666666;
  440. font-size: 24rpx;
  441. }
  442. .num {
  443. font-size: 32rpx;
  444. color: #333333;
  445. font-weight: bold;
  446. padding-top: 10rpx;
  447. }
  448. }
  449. }
  450. .tols {
  451. width: 100% !important;
  452. }
  453. }
  454. .info-cell {
  455. width: 33.33%;
  456. text-align: center;
  457. flex-shrink: 0;
  458. .cell {
  459. font-size: 30rpx;
  460. font-weight: bold;
  461. color: #333333;
  462. }
  463. .cell-title {
  464. font-size: 26rpx;
  465. font-weight: 500;
  466. color:#333333;
  467. padding-top: 20rpx;
  468. }
  469. }
  470. </style>