Browse Source

修改

master
liaoxinyu 2 years ago
parent
commit
a12298f0cd
  1. 1
      src/assets/img/home/arrow_down.svg
  2. 542
      src/views/contract/exchange-store.vue
  3. 195
      src/views/contract/handicap.vue
  4. 892
      src/views/contract/index.vue

1
src/assets/img/home/arrow_down.svg

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1716533016195" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="12819" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M904.32 453.952c-12.736-12.736-33.408-12.736-46.144 0L512 800.128 165.824 453.952c-12.736-12.736-33.408-12.736-46.144 0l-46.144 46.144c-12.736 12.736-12.736 33.408 0 46.144l415.36 415.36c12.736 12.736 33.408 12.736 46.144 0L950.4 546.24c12.736-12.736 12.736-33.408 0-46.144l-46.08-46.144zM488.896 570.048c12.736 12.736 33.408 12.736 46.144 0l415.36-415.36c12.736-12.736 12.736-33.408 0-46.144l-46.08-46.208c-12.736-12.736-33.408-12.736-46.144 0L512 408.512 165.824 62.336c-12.736-12.736-33.408-12.736-46.144 0L73.536 108.48c-12.736 12.736-12.736 33.408 0 46.144l415.36 415.424z" p-id="12820"></path></svg>

After

Width:  |  Height:  |  Size: 939 B

542
src/views/contract/exchange-store.vue

