Browse Source

修复拖动金额

master
torsenli 3 years ago
parent
commit
8cd16ecbcb
  1. 77
      pages/exchange/open-position.vue

77
pages/exchange/open-position.vue

@ -132,11 +132,10 @@
<view>
<!-- :placeholder="$t('contract.d2')"
v-model="form.amount" -->
<!-- 保证金 -->
<v-input
v-model="margin"
:placeholder="$t('contract.d2')"
@input="marginInput"
@input="sliderActive=-1"
class="h-30 p-x-sm p-y-xxs rounded-xs"
style="background-color: #F5F5F5;"
>
@ -160,7 +159,7 @@
:class="sliderActive==index?'color-theme-1 active':''">
{{item}}%
</view> -->
<slider style="width: 100%;margin:0px;" block-size="16" class="fn-center p-y-xs fn-12" :value="sliderValue" @change="sliderChangeN" step="1" />
<slider style="width: 100%;margin:0px;" block-size="16" class="fn-center p-y-xs fn-12" value="0" @change="sliderChangeN" step="1" />
<view style="width: 100%;display: flex;justify-content: space-between;">
<text style="text-align: left;font-size: 12px;">0%</text>
<text style="text-align: right;font-size: 12px;">25%</text>
@ -833,9 +832,11 @@ export default {
tradeList: [],
show: false,
accountInfo: {},
lever_rage: [],//
leverShow: '',//
maxNum: 0,//
//
lever_rage: [],
leverShow: '',
//
maxNum: 0,
form: {
type: 1,
entrust_price: "",
@ -866,8 +867,7 @@ export default {
progress: [25, 50, 75, 100],
progressPing: [25, 50, 75, 100],
sliderActive: -1,
sliderValue: 0,
showSliderNum: '0%',
sliderActive1: 0,
pingActive: 3,
contract: "0",
// contract:"0",
@ -889,7 +889,8 @@ export default {
refreshing: false,
pingAmount: '',
imgurl: '',
bao: 0
bao: 0,
showSliderNum: '0%'
};
},
computed: {
@ -911,8 +912,8 @@ export default {
// activeCommission() {
// return this.commissionTypes.find((item) => this.form.type == item.value);
// },
marginCALCU() {
console.log(this.form.amount, this.unit_amount, this.form.lever_rate, '-------');
//
margin() {
return math.omitTo(
(this.form.amount * this.unit_amount) / this.form.lever_rate,
0
@ -921,16 +922,7 @@ export default {
amount() {
if (this.margin == 0){
this.margin='';
this.sliderValue = '0';
this.showSliderNum = '0%';
}else if(this.margin>(+this.accountInfo.usable_balance) || this.margin==this.accountInfo.usable_balance){
this.margin = (+this.accountInfo.usable_balance / this.form.lever_rate).toFixed(5);
this.sliderValue = 100;
this.showSliderNum = '100%';
}else{
this.sliderValue = Math.floor(this.margin * this.form.lever_rate * 100 / this.accountInfo.usable_balance);
this.showSliderNum = '≈'+this.sliderValue.toFixed(0)+'%';
}
}
if (!this.form.lever_rate || !this.margin) return 0;
let p = this.margin * this.form.lever_rate;
p = p.toFixed(0)
@ -958,9 +950,8 @@ export default {
},
watch: {
maxNum(n) {
// this.form.amount = Math.round((this.maxNum * this.sliderValue) / 100);
//
// this.margin = (this.form.amount / this.form.lever_rate).toFixed(5)
this.form.amount = Math.round((this.maxNum * this.sliderActive1) / 100);
this.margin = (this.form.amount / this.form.lever_rate).toFixed(5)
},
symbol() {
this.$emit("symbols", this.symbol)
@ -1339,8 +1330,7 @@ export default {
};
Contract.contractAccount(data, {loading: !boo, toast: false}).then((res) => {
// console.info(res)
// res.data.account_equity = (parseInt(res.data.account_equity)).toFixed(2)
res.data.account_equity = (+res.data.account_equity).toFixed(2)
res.data.account_equity = (parseInt(res.data.account_equity)).toFixed(2)
res.data.usable_balance = (res.data.usable_balance).toFixed(2)
this.accountInfo = res.data;
if (!boo) {
@ -1365,12 +1355,6 @@ export default {
label: item,
value: item,
}));
for(let item =0;item<this.lever_rage.length;item++){
if(res.data.default_lever==this.lever_rage[item].value){
// leverShow v-dropdwontext
this.leverShow = item.toString();
}
}
let e={value:res.data.default_lever, label: res.data.default_lever}
this.openNum(e);
@ -1382,6 +1366,7 @@ export default {
//
openNum(e) {
// console.log(e, '', this.lever_rage);
if (!this.isLogin) return;
let data = {
symbol: this.symbolLeft, //ETH
lever_rate: this.form.lever_rate, //10
@ -1398,7 +1383,6 @@ export default {
}
// console.log('111111111111', this.leverShow, this.form.lever_rate);
}
if (!this.isLogin) return;
Contract.openNum(data, {toast: false}).then((res) => {
this.maxNum = res.data;
});
@ -1455,16 +1439,15 @@ export default {
// this.openNum()
});
},
//
//
sliderChangeN(e){
console.log('value 发生变化:' + e.detail.value);
let num = e.detail.value;
this.showSliderNum = num.toFixed(0)+"%";
this.form.amount = Math.round((this.accountInfo.usable_balance * num) / 100);
// this.sliderActive = this.sliderValue
console.log(this.form.amount, this.form.lever_rate);
this.sliderValue = num;
this.margin = (this.form.amount / this.form.lever_rate).toFixed(2)
this.showSliderNum = num+"%";
this.form.amount = Math.round((this.maxNum * num) / 100);
// this.sliderActive = i
this.sliderActive1 = num
this.margin = (this.form.amount / this.form.lever_rate).toFixed(5)
},
// sliderChange($ev) {
// this.form.amount = Math.round((this.maxNum * $ev) / 100)||'';
@ -1479,20 +1462,6 @@ export default {
this.sliderActive1 = n
this.margin = (this.form.amount / this.form.lever_rate).toFixed(5)
},
//
marginInput(e){
this.sliderValue = Math.floor(this.margin * this.form.lever_rate * 100 / this.accountInfo.usable_balance)
// console.log(this.sliderValue, 2);
if(this.sliderValue==0){
this.showSliderNum = '0%';
}else if(this.sliderValue>100 || this.sliderValue==100){
this.margin = (+this.accountInfo.usable_balance / this.form.lever_rate).toFixed(5);
this.sliderValue = 100;
this.showSliderNum = '100%';
}else{
this.showSliderNum = '≈'+this.sliderValue.toFixed(0)+'%';
}
},
pingChange(n, i) {
console.log(n)
this.pingAmount = Math.round((this.activeItem.avail_position * n) / 100);

Loading…
Cancel
Save