myCalculation.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. <template>
  2. <view class="container">
  3. <view class="item-wrapper" v-if="list.length > 0" v-for="(ls,index) in list" :key='index'>
  4. <view class="item">
  5. <view class="item-name">设备名称</view>
  6. <view class="item-val">{{ls.machine.name}}</view>
  7. </view>
  8. <view class="item">
  9. <view class="item-name">状态</view>
  10. <view class="item-val blue">{{ls.status == 0 ? '准备中' : ls.status == 1 ? '挖矿中' : ls.status == 2 ? '已到期' : ls.status == 3 ? '质押中' : '已回收'}}</view>
  11. </view>
  12. <view class="item">
  13. <view class="item-name">合约期限</view>
  14. <view class="item-val blue">{{ls.machine.first_step_time + ls.machine.second_step_time }}天 + {{ ls.machine.third_step_time}}天</view>
  15. </view>
  16. <view class="item">
  17. <view class="item-name">算力</view>
  18. <view class="item-val blue">{{+ls.num}} {{ls.get_money_type==='BZZ'?'节点':'T'}}</view>
  19. </view>
  20. <view class="item">
  21. <view class="item-name">管理费</view>
  22. <view class="item-val">{{ls.user_service_ratio}}%</view>
  23. </view>
  24. <view class="item">
  25. <view class="item-name">单价</view>
  26. <view class="item-val">{{ls.machine.cost_money * 1}} {{ls.machine.cost_money_type}}/{{ls.get_money_type==='BZZ'?'节点':'T'}}</view>
  27. </view>
  28. <view class="item">
  29. <view class="item-name">购买份数</view>
  30. <view class="item-val">{{+ls.num}}</view>
  31. </view>
  32. <view class="item">
  33. <view class="item-name">总价</view>
  34. <view class="item-val" v-if="ls._cost_money != '0USDT'">{{ls._cost_money}}</view>
  35. <view class="item-val" v-else>开通合伙人时赠送</view>
  36. </view>
  37. <view class="item">
  38. <view class="item-name">购买时间</view>
  39. <view class="item-val">{{ls._pay_time}}</view>
  40. </view>
  41. <view class="item">
  42. <view class="item-name">到期期限</view>
  43. <view class="item-val">{{ls.mining_end_time}}</view>
  44. </view>
  45. <view class="item" v-if="ls.status == 3">
  46. <view class="item-name">赎回最迟期限</view>
  47. <view class="item-val">{{ls.shuhuitime}}</view>
  48. </view>
  49. <view class="item" v-if="ls.redeem_money*1 > 0 && ls.status == 3">
  50. <view class="item-name">赎回价格</view>
  51. <view class="item-val">{{ls.redeem_money*1*ls.num}}{{ls.redeem_money_type}}</view>
  52. </view>
  53. <view class="item" v-if="ls.mortgage_money*1 >0 && ls.status != 3">
  54. <view class="item-name"></view>
  55. <view class="btn" @click="buy(ls,1)">
  56. 质押
  57. </view>
  58. </view>
  59. <view class="item" v-if=" ls.status == 3">
  60. <view class="item-name"></view>
  61. <view class="btn" @click="shu(ls,2)">
  62. 赎回
  63. </view>
  64. </view>
  65. </view>
  66. <view class="empty-box" v-show="list.length === 0"><u-empty></u-empty></view>
  67. <u-popup v-model="show1" mode="center" width="548rpx" border-radius="14">
  68. <view class="psw-wrapper">
  69. <view class="psw-title">请输入支付密码</view>
  70. <input type="password" v-model="password" class="psw-ipt" />
  71. <view class="psw-btn">
  72. <text @click="cancel">取消</text>
  73. <text class="psw-qd" @click="pswQd">确定</text>
  74. </view>
  75. </view>
  76. </u-popup>
  77. <uni-popup ref="mation" type="center">
  78. <view class="popup">
  79. <view class="cancel flex" @click="close2"><view class="tip"></view></view>
  80. <view class="list-boxs">
  81. <view class="textBox flex">
  82. <view class="font">质押金额:</view>
  83. <view class="number">{{ zhiya * 1*num }} {{ zhiyaType }}</view>
  84. </view>
  85. <view class="xian"></view>
  86. <view class="textBox flex">
  87. <view class="font">赎回金额:</view>
  88. <view class="number">{{ shuhui * 1 *num }} {{ shuhuiType }}</view>
  89. </view>
  90. <view class="xian"></view>
  91. <view class="tishi">质押之日起3个月内可以赎回,超过时间矿机将会背公司回收。您是否质押该框机</view>
  92. <view class="btnBox flex">
  93. <view class="btn1" @click="close()">取消</view>
  94. <view class="btn2" @click="mai()">确定</view>
  95. </view>
  96. </view>
  97. </view>
  98. </uni-popup>
  99. </view>
  100. </template>
  101. <script>
  102. import { mymining } from '@/api/market.js';
  103. import { timeComputed } from '@/utils/rocessor.js';
  104. import { redeem,mortgage } from '@/api/product.js';
  105. import uniCountdown from '@/components/uni-countdown/uni-countdown.vue';
  106. import { getTime } from '@/utils/rocessor.js'
  107. export default {
  108. components: {
  109. uniCountdown
  110. },
  111. data() {
  112. return {
  113. type: '',//判断是质押还是赎回
  114. show1: false,//是否显示密码框
  115. password:'',//交易密码
  116. list:'',
  117. num:'',//矿机数量
  118. id:'',//需要的id
  119. zhiya:'',//质押金额
  120. zhiyaType:'',//质押单位
  121. shuhui:'',//赎回金额
  122. shuhuiType:'',//赎回单位
  123. };
  124. },
  125. onLoad(option){
  126. this.loadData();
  127. },
  128. onShow() {
  129. },
  130. //下拉刷新
  131. onPullDownRefresh() {
  132. this.loadData();
  133. },
  134. methods: {
  135. async loadData() {
  136. let obj = this;
  137. uni.showLoading({
  138. title:"加载中",
  139. })
  140. mymining({
  141. page:1,
  142. limit:1000,
  143. }).then(({ data }) => {
  144. console.log(data,"基础数据")
  145. data.data.forEach(e => {
  146. if (e.mortgage_max_time != 0 && e.mortgage_max_time != null){
  147. e.shuhuitime = getTime(e.mortgage_max_time)
  148. }else {
  149. e.shuhuitime = '无期限'
  150. }
  151. })
  152. obj.list = data.data;
  153. obj.list = data.data.map((e,ind) => {
  154. let ar = e;
  155. console.log(e,"饿");
  156. // 判断是否为进行中的活动
  157. if (ar.status === 0) {
  158. // 计算倒计时时间
  159. obj.timeComputed(ar.mining_start_time * 1000, ar);
  160. console.log(ar.stopTimeD)
  161. } else {
  162. console.log('++++++++++')
  163. // 获取距离开始还需要多少时间
  164. if( ar.time){
  165. let arTime = ar.time.split(':');
  166. let h = arTime[0];
  167. let m = arTime[1];
  168. let time = new Date();
  169. // 设置时间
  170. time.setHours(h, m, 0);
  171. // 计算倒计时时间
  172. obj.timeComputed(time.getTime(), ar);}
  173. }
  174. return e;
  175. })
  176. uni.hideLoading()
  177. });
  178. },
  179. // 计算倒计时时间
  180. timeComputed(da, ar) {
  181. let obj = this;
  182. // 计算时间,保存需要多少时间到期
  183. let stopTime = timeComputed(da);
  184. console.log(stopTime);
  185. ar.stopTimeD = stopTime.day;
  186. ar.stopTimeH = stopTime.hours;
  187. ar.stopTimeM = stopTime.minutes;
  188. ar.stopTimeS = stopTime.seconds;
  189. },
  190. isTime(index) {
  191. this.list[index].status = 1
  192. },
  193. buy(data,type){
  194. this.type = type
  195. this.id = data.id;
  196. this.num = data.num*1;
  197. this.zhiya = data.mortgage_money
  198. this.zhiyaType = data.mortgage_money_type
  199. this.shuhui = data.redeem_money
  200. this.shuhuiType = data.redeem_money_type
  201. this.$refs.mation.open();
  202. },
  203. close(){
  204. this.type = '';
  205. this.id = "";
  206. this.zhiya = "";
  207. this.zhiyaType = "";
  208. this.shuhui = "";
  209. this.shuhuiType = "";
  210. this.$refs.mation.close();
  211. },
  212. mai(){
  213. this.$refs.mation.close();
  214. this.show1 = true
  215. },
  216. shu(data,type){
  217. this.type = type
  218. this.id = data.id;
  219. this.show1 = true
  220. },
  221. cancel() {
  222. this.type = '';
  223. this.password = '';
  224. this.id = "";
  225. this.zhiya = "";
  226. this.zhiyaType = "";
  227. this.shuhui = "";
  228. this.shuhuiType = "";
  229. this.show1 = false;
  230. },
  231. pswQd() {
  232. if (this.type == 1){
  233. mortgage({trade_psw: this.password},this.id).then(e => {
  234. this.password = '';
  235. this.id = "";
  236. this.zhiya = "";
  237. this.zhiyaType = "";
  238. this.shuhui = "";
  239. this.shuhuiType = "";
  240. this.show1 = false;
  241. this.$api.msg('质押成功');
  242. }).catch(e =>{
  243. console.log(e)
  244. })
  245. }else {
  246. redeem({trade_psw: this.password},this.id).then(e => {
  247. this.password = '';
  248. this.id = "";
  249. this.zhiya = "";
  250. this.zhiyaType = "";
  251. this.shuhui = "";
  252. this.shuhuiType = "";
  253. this.show1 = false;
  254. this.$api.msg('赎回成功');
  255. }).catch(e =>{
  256. console.log(e)
  257. })
  258. }
  259. }
  260. }
  261. };
  262. </script>
  263. <style lang="scss">
  264. page {
  265. min-height: 100%;
  266. background-color: #ffffff;
  267. .container {
  268. width: 100%;
  269. padding-bottom: 20rpx;
  270. }
  271. }
  272. .list-cell{
  273. padding: 40rpx 40rpx;
  274. .cell-title{
  275. padding: 29rpx 38rpx;
  276. font-size: 30rpx;
  277. font-weight: bold;
  278. color: #333333;
  279. .cellTpl{
  280. image{
  281. width: 40rpx;
  282. height: 40rpx;
  283. margin-right: 15rpx;
  284. }
  285. }
  286. .status{
  287. color: #E51C23;
  288. }
  289. }
  290. .cell-tip{
  291. padding: 0rpx 38rpx;
  292. font-size: 24rpx;
  293. font-weight: bold;
  294. color: #0EC1A1;
  295. }
  296. .cell-tpl{
  297. padding: 40rpx 31rpx;
  298. font-size: 24rpx;
  299. font-weight: bold;
  300. color: #333333;
  301. line-height: 40rpx;
  302. }
  303. .cell-info{
  304. margin-bottom: 25rpx;
  305. .tip{
  306. font-size: 30rpx;
  307. font-weight: bold;
  308. color: #44969d;
  309. }
  310. .zhiya-btn{
  311. background-color: #44969d;
  312. padding: 12rpx 22rpx;
  313. font-size: 24rpx;
  314. border-radius: 50rpx;
  315. color: #FFFFFF;
  316. }
  317. }
  318. .list-tip{
  319. word-wrap:break-word;
  320. background-color: #BAC1EF !important;
  321. font-size: 24rpx;
  322. font-weight: 500;
  323. color: #333333;
  324. padding: 36rpx 32rpx;
  325. margin-top: 15rpx;
  326. border-bottom-left-radius:15rpx ;
  327. border-bottom-right-radius:15rpx ;
  328. }
  329. }
  330. .empty-box{
  331. margin-top: 100rpx;
  332. width: 100%;
  333. height: 500rpx;
  334. }
  335. .item-wrapper {
  336. position: relative;
  337. padding: 0 35rpx;
  338. width: 690rpx;
  339. height: 748rpx;
  340. background: #F7F6FB;
  341. border: 1rpx solid #44969d;
  342. border-radius: 20rpx;
  343. margin: 20rpx auto;
  344. font-size: 28rpx;
  345. font-family: PingFang SC;
  346. font-weight: 500;
  347. color: #333333;
  348. line-height: 1;
  349. display: flex;
  350. flex-direction: column;
  351. justify-content: space-around;
  352. .item {
  353. display: flex;
  354. justify-content: space-between;
  355. .item-val {
  356. font-weight: bold;
  357. }
  358. }
  359. .blue {
  360. color: #44969d;
  361. }
  362. }
  363. .jg {
  364. height: 20rpx;
  365. }
  366. .btn {
  367. background-color: #44969d;
  368. width: 150rpx;
  369. text-align: center;
  370. line-height: 60rpx;
  371. font-size: 26rpx;
  372. border-radius: 50rpx;
  373. color: #ffffff;
  374. }
  375. .popup {
  376. height: 618rpx;
  377. background: #ffffff;
  378. box-shadow: 3rpx 3rpx 6rpx 0rpx rgba(31, 31, 31, 0.17);
  379. border-radius: 40rpx;
  380. width: 700rpx;
  381. .cancel {
  382. text-align: center;
  383. width: 100%;
  384. line-height: 60rpx;
  385. position: relative;
  386. .tip {
  387. color: #000000;
  388. border-radius: 40rpx;
  389. width: 70rpx;
  390. height: 70rpx;
  391. position: absolute;
  392. top: 0;
  393. right: 0;
  394. background-color: #fff;
  395. }
  396. }
  397. .list-boxs {
  398. width: 90%;
  399. margin: 0 auto;
  400. margin-top: 100rpx;
  401. .tishi {
  402. padding-top: 50rpx;
  403. font-size: 30rpx;
  404. font-weight: bold;
  405. width: 100%;
  406. text-align: center;
  407. }
  408. .textBox {
  409. padding: 24rpx 18rpx;
  410. .font {
  411. font-size: 28rpx;
  412. font-family: PingFang SC;
  413. font-weight: bold;
  414. color: #4f4f4f;
  415. }
  416. .number {
  417. font-size: 28rpx;
  418. font-family: PingFang SC;
  419. font-weight: bold;
  420. color: #fb3a2f;
  421. }
  422. .text {
  423. text-indent: 2em;
  424. font-size: 28rpx;
  425. font-family: PingFang SC;
  426. font-weight: bold;
  427. color: #4f4f4f;
  428. }
  429. }
  430. .btnBox {
  431. padding: 60rpx 30rpx;
  432. .btn1 {
  433. width: 200rpx;
  434. padding: 20rpx;
  435. text-align: center;
  436. border:1px solid #44969d;
  437. border-radius: 40rpx;
  438. }
  439. .btn2 {
  440. width: 200rpx;
  441. padding: 20rpx;
  442. text-align: center;
  443. color: #fff;
  444. background: #44969d;
  445. border-radius: 40rpx;
  446. }
  447. }
  448. .xian {
  449. width: 100%;
  450. height: 1px;
  451. background: #e7dfe8;
  452. }
  453. }
  454. }
  455. .psw-wrapper {
  456. width: 548rpx;
  457. height: 344rpx;
  458. background-color: #ffffff;
  459. .psw-title {
  460. width: 100%;
  461. font-size: 35rpx;
  462. padding: 43rpx 0 49rpx;
  463. text-align: center;
  464. font-weight: 800;
  465. }
  466. .psw-ipt {
  467. display: block;
  468. background-color: #dce3ed;
  469. height: 90rpx;
  470. width: 464rpx;
  471. padding-left: 30rpx;
  472. margin: 0 auto;
  473. font-size: 80rpx;
  474. }
  475. .psw-btn text {
  476. display: inline-block;
  477. text-align: center;
  478. width: 50%;
  479. padding-top: 29rpx;
  480. font-size: 35rpx;
  481. }
  482. .psw-qd {
  483. color: #45969b;
  484. }
  485. }
  486. </style>