@ -1,291 +1,177 @@
<template> <template>
<div class="markets-pair-list exchange-store bg-plain" style="margin-top: 8px;"> <div class="markets-pair-list exchange-store bg-plain">
<div class="px-3 pri"> <div class="nav nav-pills">
<div class="nav nav-pills" style="border-bottom: 1px solid #e0e3eb;"> <div class="nav-item">
<div class="nav-item"> <a class="nav-link" :class="{ active: tab == 1 }" @click="tab = 1">{{
<a class="nav-link" :class="{ active: form.type == 2 }" @click="form.type = 2">{{ $t("contract.d9") }}</a> $t("contract.d5")
</div> }}</a>
<div class="nav-item">
<a class="nav-link" :class="{ active: form.type == 1 }" @click="form.type = 1">{{ $t("contract.e0") }}</a>
</div>
</div> </div>
</div> <!-- <div class="nav-item">
<div class="nav nav-pills px-3 py-3"> <a class="nav-link" :class="{ active: tab == 2 }" @click="tab = 2">{{
<div class="nav-item" style="background-color: #F2F2F2;width:50%;text-align: center;"> $t("contract.d6")
<a class="nav-link" @click="tab = 1" style="color: #999999;">{{ $t("contract.d5") }}</a> }}</a>
</div> </div> -->
<div class="flex-fill px-3 justify-content-end d-flex align-items-center" style="background-color: #F2F2F2;width:50%;text-align: center;"> <div class="flex-fill px-3 justify-content-end d-flex align-items-center">
<el-popover style="display: block;width: 100%;" placement="bottom" width="100" v-model="visible" trigger="manual"> <el-popover
<div class="rounded p-1 bg-black pointer" slot="reference" @click="visible = !visible"> placement="bottom"
<!-- {{ $t("contract.b0") }} --> width="100"
<span class="fn-16" style="color: #999999;"> {{ form.lever_rate }}X </span> v-model="visible"
trigger="manual"
>
<div
class="rounded border p-1 bg-white pointer"
slot="reference"
@click="visible = !visible"
>
{{ $t("contract.b0") }}
<span class="fn-16"> {{ form.lever_rate }}X </span>
<i class="el-icon-edit text-primary"></i> <i class="el-icon-edit text-primary"></i>
</div> </div>
<div class="list"> <div class="list">
<div class="el-select-dropdown__item" @click=" selectLever(item); visible = false;" v-for="item in lever_rage" :key="item"> <div
class="el-select-dropdown__item"
@click="
selectLever(item);
visible = false;
"
v-for="item in lever_rage"
:key="item"
>
{{ item }}X {{ item }}X
</div> </div>
</div> </div>
</el-popover> </el-popover>
</div> </div>
</div> </div>
<div class="content-box d-flex" style="flex-wrap: wrap;justify-content: space-between;"> <div class="content-box px-3 ">
<!-- 买入表单 --> <div v-if="type == 2" class="input-group my-4 input-group-sm">
<div style="width: 50%;" class="px-3"> <div class="input-group-prepend">
<div class="d-flex my-4 align-items-center"> <span class="input-group-text">{{ $t("contract.d7") }}</span>
<div class="input-group input-group-sm"> </div>
<div class="input-group-prepend"> <input type="number" class="form-control" placeholder="" />
<span class="input-group-text">{{ $t("contract.d8") }}</span> <div class="input-group-append">
</div> <span class="input-group-text">USDT</span>
<template v-if="form.type == 1">
<input type="number" v-model="buyform.entrust_price" class="form-control" placeholder=""/>
<div class="input-group-append">
<span class="input-group-text">USDT</span>
</div>
</template>
<template v-if="form.type == 2">
<input type="text" disabled:value="$t('contract.d9')" class="form-control" :placeholder="$t('contract.d9')"/>
</template>
</div>
</div> </div>
<div class="input-group mb-4 input-group-sm"> </div>
<div class="d-flex my-4 align-items-center">
<div class="input-group input-group-sm">
<div class="input-group-prepend"> <div class="input-group-prepend">
<!-- <span class="input-group-text">{{ $t("contract.e1") }}</span> --> <span class="input-group-text">{{ $t("contract.d8") }}</span>
<span class="input-group-text">{{ $t("contract.l2") }}</span>
</div> </div>
<template v-if="form.type == 1">
<input <input
type="number" type="number"
v-model="form.entrust_price"
class="form-control" class="form-control"
v-model="marginBuy" placeholder=""
:placeholder="tips"
/>
<!-- <div class="input-group-append">
<span class="input-group-text">{{ $t("contract.e2") }}</span>
</div> -->
</div>
<div class="px-2" v-if="this.tab == 1">
<!-- :value="activeStepBuy"
@input="sliderChangeBuy" -->
<el-slider
:value="activeStepBuy"
@input="sliderChangeBuy"
:format-tooltip="tooltip"
:marks="marks"
></el-slider>
</div>
<div class="d-flex justify-content-between mb-3 color_7c fn-10">
<div>0</div>
<div style="margin-left: 35px;">25%</div>
<div style="margin-left: 15px;">50%</div>
<div style="margin-left: 20px;">75%</div>
<div>100%</div>
</div>
<!-- 开仓 -->
<div v-if="tab == 1" class="kaicang">
<div class="d-flex justify-content-between mb-3">
<div class="color_7c">{{ $t("contract.e7") }} </div>
<div>{{ maxNum }}</div>
</div>
<div class="d-flex justify-content-between mb-3">
<div class="color_7c">{{ $t("contract.e1") }}</div>
<div>{{ amountBuy }} </div>
</div>
<div class="d-flex justify-content-between mb-4">
<div class="color_7c">{{ $t("contract.a3") }}</div>
<div>
{{ accountInfo.usable_balance }} USDT
<i
class="el-icon-sort"
@click="$router.push('/wallet/assets/exchange')"
></i>
</div>
</div>
</div>
<!-- 平仓 -->
<div v-if="tab == 2">
<div class="d-flex justify-content-between">
<div>{{ $t("contract.e4") }}</div>
<div>{{ multiplePositions }} {{ $t("contract.e2") }}</div>
</div>
<div class="d-flex justify-content-between mb-4">
<div>{{ $t("contract.e5") }}:</div>
<div>{{ shortPosition }} {{ $t("contract.e2") }}</div>
</div>
</div>
<!-- 止盈止损 -->
<div class="d-flex mb-4 border-top py-2" v-if="0">
<input type="checkbox" name="" id="" v-model="checkboxBuy">
<div>{{ $t("contact.Profit&Loss") }}</div>
</div>
<template v-if="checkboxBuy">
<div class="input-group mb-4 input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text">{{ $t("contract.j3") }}</span>
</div>
<input
type="number"
class="form-control"
v-model="buyform.pri1"
:placeholder="tips"
/> />
</div> <div class="input-group-append">
<div class="input-group mb-4 input-group-sm"> <span class="input-group-text">USDT</span>
<div class="input-group-prepend">
<span class="input-group-text">{{ $t("contract.j4") }}</span>
</div> </div>
</template>
<template v-if="form.type == 2">
<input <input
type="number" type="text"
class="form-control" disabled
v-model="buyform.pri2" :value="$t('contract.d9')"
:placeholder="tips"
/>
</div>
</template>
</div>
<!-- 卖出表单 -->
<div style="width: 50%;" class="px-3">
<div class="d-flex my-4 align-items-center">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text">{{ $t("contract.d8") }}</span>
</div>
<template v-if="form.type == 1">
<input
type="number"
v-model="sellform.entrust_price"
class="form-control"
placeholder=""
/>
<div class="input-group-append">
<span class="input-group-text">USDT</span>
</div>
</template>
<template v-if="form.type == 2">
<input
type="text"
disabled
:value="$t('contract.d9')"
class="form-control"
:placeholder="$t('contract.d9')"
/>
</template>
</div>
</div>
<div class="input-group mb-4 input-group-sm">
<div class="input-group-prepend">
<!-- <span class="input-group-text">{{ $t("contract.e1") }}</span> -->
<span class="input-group-text">{{ $t("contract.l2") }}</span>
</div>
<input
type="number"
class="form-control" class="form-control"
v-model="marginSell" :placeholder="$t('contract.d9')"
:placeholder="tips" />
/> </template>
<!-- <div class="input-group-append">
<span class="input-group-text">{{ $t("contract.e2") }}</span>
</div> -->
</div> </div>
<div class="px-2" v-if="this.tab == 1"> <button
<!-- :value="activeStepSell" @click="form.type == 1 ? (form.type = 2) : (form.type = 1)"
@input="sliderChangeSell" --> class="btn btn-sm btn-outline-primary ml-2 text-nowrap"
<el-slider >
:value="activeStepSell" {{ form.type == 1 ? $t("common.limit") : $t("common.market") }}
@input="sliderChangeSell" </button>
:format-tooltip="tooltip" </div>
:marks="marks" <div class="input-group mb-4 input-group-sm">
></el-slider> <div class="input-group-prepend">
<!-- <span class="input-group-text">{{ $t("contract.e1") }}</span> -->
<span class="input-group-text">{{ $t("contract.l2") }}</span>
</div> </div>
<div class="d-flex justify-content-between mb-3 color_7c fn-10">
<div>0</div> <input
<div style="margin-left: 35px;">25%</div> type="number"
<div style="margin-left: 15px;">50%</div> class="form-control"
<div style="margin-left: 20px;">75%</div> v-model="margin"
<div>100%</div> :placeholder="tips"
/>
<!-- <div class="input-group-append">
<span class="input-group-text">{{ $t("contract.e2") }}</span>
</div> -->
</div>
<div class="px-2 mb-4" v-if="this.tab == 1">
<el-slider
:value="activeStep"
@input="sliderChange"
:format-tooltip="tooltip"
:marks="marks"
></el-slider>
<!-- :step="25" -->
</div>
<!-- 开仓 -->
<div v-if="tab == 1" class="kaicang">
<div class="d-flex justify-content-between mb-3">
<div>{{ $t("contract.e1") }}</div>
<!-- {{$t("contract.e2")}} -->
<div>{{ amount }} </div>
</div> </div>
<!-- 开仓 --> <div class="d-flex justify-content-between mb-4">
<div v-if="tab == 1" class="kaicang"> <div>{{ $t("contract.a3") }}:</div>
<div class="d-flex justify-content-between mb-3"> <div>
<div class="color_7c">{{ $t("contract.e7") }} </div> {{ accountInfo.usable_balance }} USDT
<div>{{ accountInfo.account_equity }}</div> <i
</div> class="el-icon-sort"
<div class="d-flex justify-content-between mb-3"> @click="$router.push('/wallet/assets/exchange')"
<div class="color_7c">{{ $t("contract.e1") }}</div> ></i>
<div>{{ amountSell }} </div>
</div>
<div class="d-flex justify-content-between mb-4">
<div class="color_7c">{{ $t("contract.a3") }}</div>
<div>
{{ accountInfo.usable_balance }} USDT
<i
class="el-icon-sort"
@click="$router.push('/wallet/assets/exchange')"
></i>
</div>
</div> </div>
</div> </div>
<!-- 止盈止损 --> </div>
<div class="d-flex mb-4 border-top py-2" v-if="0"> <!-- 平仓 -->
<input type="checkbox" name="" id="" v-model="checkboxSell"> <div v-if="tab == 2">
<div>{{ $t("contact.Profit&Loss") }}</div> <div class="d-flex justify-content-between">
<div>{{ $t("contract.e4") }}</div>
<div>{{ multiplePositions }} {{ $t("contract.e2") }}</div>
</div>
<div class="d-flex justify-content-between mb-4">
<div>{{ $t("contract.e5") }}:</div>
<div>{{ shortPosition }} {{ $t("contract.e2") }}</div>
</div> </div>
<template v-if="checkboxSell">
<div class="input-group mb-4 input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text">{{ $t("contract.j3") }}</span>
</div>
<input
type="number"
class="form-control"
v-model="sellform.pri1"
:placeholder="tips"
/>
</div>
<div class="input-group mb-4 input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text">{{ $t("contract.j4") }}</span>
</div>
<input
type="number"
class="form-control"
v-model="sellform.pri2"
:placeholder="tips"
/>
</div>
</template>
</div> </div>
<div class="exchange_button" v-if="tab == 1" style="width: 100%;"> <div class="exchange_button" v-if="tab == 1">
<div class="px-3 flex-fill mb-4"> <div class="px-1 flex-fill mb-4">
<button <button
@click="ifOpenPosition(1)" @click="ifOpenPosition(1)"
type="button" type="button"
class="sub w-24/24 btn-success btn btn-sm mb-3" class="sub w-24/24 btn-success btn btn-sm mb-3"
> >
{{ $t("contract.d0") }} {{ $t("contract.d0") }}
<!-- {{ $t("contract.d0") }}{{ symbol }} -->
<!-- {{ $t("contract.d0") }} -->
<!-- <span class="fn-12"> {{ $t("contract.e6") }} </span> --> <!-- <span class="fn-12"> {{ $t("contract.e6") }} </span> -->
</button> </button>
<div class="text-left">
{{ $t("contract.e7") }} {{ maxNum }}
<!-- {{ $t("contract.e2") }} -->
</div>
</div> </div>
<div class="px-3 flex-fill"> <div class="px-1 flex-fill">
<button <button
@click="ifOpenPosition(2)" @click="ifOpenPosition(2)"
type="button" type="button"
class="sub w-24/24 btn-danger btn btn-sm mb-3" class="sub w-24/24 btn-danger btn btn-sm mb-3"
> >
{{ $t("contract.d2") }} {{ $t("contract.d2") }}
<!-- {{ $t("contract.d2") }}{{ symbol }} -->
<!-- {{ $t("contract.d2") }} -->
<!-- <span class="fn-12"> {{ $t("contract.e8") }} </span> --> <!-- <span class="fn-12"> {{ $t("contract.e8") }} </span> -->
</button> </button>
<!-- <div class="text-center"> --> <!-- <div class="text-center"> -->
<div class="text-right">
{{ $t("contract.e7") }} {{ maxNum }}
<!-- {{ $t("contract.e2") }} -->
</div>
</div> </div>
</div> </div>
<div class="" v-if="tab == 2" style="width: 100%;"> <div class="" v-if="tab == 2">
<div class="px-2 flex-fill mb-4"> <div class="px-2 flex-fill mb-4">
<button <button
@click="ifOpenPosition(1)" @click="ifOpenPosition(1)"
@ -322,23 +208,14 @@ export default {
data() { data() {
return { return {
tab: 1, tab: 1,
type: 1,
visible: false, visible: false,
form: { form: {
type: 2,//21 // 1: 2:
lever_rate: "" type: 2,
},
buyform: {
entrust_price: undefined,
amount:"",
pri1: "",//
pri2: ""//
},
sellform: {
entrust_price: undefined, entrust_price: undefined,
amount:"", amount:"",
pri1: "",// lever_rate: ""
pri2: ""//
}, },
// //
maxNum: 0, maxNum: 0,
@ -351,12 +228,7 @@ export default {
50:'', 50:'',
75:'' 75:''
}, },
marginBuy:0, margin:0,
marginSell:0,
checkboxBuy: false,
checkboxSell: false,
// activeStepBuy:0,
// activeStepSell:0
}; };
}, },
props: { props: {
@ -384,21 +256,16 @@ export default {
}, },
watch: { watch: {
symbol() { symbol() {
this.buyform.entrust_price = undefined; this.form.entrust_price = undefined;
this.sellform.entrust_price = undefined;
this.contractAccount(); this.contractAccount();
this.getSymbolDetail(); this.getSymbolDetail();
}, },
defaultPrice(n) { defaultPrice(n) {
this.buyform.entrust_price = n; this.form.entrust_price = n;
this.sellform.entrust_price = n;
}, },
newPriceObj(n) { newPriceObj(n) {
if (n && this.buyform.entrust_price === undefined) { if (n && this.form.entrust_price === undefined) {
this.buyform.entrust_price = n.price; this.form.entrust_price = n.price;
}
if (n && this.sellform.entrust_price === undefined) {
this.sellform.entrust_price = n.price;
} }
}, },
contractOpen(n, o) { contractOpen(n, o) {
@ -413,7 +280,6 @@ export default {
mounted() { mounted() {
if (this.symbol) { if (this.symbol) {
this.contractAccount(); this.contractAccount();
this.getSymbolDetail(); this.getSymbolDetail();
} }
this._time = setInterval(() => { this._time = setInterval(() => {
@ -456,45 +322,23 @@ export default {
if (!item) return 0; if (!item) return 0;
return item.avail_position; return item.avail_position;
}, },
activeStepBuy() { activeStep() {
let num = 0 // if (!this.form.amount || !this.maxNum) return 0;
if (!this.buyform.amount || !this.maxNum){ let num = (this.form.amount / this.maxNum) * 100;
num = (this.buyform.amount / this.maxNum) * 100; return num;
}else{
num = (this.buyform.amount / this.maxNum) * 100;
}
return num;
},
activeStepSell() {
let num = 0
if (!this.sellform.amount || !this.maxNum){
num = (this.sellform.amount / this.maxNum) * 100;
}else{
num = (this.sellform.amount / this.maxNum) * 100;
}
return num;
}, },
// //
// margin() { // margin() {
// if (!this.form.lever_rate) return ''; // if (!this.form.lever_rate) return '';
// return math.omitTo(this.form.amount*this.unit_amount / this.form.lever_rate, 4); // return math.omitTo(this.form.amount*this.unit_amount / this.form.lever_rate, 4);
// }, // },
amountBuy(){ amount(){
// console.info(this.form.lever_rate)
// console.info(this.margin)
if (!this.form.lever_rate || !this.marginBuy) return 0;
let p=this.marginBuy*this.form.lever_rate;
this.buyform.amount=p;
return p
},
amountSell(){
// console.info(this.form.lever_rate) // console.info(this.form.lever_rate)
// console.info(this.margin) // console.info(this.margin)
if (!this.form.lever_rate || !this.marginSell) return 0; if (!this.form.lever_rate || !this.margin) return 0;
let p=this.marginSell*this.form.lever_rate; let p=this.margin*this.form.lever_rate;
this.sellform.amount=p; this.form.amount=p;
return p return p
} }
}, },
@ -537,21 +381,16 @@ export default {
this.lever_rage = res.lever_rage; this.lever_rage = res.lever_rage;
this.unit_amount = res.unit_amount this.unit_amount = res.unit_amount
this.$emit('getSymbolDetail',res) this.$emit('getSymbolDetail',res)
if (!this.form.lever_rate) { // if (!this.form.lever_rate) {
this.form.lever_rate = res.default_lever; this.form.lever_rate = res.default_lever;
} // }
}); });
}, },
// //
sliderChangeBuy($ev) { sliderChange($ev) {
this.buyform.amount = Math.round((this.maxNum * $ev) / 100)||''; this.form.amount = Math.round((this.maxNum * $ev) / 100)||'';
// console.info(this.buyform) // console.info(this.form)
this.marginBuy=this.buyform.amount/this.form.lever_rate || 0 this.margin=this.form.amount/this.form.lever_rate || 0
},
sliderChangeSell($ev) {
this.sellform.amount = Math.round((this.maxNum * $ev) / 100)||'';
// console.info(this.sellform)
this.marginSell=this.sellform.amount/this.form.lever_rate || 0
}, },
// //
selectLever(idx) { selectLever(idx) {
@ -568,7 +407,7 @@ export default {
} else { } else {
this.closePosition(side); this.closePosition(side);
} }
// let typeStr = // let typeStr =
// this.form.type == 1 // this.form.type == 1
// ? `${this.form.entrust_price}${this.$t("contract.f0")}` // ? `${this.form.entrust_price}${this.$t("contract.f0")}`
@ -581,8 +420,7 @@ export default {
// : `${this.$t("contract.d6")}${this.form.amount}${this.$t( // : `${this.$t("contract.d6")}${this.form.amount}${this.$t(
// "contract.e2" // "contract.e2"
// )}`; // )}`;
// `${this.$t("contract.f3")}${typeStr}${this.form.lever_rate}${this.$t( // `${this.$t("contract.f3")}${typeStr}${this.form.lever_rate}${this.$t(
// "contract.f4" // "contract.f4"
// )}${decStr}?` // )}${decStr}?`
@ -606,24 +444,14 @@ export default {
symbol: this.symbol, symbol: this.symbol,
...this.form ...this.form
}; };
if(side==1){
data.entrust_price = this.buyform.entrust_price;
data.amount = this.buyform.amount;
data.checkbox = this.checkboxBuy;
}else{
data.entrust_price = this.sellform.entrust_price;
data.amount = this.sellform.amount;
data.checkbox = this.checkboxSell;
}
Contract.openPosition(data).then(() => { Contract.openPosition(data).then(() => {
this.contractAccount(); this.contractAccount();
this.buyform.amount = 0; this.form.amount = 0;
this.sellform.amount = 0;
this.$message.success(this.$t("contract.f5")); this.$message.success(this.$t("contract.f5"));
this.$emit("position"); this.$emit("position");
}); });
}, },
// - //
closePosition(side) { closePosition(side) {
let data = { let data = {
side: side == 1 ? 2 : 1, side: side == 1 ? 2 : 1,
@ -642,7 +470,7 @@ export default {
} }
}; };
</script> </script>
<style scoped="scoped"> <style scoped="scoped" lang="scss">
.exchange_button{ .exchange_button{
display: flex; display: flex;
font-size: 16px !important; font-size: 16px !important;
@ -650,58 +478,8 @@ export default {
.btn,.kaicang{ .btn,.kaicang{
font-size: 0.9rem; font-size: 0.9rem;
} }
/* ::v-deep .el-slider__stop{ ::v-deep .el-slider__button-wrapper{
background-color: ; // background-color: ;
} */ z-index: 999;
.exchange-store.markets-pair-list .pri .nav-link.active::after{
content: "";
display: block;
position: absolute;
bottom: 0px;
left: 50%;
width: 52px;
height: 4px;
background-color: #fff;
border-radius: 0px;
transform: translateX(-50%);
margin-left: 0px;
}
.exchange-store.markets-pair-list .nav{
padding: 7px 0px 0px;
font-size: 14px;
}
.exchange-store .btn-success,
.exchange-store .btn-success:hover{
background-color: #52A45A;
border-color: #52A45A;
border-radius: 100px;
color: #fff;
background-image: none;
height: 44px;
}
.exchange-store .btn-danger,
.exchange-store .btn-danger:hover{
background-color: #BB4965;
border-color: #BB4965;
border-radius: 100px;
color: #fff;
background-image: none;
height: 44px;
}
.color_7c{
color: #7c7c7c !important;
}
.exchange-store .input-group-text{
background-color: #F2F2F2;
color: #999999;
border-color: #D3D3D3 !important;
}
.exchange-store .form-control{
height: 44px !important;
border-color: #D3D3D3 !important;
}
.el-icon-sort:before{
color: #2C60DC;
} }
</style> </style>

195
src/views/contract/handicap.vue

@ -1,17 +1,21 @@
<template> <template>
<div class="markets-pair-list handicap bg-plain" style="width: 100%;"> <div class="markets-pair-list handicap bg-plain">
<div class="nav nav-pills" style="border-bottom: 1px solid #e0e3eb;"> <!-- <div class="nav nav-pills">
<div class="nav-item"> <div class="nav-item">
<a class="nav-link" :class="{ active: tab == 1 }" @click="tab = 1">{{ $t("contract.f7") }}</a> <a class="nav-link" :class="{ active: tab == 1 }" @click="tab = 1">{{
$t("contract.f7")
}}</a>
</div> </div>
<div class="nav-item"> <div class="nav-item">
<a class="nav-link" :class="{ active: tab == 2 }" @click="tab = 2">{{ $t("contract.f8") }}</a> <a class="nav-link" :class="{ active: tab == 2 }" @click="tab = 2">{{
$t("contract.f8")
}}</a>
</div> </div>
</div> </div> -->
<div> <div>
<!-- 盘口 --> <!-- 盘口 -->
<div class="handicap-body" v-if="tab == 1"> <div class="handicap-body px-3" v-if="tab == 1">
<div class="d-flex justify-content-between py-2 px-3" v-if="false"> <div class="d-flex justify-content-between py-2" v-if="false">
<div class="d-flex"> <div class="d-flex">
<div class="border border-primary rounded px-1 mr-2"> <div class="border border-primary rounded px-1 mr-2">
{{ $t("contract.f9") }} {{ $t("contract.f9") }}
@ -28,33 +32,42 @@
<i class="el-icon-arrow-down"></i> <i class="el-icon-arrow-down"></i>
</div> </div>
</div> </div>
<div class="label-group d-flex text-secondary fn-14 py-2 px-3"> <div class="label-group d-flex text-secondary fn-12 py-2">
<div class="w-8/24"> <div class="w-7/24">
{{ $t("contract.d8") }} {{ $t("contract.d8") }}
</div> </div>
<div class="w-5/24 text-right"> <div class="w-8/24">
{{ $t("contract.e1") }} {{ $t("contract.e1") }}
</div> </div>
<div class="w-9/24 text-right"> <div class="w-7/24 text-right">
{{ $t("contract.g2") }} {{ $t("contract.g2") }}
<!-- ({{ $t("contract.e2") }}) --> <!-- ({{ $t("contract.e2") }}) -->
</div> </div>
</div> </div>
<div class="sell px-3"> <div class="sell fn-12">
<template v-for="(item, idx) in sellListShow"> <template v-for="(item, idx) in sellListShow">
<div class="item pointer" :key="idx" @click="$emit('selectprice', item.price)"> <div
<div class="d-flex fn-14"> class="item pointer"
<div class="w-8/24 decreace">{{ item.price}}</div> :key="idx"
<div class="w-5/24 text-right">{{ omitTo(item.amount, 2) }}</div> @click="$emit('selectprice', item.price)"
<div class="w-9/24 text-right">{{ item.total }}</div> >
<div class="d-flex">
<div class="w-7/24 decreace">{{ item.price}}</div>
<div class="w-8/24">{{ omitTo(item.amount, 2) }}</div>
<div class="w-8/24 text-right">{{ item.total }}</div>
</div> </div>
<div class="pgs" :style="{ width: getValue(item.amount) + '%' }"></div> <div
class="pgs"
:style="{ width: getValue(item.amount) + '%' }"
></div>
</div> </div>
</template> </template>
</div> </div>
<div class="current-nav d-flex align-items-center my-2 py-2" style="background-color: #fff;"> <div
<div class="w-10/24 d-flex align-items-center"> class="current-nav d-flex border-top border-bottom align-items-center"
<div class="name fn-12 px-3">{{ $t("contract.g3") }}</div> >
<div class="w-10/24">
<div class="name text-secondary fn-12">{{ $t("contract.g3") }}</div>
<div class="num fn-20 increace"> <div class="num fn-20 increace">
{{ newPriceObj.price }} {{ newPriceObj.price }}
</div> </div>
@ -63,13 +76,17 @@
<!-- <button class="btn btn-sm btn-outline-primary fn-12">更多</button> --> <!-- <button class="btn btn-sm btn-outline-primary fn-12">更多</button> -->
</div> </div>
</div> </div>
<div class="buy px-3"> <div class="buy fn-12">
<template v-for="(item, idx) in buyListShow"> <template v-for="(item, idx) in buyListShow">
<div class="item pointer" :key="idx" @click="$emit('selectprice', item.price)"> <div
<div class="d-flex fn-14"> class="item pointer"
<div class="w-8/24 increace">{{ item.price }}</div> :key="idx"
<div class="w-5/24 text-right">{{ omitTo(item.amount, 2) }}</div> @click="$emit('selectprice', item.price)"
<div class="w-9/24 text-right">{{ item.total }}</div> >
<div class="d-flex">
<div class="w-7/24 increace">{{ item.price }}</div>
<div class="w-8/24">{{ omitTo(item.amount, 2) }}</div>
<div class="w-8/24 text-right">{{ item.total }}</div>
</div> </div>
<div <div
class="pgs" class="pgs"
@ -78,30 +95,34 @@
</div> </div>
</template> </template>
</div> </div>
</div> <!-- 实时成交 -->
<!-- 实时成交 --> <div class="d-flex text-secondary fn-12">
<div class="real-time p-3" v-if="tab == 2"> <div class="w-7/24">
<div class="d-flex text-secondary fn-14">
<div class="w-10/24">
{{ $t("contract.b1") }} {{ $t("contract.b1") }}
</div> </div>
<div class="w-7/24">{{ $t("contract.d8") }}(USDT)</div> <div class="w-8/24">{{ $t("contract.d8") }}(USDT)</div>
<div class="w-7/24 text-right"> <div class="w-8/24 text-right">
{{ $t("contract.e1") }}({{ $t("contract.e2") }}) {{ $t("contract.e1") }}({{ $t("contract.e2") }})
</div> </div>
</div> </div>
<div class="d-flex fn-14" v-for="(item, idx) in tradeList" :key="idx"> <div class="deal">
<div class="w-10/24"> <div class="d-flex fn-12" v-for="(item, idx) in tradeList" :key="idx">
{{ parseTime(item.ts, false, "{h}:{i}:{s}") }} <div class="w-7/24">
</div> {{ parseTime(item.ts, false, "{h}:{i}:{s}") }}
<div class="w-7/24 increace"> </div>
{{ item.price }} <div class="w-8/24 increace">
</div> {{ item.price }}
<div class="w-7/24 text-right"> </div>
{{ omitTo(item.amount, 2) }} <div class="w-8/24 text-right">
{{ omitTo(item.amount, 2) }}
</div>
</div> </div>
</div> </div>
</div> </div>
<!-- -->
<div class="real-time p-3" v-if="tab == 2">
</div>
</div> </div>
</div> </div>
</template> </template>
@ -152,21 +173,20 @@ export default {
}; };
}, },
sellListShow() { sellListShow() {
let list = this.sellList.splice(0, 12); let list = this.sellList.splice(0, 12);
let total = 0; let total = 0;
list.forEach(item => { list.forEach(item => {
// total = total -0; // item.total = total += item.amount;
// console.log(Number(total)); item.total = total += Number(item.amount);
item.total = total += Number(item.amount); item.total = item.total.toFixed(3)
item.total = item.total.toFixed(3); });
// item.total =item.total-0; return list.reverse();
});
return list.reverse();
}, },
buyListShow() { buyListShow() {
let list = this.buyList.splice(0, 12); let list = this.buyList.splice(0, 12);
let total = 0; let total = 0;
list.forEach(item => { list.forEach(item => {
// item.total = total += item.amount;
item.total = total += Number(item.amount); item.total = total += Number(item.amount);
item.total = item.total.toFixed(3); item.total = item.total.toFixed(3);
}); });
@ -180,7 +200,16 @@ export default {
} }
bus.$on('collapse', msg => { bus.$on('collapse', msg => {
this.newPriceObj.price =this.symbol=='BTC'? (msg.close).toFixed(1):(msg.close).toFixed(3); this.newPriceObj.price =this.symbol=='BTC'? (msg.close).toFixed(1):(msg.close).toFixed(3);
// if (msg.close.endsWith('.')) {
// // '0'
// msg.close += '0';
// }
this.newPriceObj.price = msg.close;
this.$emit("input", this.newPriceObj); this.$emit("input", this.newPriceObj);
// console.log(this.newPriceObj.price, 'this.newPriceObj.price-----')
// const closeStr = msg.close.toString();
// this.newPriceObj.price = this.symbol === 'BTC' ? closeStr.slice(0, closeStr.indexOf('.') + 2) : closeStr.slice(0, closeStr.indexOf('.') + 4);
// this.$emit("input", this.newPriceObj);
}); });
}, },
// //
@ -195,7 +224,9 @@ export default {
this.sellList = res.swapSellList; this.sellList = res.swapSellList;
this.buyList = res.swapBuyList; this.buyList = res.swapBuyList;
this.tradeList = res.swapTradeList; this.tradeList = res.swapTradeList;
this.newPriceObj = this.tradeList[0]; // if(this.tradeList.length>0){
this.newPriceObj = this.tradeList[0];
// }
this.$emit("input", this.newPriceObj); this.$emit("input", this.newPriceObj);
}); });
}, },
@ -241,18 +272,19 @@ export default {
this.ws.on("message", res => { this.ws.on("message", res => {
let { data, msg, code, sub, type, status, cmd } = res; let { data, msg, code, sub, type, status, cmd } = res;
if (sub == this.msg.buy) { if (sub == this.msg.buy) {
this.buyList = data; this.buyList = data;
} else if (sub == this.msg.sell) { } else if (sub == this.msg.sell) {
this.sellList = data; this.sellList = data;
} else if (sub == this.msg.trade) { } else if (sub == this.msg.trade) {
this.tradeList.unshift(data); // console.log('if (sub == this.msg.trade)', this.msg.trade)
this.tradeList.pop(); this.tradeList.unshift(data);
// this.newPriceObj = data; this.tradeList.pop();
// this.$emit("input", this.newPriceObj); // this.newPriceObj = data;
// this.$emit("input", this.newPriceObj);
} else if (type == "ping" ||cmd == "ping") { } else if (type == "ping" ||cmd == "ping") {
this.ws.send({ this.ws.send({
cmd: "pong" cmd: "pong"
}); });
} }
}); });
@ -277,39 +309,4 @@ export default {
} }
} }
}; };
</script> </script>
<style scoped>
.handicap .nav-link{
padding: 0.5rem 1.35rem !important;
color: #828282;
}
.handicap.markets-pair-list .nav{
padding: 7px 0px 0px;
font-size: 16px;
}
.handicap.markets-pair-list .nav-link.active{
color: #147797;
}
.handicap.markets-pair-list .nav-link.active::after{
content: "";
display: block;
position: absolute;
bottom: 0px;
left: 50%;
width: 52px;
height: 4px;
background-color: #fff;
border-radius: 0px;
transform: translateX(-50%);
margin-left: 0px;
}
.contract-page .page-top .handicap .handicap-body .sell,
.contract-page .page-top .handicap .handicap-body .buy{
height: 430px;
overflow: auto;
}
.contract-page .page-top .handicap .handicap-body .sell .item,
.contract-page .page-top .handicap .handicap-body .buy .item{
line-height: 40px;
}
</style>

