myCalculation.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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>
  41. <view class="jg" v-if="list.length !== 0"></view>
  42. <!-- <view class="list-cell" v-if="list.length > 0" v-for="(ls,index) in list" :key='index'>
  43. <view class="cell-title flex">
  44. <view class="cellTpl flex_item">
  45. <image :src="ls.machine.logo"></image>
  46. <view class="title">{{ls.machine.name}}</view>
  47. </view>
  48. <view class="status">{{ls.status == 0 ? '准备中' : ls.status == 1 ? '挖矿中' : '已到期'}}</view>
  49. </view>
  50. <view class="cell-tip">{{ls.machine.first_step_time + ls.machine.second_step_time + ls.machine.third_step_time}}天矿机</view>
  51. <view class="flex cell-tpl">
  52. <view class="tpl">
  53. <view class="" v-if="ls.get_money_type == 'BZZ'">单价(节点)</view>
  54. <view class="" v-else>单价(T)</view>
  55. <view class="">{{ls.machine.cost_money * 1}} {{ls.machine.cost_money_type}}</view>
  56. </view>
  57. <view class="tpl">
  58. <view class="">有效算力</view>
  59. <view class="" v-if="ls.get_money_type == 'BZZ'">{{ls.num * 1}}节点</view>
  60. <view class="" v-else>{{ls.num * 1}}T</view>
  61. </view>
  62. <view class="tpl">
  63. <view class="">合约周期</view>
  64. <view class="">{{ls.machine.first_step_time + ls.machine.second_step_time + ls.machine.third_step_time}}天</view>
  65. </view>
  66. </view>
  67. <view class="cell-info flex">
  68. <view class="tip">到期时间:{{ls.mining_end_time}}</view>
  69. </view>
  70. <view class="cell-info flex">
  71. <view class="tip">购买时间:{{ls._pay_time}}</view>
  72. </view>
  73. <view class="cell-info flex" v-if="ls.status == 0">
  74. <view class="tip">倒计时:<uni-countdown
  75. color="#FFF"
  76. background-color="#BAC1EF"
  77. :day="ls.stopTimeD"
  78. :hour="ls.stopTimeH"
  79. :minute="ls.stopTimeM"
  80. :second="ls.stopTimeS"
  81. :index="index"
  82. @timeover="isTime"
  83. ></uni-countdown></view>
  84. </view>
  85. </view> -->
  86. <view class="empty-box" v-show="list.length === 0"><u-empty></u-empty></view>
  87. </view>
  88. </template>
  89. <script>
  90. import { mymining } from '@/api/market.js';
  91. import { timeComputed } from '@/utils/rocessor.js';
  92. import uniCountdown from '@/components/uni-countdown/uni-countdown.vue';
  93. export default {
  94. components: {
  95. uniCountdown
  96. },
  97. data() {
  98. return {
  99. list:'',
  100. };
  101. },
  102. onLoad(option){
  103. this.loadData();
  104. },
  105. onShow() {
  106. },
  107. //下拉刷新
  108. onPullDownRefresh() {
  109. this.loadData();
  110. },
  111. methods: {
  112. async loadData() {
  113. let obj = this;
  114. uni.showLoading({
  115. title:"加载中",
  116. })
  117. mymining({
  118. page:1,
  119. limit:1000,
  120. }).then(({ data }) => {
  121. console.log(data,"基础数据")
  122. obj.list = data.data;
  123. obj.list = data.data.map((e,ind) => {
  124. let ar = e;
  125. console.log(e,"饿");
  126. // 判断是否为进行中的活动
  127. if (ar.status === 0) {
  128. // 计算倒计时时间
  129. obj.timeComputed(ar.mining_start_time * 1000, ar);
  130. console.log(ar.stopTimeD)
  131. } else {
  132. console.log('++++++++++')
  133. // 获取距离开始还需要多少时间
  134. if( ar.time){
  135. let arTime = ar.time.split(':');
  136. let h = arTime[0];
  137. let m = arTime[1];
  138. let time = new Date();
  139. // 设置时间
  140. time.setHours(h, m, 0);
  141. // 计算倒计时时间
  142. obj.timeComputed(time.getTime(), ar);}
  143. }
  144. return e;
  145. })
  146. uni.hideLoading()
  147. });
  148. },
  149. // 计算倒计时时间
  150. timeComputed(da, ar) {
  151. let obj = this;
  152. // 计算时间,保存需要多少时间到期
  153. let stopTime = timeComputed(da);
  154. console.log(stopTime);
  155. ar.stopTimeD = stopTime.day;
  156. ar.stopTimeH = stopTime.hours;
  157. ar.stopTimeM = stopTime.minutes;
  158. ar.stopTimeS = stopTime.seconds;
  159. },
  160. isTime(index) {
  161. this.list[index].status = 1
  162. }
  163. }
  164. };
  165. </script>
  166. <style lang="scss">
  167. page {
  168. min-height: 100%;
  169. background-color: #ffffff;
  170. .container {
  171. width: 100%;
  172. }
  173. }
  174. .list-cell{
  175. padding: 40rpx 40rpx;
  176. .cell-title{
  177. padding: 29rpx 38rpx;
  178. font-size: 30rpx;
  179. font-weight: bold;
  180. color: #333333;
  181. .cellTpl{
  182. image{
  183. width: 40rpx;
  184. height: 40rpx;
  185. margin-right: 15rpx;
  186. }
  187. }
  188. .status{
  189. color: #E51C23;
  190. }
  191. }
  192. .cell-tip{
  193. padding: 0rpx 38rpx;
  194. font-size: 24rpx;
  195. font-weight: bold;
  196. color: #0EC1A1;
  197. }
  198. .cell-tpl{
  199. padding: 40rpx 31rpx;
  200. font-size: 24rpx;
  201. font-weight: bold;
  202. color: #333333;
  203. line-height: 40rpx;
  204. }
  205. .cell-info{
  206. margin-bottom: 25rpx;
  207. .tip{
  208. font-size: 30rpx;
  209. font-weight: bold;
  210. color: #44969d;
  211. }
  212. .zhiya-btn{
  213. background-color: #44969d;
  214. padding: 12rpx 22rpx;
  215. font-size: 24rpx;
  216. border-radius: 50rpx;
  217. color: #FFFFFF;
  218. }
  219. }
  220. .list-tip{
  221. word-wrap:break-word;
  222. background-color: #BAC1EF !important;
  223. font-size: 24rpx;
  224. font-weight: 500;
  225. color: #333333;
  226. padding: 36rpx 32rpx;
  227. margin-top: 15rpx;
  228. border-bottom-left-radius:15rpx ;
  229. border-bottom-right-radius:15rpx ;
  230. }
  231. }
  232. .empty-box{
  233. margin-top: 100rpx;
  234. width: 100%;
  235. height: 500rpx;
  236. }
  237. .item-wrapper {
  238. padding: 0 35rpx;
  239. width: 690rpx;
  240. height: 748rpx;
  241. background: #F7F6FB;
  242. border: 1rpx solid #44969d;
  243. border-radius: 20rpx;
  244. margin: 20rpx auto;
  245. font-size: 28rpx;
  246. font-family: PingFang SC;
  247. font-weight: 500;
  248. color: #333333;
  249. line-height: 1;
  250. display: flex;
  251. flex-direction: column;
  252. justify-content: space-around;
  253. .item {
  254. display: flex;
  255. justify-content: space-between;
  256. .item-val {
  257. font-weight: bold;
  258. }
  259. }
  260. .blue {
  261. color: #44969d;
  262. }
  263. }
  264. .jg {
  265. height: 20rpx;
  266. }
  267. </style>