Browse Source

修改合约保证金只能输入2位小数点

master
liaoxinyu 11 months ago
parent
commit
035ee36bc5
  1. 20
      pages/base/mine.vue
  2. 21
      pages/exchange/open-position.vue

20
pages/base/mine.vue

@ -40,8 +40,10 @@
</text> </text>
</view> --> </view> -->
<view class=""> <view class="">
<view class="text_figure col-fff">{{filterMoney(account.total_assets_btc, true)}}</view> <!-- <view class="text_figure col-fff">{{filterMoney(account.total_assets_btc, true)}}</view>
<view style="color: #6FB58A;">{{ filterMoney(account.total_assets_usd, false) }} USDT</view> <view style="color: #6FB58A;">{{ filterMoney(account.total_assets_usd, false) }} USDT</view> -->
<view class="text_figure col-fff">{{price1(account.total_assets_btc, 8)}}</view>
<view style="color: #6FB58A;"> ${{ price1(account.total_assets_usd, 2) }}</view>
</view> </view>
<view class="m-t-ms p-b-ms w-max" style="display: flex;justify-content: space-between;"> <view class="m-t-ms p-b-ms w-max" style="display: flex;justify-content: space-between;">
@ -187,7 +189,8 @@
<text class="fn-20 d-block color-light m-t-xs"> <text class="fn-20 d-block color-light m-t-xs">
<!-- {{ filterMoney(account.funds_account_usd) }} --> <!-- {{ filterMoney(account.funds_account_usd) }} -->
<!-- {{ (account.funds_account_usd).toFixed(2) }} --> <!-- {{ (account.funds_account_usd).toFixed(2) }} -->
{{ omitTo(account.funds_account_usd,2) }} <!-- {{ omitTo(account.funds_account_usd,2) }} -->
{{ price1(account.funds_account_usd,2) }}
</text> </text>
<text class="fn-sm d-block color-gray-6 m-t-xs">{{ $t("base.d6") }}(USDT)</text> <text class="fn-sm d-block color-gray-6 m-t-xs">{{ $t("base.d6") }}(USDT)</text>
@ -298,7 +301,8 @@
</v-link> </v-link>
</view> </view>
<span class="fn-20 d-block color-light" style="margin-top: 100rpx;"> <span class="fn-20 d-block color-light" style="margin-top: 100rpx;">
{{ filterMoney(account.contract_account_usd)}}{{ account.symbol }} <!-- {{ filterMoney(account.contract_account_usd)}}{{ account.symbol }} -->
{{ price1(account.contract_account_usd,2)}}{{ account.symbol }}
</span> </span>
<view class="d-flex justify-between m-t-xs"> <view class="d-flex justify-between m-t-xs">
<v-link to="/pages/transfer/index" class="d-flex"> <v-link to="/pages/transfer/index" class="d-flex">
@ -420,6 +424,14 @@ export default {
} }
}, },
methods: { methods: {
price1(item,index){
if (item) {
let price = item.toFixed(index).toString();
let parts = price.split(".");
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return parts.join(".");
}
},
tohome(){ tohome(){
this._router.push("/pages/base/index"); this._router.push("/pages/base/index");
// this.tabChange('home') // this.tabChange('home')

21
pages/exchange/open-position.vue

@ -173,7 +173,7 @@
</v-input> --> </v-input> -->
<v-input <v-input
v-model="margin" v-model="margin"
@input="sliderActive=-1" @input="inputEnter"
:placeholder="$t('exchange.c5')" style="border: 1px solid #202020;"> :placeholder="$t('exchange.c5')" style="border: 1px solid #202020;">
<template #right> <template #right>
<view class="color-light fn-bold" style="margin-right: 10px;"> <view class="color-light fn-bold" style="margin-right: 10px;">
@ -183,6 +183,13 @@
</view> </view>
</template> </template>
</v-input> </v-input>
<!-- <view class="d-flex align-center" style="border: 1px solid #202020;padding: 0px 20rpx;height: 80rpx;">
<input v-model="margin" @input="inputEnter" class="flex-fill" />
<view class="color-light fn-bold" style="margin-left: 10px;">
{{ $t("contract.d8") }}
<i class="iconfont m-l-xs fn-sm">&#xe6e9;</i>
</view>
</view> -->
</view> </view>
<view class="m-b-xs"> <view class="m-b-xs">
<view class="m-t-xs"> <view class="m-t-xs">
@ -1074,7 +1081,7 @@ export default {
watch: { watch: {
maxNum(n) { maxNum(n) {
this.form.amount = Math.round((this.maxNum * this.sliderActive1) / 100); this.form.amount = Math.round((this.maxNum * this.sliderActive1) / 100);
this.margin = (this.form.amount / this.form.lever_rate).toFixed(5) this.margin = (this.form.amount / this.form.lever_rate).toFixed(2)
}, },
symbol() { symbol() {
this.$emit("symbols", this.symbol) this.$emit("symbols", this.symbol)
@ -1151,6 +1158,14 @@ export default {
} }
}, },
methods: { methods: {
inputEnter(e){
this.$nextTick(()=> {
this.margin = e
.replace(/[^\d.]/g, "") //
.replace(/^(\d*\.?\d{0,2}).*$/, "$1"); //
this.sliderActive=-1
})
},
onRefresh() { onRefresh() {
if (this.refreshing) return; if (this.refreshing) return;
this.refreshing = true; this.refreshing = true;
@ -1574,7 +1589,7 @@ export default {
this.form.amount = Math.round((this.maxNum * n) / 100); this.form.amount = Math.round((this.maxNum * n) / 100);
this.sliderActive = i this.sliderActive = i
this.sliderActive1 = n this.sliderActive1 = n
this.margin = (this.form.amount / this.form.lever_rate).toFixed(5) this.margin = (this.form.amount / this.form.lever_rate).toFixed(2)
}, },
pingChange(n, i) { pingChange(n, i) {
// console.log(n) // console.log(n)

Loading…
Cancel
Save