revenue.vue 13 KB

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