myCalculation.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <view class="container">
  3. <view class="list-cell" v-if="list.length > 0" v-for="(ls,index) in list" :key='index'>
  4. <view class="cell-title flex">
  5. <view class="cellTpl flex_item">
  6. <image :src="ls.machine.logo"></image>
  7. <view class="title">{{ls.machine.name}}</view>
  8. </view>
  9. <view class="status">{{ls.status == 0 ? '准备中' : ls.status == 1 ? '挖矿中' : '已到期'}}</view>
  10. </view>
  11. <view class="cell-tip">{{ls.machine.first_step_time + ls.machine.second_step_time + ls.machine.third_step_time}}天矿机</view>
  12. <view class="flex cell-tpl">
  13. <view class="tpl">
  14. <view class="">单价(T)</view>
  15. <view class="">{{ls.machine.cost_money * 1}} {{ls.machine.cost_money_type}}</view>
  16. </view>
  17. <view class="tpl">
  18. <view class="">有效算力</view>
  19. <view class="">{{ls.num * 1}}T</view>
  20. </view>
  21. <view class="tpl">
  22. <view class="">合约周期</view>
  23. <view class="">{{ls.machine.first_step_time + ls.machine.second_step_time + ls.machine.third_step_time}}天</view>
  24. </view>
  25. </view>
  26. <view class="cell-info flex">
  27. <view class="tip">到期时间:{{ls.mining_end_time}}</view>
  28. </view>
  29. <view class="cell-info flex">
  30. <view class="tip">购买时间:{{ls._pay_time}}</view>
  31. </view>
  32. <view class="cell-info flex" v-if="ls.status == 0">
  33. <view class="tip">倒计时:<uni-countdown
  34. color="#FFF"
  35. background-color="#BAC1EF"
  36. :day="ls.stopTimeD"
  37. :hour="ls.stopTimeH"
  38. :minute="ls.stopTimeM"
  39. :second="ls.stopTimeS"
  40. :index="index"
  41. @timeover="isTime"
  42. ></uni-countdown></view>
  43. </view>
  44. <!-- <view class="cell-info flex">
  45. <view class="tip">正式挖矿时间:{{ls.mining_start_time}}</view>
  46. </view> -->
  47. <!-- <view class="list-tip">
  48. <rich-text :nodes="ls.machine.detail"></rich-text>
  49. </view> -->
  50. </view>
  51. <view class="empty-box" v-show="list.length === 0"><empty></empty></view>
  52. </view>
  53. </template>
  54. <script>
  55. import { mymining } from '@/api/calculation.js';
  56. import empty from '@/components/empty';
  57. import { timeComputed } from '@/utils/rocessor.js';
  58. import uniCountdown from '@/components/uni-countdown/uni-countdown.vue';
  59. export default {
  60. components: {
  61. empty,uniCountdown
  62. },
  63. data() {
  64. return {
  65. list:'',
  66. };
  67. },
  68. onLoad(option){
  69. this.loadData();
  70. },
  71. onShow() {
  72. },
  73. //下拉刷新
  74. onPullDownRefresh() {
  75. this.loadData();
  76. },
  77. methods: {
  78. async loadData() {
  79. let obj = this;
  80. mymining({
  81. page:1,
  82. limit:1000,
  83. }).then(({ data }) => {
  84. console.log(data,"基础数据")
  85. obj.list = data.data;
  86. obj.list = data.data.map((e,ind) => {
  87. let ar = e;
  88. console.log(e,"饿");
  89. // 判断是否为进行中的活动
  90. if (ar.status === 0) {
  91. // 计算倒计时时间
  92. obj.timeComputed(ar.mining_start_time * 1000, ar);
  93. console.log(ar.stopTimeD)
  94. } else {
  95. console.log('++++++++++')
  96. // 获取距离开始还需要多少时间
  97. if( ar.time){
  98. let arTime = ar.time.split(':');
  99. let h = arTime[0];
  100. let m = arTime[1];
  101. let time = new Date();
  102. // 设置时间
  103. time.setHours(h, m, 0);
  104. // 计算倒计时时间
  105. obj.timeComputed(time.getTime(), ar);}
  106. }
  107. return e;
  108. })
  109. });
  110. },
  111. // 计算倒计时时间
  112. timeComputed(da, ar) {
  113. let obj = this;
  114. // 计算时间,保存需要多少时间到期
  115. let stopTime = timeComputed(da);
  116. console.log(stopTime);
  117. ar.stopTimeD = stopTime.day;
  118. ar.stopTimeH = stopTime.hours;
  119. ar.stopTimeM = stopTime.minutes;
  120. ar.stopTimeS = stopTime.seconds;
  121. },
  122. isTime(index) {
  123. this.list[index].status = 1
  124. }
  125. }
  126. };
  127. </script>
  128. <style lang="scss">
  129. page {
  130. min-height: 100%;
  131. background-color: #ffffff;
  132. .container {
  133. width: 100%;
  134. }
  135. }
  136. .list-cell{
  137. padding: 40rpx 40rpx;
  138. .cell-title{
  139. padding: 29rpx 38rpx;
  140. font-size: 30rpx;
  141. font-weight: bold;
  142. color: #333333;
  143. .cellTpl{
  144. image{
  145. width: 40rpx;
  146. height: 40rpx;
  147. margin-right: 15rpx;
  148. }
  149. }
  150. .status{
  151. color: #E51C23;
  152. }
  153. }
  154. .cell-tip{
  155. padding: 0rpx 38rpx;
  156. font-size: 24rpx;
  157. font-weight: bold;
  158. color: #0EC1A1;
  159. }
  160. .cell-tpl{
  161. padding: 40rpx 31rpx;
  162. font-size: 24rpx;
  163. font-weight: bold;
  164. color: #333333;
  165. line-height: 40rpx;
  166. }
  167. .cell-info{
  168. margin-bottom: 25rpx;
  169. .tip{
  170. font-size: 30rpx;
  171. font-weight: bold;
  172. color: #5771DF;
  173. }
  174. .zhiya-btn{
  175. background-color: #5771DF;
  176. padding: 12rpx 22rpx;
  177. font-size: 24rpx;
  178. border-radius: 50rpx;
  179. color: #FFFFFF;
  180. }
  181. }
  182. .list-tip{
  183. word-wrap:break-word;
  184. background-color: #BAC1EF !important;
  185. font-size: 24rpx;
  186. font-weight: 500;
  187. color: #333333;
  188. padding: 36rpx 32rpx;
  189. margin-top: 15rpx;
  190. border-bottom-left-radius:15rpx ;
  191. border-bottom-right-radius:15rpx ;
  192. }
  193. }
  194. .empty-box{
  195. margin-top: 100rpx;
  196. width: 100%;
  197. height: 500rpx;
  198. }
  199. </style>