Browse Source

修改币币最新价格问题

master
liaoxinyu 7 months ago
parent
commit
c6d77cd50f
  1. 6
      api/serve/index.js
  2. 55
      pages/exchange/open-position.vue

6
api/serve/index.js

@ -82,7 +82,7 @@ x.fn = x.prototype = {
return new Promise((resolve, reject) => {
let reg=new RegExp('/','g')//g代表全部
let newMsg=options.url.replace(reg,'_');
console.info(newMsg)
// console.info(newMsg)
if(Cache.get(newMsg).data){
if(newMsg!='_user_walletImage'&& newMsg!='_user_getAuthInfo' && newMsg!='_user_withdrawalBalance'
&& newMsg!='_wallet_getBalance' && newMsg!='_contract_getMarketInfo'&& newMsg!='_contract_openNum'
@ -100,7 +100,7 @@ x.fn = x.prototype = {
dataType: this.dataType,
sslVerify: false,
success: (res) => {
console.info(res)
// console.info(res)
let message = res.data.message
let code = res.data.code
if (code != 200) {
@ -144,7 +144,7 @@ x.fn = x.prototype = {
}
},
fail: (err) => {
console.log(err)
// console.log(err)
reject(err)
if (config.toast !== false) {
// uni.showToast({

55
pages/exchange/open-position.vue

@ -455,7 +455,7 @@
:max="6"
:contract="1"
>
<view class="fn-lg color-buy" style="color: #C83F64;font-size: 20px;">{{ newPrice.price }}</view>
<view class="fn-lg color-buy" style="color: #C83F64;font-size: 20px;">{{ activeCoin }}</view>
</sell-and-buy>
</view>
</view>
@ -1015,7 +1015,8 @@ export default {
100: '100%',
},
activeStep: 0,
showsStopLoss:false
showsStopLoss:false,
newPrice1:[]
};
},
computed: {
@ -1045,8 +1046,8 @@ export default {
// );
// },
amount() {
console.info(this.form.lever_rate)
console.info(this.margin)
// console.info(this.form.lever_rate)
// console.info(this.margin)
if (!this.form.lever_rate || !this.margin) return 0;
let p = this.margin * this.form.lever_rate;
p = p.toFixed(0)
@ -1070,7 +1071,26 @@ export default {
// #ifdef APP-PLUS
return plus.os.name
// #endif
}
},
activeCoin() {
if (!this.newPrice1.length) return {};
// let list = [];
// this.newPrice1.forEach((parentItem) => {
// parentItem.marketInfoList.forEach((item) => {
// list.push(item);
// });
// });
const targetPair = this.newPrice1?.flatMap(parentItem =>
parentItem.marketInfoList || []
).find(item => item.pair_name === this.query.symbol);
let num = targetPair.pair_name === 'BTC/USDT' ? (+targetPair.price).toFixed(1) : (+targetPair.price).toFixed(3);
this.list.map(item=>{
if(item.symbol==targetPair.symbol) item.realtimePrice = num
})
// console.log(targetPair,'1111');
return num;
},
},
watch: {
maxNum(n) {
@ -1388,6 +1408,7 @@ export default {
// symbol: market||"",
// };
Contract.holdPosition(data, {loading: !boo}).then((res) => {
// console.log(res,'111111');
this.list = res.data.filter((item) => item.hold_position);
this.list.map(item => {
item.unRealProfit = (parseFloat(item.unRealProfit)).toFixed(2)
@ -1452,7 +1473,8 @@ export default {
this.buyList = res.data.swapBuyList;
this.tradeList = res.data.swapTradeList;
this.newPrice = this.tradeList[0] || {};
console.info(this.newPrice)
this.newPrice1 = this.tradeList[0] || {};
// console.info(this.newPrice)
this.form.entrust_price = this.newPrice.price;
this.linkSocket(data.symbol);
});
@ -1484,7 +1506,7 @@ export default {
symbol: this.symbolLeft,
};
Contract.getSymbolDetail(data).then((res) => {
console.info('res.data', res.data.default_lever, res.data.lever_rage)
// console.info('res.data', res.data.default_lever, res.data.lever_rage)
this.unit_amount = res.data.unit_amount;
this.lever_rage = res.data.lever_rage.map((item) => ({
@ -1568,7 +1590,7 @@ export default {
}
Contract.openPosition(data, {btn}).then(() => {
this.$toast(this.$t("contract.g2"));
console.info(this.form.type)
// console.info(this.form.type)
if (this.form.type == 1) {
this.holdPosition()
} else {
@ -1579,14 +1601,14 @@ export default {
});
},
sliderChange(n, i) {
console.info(n, i)
// console.info(n, i)
this.form.amount = Math.round((this.maxNum * n) / 100);
this.sliderActive = i
this.sliderActive1 = n
this.margin = (this.form.amount / this.form.lever_rate).toFixed(2)
},
pingChange(n, i) {
console.log(n)
// console.log(n)
this.pingAmount = Math.round((this.activeItem.avail_position * n) / 100);
this.pingActive = i
},
@ -1608,6 +1630,11 @@ export default {
cmd: "sub",
msg: `swapTradeList_${symbol}`,
});
//
this.ws.send({
cmd: "sub",
msg: `swapMarketList`,
});
},
//
unLink(symbol) {
@ -1626,6 +1653,11 @@ export default {
cmd: "unsub",
msg: `swapTradeList_${symbol}`,
});
//
this.ws.send({
cmd: "unsub",
msg: `swapMarketList`,
});
},
socketMessage() {
//
@ -1651,6 +1683,9 @@ export default {
this.tradeList.pop();
this.newPrice = data;
break;
case `swapMarketList`:
this.newPrice1 = JSON.parse(JSON.stringify(data));
break;
}
});
},

Loading…
Cancel
Save