myCalculation.vue 11 KB

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