Browse Source

Merge branch 'master' of ssh://git.xingtongworld.com:10022/luyisha/jiaoyi_xtzcoins_h5

master
luyisha 3 years ago
parent
commit
b87a59b52e
  1. 6
      pages/currency/index.vue
  2. 4
      pages/exchange/exchange-transaction.vue
  3. 77
      pages/exchange/open-position.vue

6
pages/currency/index.vue

@ -36,7 +36,7 @@
<span class="fn-bold color-theme-1 fn-16"> USDT </span> <span class="fn-bold color-theme-1 fn-16"> USDT </span>
</template> </template>
<template #left v-if="!showPrice"> <template #left v-if="!showPrice">
<span class="fn-bold color-theme-1 fn-16"> </span> <span class="fn-bold color-theme-1 fn-16"> $ </span>
</template> </template>
</v-input> </v-input>
</view> </view>
@ -51,12 +51,12 @@
<span class="fn-bold color-theme-1 fn-16"> USDT </span> <span class="fn-bold color-theme-1 fn-16"> USDT </span>
</template> </template>
<template #left v-if="!showPrice"> <template #left v-if="!showPrice">
<span class="fn-bold color-theme-1 fn-16"> </span> <span class="fn-bold color-theme-1 fn-16"> $ </span>
</template> </template>
</v-input> </v-input>
</view> </view>
<view class="d-flex justify-between m-t-lg fn-12 align-center"> <view class="d-flex justify-between m-t-lg fn-12 align-center">
<text class="w-100">{{$t("currency.b1")}} {{price_cny}}</text> <text class="w-100">{{$t("currency.b1")}} ${{price_cny}}</text>
</view> </view>
</view> </view>
<button tag="button" v-if="active==1" @click="buy" class="rounded-xs m-x-lg color-white bg-theme-1">{{$t("currency.b2")}}</button> <button tag="button" v-if="active==1" @click="buy" class="rounded-xs m-x-lg color-white bg-theme-1">{{$t("currency.b2")}}</button>

4
pages/exchange/exchange-transaction.vue

@ -63,7 +63,7 @@
input-width="61%" input-width="61%"
step="0.01" step="0.01"
/> />
<view class="tips fn-xs m-t-xs"> {{ omitTo(form.entrust_price*price_cny,2) }}</view> <view class="tips fn-xs m-t-xs"> ${{ omitTo(form.entrust_price*price_cny,2) }}</view>
</view> </view>
<view class="m-t-ms"> <view class="m-t-ms">
<v-input <v-input
@ -197,7 +197,7 @@
{{ newPrice.price }} {{ newPrice.price }}
</view> </view>
<!-- <view class="fn-xs" v-if="newPrice.price"> <!-- <view class="fn-xs" v-if="newPrice.price">
{{ omitTo(newPrice.price * price_cny, 2) }} ${{ omitTo(newPrice.price * price_cny, 2) }}
</view> --> </view> -->
</sell-and-buy> </sell-and-buy>
</view> </view>

77
pages/exchange/open-position.vue

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

Loading…
Cancel
Save