myCalculation.vue 11 KB

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