|
@@ -31,7 +31,7 @@
|
|
|
$t('blf.computing')
|
|
$t('blf.computing')
|
|
|
}}</van-button>
|
|
}}</van-button>
|
|
|
<van-button type="primary" class="getted" v-else block
|
|
<van-button type="primary" class="getted" v-else block
|
|
|
- >{{ $t('blf.buying') }} +{{ orderInfo.profit }}</van-button
|
|
|
|
|
|
|
+ >{{ $t('blf.buying') }} +{{ profit }}</van-button
|
|
|
>
|
|
>
|
|
|
</template>
|
|
</template>
|
|
|
<template v-if="orderInfo.productId !== productInfo.id">
|
|
<template v-if="orderInfo.productId !== productInfo.id">
|
|
@@ -62,8 +62,9 @@ import '@/styles/animate.css'
|
|
|
import http from '@/plugins/http'
|
|
import http from '@/plugins/http'
|
|
|
import { useRouter } from 'vue-router'
|
|
import { useRouter } from 'vue-router'
|
|
|
import { onIonViewWillEnter } from '@ionic/vue'
|
|
import { onIonViewWillEnter } from '@ionic/vue'
|
|
|
-import { differenceInMilliseconds } from 'date-fns'
|
|
|
|
|
|
|
+import { differenceInMilliseconds, differenceInSeconds } from 'date-fns'
|
|
|
import { useUserStore } from '@/stores/user'
|
|
import { useUserStore } from '@/stores/user'
|
|
|
|
|
+import { accDiv, accMul } from '@/plugins/calc'
|
|
|
|
|
|
|
|
const userStore = useUserStore()
|
|
const userStore = useUserStore()
|
|
|
const user = computed(() => {
|
|
const user = computed(() => {
|
|
@@ -107,7 +108,6 @@ function onFinish() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const productInfo = ref({})
|
|
const productInfo = ref({})
|
|
|
-const orderInfo = ref({})
|
|
|
|
|
const time = ref(0)
|
|
const time = ref(0)
|
|
|
function init() {
|
|
function init() {
|
|
|
http.http
|
|
http.http
|
|
@@ -128,6 +128,27 @@ function init() {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+const profit = ref(0)
|
|
|
|
|
+let time1 = null
|
|
|
|
|
+function getProfit() {
|
|
|
|
|
+ if (time1) {
|
|
|
|
|
+ clearTimeout(time1)
|
|
|
|
|
+ }
|
|
|
|
|
+ if (orderInfo.value.profit) {
|
|
|
|
|
+ let _se = differenceInSeconds(new Date(orderInfo.value.redeemTime), new Date(orderInfo.value.createdAt))
|
|
|
|
|
+ let _se2 = differenceInSeconds(new Date(), new Date(orderInfo.value.createdAt))
|
|
|
|
|
+ if (_se2 < _se) {
|
|
|
|
|
+ profit.value = accMul(accDiv(orderInfo.value.profit, _se), _se2).toFixed(2)
|
|
|
|
|
+ time1 = setTimeout(getProfit, 1000)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ profit.value = orderInfo.value.profit
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ profit.value = 0
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const orderInfo = ref({})
|
|
|
function getOrder() {
|
|
function getOrder() {
|
|
|
http.http
|
|
http.http
|
|
|
.post(
|
|
.post(
|
|
@@ -135,13 +156,15 @@ function getOrder() {
|
|
|
{
|
|
{
|
|
|
query: {
|
|
query: {
|
|
|
status: 'PENDING, STAKING'
|
|
status: 'PENDING, STAKING'
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ sort: 'id,desc'
|
|
|
},
|
|
},
|
|
|
{ body: 'json' }
|
|
{ body: 'json' }
|
|
|
)
|
|
)
|
|
|
.then(res => {
|
|
.then(res => {
|
|
|
if (!res.empty) {
|
|
if (!res.empty) {
|
|
|
orderInfo.value = res.content[0]
|
|
orderInfo.value = res.content[0]
|
|
|
|
|
+ getProfit()
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|