892
src/views/contract/index.vue

@ -1,516 +1,396 @@
<template> <template>
<div class="contract-page" style="background-color: #F8F8F8;"> <div class="contract-page">
<!-- <div class="banner-block col-xs-8">--> <!-- <div class="banner-block col-xs-8">-->
<!-- <el-carousel :interval="6000" height="450px">--> <!-- <el-carousel :interval="6000" height="450px">-->
<!-- <el-carousel-item v-for="item in pcBannerList" :key="item.id">--> <!-- <el-carousel-item v-for="item in pcBannerList" :key="item.id">-->
<!-- <img :src="item.imgurl" width="100%" height="100%" />--> <!-- <img :src="item.imgurl" width="100%" height="100%" />-->
<!-- </el-carousel-item>--> <!-- </el-carousel-item>-->
<!-- </el-carousel>--> <!-- </el-carousel>-->
<!-- </div>--> <!-- </div>-->
<div class="d-flex align-items-center" style="background-color: #fff;"> <div class="page-top d-flex pt-2">
<div class="price px-3"> <div class="kline-box flex-fill mr-2">
<img :src="currentIcon" alt="" style="width: 26px;height: 26px;"> <div class="coin-change d-flex align-items-center py-2 pl-4 heading justify-content-between" style="height: 60px;">
</div> <div class="d-flex align-items-center">
<div class="price"> <div class="coin d-flex align-items-center">
<div class="item fn-16" style="font-weight: bold;">{{ activeContract.pair_name }}</div> <el-popover placement="bottom" ref="popover" width="400" trigger="click">
</div> <div slot="reference" style="display: flex;align-items: center;">
<div class="d-flex fn-14 px-4 p-l-A align-items-center py-2"> <img :src="currentIcon" width="20" height="20" />
<div class="item px-2 min-width-A" style="font-weight: bold;"> <div style="font-weight: 500;color: #000;margin: 0px 5px;">{{ activeContract.pair_name }}</div>
<div class="title" :class="{ decreace2: activeContract.increase < 0, increase: activeContract.increase >= 0}" style="margin-bottom: 10px;"> <el-button size="mini">
{{ activeContract.price }} <img src="@/assets/img/home/arrow_down.svg" width="10" height="10" />
</div> <!-- <i class="el-icon-arrow-down"></i> -->
<div :class="{ decreace2: activeContract.increase < 0, increase: activeContract.increase >= 0}"> </el-button>
{{ activeContract.increaseStr }} </div>
</div> <div class="markets-pair-list" style="max-height:300px;overflow:auto;">
</div> <template v-for="parent in contractList">
</div> <div class="px-3 text-primary" :key="parent.coin_name">
<!-- 币种价值数据 --> {{ parent.coin_name }}
<div class="d-flex fn-14"> </div>
<div class="item px-2 min-width-B"> <table class="table" :key="parent.coin_name + 1">
<div class="title text-secondary" style="margin-bottom: 10px;"> <thead>
24h {{ $t("contract.h7") }} <tr class="text-secondary">
</div> <th class="w-10/24">{{ $t("contract.h5") }}</th>
<div class="fn-12" style="color: #a8263b;font-weight: bold;"> <th class="w-7/24">{{ $t("contract.g3") }}</th>
{{ activeContract.high }} <th class="w-7/24 text-right">
</div> {{ $t("contract.h6") }}
</div> </th>
<div class="item px-2 min-width-B"> </tr>
<div class="title text-secondary" style="margin-bottom: 10px;"> </thead>
24h {{ $t("contract.h8") }} <tbody>
</div> <!-- @click="activeSymbol = item.symbol" -->
<div class="fn-12" style="color: #a8263b;font-weight: bold;"> <tr v-for="item in parent.marketInfoList" :key="item.symbol"
{{ activeContract.low }} :class="{ active: item.symbol == activeSymbol }" @click="ispopover1(item.symbol)">
</div> <td class="" style="display: flex;">
</div> <div v-for="items in Liste" :key="items.symbol">
<div class="item px-2 min-width-B"> <img :src="items.icon" width="20" height="20" v-if="items.symbol==item.symbol" />
<div class="title text-secondary" style="margin-bottom: 10px;"> </div>
24h {{ $t("contract.h9") }} <div style="font-weight: 500;color: #000;">{{ item.symbol }}/{{ parent.coin_name }}</div>
(USDT) </td>
</div> <td class="w-7/24 " :class="item.increase < 0 ? 'decreace' : 'increace'" style="font-weight: bold;">
<div class="fn-12" style="color: #a8263b;font-weight: bold;"> {{ item.price }}
{{ activeContract.vol }} </td>
</div> <td class="w-7/24" :class="item.increase < 0 ? 'decreace' : 'increace'" style="font-weight: bold;">
</div> {{ item.increaseStr }}
</div> </td>
</div> </tr>
<div class="page-top d-flex pt-2"> </tbody>
<!-- 交易对 --> </table>
<div style="width: 23%;background-color: #fff;margin-right: 7px;"> </template>
<div class="d-flex search_box"> </div>
<i class="el-icon-search"></i> </el-popover>
<input type="text" :placeholder="$t('exchange.search')" v-model="filterCoin" style="color: black;"> </div>
</div> <div class="price border-right" style="padding: 0px 30px;" :class="{ decreace: activeContract.increase < 0, increace: activeContract.increase >= 0 }">
<div class="bottom-box-left"> <div class="current">{{ activeContract.price }}$</div>
<template v-for="parent in contractListFilter"> <div class="zf">{{ activeContract.increaseStr }}</div>
<table class="table" :key="parent.coin_name + 1"> </div>
<thead> <!-- 币种价值数据 -->
<tr class=""> <div class="d-flex fn-12">
<th class="w-9/24">{{ $t("contract.h5") }}</th> <div class="item" style="padding: 0px 20px;">
<th class="w-7/24 text-right">{{ $t("contract.g3") }}</th> <div class="title" style="margin-bottom: 10px;color: #000;">
<th class="w-8/24 text-right"> 24h {{ $t("contract.h7") }}
{{ $t("contract.h6") }} </div>
</th> <div style="color: rgb(168, 38, 59);font-weight: bold;">
</tr> {{ activeContract.high }}
</thead> </div>
<tbody> </div>
<tr v-for="item in Liste" :key="item.symbol" <div class="item" style="padding: 0px 20px;">
:class="{ active: item.symbol == activeSymbol }" @click="ispopover1(item.symbol)"> <div class="title" style="margin-bottom: 10px;color: #000;">
<td class="w-9/24 tr-text" style="font-weight: bold;color: #000;padding: 15px 18px;"> 24h {{ $t("contract.h8") }}
<img :src="item.icon" width="20" height="20" /> </div>
{{ item.symbol }}/{{ parent.coin_name }} <div style="color: rgb(168, 38, 59);font-weight: bold;">
</td> {{ activeContract.low }}
<td class="w-7/24 text-right" :class="item.increase < 0 ? 'decreace' : 'increase'" style="font-weight: bold;padding: 15px 18px;"> </div>
{{ item.close }} </div>
</td> <div class="item" style="padding: 0px 20px;">
<td class="w-8/24 text-right" :class="item.increase < 0 ? 'decreace' : 'increase'" style="font-weight: bold;padding: 15px 18px;"> <div class="title" style="margin-bottom: 10px;color: #000;">
{{ item.increaseStr }} 24h {{ $t("contract.h9") }}
</td> <!-- {{ $t("contract.e2") }} -->
</tr> <!-- (USDT) -->
</tbody> </div>
</table> <div style="color: rgb(168, 38, 59);font-weight: bold;">
</template> {{ activeContract.vol }}
</div> </div>
</div> </div>
<div class="kline-box flex-fill mr-2"> </div>
<kline :activeCoin="{ pair_name: activeContract.pair_name }" v-if="activeContract.pair_name" </div>
:contract="true" :wsUrl="wsUrl" /> <!-- <div><theme-change /></div> -->
<!-- 交易 --> </div>
<exchange-store :holdPositionList="holdPositionList" :symbol="activeSymbol" :defaultPrice="defaultPrice" <kline
:newPriceObj="newPriceObj" :contractOpen="contractOpen" @accountInfo="accountInfo = $event" :activeCoin="{ pair_name: activeContract.pair_name }"
@position="getLastHoldPosition" @getSymbolDetail="symbolDetail=$event" /> v-if="activeContract.pair_name"
</div> :contract="true"
<div style="width: 20%;"> :wsUrl="wsUrl"
<!-- 盘口 --> />
<handicap @input="newPriceObj = $event" @selectprice="defaultPrice = $event" :symbol="activeSymbol" </div>
:wsUrl="wsUrl" :ws="ws" class="" ref="handicap" /> <!-- 盘口 -->
<!-- 合约账户 --> <handicap
<div style="margin-top: 8px;"> @input="newPriceObj = $event"
<account class="bg-plain" :accountInfo="accountInfo" /> @selectprice="defaultPrice = $event"
</div> :symbol="activeSymbol"
</div> :wsUrl="wsUrl"
:ws="ws"
</div> class="mr-2"
<page-bottom @position="getLastHoldPosition" @isall=" holdPositionAll = $event; holdPosition();" ref="handicap"
@setactiveItem="setactiveItem" :accountInfo="accountInfo" :newPriceObj="newPriceObj" />
:holdPositionList="holdPositionList" :holdPositionAll="holdPositionAll" :symbol="activeSymbol" <!-- 交易 -->
:symbolDetail="symbolDetail" /> <exchange-store
<div class="modal fade" id="openContract" tabindex="-1" role="dialog" aria-labelledby="contractClose" :holdPositionList="holdPositionList"
aria-hidden="true"> :symbol="activeSymbol"
<div class="modal-dialog modal-dialog-centered"> :defaultPrice="defaultPrice"
<div class="modal-content"> :newPriceObj="newPriceObj"
<div class="modal-header"> :contractOpen="contractOpen"
<h5 class="modal-title" id="contractClose"> @accountInfo="accountInfo = $event"
{{ contractAgreement.title }} @position="getLastHoldPosition"
</h5> @getSymbolDetail="symbolDetail=$event"
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> />
<span aria-hidden="true">&times;</span> </div>
</button> <page-bottom
</div> @position="getLastHoldPosition"
<div class="modal-body"> @isall="
<div v-html="contractAgreement.body"></div> holdPositionAll = $event;
</div> holdPosition();
<div class="modal-footer d-flex justify-content-center"> "
@setactiveItem="setactiveItem"
<button type="button" class="btn btn-primary" @click="opening"> :accountInfo="accountInfo"
{{$t('contract.j8')}} :newPriceObj="newPriceObj"
</button> :holdPositionList="holdPositionList"
</div> :holdPositionAll="holdPositionAll"
</div> :symbol="activeSymbol"
</div> :symbolDetail="symbolDetail"
</div> />
</div> <div class="modal fade" id="openContract" tabindex="-1" role="dialog" aria-labelledby="contractClose" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="contractClose">
{{ contractAgreement.title }}
</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div v-html="contractAgreement.body"></div>
</div>
<div class="modal-footer d-flex justify-content-center">
<button type="button" class="btn btn-primary" @click="opening">
{{$t('contract.j8')}}
</button>
</div>
</div>
</div>
</div>
</div>
</template> </template>
<script> <script>
import kline from "../option/kline"; import kline from "../option/kline";
import handicap from "./handicap.vue"; import handicap from "./handicap.vue";
import account from "./account.vue"; import account from "./account.vue";
import exchangeStore from "./exchange-store.vue"; import exchangeStore from "./exchange-store.vue";
import pageBottom from "./page-bottom.vue"; import pageBottom from "./page-bottom.vue";
import Contract from "../../api/contract"; import Contract from "../../api/contract";
import Socket from "@/api/server/Socket.js"; import Socket from "@/api/server/Socket.js";
import Home from "@/api/home"; import Home from "@/api/home";
import bus from "@/components/bus.js"; import bus from "@/components/bus.js";
export default { export default {
components: { components: {
kline, kline,
handicap, handicap,
account, account,
exchangeStore, exchangeStore,
pageBottom pageBottom
}, },
data() { data() {
return { return {
contractList: [], contractList: [],
activeSymbol: "", activeSymbol: "",
holdPositionAll: false, holdPositionAll: false,
holdPositionList: [], holdPositionList: [],
newPriceObj: {}, newPriceObj: {},
pcBannerList: [], pcBannerList:[],
accountInfo: {}, accountInfo: {},
defaultPrice: "", defaultPrice: "",
wsUrl: this.Globals.Server.Path.WS1, wsUrl: this.Globals.Server.Path.WS1,
ws: new Socket(this.Globals.Server.Path.WS1), ws: new Socket(this.Globals.Server.Path.WS1),
_time: null, _time: null,
contractOpen: false, contractOpen: false,
contractAgreement: {}, contractAgreement: {},
symbolDetail: {}, symbolDetail:{},
currentIcon: '', currentIcon: '',
filterCoin: "", imge:[],
contractListFilter: [], Liste:[]
imgList:[], };
imge:[], },
Liste:[] computed: {
}; activeContract(val) {
}, let contractList=this.contractList
computed: { .map(item => item.marketInfoList)
activeContract(val) { .flat()
let contractList = this.contractList .find(item => item.symbol == this.activeSymbol) || {}
.map(item => item.marketInfoList) if(val.price){
.flat() delete contractList.price
.find(item => item.symbol == this.activeSymbol) || {} }
if (val.price) { return contractList;
delete contractList.price },
isLogin() {
return Boolean(localStorage.token);
}
},
watch: {
activeSymbol() {
this.holdPosition();
},
},
destroyed() {
clearInterval(this._time);
},
created() {
// this.openStatus();
this.getMarketList();
this.holdPosition();
this.indexList();
this._time = setInterval(() => {
if (this.contractOpen) {
// mounted holdPosition
this.holdPosition();
}
}, 3000);
this.ws.on("open", () => {
this.swapMarketList();
});
// console.info(this.$refs)
bus.$on('collapse', msg => {
this.activeContract.price =this.activeContract.symbol=='BTC'? (msg.close).toFixed(1):(msg.close).toFixed(3);
this.holdPositionList.map(item=>{
if(item.symbol==this.activeContract.symbol) item.realtimePrice=this.activeContract.price
})
});
},
//
mounted: function () {
setInterval(() => {
this.holdPosition();
}, 2000)
},
methods: {
ispopover1(item){
this.activeSymbol=item;
this.getMarketList();
this.$refs.popover.showPopper = false;
},
swapMarketList() {
let msg = "swapMarketList";
this.ws.send({
cmd: "sub",
msg: msg
});
this.ws.on("message", res => {
let { data, sub,cmd } = res;
if (sub == msg) {
// console.log(data, '11--------------------')
if( data.symbol=='BTC' )(data.price).toFixed(1)
this.contractList = data;
this.Listes();
}else if (cmd == "ping") {
this.ws.send({
cmd: "pong"
});
}
});
this.ws.on('close',()=>{
this.ws= new Socket(this.Globals.Server.Path.WS1),
console.log('链接关闭');
this.wsOpen();
})
},
Listes(){
this.Liste = []
this.contractList[0].marketInfoList.map(item=>{
this.imge[0].marketInfoList.map(items=>{
if(item.symbol==items.symbol){
this.Liste.push({
pair_name: item.pair_name,
symbol: item.symbol,
icon:items.icon
})
} }
return contractList; })
}, })
isLogin() { },
return Boolean(localStorage.token); wsOpen(){
}, this.ws.on("open", () => {
// contractListFilter(){ this.swapMarketList();
// return this.contractList.map((item1, index1)=>{ this.$refs.handicap.linkSocket()
// item1.marketInfoList.filter(item2=>{ });
// return item2.symbol.indexOf(this.filterCoin)!=-1 },
// }) //
// return item1; getMarketList() {
// }) this.currentIcon = "";
// } Contract.getMarketList().then(res => {
}, if(this.activeSymbol==''){
watch: { this.contractList = res;
activeSymbol() { this.imge = res;
this.holdPosition(); //
}, let firstParent = res[0];
filterCoin: { if (firstParent) {
handler(n, o) { let first = firstParent.marketInfoList[0];
if (!n) { if (first) this.activeSymbol = first.symbol;
this.contractListFilter = this.contractList; this.currentIcon = res[0].marketInfoList[0].icon;
} else {
this.Liste = this.Liste.filter(item2 => {
return item2.symbol.indexOf(n.toUpperCase()) != -1
})
}
// if (!n) {
// this.contractListFilter = this.contractList;
// } else {
// this.contractListFilter = this.contractList.map((item1, index1) => {
// let arr = item1;
// arr.marketInfoList = item1.marketInfoList.filter(item2 => {
// return item2.symbol.indexOf(n.toUpperCase()) != -1
// })
// console.log(arr,'111');
// return arr;
// })
// }
},
immediate: true
} }
}, }else{
destroyed() { // icon
clearInterval(this._time); console.log('11111');
}, for(let item of res[0].marketInfoList){
created() { if(this.activeSymbol==item.symbol){
// this.openStatus(); this.currentIcon = item.icon;
this.getMarketList(); }
this.holdPosition();
this.indexList();
this._time = setInterval(() => {
if (this.contractOpen) {
this.holdPosition();
}
}, 3000);
this.ws.on("open", () => {
this.swapMarketList();
});
// console.info(this.$refs)
bus.$on('collapse', msg => {
this.activeContract.price = this.activeContract.symbol == 'BTC' ? (msg.close).toFixed(1) : (msg
.close).toFixed(3);
this.holdPositionList.map(item => {
if (item.symbol == this.activeContract.symbol) item.realtimePrice = this.activeContract
.price
})
});
},
//
mounted: function() {
setInterval(() => {
this.holdPosition();
}, 2000)
},
methods: {
ispopover1(item) {
this.activeSymbol = item;
// this.$refs.popover.showPopper = false;
this.getMarketList();
},
swapMarketList() {
let msg = "swapMarketList";
this.ws.send({
cmd: "sub",
msg: msg
});
this.ws.on("message", res => {
let {
data,
sub,
cmd
} = res;
if (sub == msg) {
if (data.symbol == 'BTC')(data.price).toFixed(1)
this.contractList = data;
if (this.filterCoin == '') {
this.contractListFilter = data;
this.Listes();
// console.log(this.Liste,'2222');
}
} else if (cmd == "ping") {
this.ws.send({
cmd: "pong"
});
}
});
this.ws.on('close', () => {
this.ws = new Socket(this.Globals.Server.Path.WS1),
console.log('链接关闭');
this.wsOpen();
})
},
wsOpen() {
this.ws.on("open", () => {
this.swapMarketList();
this.$refs.handicap.linkSocket()
});
},
Listes(){
this.Liste = []
this.contractListFilter[0].marketInfoList.map(item=>{
this.imge[0].marketInfoList.map(items=>{
if(item.symbol==items.symbol){
this.Liste.push({
amount:item.amount,
close:item.close,
count: item.count,
high:item.high,
id: item.id,
increase: item.increase,
increaseStr: item.increaseStr,
low: item.low,
mrid: item.mrid,
open: item.open,
pair_name: item.pair_name,
price:item.price,
symbol: item.symbol,
trade_turnover: item.trade_turnover,
type: item.type,
vol: item.vol,
icon:items.icon
})
}
})
})
},
//
getMarketList() {
this.currentIcon = "";
Contract.getMarketList().then(res => {
if (this.activeSymbol == '') {
//
this.imge = res
this.contractList = res;
if (this.filterCoin == '') {
this.contractListFilter = res;
this.Listes();
}
//
let firstParent = res[0];
if (firstParent) {
let first = firstParent.marketInfoList[0];
if (first) this.activeSymbol = first.symbol;
this.currentIcon = res[0].marketInfoList[0].icon;
}
} else {
// icon
for (let item of res[0].marketInfoList) {
if (this.activeSymbol == item.symbol) {
this.currentIcon = item.icon;
}
}
}
});
},
//
holdPosition() {
if (!this.isLogin) return;
let data = {
symbol: (this.holdPositionAll && this.activeSymbol) || ""
};
Contract.holdPosition(data, {
loading: false
}).then(res => {
// console.info(res)
res.map(item => {
if (item.symbol == this.activeContract.symbol) item.realtimePrice = this
.activeContract.price
})
this.holdPositionList = res;
});
},
//
openStatus() {
if (!this.isLogin) return;
Contract.openStatus().then(res => {
this.contractOpen = res.open;
if (!this.contractOpen) {
this.contractAgreement = res.contractAgreement;
$("#openContract").modal("show");
}
});
},
//
opening() {
Contract.opening().then(res => {
$("#openContract").modal("hide");
this.contractOpen = true;
this.$message.success(this.$t('contract.j9'));
});
},
indexList() {
Home.indexList().then((res) => {
this.pcBannerList = res.pcBannerList
// setTimeout(() => {
// this.skroll();
// }, 100);
}).catch((res) => {});
},
//
setactiveItem(index = 0) {
this.accountInfo = this.holdPositionList[index]
},
// 线
getLastHoldPosition(){
let ti = 0,timer=null;
timer = setInterval(()=>{
this.holdPosition();
ti++;
if(ti==3){
clearInterval(timer);
}
}, 1000)
} }
} }
}; });
},
//
holdPosition() {
if (!this.isLogin) return;
let data = {
symbol: (this.holdPositionAll && this.activeSymbol) || ""
};
Contract.holdPosition(data, { loading: false }).then(res => {
// console.info(res)
res.map(item=>{
if(item.symbol==this.activeContract.symbol) item.realtimePrice=this.activeContract.price
})
this.holdPositionList = res;
});
},
//
openStatus() {
if(!this.isLogin) return;
Contract.openStatus().then(res => {
this.contractOpen = res.open;
if (!this.contractOpen) {
this.contractAgreement = res.contractAgreement;
$("#openContract").modal("show");
}
});
},
//
opening() {
Contract.opening().then(res => {
$("#openContract").modal("hide");
this.contractOpen = true;
this.$message.success(this.$t('contract.j9'));
});
},
indexList() {
Home.indexList().then((res) => {
this.pcBannerList = res.pcBannerList
// setTimeout(() => {
// this.skroll();
// }, 100);
}).catch((res) => {});
},
//
setactiveItem(index=0){
this.accountInfo=this.holdPositionList[index]
},
// 线
getLastHoldPosition(){
let ti = 0,timer=null;
timer = setInterval(()=>{
this.holdPosition();
ti++;
if(ti==3){
clearInterval(timer);
}
}, 1000)
}
}
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.justify-content-between ::v-deep .dark-app .theme-switch .theme-switch-button .left, .justify-content-between ::v-deep .dark-app .theme-switch .theme-switch-button .left, .dark-app .theme-switch .theme-switch-button .right{
.dark-app .theme-switch .theme-switch-button .right { color:white !important
color: white !important }
}
thead th,
table td {
font-size: 14px;
}
tbody tr {
cursor: pointer;
}
.page-top table tbody tr:hover {
background-color: #f8f8ff;
td:first-child {
color: #2C60DC;
}
}
.page-top table tbody tr.active {
background-color: #f8f8ff;
td:first-child {
color: #2C60DC;
}
}
.page-top table tbody td {
border: none;
}
.decreace {
color: #E33F31;
}
.increase {
color: #6EB189;
}
.decreace2 {
color: #BB4965;
}
.text-secondary {
color: #636363 !important;
}
.search_box {
width: 95%;
height: 40px;
margin: 10px auto;
border: 1px solid #D9D9D9;
border-radius: 5px;
color: #2e2e2e;
align-items: center;
i {
width: 40px;
text-align: center;
font-size: 16px;
}
input {
background-color: transparent;
border: none;
border-left: 1px solid #D9D9D9;
padding: 0px 10px;
height: 40px;
font-size: 16px;
color: #fff;
}
}
.min-width-B {
min-width: 130px;
}
</style> </style>
Loading…
Cancel
Save