4 changed files with 3721 additions and 305 deletions
@ -1,300 +1,568 @@ |
|||||
<template> |
<template> |
||||
<view class="main"> |
<view class="main"> |
||||
<!-- nav --> |
<!-- nav --> |
||||
<navigation>{{ 'BTC/USDT' }}</navigation> |
<navigation>{{ 'BTC/USDT' }}</navigation> |
||||
<!-- 价格百分比 --> |
<!-- 价格百分比 --> |
||||
<view class="header"> |
<view class="header"> |
||||
<view class="top"> |
<view class="top"> |
||||
<!-- 实时价格 --> |
<!-- 实时价格 --> |
||||
<text class="price">34985.93</text> |
<text class="price">34985.93</text> |
||||
<!-- 百分比,根据数据正负判断颜色 --> |
<!-- 百分比,根据数据正负判断颜色 --> |
||||
<text class="percent" :class="{ rise: false }">-15.30%</text> |
<text class="percent" :class="{ rise: false }">-15.30%</text> |
||||
</view> |
</view> |
||||
<view class="bottom"> |
<view class="bottom"> |
||||
<view class="left"> |
<view class="left"> |
||||
<view class="title">{{ i18n.Highest }}</view> |
<view class="title">{{ i18n.Highest }}</view> |
||||
<view class="value">45930.24</view> |
<view class="value">45930.24</view> |
||||
</view> |
</view> |
||||
<view class="center"> |
<view class="center"> |
||||
<view class="title">{{ i18n.Lowest }}</view> |
<view class="title">{{ i18n.Lowest }}</view> |
||||
<view class="value">45930.24</view> |
<view class="value">45930.24</view> |
||||
</view> |
</view> |
||||
<view class="right"> |
<view class="right"> |
||||
<view class="title">{{ i18n.Amount }}</view> |
<view class="title">{{ i18n.Amount }}</view> |
||||
<view class="value">28394893.30943094</view> |
<view class="value">28394893.30943094</view> |
||||
</view> |
</view> |
||||
</view> |
</view> |
||||
</view> |
</view> |
||||
<!-- K线图 --> |
<!-- K线图 --> |
||||
<view class="kline"> |
<view class="kline" id="kline" :kdata="kdata" |
||||
</view> |
:change:kdata="klineE.receive" style="height:1000rpx;color:aliceblue "> |
||||
<!-- 买卖挂牌表 --> |
|
||||
<view class="MarketTrades"> |
</view> |
||||
<view class="headTitle">Market trades</view> |
<!-- 买卖挂牌表 --> |
||||
<view class="table"> |
<view class="MarketTrades"> |
||||
<view class="box"> |
<view class="headTitle">Market trades</view> |
||||
<view class="title"> |
<view class="table"> |
||||
<view class="quantity">{{ i18n.Quantity }}</view> |
<view class="box"> |
||||
<view class="price">{{ i18n.BuyingPrice }}</view> |
<view class="title"> |
||||
</view> |
<view class="quantity">{{ i18n.Quantity }}</view> |
||||
<view class="list"> |
<view class="price">{{ i18n.BuyingPrice }}</view> |
||||
<view class="item" v-for="(item, index) in buyList" :key="index"> |
</view> |
||||
<text class="price">0.87897874</text> |
<view class="list"> |
||||
<text class="num buy">{{ item }}</text> |
<view class="item" v-for="(item, index) in buyList" :key="index"> |
||||
<view class="buybg" :style="`width: ${20 * index}%;`"></view> |
<text class="price">0.87897874</text> |
||||
</view> |
<text class="num buy">{{ item }}</text> |
||||
</view> |
<view class="buybg" :style="`width: ${20 * index}%;`"></view> |
||||
</view> |
</view> |
||||
<view class="box"> |
</view> |
||||
<view class="title"> |
</view> |
||||
<view class="quantity">{{ i18n.Quantity }}</view> |
<view class="box"> |
||||
<view class="price">{{ i18n.SellPrice20 }}</view> |
<view class="title"> |
||||
</view> |
<view class="quantity">{{ i18n.Quantity }}</view> |
||||
<view class="list"> |
<view class="price">{{ i18n.SellPrice20 }}</view> |
||||
<view class="item" v-for="(item, index) in sellList" :key="index"> |
</view> |
||||
<text class="price">0.87897874</text> |
<view class="list"> |
||||
<text class="num sell">{{ item }}</text> |
<view class="item" v-for="(item, index) in sellList" :key="index"> |
||||
<view class="sellbg" :style="`width: ${20 * index}%;`"></view> |
<text class="price">0.87897874</text> |
||||
</view> |
<text class="num sell">{{ item }}</text> |
||||
</view> |
<view class="sellbg" :style="`width: ${20 * index}%;`"></view> |
||||
|
</view> |
||||
</view> |
</view> |
||||
</view> |
|
||||
</view> |
</view> |
||||
|
</view> |
||||
<view class="btn"> |
</view> |
||||
<!-- open按钮 --> |
|
||||
<u-button class="button" color="#00E8A2" throttleTime="500" @click="openBtnClick"> |
<view class="btn"> |
||||
{{ i18n.open }} |
<!-- open按钮 --> |
||||
</u-button> |
<u-button class="button" color="#00E8A2" throttleTime="500" @click="openBtnClick"> |
||||
<!-- close按钮 --> |
{{ i18n.open }} |
||||
<u-button class="button" color="#F4506A" throttleTime="500" @click="closeBtnClick"> |
</u-button> |
||||
{{ i18n.close }} |
<!-- close按钮 --> |
||||
</u-button> |
<u-button class="button" color="#F4506A" throttleTime="500" @click="closeBtnClick"> |
||||
</view> |
{{ i18n.close }} |
||||
|
</u-button> |
||||
</view> |
</view> |
||||
</template> |
|
||||
|
</view> |
||||
|
</template> |
||||
|
|
||||
<script> |
<script> |
||||
export default { |
import ktest from '@/utils/ktest.js' |
||||
name: "trade", |
export default { |
||||
data() { |
name: "trade", |
||||
return { |
components: { ktest }, |
||||
buyList: 7, |
data() { |
||||
sellList: 9, |
return { |
||||
|
buyList: 7, |
||||
}; |
sellList: 9, |
||||
}, |
kdata:[] |
||||
computed: { |
|
||||
i18n() { |
}; |
||||
return this.$t("markets"); |
}, |
||||
}, |
computed: { |
||||
}, |
i18n() { |
||||
onLoad() { |
return this.$t("markets"); |
||||
|
}, |
||||
}, |
}, |
||||
onShow() { }, |
onLoad() { |
||||
methods: { |
this.kdata=this.splitData(ktest.JSON); |
||||
depthChange(e) { |
console.log(this.kdata,1111) |
||||
console.log(e); |
}, |
||||
}, |
onShow() {}, |
||||
goto(page) { |
methods: { |
||||
let url = ''; |
into(){ |
||||
switch (page) { |
|
||||
case 'kLine': |
}, |
||||
url = '/pages/markets/kLine' |
splitData(rawData) { |
||||
break; |
let categoryData = []; |
||||
default: |
let values = []; |
||||
break; |
let volumes = []; |
||||
} |
for (let i = 0; i < rawData.length; i++) { |
||||
uni.navigateTo({ |
categoryData.push(rawData[i].splice(0, 1)[0]); |
||||
url, |
values.push(rawData[i]); |
||||
}); |
volumes.push([i, rawData[i][4], rawData[i][0] > rawData[i][1] ? 1 : -1]); |
||||
} |
} |
||||
|
return { |
||||
}, |
categoryData: categoryData, |
||||
} |
values: values, |
||||
</script> |
volumes: volumes |
||||
|
}; |
||||
<style lang="scss" scoped> |
}, |
||||
.main { |
depthChange(e) { |
||||
|
console.log(e); |
||||
.header { |
}, |
||||
background: #000000; |
goto(page) { |
||||
margin-top: 200rpx; |
let url = ''; |
||||
padding: 0 32rpx; |
switch (page) { |
||||
|
case 'kLine': |
||||
|
url = '/pages/markets/kLine' |
||||
.top { |
break; |
||||
height: 80rpx; |
default: |
||||
border-bottom: 2rpx solid #A1A0A8; |
break; |
||||
|
} |
||||
.price { |
uni.navigateTo({ |
||||
line-height: 80rpx; |
url, |
||||
font-size: 40rpx; |
}); |
||||
} |
} |
||||
|
|
||||
.percent { |
}, |
||||
vertical-align: text-top; |
} |
||||
margin-left: 20rpx; |
</script> |
||||
padding: 8rpx 20rpx; |
<script module="klineE" lang="renderjs"> |
||||
border-radius: 8rpx; |
let kline |
||||
font-size: 24rpx; |
export default { |
||||
background-color: rgba($color: #F26666, $alpha: 0.2); |
mounted() { |
||||
color: #F26666; |
console.log(0); |
||||
|
console.log(window); |
||||
&.rise { |
console.log(typeof window.echarts); |
||||
color: #00E8A2; |
// this.initEcharts(); |
||||
background-color: rgba($color: #00E8A2, $alpha: 0.2); |
if (typeof window.echarts === 'object') { |
||||
} |
//this.initEcharts() |
||||
} |
} else if (typeof window.echarts === 'function') { |
||||
} |
//this.initEcharts() |
||||
|
} else { |
||||
.bottom { |
// console.log(1); |
||||
display: flex; |
// // 动态引入较大类库避免影响页面展示 |
||||
font-size: 24rpx; |
// const script = document.createElement('script'); |
||||
|
// console.log(2); |
||||
.title { |
// //this.kdata=this.splitData(this.kdata); |
||||
margin-top: 24rpx; |
// // view 层的页面运行在 www 根目录,其相对路径相对于 www 计算 |
||||
line-height: 32rpx; |
// script.src = './static/echarts.js'; |
||||
} |
// console.log(3); |
||||
|
// script.onload = this.initEcharts.bind(this); |
||||
.value { |
// console.log(4); |
||||
margin: 24rpx 0; |
// document.head.appendChild(script); |
||||
color: #A1A0A8; |
// console.log(5); |
||||
} |
} |
||||
|
}, |
||||
.left { |
|
||||
flex: 1; |
methods: { |
||||
text-align: left; |
receive(newValue, oldValue, ownerVm, vm) { |
||||
} |
console.log('newValue', newValue) |
||||
|
const script = document.createElement('script'); |
||||
.center { |
// view 层的页面运行在 www 根目录,其相对路径相对于 www 计算 |
||||
flex: 1; |
script.src = './static/echarts.js'; |
||||
text-align: center; |
console.log(3); |
||||
} |
script.onload = this.upData.bind(this); |
||||
|
console.log(4); |
||||
.right { |
document.head.appendChild(script); |
||||
flex: 1; |
|
||||
text-align: right; |
}, |
||||
} |
|
||||
|
calculateMA(dayCount, data) { |
||||
} |
var result = []; |
||||
} |
for (var i = 0, len = data.values.length; i < len; i++) { |
||||
|
if (i < dayCount) { |
||||
.MarketTrades { |
result.push('-'); |
||||
.headTitle { |
continue; |
||||
padding-left: 32rpx; |
} |
||||
font-size: 34rpx; |
var sum = 0; |
||||
height: 80rpx; |
for (var j = 0; j < dayCount; j++) { |
||||
line-height: 80rpx; |
sum += data.values[i - j][1]; |
||||
} |
} |
||||
|
result.push(+(sum / dayCount).toFixed(3)); |
||||
.table { |
} |
||||
display: flex; |
return result; |
||||
font-size: 24rpx; |
}, |
||||
|
upData(myChart){ |
||||
.box { |
const upColor = '#00da3c'; |
||||
flex: 1; |
const downColor = '#ec0000'; |
||||
overflow: hidden; |
var chartDom = document.getElementById('kline'); |
||||
height: 450rpx; |
var myChart = echarts.init(chartDom); |
||||
|
var option; |
||||
.title { |
myChart.setOption( |
||||
display: flex; |
(option = { |
||||
margin-bottom: 16rpx; |
animation: false, |
||||
color: #A1A0A8; |
legend: { |
||||
|
bottom: 10, |
||||
.quantity { |
left: 'center', |
||||
flex: 1; |
data: [] |
||||
} |
}, |
||||
|
tooltip: { |
||||
.price { |
trigger: 'axis', |
||||
flex: 1; |
axisPointer: { |
||||
text-align: center; |
type: 'cross' |
||||
} |
}, |
||||
} |
borderWidth: 1, |
||||
|
borderColor: '#ccc', |
||||
.list { |
padding: 10, |
||||
overflow: hidden; |
textStyle: { |
||||
|
color: '#ffffff' |
||||
.item { |
}, |
||||
position: relative; |
position: function (pos, params, el, elRect, size) { |
||||
width: 100%; |
const obj = { |
||||
height: 50rpx; |
top: 10 |
||||
line-height: 50rpx; |
}; |
||||
display: flex; |
obj[['left', 'right'][+(pos[0] < size.viewSize[0] / 2)]] = 30; |
||||
|
return obj; |
||||
.price { |
} |
||||
display: block; |
// extraCssText: 'width: 170px' |
||||
width: 50%; |
}, |
||||
text-align: left; |
axisPointer: { |
||||
z-index: 1; |
link: [ |
||||
|
{ |
||||
} |
xAxisIndex: 'all' |
||||
|
} |
||||
.num { |
], |
||||
display: block; |
label: { |
||||
width: 50%; |
backgroundColor: '#fff' |
||||
text-align: right; |
} |
||||
padding-right: 32rpx; |
}, |
||||
z-index: 1; |
toolbox: { |
||||
|
feature: { |
||||
&.buy { |
dataZoom: { |
||||
color: #00E8A2; |
yAxisIndex: false |
||||
} |
}, |
||||
|
brush: { |
||||
&.sell { |
type: ['lineX', 'clear'] |
||||
color: #F4506A; |
} |
||||
} |
} |
||||
} |
}, |
||||
|
brush: { |
||||
.buybg { |
xAxisIndex: 'all', |
||||
height: 100%; |
brushLink: 'all', |
||||
position: absolute; |
outOfBrush: { |
||||
top: 0; |
colorAlpha: 0.1 |
||||
left: 0; |
} |
||||
z-index: 0; |
}, |
||||
background: rgba($color: #00E8A2, $alpha: 0.1) |
visualMap: { |
||||
} |
show: false, |
||||
|
seriesIndex: 5, |
||||
.sellbg { |
dimension: 2, |
||||
height: 100%; |
pieces: [ |
||||
position: absolute; |
{ |
||||
top: 0; |
value: 1, |
||||
right: 0; |
color: downColor |
||||
z-index: 0; |
}, |
||||
background: rgba($color: #F4506A, $alpha: 0.1) |
{ |
||||
} |
value: -1, |
||||
|
color: upColor |
||||
} |
} |
||||
} |
] |
||||
} |
}, |
||||
|
grid: [ |
||||
|
{ |
||||
|
left: '10%', |
||||
|
right: '8%', |
||||
} |
height: '50%' |
||||
} |
}, |
||||
|
{ |
||||
.btn { |
left: '10%', |
||||
display: flex; |
right: '8%', |
||||
margin: 96rpx 32rpx; |
top: '63%', |
||||
|
height: '16%' |
||||
.button { |
} |
||||
flex: 1; |
], |
||||
box-sizing: border-box; |
xAxis: [ |
||||
height: 96rpx; |
{ |
||||
border-radius: 16rpx; |
type: 'category', |
||||
font-weight: 700; |
data: this.kdata.categoryData, |
||||
font-size: 28rpx; |
boundaryGap: false, |
||||
color: #15141F !important; |
axisLine: { onZero: false }, |
||||
|
splitLine: { show: false }, |
||||
&:nth-child(2) { |
min: 'dataMin', |
||||
margin-left: 14rpx; |
max: 'dataMax', |
||||
} |
axisPointer: { |
||||
} |
z: 100 |
||||
} |
} |
||||
|
}, |
||||
} |
{ |
||||
|
type: 'category', |
||||
|
gridIndex: 1, |
||||
|
data: this.kdata.categoryData, |
||||
|
boundaryGap: false, |
||||
|
axisLine: { onZero: false }, |
||||
|
axisTick: { show: false }, |
||||
|
splitLine: { show: false }, |
||||
|
axisLabel: { show: false }, |
||||
|
min: 'dataMin', |
||||
|
max: 'dataMax' |
||||
|
} |
||||
|
], |
||||
|
yAxis: [ |
||||
|
{ |
||||
|
scale: true, |
||||
|
splitArea: { |
||||
|
show: true |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
scale: true, |
||||
|
gridIndex: 1, |
||||
|
splitNumber: 2, |
||||
|
axisLabel: { show: false }, |
||||
|
axisLine: { show: false }, |
||||
|
axisTick: { show: false }, |
||||
|
splitLine: { show: false } |
||||
|
} |
||||
|
], |
||||
|
dataZoom: [ |
||||
|
{ |
||||
|
type: 'inside', |
||||
|
xAxisIndex: [0, 1], |
||||
|
start: 98, |
||||
|
end: 100 |
||||
|
}, |
||||
|
{ |
||||
|
show: true, |
||||
|
xAxisIndex: [0, 1], |
||||
|
type: 'slider', |
||||
|
top: '85%', |
||||
|
start: 98, |
||||
|
end: 100 |
||||
|
} |
||||
|
], |
||||
|
series: [ |
||||
|
{ |
||||
|
name: 'Dow-Jones index', |
||||
|
type: 'candlestick', |
||||
|
data: this.kdata.values, |
||||
|
itemStyle: { |
||||
|
color: upColor, |
||||
|
color0: downColor, |
||||
|
borderColor: undefined, |
||||
|
borderColor0: undefined |
||||
|
}, |
||||
|
tooltip: { |
||||
|
formatter: function (param) { |
||||
|
param = param[0]; |
||||
|
return [ |
||||
|
'Date: ' + param.name + '<hr size=1 style="margin: 3px 0">', |
||||
|
'Open: ' + param.data[0] + '<br/>', |
||||
|
'Close: ' + param.data[1] + '<br/>', |
||||
|
'Lowest: ' + param.data[2] + '<br/>', |
||||
|
'Highest: ' + param.data[3] + '<br/>' |
||||
|
].join(''); |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
] |
||||
|
}), |
||||
|
true |
||||
|
); |
||||
|
} |
||||
|
}, |
||||
|
watch: { |
||||
|
// 如果 `question` 发生改变,这个函数就会运行 |
||||
|
columData: function(newQuestion, oldQuestion) { |
||||
|
|
||||
|
// this.updateEcharts(this.option) |
||||
|
} |
||||
|
}, |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.main { |
||||
|
|
||||
|
.header { |
||||
|
background: #000000; |
||||
|
margin-top: 200rpx; |
||||
|
padding: 0 32rpx; |
||||
|
|
||||
|
|
||||
|
.top { |
||||
|
height: 80rpx; |
||||
|
border-bottom: 2rpx solid #A1A0A8; |
||||
|
|
||||
|
.price { |
||||
|
line-height: 80rpx; |
||||
|
font-size: 40rpx; |
||||
|
} |
||||
|
|
||||
|
.percent { |
||||
|
vertical-align: text-top; |
||||
|
margin-left: 20rpx; |
||||
|
padding: 8rpx 20rpx; |
||||
|
border-radius: 8rpx; |
||||
|
font-size: 24rpx; |
||||
|
background-color: rgba($color: #F26666, $alpha: 0.2); |
||||
|
color: #F26666; |
||||
|
|
||||
|
&.rise { |
||||
|
color: #00E8A2; |
||||
|
background-color: rgba($color: #00E8A2, $alpha: 0.2); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.bottom { |
||||
|
display: flex; |
||||
|
font-size: 24rpx; |
||||
|
|
||||
|
.title { |
||||
|
margin-top: 24rpx; |
||||
|
line-height: 32rpx; |
||||
|
} |
||||
|
|
||||
|
.value { |
||||
|
margin: 24rpx 0; |
||||
|
color: #A1A0A8; |
||||
|
} |
||||
|
|
||||
|
.left { |
||||
|
flex: 1; |
||||
|
text-align: left; |
||||
|
} |
||||
|
|
||||
|
.center { |
||||
|
flex: 1; |
||||
|
text-align: center; |
||||
|
} |
||||
|
|
||||
|
.right { |
||||
|
flex: 1; |
||||
|
text-align: right; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.MarketTrades { |
||||
|
.headTitle { |
||||
|
padding-left: 32rpx; |
||||
|
font-size: 34rpx; |
||||
|
height: 80rpx; |
||||
|
line-height: 80rpx; |
||||
|
} |
||||
|
|
||||
|
.table { |
||||
|
display: flex; |
||||
|
font-size: 24rpx; |
||||
|
|
||||
|
.box { |
||||
|
flex: 1; |
||||
|
overflow: hidden; |
||||
|
height: 450rpx; |
||||
|
|
||||
|
.title { |
||||
|
display: flex; |
||||
|
margin-bottom: 16rpx; |
||||
|
color: #A1A0A8; |
||||
|
|
||||
|
.quantity { |
||||
|
flex: 1; |
||||
|
} |
||||
|
|
||||
|
.price { |
||||
|
flex: 1; |
||||
|
text-align: center; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.list { |
||||
|
overflow: hidden; |
||||
|
|
||||
|
.item { |
||||
|
position: relative; |
||||
|
width: 100%; |
||||
|
height: 50rpx; |
||||
|
line-height: 50rpx; |
||||
|
display: flex; |
||||
|
|
||||
|
.price { |
||||
|
display: block; |
||||
|
width: 50%; |
||||
|
text-align: left; |
||||
|
z-index: 1; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
.num { |
||||
|
display: block; |
||||
|
width: 50%; |
||||
|
text-align: right; |
||||
|
padding-right: 32rpx; |
||||
|
z-index: 1; |
||||
|
|
||||
|
&.buy { |
||||
|
color: #00E8A2; |
||||
|
} |
||||
|
|
||||
|
&.sell { |
||||
|
color: #F4506A; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.buybg { |
||||
|
height: 100%; |
||||
|
position: absolute; |
||||
|
top: 0; |
||||
|
left: 0; |
||||
|
z-index: 0; |
||||
|
background: rgba($color: #00E8A2, $alpha: 0.1) |
||||
|
} |
||||
|
|
||||
|
.sellbg { |
||||
|
height: 100%; |
||||
|
position: absolute; |
||||
|
top: 0; |
||||
|
right: 0; |
||||
|
z-index: 0; |
||||
|
background: rgba($color: #F4506A, $alpha: 0.1) |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
.btn { |
||||
|
display: flex; |
||||
|
margin: 96rpx 32rpx; |
||||
|
|
||||
|
.button { |
||||
|
flex: 1; |
||||
|
box-sizing: border-box; |
||||
|
height: 96rpx; |
||||
|
border-radius: 16rpx; |
||||
|
font-weight: 700; |
||||
|
font-size: 28rpx; |
||||
|
color: #15141F !important; |
||||
|
|
||||
|
&:nth-child(2) { |
||||
|
margin-left: 14rpx; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
</style> |
</style> |
||||
|
File diff suppressed because it is too large
Loading…
Reference in new issue