revenue.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  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==null?"0":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==null?"0":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_time }}</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{getTime} from '../../utils/rocessor.js'
  159. import empty from '@/components/empty';
  160. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  161. import { mining, miningIndex, myMiningGet } from '@/api/calculation.js';
  162. export default {
  163. components: {
  164. empty,
  165. uniLoadMore
  166. },
  167. data() {
  168. return {
  169. list: '',
  170. // time:0,
  171. navList: [
  172. {
  173. title: 'BTC',
  174. unit: 'BTC',
  175. slUnit: 'T',
  176. list: [],
  177. page: 1,
  178. limit: 10,
  179. loadingType: 'more',
  180. all_lock: 0, //待释放
  181. all_get: 0, //总收益
  182. all_unlock: 0 ,//累计释放
  183. time:"",//结算时间
  184. },
  185. // {
  186. // title: 'Chia',
  187. // unit: 'XCH',
  188. // slUnit: 'T',
  189. // list: [],
  190. // page: 1,
  191. // limit: 10,
  192. // loadingType: 'more',
  193. // all_lock: 0, //待释放
  194. // all_get: 0, //总收益
  195. // all_unlock: 0 //累计释放
  196. // },
  197. {
  198. title: 'ETH',
  199. unit: 'ETH',
  200. slUnit: 'T',
  201. list: [],
  202. page: 1,
  203. limit: 10,
  204. loadingType: 'more',
  205. all_lock: 0, //待释放
  206. all_get: 0, //总收益
  207. all_unlock: 0 //累计释放
  208. }
  209. ],
  210. currentIndex: 0,
  211. height: 0,
  212. allIncome: 0, //总收益
  213. ljIncome: 0, //累计收益
  214. wait: 0, //待释放,
  215. all_lock: 0, //待释放
  216. all_get: 0, //总收益
  217. all_unlock: 0 //累计释放
  218. };
  219. },
  220. filters: {
  221. four(val) {
  222. if (val) {
  223. val = val.toString();
  224. let index = val.indexOf('.');
  225. if (index !== -1) {
  226. val = val.substring(0, 8 + index + 1);
  227. } else {
  228. val = val.substring(0);
  229. }
  230. return parseFloat(val).toFixed(8);
  231. }
  232. return '0.0000';
  233. }
  234. },
  235. onReady(res) {
  236. var _this = this;
  237. uni.getSystemInfo({
  238. success: resu => {
  239. const query = uni.createSelectorQuery();
  240. query.select('.days').boundingClientRect();
  241. query.exec(function(res) {
  242. console.log(res, 'ddddddddddddd');
  243. _this.height = resu.windowHeight - res[0].top + 'px';
  244. console.log('打印页面的剩余高度', _this.height);
  245. });
  246. },
  247. fail: res => {}
  248. });
  249. },
  250. onLoad() {
  251. let userInfo = uni.getStorageSync('userInfo') || '';
  252. this.level = userInfo.level;
  253. this.loadData();
  254. this.loadTopDate('BTC');
  255. },
  256. methods: {
  257. async loadTopDate(type) {
  258. uni.showLoading({
  259. title: '加载中...'
  260. });
  261. let obj = this;
  262. miningIndex({
  263. type: type
  264. }).then(({ data }) => {
  265. obj.list = data;
  266. uni.hideLoading();
  267. console.log(obj.list,'222');
  268. });
  269. },
  270. //切换币种
  271. navClick(index) {
  272. if (index !== this.currentIndex) {
  273. this.currentIndex = index;
  274. this.loadTopDate(this.navList[index].unit);
  275. this.loadData('tabChange');
  276. }
  277. },
  278. loadData(source) {
  279. let obj =this
  280. console.log('loadnoe');
  281. //这里是将list挂载到nav列表下
  282. let index = this.currentIndex;
  283. let navItem = this.navList[index];
  284. // let state = navItem.state;
  285. if (source === 'tabChange' && navItem.loaded === true) {
  286. //tab切换只有第一次需要加载数据
  287. return;
  288. }
  289. if (navItem.loadingType === 'loading') {
  290. //防止重复加载
  291. return;
  292. }
  293. if (navItem.loadingType === 'noMore') {
  294. //防止重复加载
  295. return;
  296. }
  297. // 修改当前对象状态为加载中
  298. navItem.loadingType = 'loading';
  299. myMiningGet({
  300. type: navItem.unit,
  301. page: navItem.page,
  302. limit: navItem.limit
  303. })
  304. .then(({ data }) => {
  305. console.log(data, '888888888888888888888');
  306. data.list.data.forEach(e=>{
  307. // console.log(e,'2');
  308. e.add_time= getTime(e.add_time)
  309. // console.log(e.add_time,'时间');
  310. })
  311. // navItem.time =getTime(data.list.data.add_time) ;
  312. // console.log(data.list.data[0].add_time);
  313. navItem.all_lock = data.all_lock;
  314. navItem.all_get = data.all_get;
  315. navItem.all_unlock = data.all_unlock;
  316. navItem.all_recommend = data.all_recommend*1
  317. navItem.today_recommend = data.today_recommend*1
  318. let arr = data.list.data.map(e => {
  319. return e;
  320. });
  321. navItem.list = navItem.list.concat(arr);
  322. console.log(arr);
  323. navItem.page++;
  324. if (navItem.limit == data.list.data.length) {
  325. //判断是否还有数据, 有改为 more, 没有改为noMore
  326. navItem.loadingType = 'more';
  327. console.log('more');
  328. return;
  329. } else {
  330. //判断是否还有数据, 有改为 more, 没有改为noMore
  331. navItem.loadingType = 'noMore';
  332. console.log('noMore');
  333. }
  334. this.$set(navItem, 'loaded', true);
  335. })
  336. .catch(e => {
  337. console.log(e);
  338. });
  339. }
  340. }
  341. };
  342. </script>
  343. <style lang="scss" scoped>
  344. page {
  345. width: 100%;
  346. }
  347. .top-jg {
  348. height: 55rpx;
  349. }
  350. .nav-wrapper {
  351. margin: 0rpx auto 10rpx;
  352. width: 627rpx;
  353. height: 60rpx;
  354. border: 2px solid #141E47;
  355. border-radius: 5rpx;
  356. display: flex;
  357. .nav-item {
  358. width: 50%;
  359. text-align: center;
  360. line-height: 60rpx;
  361. font-size: 28rpx;
  362. font-family: PingFang SC;
  363. font-weight: bold;
  364. color: #141E47;
  365. }
  366. .active {
  367. background: #141E47;
  368. color: #fff;
  369. }
  370. }
  371. .all-num {
  372. width: 627rpx;
  373. margin: 0 auto;
  374. display: flex;
  375. justify-content: space-between;
  376. font-size: 30rpx;
  377. font-family: PingFang SC;
  378. font-weight: bold;
  379. color: #333333;
  380. .num-item {
  381. width: 33.3%;
  382. flex-shrink: 0;
  383. display: flex;
  384. flex-direction: column;
  385. justify-content: center;
  386. align-items: center;
  387. .title {
  388. padding-bottom: 20rpx;
  389. }
  390. .num {
  391. font-weight: 500;
  392. }
  393. }
  394. }
  395. .tip {
  396. width: 627rpx;
  397. margin: 30rpx auto 30rpx;
  398. display: flex;
  399. justify-content: space-between;
  400. align-items: center;
  401. .line {
  402. width: 193rpx;
  403. height: 2rpx;
  404. background: #FF6600;
  405. }
  406. .title {
  407. font-size: 28rpx;
  408. font-family: PingFang SC;
  409. font-weight: bold;
  410. color: #FF6600;
  411. }
  412. }
  413. .days {
  414. // background-color: red;
  415. padding: 0 65rpx;
  416. .day-item {
  417. // height: 230rpx;
  418. border-bottom: 1px solid #f3f4f6;
  419. background-color: #fff;
  420. font-size: 24rpx;
  421. font-family: PingFang SC;
  422. font-weight: bold;
  423. color: #333333;
  424. display: flex;
  425. flex-direction: column;
  426. justify-content: space-around;
  427. padding: 20rpx 0;
  428. .item {
  429. display: flex;
  430. justify-content: space-between;
  431. text {
  432. display: inline-block;
  433. margin-left: 10rpx;
  434. }
  435. }
  436. }
  437. }
  438. .list {
  439. padding: 10rpx 65rpx 0;
  440. .list-item {
  441. // padding: 90rpx 118rpx 0 118rpx;
  442. margin-bottom: 15rpx;
  443. .item-tpl {
  444. background-color: #f7f6fb;
  445. text-align: center;
  446. // background-color: #FFFFFF;
  447. padding: 20rpx 0;
  448. width: 48%;
  449. .name {
  450. color: #666666;
  451. font-size: 24rpx;
  452. }
  453. .num {
  454. font-size: 32rpx;
  455. color: #333333;
  456. font-weight: bold;
  457. padding-top: 10rpx;
  458. }
  459. }
  460. }
  461. .tols {
  462. width: 100% !important;
  463. }
  464. }
  465. .info-cell {
  466. width: 33.33%;
  467. text-align: center;
  468. flex-shrink: 0;
  469. .cell {
  470. font-size: 30rpx;
  471. font-weight: bold;
  472. color: #333333;
  473. }
  474. .cell-title {
  475. font-size: 26rpx;
  476. font-weight: 500;
  477. color:#333333;
  478. padding-top: 20rpx;
  479. }
  480. }
  481. </style>