myCalculation.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. <template>
  2. <view class="container">
  3. <view class="empty-box" v-show="list.length === 0">
  4. <empty></empty>
  5. </view>
  6. <view class="item-wrapper" v-if="list.length > 0" v-for="(ls,index) in list" :key='index'>
  7. <view class="item">
  8. <view class="item-name">设备名称</view>
  9. <view class="item-val">{{ls.machine.name}}</view>
  10. </view>
  11. <view class="item">
  12. <view class="item-name">状态</view>
  13. <view class="item-val blue">{{ls.status == 0 ? '准备中' : ls.status == 1 ? '挖矿中' : '已到期'}}</view>
  14. </view>
  15. <!-- <view class="item">
  16. <view class="item-name">合约期限</view>
  17. <view class="item-val blue">{{ls.machine.first_step_time + ls.machine.second_step_time }}天 + {{ ls.machine.third_step_time}}天</view>
  18. </view> -->
  19. <view class="item">
  20. <view class="item-name">算力</view>
  21. <view class="item-val blue">{{+ls.num}} {{ls.get_money_type==='BZZ'?'节点':'台'}}</view>
  22. </view>
  23. <view class="item">
  24. <view class="item-name">管理费</view>
  25. <view class="item-val">{{ls.user_service_ratio}}%</view>
  26. </view>
  27. <!-- <view class="item">
  28. <view class="item-name">单价</view>
  29. <view class="item-val">{{ls.machine.cost_money * 1}} {{ls.machine.cost_money_type}}/{{ls.get_money_type==='BZZ'?'节点':'T'}}</view>
  30. </view> -->
  31. <view class="item">
  32. <view class="item-name">购买份数</view>
  33. <view class="item-val">{{+ls.num}}</view>
  34. </view>
  35. <view class="item">
  36. <view class="item-name">电费到期时间</view>
  37. <view class="item-val">{{ls._stop_time}}</view>
  38. </view>
  39. <view class="item">
  40. <view class="item-name">30天电费</view>
  41. <view class="item-val">{{ls.electric_price*30}}USDT</view>
  42. </view>
  43. <view class="item">
  44. <view class="item-name">购买时间</view>
  45. <view class="item-val">{{ls._pay_time}}</view>
  46. </view>
  47. <!-- <view class="dianfei" @click="getDf(ls.electric_price*30)">
  48. 支付电费
  49. </view> -->
  50. </view>
  51. <uni-popup ref="popup" type="center">
  52. <view class="popup">
  53. <view class="popup-dox">
  54. <image class="popup-logo" src="../../static/index/dianfei.png"></image>
  55. <!-- <view class="pop-title">已为您定制专属客服</view> -->
  56. <view class="pop-title">需支付<text>{{(dianfei*1).toFixed(3)}}USDT</text></view>
  57. <view class="pop-tip" @click="buy()">
  58. 立即支付
  59. </view>
  60. </view>
  61. </view>
  62. <view class="close_icon" @click="close">
  63. <image src="../../static/img/img49.png"></image>
  64. </view>
  65. </uni-popup>
  66. <view class="curtain" :class="{'ishiden':isHiden}" @touchmove.stop.prevent="moveHandle">
  67. <view class="psw-wrapper">
  68. <view class="psw-title">请输入支付密码</view>
  69. <input type="password" v-model="password" class="psw-ipt" />
  70. <view class="psw-btn">
  71. <text @click="cancel">取消</text>
  72. <text class="psw-qd" @click="pswQd">确定</text>
  73. </view>
  74. </view>
  75. </view>
  76. <!-- <view class="jg" v-if="list.length !== 0"></view> -->
  77. <uni-load-more :status="loadingType"></uni-load-more>
  78. <!-- <view class="list-cell" v-if="list.length > 0" v-for="(ls,index) in list" :key='index'>
  79. <view class="cell-title flex">
  80. <view class="cellTpl flex_item">
  81. <image :src="ls.machine.logo"></image>
  82. <view class="title">{{ls.machine.name}}</view>
  83. </view>
  84. <view class="status">{{ls.status == 0 ? '准备中' : ls.status == 1 ? '挖矿中' : '已到期'}}</view>
  85. </view>
  86. <view class="cell-tip">{{ls.machine.first_step_time + ls.machine.second_step_time + ls.machine.third_step_time}}天矿机</view>
  87. <view class="flex cell-tpl">
  88. <view class="tpl">
  89. <view class="" v-if="ls.get_money_type == 'BZZ'">单价(节点)</view>
  90. <view class="" v-else>单价(T)</view>
  91. <view class="">{{ls.machine.cost_money * 1}} {{ls.machine.cost_money_type}}</view>
  92. </view>
  93. <view class="tpl">
  94. <view class="">有效算力</view>
  95. <view class="" v-if="ls.get_money_type == 'BZZ'">{{ls.num * 1}}节点</view>
  96. <view class="" v-else>{{ls.num * 1}}T</view>
  97. </view>
  98. <view class="tpl">
  99. <view class="">合约周期</view>
  100. <view class="">{{ls.machine.first_step_time + ls.machine.second_step_time + ls.machine.third_step_time}}天</view>
  101. </view>
  102. </view>
  103. <view class="cell-info flex">
  104. <view class="tip">到期时间:{{ls.mining_end_time}}</view>
  105. </view>
  106. <view class="cell-info flex">
  107. <view class="tip">购买时间:{{ls._pay_time}}</view>
  108. </view>
  109. <view class="cell-info flex" v-if="ls.status == 0">
  110. <view class="tip">倒计时:<uni-countdown
  111. color="#FFF"
  112. background-color="#BAC1EF"
  113. :day="ls.stopTimeD"
  114. :hour="ls.stopTimeH"
  115. :minute="ls.stopTimeM"
  116. :second="ls.stopTimeS"
  117. :index="index"
  118. @timeover="isTime"
  119. ></uni-countdown></view>
  120. </view>
  121. </view> -->
  122. </view>
  123. </template>
  124. <script>
  125. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  126. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  127. import {
  128. miningDateils,
  129. buyMining,
  130. mymining,
  131. charge
  132. } from '@/api/calculation.js';
  133. // import{} from '@/api/calculation.js'
  134. import empty from '@/components/empty';
  135. import {
  136. timeComputed
  137. } from '@/utils/rocessor.js';
  138. import uniCountdown from '@/components/uni-countdown/uni-countdown.vue';
  139. export default {
  140. components: {
  141. empty,
  142. uniCountdown,
  143. uniPopup
  144. },
  145. data() {
  146. return {
  147. id: '',
  148. type: '',
  149. num: 1,
  150. step: 0,
  151. password: '',
  152. price: '',
  153. list: {
  154. },
  155. checked: false,
  156. isHiden: true,
  157. dianfei: '',
  158. isShow: false,
  159. list: [],
  160. page: 1,
  161. limit: 10,
  162. loadingType: 'more',
  163. };
  164. },
  165. onLoad(option) {
  166. this.loadData();
  167. },
  168. onShow() {
  169. },
  170. onReachBottom() {
  171. this.loadData();
  172. },
  173. methods: {
  174. cancel() {
  175. this.password = ''
  176. this.isHiden = true
  177. },
  178. pswQd() {
  179. let obj = this;
  180. if (obj.password === '') {
  181. obj.$api.msg('请输入交易密码!');
  182. return
  183. }
  184. obj.isHiden = true
  185. console.log(obj.id ,'131',obj.num,'12',obj.password);
  186. charge({
  187. trade_psw: obj.password,
  188. num:obj.dianfei
  189. }
  190. )
  191. .then(data => {
  192. obj.$api.msg(data.msg);
  193. obj.password = '';
  194. obj.num = 1;
  195. setTimeout(function() {
  196. uni.navigateTo({
  197. url: '/pages/calculation/myCalculation'
  198. });
  199. }, 1500);
  200. })
  201. .catch(e => {
  202. obj.password = '';
  203. obj.num = 1;
  204. if (e.msg == '交易密码错误') {
  205. return;
  206. }
  207. console.log(e);
  208. var reg = new RegExp('购买矿机所需的');
  209. if (e.msg.match(reg) == -1) {} else {
  210. setTimeout(function() {
  211. uni.navigateTo({
  212. url: '/pages/finance/recharge'
  213. });
  214. }, 1500);
  215. }
  216. });
  217. },
  218. buy() {
  219. this.$refs.popup.close();
  220. this.isHiden = false
  221. },
  222. getDf(dianfei) {
  223. this.$refs.popup.open();
  224. this.dianfei = dianfei
  225. // this.id = id
  226. },
  227. close() {
  228. this.$refs.popup.close();
  229. },
  230. async loadData() {
  231. let obj = this;
  232. if (obj.loadingType == 'loading' || obj.loadingType == 'noMore') {
  233. return
  234. }
  235. obj.loadingType = 'loading'
  236. mymining({
  237. page: obj.page,
  238. limit: obj.limit,
  239. }).then(({
  240. data
  241. }) => {
  242. console.log(data, "基础数据")
  243. // obj.list = data.data;
  244. obj.list = obj.list.concat(data.data)
  245. if (data.data.length == obj.limit) {
  246. obj.page++
  247. obj.loadingType = 'more'
  248. } else {
  249. obj.loadingType = 'noMore'
  250. }
  251. // obj.list = data.data.map((e,ind) => {
  252. // let ar = e;
  253. // console.log(e,"饿");
  254. // // 判断是否为进行中的活动
  255. // if (ar.status === 0) {
  256. // // 计算倒计时时间
  257. // obj.timeComputed(ar.mining_start_time * 1000, ar);
  258. // console.log(ar.stopTimeD)
  259. // } else {
  260. // console.log('++++++++++')
  261. // // 获取距离开始还需要多少时间
  262. // if( ar.time){
  263. // let arTime = ar.time.split(':');
  264. // let h = arTime[0];
  265. // let m = arTime[1];
  266. // let time = new Date();
  267. // // 设置时间
  268. // time.setHours(h, m, 0);
  269. // // 计算倒计时时间
  270. // obj.timeComputed(time.getTime(), ar);}
  271. // }
  272. // return e;
  273. // })
  274. });
  275. },
  276. // 计算倒计时时间
  277. timeComputed(da, ar) {
  278. let obj = this;
  279. // 计算时间,保存需要多少时间到期
  280. let stopTime = timeComputed(da);
  281. console.log(stopTime);
  282. ar.stopTimeD = stopTime.day;
  283. ar.stopTimeH = stopTime.hours;
  284. ar.stopTimeM = stopTime.minutes;
  285. ar.stopTimeS = stopTime.seconds;
  286. },
  287. isTime(index) {
  288. this.list[index].status = 1
  289. }
  290. }
  291. };
  292. </script>
  293. <style lang="scss">
  294. page {
  295. min-height: 100%;
  296. background-color: #ffffff;
  297. .container {
  298. width: 100%;
  299. }
  300. }
  301. .close_icon {
  302. image {
  303. width: 100%;
  304. height: 100%;
  305. }
  306. }
  307. .popup {
  308. width: 620rpx;
  309. height: 700rpx;
  310. background-color: #FFFFFF;
  311. border-radius: 15rpx;
  312. text-align: center;
  313. .popup-dox {
  314. // position: relative;
  315. // top: -60rpx;
  316. .popup-logo {
  317. margin-top: 80rpx;
  318. width: 449rpx;
  319. height: 329rpx;
  320. }
  321. .pop-title {
  322. font-size: 43rpx;
  323. font-family: Source Han Sans CN;
  324. font-weight: 500;
  325. color: #333333;
  326. padding: 40rpx 0rpx;
  327. text {
  328. font-size: 59rpx;
  329. font-weight: 500;
  330. color: #FF6600;
  331. }
  332. }
  333. .pop-tip {
  334. font-size: 35rpx;
  335. font-weight: 500;
  336. color: #FFFFFF;
  337. width: 434rpx;
  338. line-height: 78rpx;
  339. text-align: center;
  340. height: 78rpx;
  341. background: #141E47;
  342. border-radius: 39rpx;
  343. margin: 0 auto;
  344. }
  345. }
  346. }
  347. .list-cell {
  348. padding: 40rpx 40rpx;
  349. .cell-title {
  350. padding: 29rpx 38rpx;
  351. font-size: 30rpx;
  352. font-weight: bold;
  353. color: #333333;
  354. .cellTpl {
  355. image {
  356. width: 40rpx;
  357. height: 40rpx;
  358. margin-right: 15rpx;
  359. }
  360. }
  361. .status {
  362. color: #E51C23;
  363. }
  364. }
  365. .cell-tip {
  366. padding: 0rpx 38rpx;
  367. font-size: 24rpx;
  368. font-weight: bold;
  369. color: #0EC1A1;
  370. }
  371. .cell-tpl {
  372. padding: 40rpx 31rpx;
  373. font-size: 24rpx;
  374. font-weight: bold;
  375. color: #333333;
  376. line-height: 40rpx;
  377. }
  378. .cell-info {
  379. margin-bottom: 25rpx;
  380. .tip {
  381. font-size: 30rpx;
  382. font-weight: bold;
  383. color: #5771DF;
  384. }
  385. .zhiya-btn {
  386. background-color: #5771DF;
  387. padding: 12rpx 22rpx;
  388. font-size: 24rpx;
  389. border-radius: 50rpx;
  390. color: #FFFFFF;
  391. }
  392. }
  393. .list-tip {
  394. word-wrap: break-word;
  395. background-color: #BAC1EF !important;
  396. font-size: 24rpx;
  397. font-weight: 500;
  398. color: #333333;
  399. padding: 36rpx 32rpx;
  400. margin-top: 15rpx;
  401. border-bottom-left-radius: 15rpx;
  402. border-bottom-right-radius: 15rpx;
  403. }
  404. }
  405. .empty-box {
  406. margin-top: 100rpx;
  407. width: 100%;
  408. height: 500rpx;
  409. }
  410. .dianfei {
  411. position: absolute;
  412. right: 35rpx;
  413. bottom: 15rpx;
  414. font-size: 26rpx;
  415. font-weight: 500;
  416. color: #FFFFFF;
  417. line-height: 50rpx;
  418. width: 155rpx;
  419. height: 51rpx;
  420. background: #141E47;
  421. border-radius: 26rpx;
  422. text-align: center;
  423. }
  424. .item-wrapper {
  425. position: relative;
  426. padding: 0 35rpx 70rpx;
  427. width: 690rpx;
  428. height: 777rpx;
  429. background: #F7F6FB;
  430. border: 1rpx solid #071228;
  431. border-radius: 20rpx;
  432. margin: 20rpx auto;
  433. font-size: 28rpx;
  434. font-family: PingFang SC;
  435. font-weight: 500;
  436. color: #333333;
  437. line-height: 1;
  438. display: flex;
  439. flex-direction: column;
  440. justify-content: space-around;
  441. .item {
  442. display: flex;
  443. justify-content: space-between;
  444. align-items: baseline;
  445. .item-val {
  446. font-weight: bold;
  447. }
  448. }
  449. .blue {
  450. color: #FF6600;
  451. }
  452. }
  453. .jg {
  454. height: 20rpx;
  455. }
  456. .curtain {
  457. position: fixed;
  458. width: 100%;
  459. height: 100%;
  460. top: 0;
  461. background-color: rgba($color: #000000, $alpha: 0.2);
  462. .psw-wrapper {
  463. position: fixed;
  464. top: 50%;
  465. left: 50%;
  466. transform: translate(-50%, -100%);
  467. width: 548.6rpx;
  468. height: 344.4rpx;
  469. background-color: #FFFFFF;
  470. border-radius: 15rpx 15rpx;
  471. .psw-title {
  472. width: 100%;
  473. font-size: 35rpx;
  474. padding: 43rpx 0 49rpx;
  475. text-align: center;
  476. font-weight: 800;
  477. }
  478. .psw-ipt {
  479. display: block;
  480. background-color: #dce3ed;
  481. height: 90rpx;
  482. width: 464rpx;
  483. padding-left: 30rpx;
  484. margin: 0 auto;
  485. font-size: 80rpx;
  486. }
  487. .psw-btn text {
  488. display: inline-block;
  489. text-align: center;
  490. width: 50%;
  491. padding-top: 29rpx;
  492. font-size: 35rpx;
  493. }
  494. .psw-qd {
  495. color: #5771DF;
  496. }
  497. }
  498. }
  499. .ishiden {
  500. display: none;
  501. }
  502. </style>