diff --git a/assets/img/home/illustration_1.png b/assets/img/home/illustration_1.png index c5057a7..c186800 100644 Binary files a/assets/img/home/illustration_1.png and b/assets/img/home/illustration_1.png differ diff --git a/pages/exchange/exchange-transaction.vue b/pages/exchange/exchange-transaction.vue index aeaaa99..2ec9b31 100644 --- a/pages/exchange/exchange-transaction.vue +++ b/pages/exchange/exchange-transaction.vue @@ -194,11 +194,12 @@ - - {{ newPrice.price }} + + {{ Price }} + {{riskRate || "0%"}} @@ -311,7 +310,8 @@ :max="6" :contract="1" > - {{ newPrice.price }} + {{ modifiedPrice }} + @@ -437,17 +437,19 @@ {{ $t("contract.g6") }} - {{item.avg_price}} + + {{avg_price1(item.avg_price)}} {{ $t("first.c5") }} - + + {{ $t("contract.b1") }} - {{item.position_margin}} + {{avg_price1(item.position_margin)}} @@ -464,7 +466,7 @@ {{ $t("contract.a1") }}({{ $t("contract.d8") }}) - {{item.avail_position}} + {{avg_price1(item.avail_position)}} @@ -473,7 +475,9 @@ {{ $t("option.b6") }} - {{item.unRealProfit}} + + {{avg_price1(item.unRealProfit)}} + + {{avg_price1(item.profitRate)}} @@ -921,7 +926,23 @@ export default { // #ifdef APP-PLUS return plus.os.name // #endif - } + }, + modifiedPrice(){ + if (this.newPrice.price) { + let price = this.newPrice.price; + let parts = price.split("."); + parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); + return parts.join(","); + } + }, + riskRate(){ + if (this.accountInfo.riskRate) { + let price = this.accountInfo.riskRate; + let parts = price.split("."); + parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); + return parts.join(","); + } + } }, watch: { maxNum(n) { @@ -1003,6 +1024,22 @@ export default { } }, methods: { + avg_price1(item){ + if (item) { + let price = item.toString(); + let parts = price.split("."); + parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); + return parts.join(","); + } + }, + realtimePrice1(item){ + if (item) { + let price = item; + let parts = price.split("."); + parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); + return parts.join(","); + } + }, onRefresh() { if (this.refreshing) return; this.refreshing = true; @@ -1311,9 +1348,23 @@ 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.usable_balance = (res.data.usable_balance).toFixed(2) + // res.data.account_equity = (parseInt(res.data.account_equity)).toFixed(2) + // res.data.usable_balance = (res.data.usable_balance).toFixed(2) + + res.data.account_equity = (parseInt(res.data.account_equity)).toFixed(2) + var parts1 = res.data.account_equity.split("."); + parts1[0] = parts1[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); + res.data.account_equity = parts1.join(","); + + + res.data.usable_balance = res.data.usable_balance.toFixed(2).toString(); + var parts = res.data.usable_balance.split("."); + parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); + res.data.usable_balance = parts.join(","); + + this.accountInfo = res.data; + console.log(res.data,'12345612'); if (!boo) { // this.form.lever_rate = res.data.lever_rate; if (this.form.lever_rate) { @@ -1470,6 +1521,15 @@ export default { socketMessage() { // 节流防抖 let buyFun = lodash.throttle((data) => { + // data.forEach((item) => { + // let price = item.price.toString(); + // let parts = price.split("."); + // parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); + // item.price = parts.join(","); + // }); + // data.forEach((item) => { + // item.price = (parseFloat(item.price)).toString().replace("." , ","); + // }); this.buyList = data; }, 500); let sellFun = lodash.throttle((data) => { diff --git a/pages/exchange/sell-and-buy.vue b/pages/exchange/sell-and-buy.vue index 52dafdd..f4e767a 100644 --- a/pages/exchange/sell-and-buy.vue +++ b/pages/exchange/sell-and-buy.vue @@ -14,6 +14,7 @@ @click="$emit('price',item.price)" > {{omitTo(item.price,2)}} + {{omitTo(item.price,4)}} {{omitTo(item.price,6)}} {{omitTo(item.amount,2)}} @@ -105,6 +106,14 @@ export default { let max = Math.max(...arr); return math.division(amount, max, 2) * 100; }, + price1(item){ + if (item) { + let price = item.toString(); + let parts = price.split("."); + parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); + return parts.join(","); + } + } }, }; diff --git a/utils/class/math.js b/utils/class/math.js index 4615de1..959d61d 100644 --- a/utils/class/math.js +++ b/utils/class/math.js @@ -90,6 +90,7 @@ function omitTo(val, scale) { // 提取实体集和精度值 let [entity, precisionVal] = val.toString().split("."); + entity = entity.replace(/\B(?=(\d{3})+(?!\d))/g, ","); if (precisionVal.length > scale) { // trunc() 方法会将数字的小数部分去掉,只保留整数部分。 let tmp = scientific2No(Math.trunc(val * Math.pow(10, scale))); @@ -118,11 +119,14 @@ function omitTo(val, scale) { } else { // 补全小数点 - ret = entity + '.' + precisionVal.padEnd(scale, '0'); + ret = entity + ',' + precisionVal.padEnd(scale, '0'); } // 检测整型值 - } else ret = val + '.' + '0'.repeat(scale); + } else { + val = val.replace(/\B(?=(\d{3})+(?!\d))/g, ","); + ret = val + ',' + '0'.repeat(scale); + } // 去除末尾可能产生的多余的. if (ret.toString().endsWith('.')) ret = ret.slice(0, -1);