['设置中心']

This commit is contained in:
2021-09-24 15:11:14 +08:00
parent 08c56ea921
commit 3dc185139c
172 changed files with 13194 additions and 433 deletions

173
pages/index/deal.vue Normal file
View File

@@ -0,0 +1,173 @@
<template>
<view>
<view class="deal-back"></view>
<!-- 区块信息 -->
<view class="block-shadow chian-hash">
<view class="title">区块HASH</view>
<view class="hash">{{info.hash || '-'}}</view>
<view class="button" @click="copyHash">复制</view>
<view class="chian-info">
<view class="item-flex">
<view class="label webkit-box">交易数据</view>
<view class="ellipsis">
{{ info.tx_count || '-' }}
</view>
</view>
<view class="item-flex">
<view class="label webkit-box">区块高度</view>
<view class="ellipsis">
{{ info.height || '-' }}
</view>
</view>
<view class="item-flex">
<view class="label webkit-box">时间</view>
<view class="ellipsis">
{{ info.block_time || '-' }}
</view>
</view>
<view class="item-flex webkit-box">
<view class="label">上一块</view>
<view class="ellipsis">
{{ info.parent_hash || '-' }}
</view>
</view>
<view class="item-flex webkit-box">
<view class="label">区块难度</view>
<view class="ellipsis">
{{ info.difficulty || '-' }}
</view>
</view>
<view class="item-flex webkit-box">
<view class="label">默克尔跟</view>
<view class="ellipsis">
{{ info.tx_hash || '-' }}
</view>
</view>
<view class="item-flex">
<view class="label">状态哈希</view>
<view class="ellipsis">
{{ info.state_hash || '-' }}
</view>
</view>
</view>
</view>
<!-- 交易记录 -->
<view class="deals">
<view class="title">交易记录</view>
<deal-list :list="deal" />
</view>
</view>
</template>
<script>
import { hash } from '@/apis/interfaces/chain'
import dealList from '@/components/chain/deal'
export default {
components:{
dealList
},
data() {
return {
info: {},
deal: [],
}
},
onLoad(e){
// 交易详情
if(e.hash && e.hash != '') hash(e.hash).then(res=>{
this.info = res.head
this.deal = res.trades
}).catch(err => {
uni.showToast({
icon: 'none',
title: '错误 22 line in chain/deal'
})
})
else uni.showToast({
icon: 'none',
title: 'hash值不存在系统错误'
})
},
methods:{
copyHash(){
if(this.info.hash) uni.setClipboardData({
data: this.info.hash
})
}
}
}
</script>
<style lang="scss">
.block-shadow{
box-shadow: 0 0 2rpx 2rpx rgba($color: #000000, $alpha: .02);
}
// 背景
.deal-back {
position: fixed;
top: 0;
left: 0;
z-index: -1;
width: 100vw;
height: 100vh;
background: linear-gradient(to bottom, #009B69, #00562d);
}
// 区块详情
.chian-hash{
margin: $margin + ($margin/2);
background-color: white;
padding: ($padding * 3) ($padding * 2);
border-radius: $radius;
text-align: center;
.title{
font-size: $title-size + 8;
font-weight: bold;
color: $text-color;
}
.hash{
padding: $padding 0 ($padding*2) 0;
word-wrap: break-word;
color: $text-gray;
}
.button{
background-color: $red-color;
width: 50%;
display: inline-block;
height: 90rpx;
line-height: 90rpx;
color: white;
font-size: $title-size;
border-radius: 45rpx;
font-weight: bold;
}
.chian-info{
margin-top: $margin * 2;
background-color: $border-color-lg;
padding: $padding;
.item-flex{
padding-left: 220rpx;
text-align: right;
position: relative;
line-height: 70rpx;
min-height: 70rpx;
.label{
position: absolute;
left: 0;
width: 200rpx;
text-align: left;
color: $text-gray;
}
}
}
}
// 区块交易信息
.deals{
padding: $padding;
.title{
text-align: center;
font-weight: bold;
color: white;
font-size: $title-size;
}
}
</style>

View File

@@ -1,19 +1,484 @@
<template>
<view>
发现能量
<view class="content">
<!-- 水晶获得公告 -->
<view class="notice" v-if="notice.length >= 1">
<swiper class="notice-swiper" :vertical="true" autoplay circular>
<swiper-item v-for="(item, index) in notice" :key="index">
<view class="notice-item">
<image class="notice-cover" :src="item.avatar" mode="aspectFill"></image>
<view class="notice-title ellipsis">{{item.nickname}} {{item.title}} {{item.amount}}</view>
</view>
</swiper-item>
</swiper>
</view>
<!-- 账户余额 -->
<view class="info">
<view class="info-number">
<image class="number-background number-rotate" src="@/static/background/chain-back-01.png" />
<view class="info-content webkit-box">
<view class="text">{{isAuth ? '持有原石量': '恒量发行原石量'}}<uni-icons class="help-icon" @click="showHelp('occ')" type="help-filled" size="18" color="#fff" /></view>
<view class="number">{{occ}}</view>
<view class="login" @click="$Router.push({name: 'Login'})" v-if="!isAuth">立即登录</view>
<view class="login" @click="openWallet" v-else>我的钱包</view>
</view>
</view>
</view>
<!-- 公告信息 -->
<!-- <view class="increase">今日消费100元预计原石单价增长0.1%</view> -->
<!-- 平台概况 -->
<view class="situation">
<view class="header">
<view class="header-item">
<view class="title">平台原石余量<uni-icons class="help-icon" @click="showHelp('occBalance')" type="help-filled" size="18" color="#009b69" /></view>
<view class="number ellipsis">{{ occBalance }}</view>
</view>
<view class="header-item">
<view class="title">昨日瓜分水晶<uni-icons class="help-icon" @click="showHelp('yesterdayCrystal')" type="help-filled" size="18" color="#009b69" /></view>
<view class="number ellipsis">{{ yesterdayCrystal }}</view>
</view>
<view class="header-item">
<view class="title">区块链高度<uni-icons class="help-icon" @click="showHelp('blockHeight')" type="help-filled" size="18" color="#009b69" /></view>
<view class="number ellipsis">{{ blockHeight }}</view>
</view>
<view class="header-item">
<view class="title">平台累计盈利额<uni-icons class="help-icon" @click="showHelp('gain')" type="help-filled" size="18" color="#009b69" /></view>
<view class="number ellipsis">{{ gain }}</view>
</view>
<view class="header-item">
<view class="title">已开通节点数<uni-icons class="help-icon" @click="showHelp('nodeNumber')" type="help-filled" size="18" color="#009b69" /></view>
<view class="number ellipsis">{{ nodeNumber }}</view>
</view>
</view>
<!-- 节点信息 -->
<view class="node-info">
<view class="node-item">
<view class="title">轻节点</view>
<view class="number ellipsis">{{occs.light || '-'}}</view>
</view>
<view class="node-item">
<view class="title">合作节点</view>
<view class="number ellipsis">{{occs.cooperation || '-'}}</view>
</view>
<view class="node-item">
<view class="title">主节点</view>
<view class="number ellipsis">{{occs.main || '-'}}</view>
</view>
<view class="node-item">
<view class="title">超级节点</view>
<view class="number ellipsis">{{occs.super || '-'}}</view>
</view>
<view class="node-item">
<view class="title">运营节点</view>
<view class="number ellipsis">{{occs.operating || '-'}}</view>
</view>
<view class="node-item">
<view class="title">技术节点</view>
<view class="number ellipsis">{{occs.technology || '-'}}</view>
</view>
</view>
<!-- 平台盈利额原石数量 -->
<view class="chart">
<view class="title">平台累计营业额和原石价值走势图</view>
<view class="chart-f2">
<l-f2 ref="chartChange"></l-f2>
</view>
</view>
</view>
</view>
</template>
<script>
import { occ } from '@/apis/interfaces/chain'
import { certified, security } from '@/apis/interfaces/index'
import F2 from '@/uni_modules/lime-f2/components/lime-f2/f2.min.js'
import lF2 from '@/uni_modules/lime-f2/components/lime-f2/'
export default {
components: {
lF2
},
data() {
return {
occs: {},
blockHeight: 0,
occBalance: 0,
occ: 0,
yesterdayCrystal: 0,
gain: 0,
nodeNumber: 0,
notice: [],
isAuth: false,
helpToast: {
occ: '恒量发行原石量',
occBalance: '平台原石量',
yesterdayCrystal: '昨日瓜分水晶',
blockHeight: '区块链高度',
gain: '平台累计盈利额',
nodeNumber: '已开通节点数'
}
};
},
onShow() {
if(this.$store.state.token != '') this.isAuth = true
this.getOcc()
},
methods:{
// 求助信息
showHelp(type) {
uni.showModal({
title: '提示',
content: this.helpToast[type],
showCancel: false
})
},
// 原石钱包
openWallet(){
Promise.all([certified(), security()]).then(res=> {
let certified = res[0],
security = res[1]
if(!certified){
uni.showModal({
title: '提示',
content: '您还为完成个人认证,无法激活您的钱包',
confirmText: '去认证',
confirmColor: '#009B69',
cancelColor: '#666666',
cancelText: '稍后再说',
success: res=> {
if(res.confirm) {
uni.navigateTo({
url: '/pages/certification/personal'
})
}
}
})
return
}
if(!security) {
uni.showModal({
title: '激活提示',
content: '您的钱包未激活,是否立即导出助记词并激活您的钱包?',
confirmText: '去激活',
confirmColor: '#009B69',
cancelColor: '#666666',
cancelText: '稍后再说',
success: res=> {
if(res.confirm) {
uni.navigateTo({
url: '/pages/wallet/add'
})
}
}
})
return
}
uni.navigateTo({
url: '/pages/wallet/property'
})
})
},
// occ信息
getOcc(){
occ().then(res => {
this.occs = res.occs
this.yesterdayCrystal = res.yesterday_crystal
this.occ = res.occ
this.occBalance = res.occ_balance
this.blockHeight = res.block_height
this.gain = res.gain
this.nodeNumber = res.node_number
this.notice = res.notice
if(res.help_toast) this.helpToast = res.help_toast
this.showCartc(res.movements)
}).catch(err => {
console.log(err)
})
},
// 绘制图表
showCartc(data){
// 图表信息
this.$refs.chartChange.init(config => {
config.appendPadding = [10, 15, 10, 15]
const chart = new F2.Chart(config);
chart.source(data, {
date: {
range: [0, 1],
type: 'timeCat',
mask: 'MM-DD'
},
value: {
tickCount: 5
}
});
chart.axis('time', {
line: null,
label: function label(text, index, total) {
const textCfg = {};
if (index === 0) {
textCfg.textAlign = 'left';
} else if (index === total - 1) {
textCfg.textAlign = 'right';
}
return textCfg;
}
});
chart.axis('tem', {
grid: function grid(text) {
if (text === '0%') {
return {
lineDash: null,
lineWidth: 1
};
}
}
});
chart.tooltip({
showCrosshairs: true
});
chart.legend({
position: 'bottom',
offsetY: 0,
offsetX: 30
});
chart.area()
.position('date*value')
.color('name', [ '#009b69', '#9f8052' ])
.shape('smooth')
chart.line()
.position('date*value')
.color('name', [ '#009b69', '#9f8052' ])
.shape('smooth', name=> {
if (name === '预期收益率') {
return 'line';
}
if (name === '实际收益率') {
return 'dash';
}
});
chart.render();
return chart;
})
}
}
}
</script>
<style lang="scss">
<style scoped>
/* 气泡漂浮 */
.number-float{
animation: 4s octfloat infinite;
}
@keyframes octfloat{
0%{
margin-top: 0;
}
50%{
margin-top: 15rpx;
}
100%{
margin-top: 0;
}
}
/* 背景旋转 */
.number-rotate{
animation: 30s octrotate infinite linear;
}
@keyframes octrotate{
from{
transform:rotate(0deg);
}
to{
transform:rotate(360deg);
}
}
</style>
<style lang="scss">
// 背景
.content{
background: $mian-color-deep;
min-height: 100vh;
padding-top: var(--status-bar-height);
box-sizing: border-box;
background-image: url(@/static/background/chain-back-00.png);
background-size: 100%;
background-position: top center;
background-repeat: no-repeat;
}
// 求助icon
.help-icon{
vertical-align: middle;
margin-bottom: 4px;
margin-left: $margin/2;
opacity: .7;
}
// 原石账户
.info{
margin-top: calc(#{$margin * 2} + 60rpx);
padding: var(--status-bar-height) $padding * 2 $padding * 3;
text-align: center;
.info-number{
position: relative;
display: inline-block;
width: 568rpx;
height: 568rpx;
.number-background{
width: 100%;
height: 100%;
}
.info-content{
position: absolute;
top: 12%;
left: 12%;
width: 76%;
height: 76%;
background-image: url(@/static/background/chain-back-02.png);
background-size: cover;
color: white;
.text{
font-size: $title-size-m;
text-shadow: 2rpx 2rpx 0 rgba($color: $mian-color-deep, $alpha: .5);
}
.number{
font-weight: bold;
font-size: $title-size + 8;
line-height: 70rpx;
text-shadow: 2rpx 2rpx 0 rgba($color: $mian-color-deep, $alpha: .5);
}
.login{
margin-top: $margin;
background-color: $mian-color;
display: inline-block;
padding: ( $padding / 2 ) $padding;
font-size: $title-size-m;
border-radius: 30rpx;
border:solid 1rpx $mian-color-deep;
}
}
}
}
// 预计增长
.increase{
margin: 0 ($margin + $margin / 2) ($margin * 2);
background: rgba($color: $mian-color, $alpha: .1);
text-align: center;
height: 80rpx;
line-height: 80rpx;
font-size: $title-size-m;
color: $mian-color;
border-radius: $radius-sm;
padding: 0 $padding;
}
// 公告信息
.notice{
position: fixed;
top: $margin * 2;
left: $margin + $margin / 2;
right: $margin + $margin / 2;
padding-top: var(--status-bar-height);
z-index: 99;
.notice-swiper{
height: 60rpx;
}
.notice-item{
position: relative;
height: 60rpx;
padding-left: 80rpx;
padding-right: $padding * 2;
display: inline-block;
background: rgba($color: $mian-color-deep, $alpha: .3);
border-radius: 30rpx;
box-sizing: border-box;
max-width: 100%;
.notice-cover{
position: absolute;
height: 60rpx;
width: 60rpx;
left: 0;
top: 0;
background-color: $mian-color-deep;
border-radius: 50%;
}
.notice-title{
line-height: 60rpx;
color: white;
font-size: $title-size-m;
}
}
}
// 平台概况
.situation{
margin: 0 ($margin + $margin / 2);
background-image: linear-gradient(to bottom, rgba($color: $mian-color, $alpha: .1), $mian-color-deep);
border-radius: $radius-sm;
padding: $padding;
// 平台统计
.header{
display: flex;
flex-wrap: wrap;
margin-bottom: $margin*2;
.number{
color: white;
font-size: $title-size + 4;
font-weight: bold;
line-height: 90rpx;
}
.title{
color: $mian-color;
font-weight: bold;
font-size: $title-size-sm;
}
.header-item{
width: 50%;
padding: $padding $padding / 2;
box-sizing: border-box;
&:first-child{
width: 100%;
.number{
font-size: $title-size + 10;
}
}
}
}
// 节点信息
.node-info{
display: flex;
flex-wrap: wrap;
margin: 0 -$margin / 2;
.node-item{
background: rgba($color: $mian-color, $alpha: .2);
width: calc(50% - #{$margin});
margin: $margin / 2;
padding: $padding;
box-sizing: border-box;
border-radius: $radius-sm;
}
.number{
font-size: $title-size + 4;
font-weight: bold;
color: white;
}
.title{
font-size: $title-size-m;
font-weight: bold;
color: rgba($color: white, $alpha: .7);
}
}
// 图表
.chart{
background: rgba($color: $mian-color, $alpha: .2);
padding: $padding;
border-radius: $radius-sm;
margin-top: $margin*2;
.title{
text-align: center;
line-height: 80rpx;
color: rgba($color: $mian-color, $alpha: 1.0);
font-size: $title-size-m;
}
.chart-f2{
height: 200px;
}
}
}
</style>

209
pages/index/info.vue Normal file
View File

@@ -0,0 +1,209 @@
<template>
<view>
<!-- 区块信息 -->
<view class="info-back"></view>
<view class="info-list">
<view class="flex" v-for="(item, index) in assetsList" :key="index">
<view class="item-name ellipsis">
<image class="icon" :src="item.icon" mode="widthFix" />
{{ item.name || '-' }}
</view>
<view class="item-label">
<view class="number ellipsis">{{ item.balance || '0.00' }}</view>
<view class="unit ellipsis">{{ item.symbol || '-' }}</view>
</view>
</view>
</view>
<!-- 区块链变化 -->
<view class="movements">
<view class="title">区块链变化</view>
<view class="chart">
<l-f2 ref="chartChange"></l-f2>
</view>
</view>
<!-- 区块记录 -->
<view class="chain-record">
<view class="title">区块记录</view>
<chain-list :list="chainList" @onChain="chainInfo"/>
</view>
<!-- 底部安全区 -->
<view class="ios-bottom"></view>
</view>
</template>
<script>
import { chain, situation } from '@/apis/interfaces/chain'
import chainList from '@/components/chain/chain'
import F2 from '@/uni_modules/lime-f2/components/lime-f2/f2.min.js'
import lF2 from '@/uni_modules/lime-f2/components/lime-f2/'
export default {
components: {
chainList,
lF2
},
data() {
return {
data: [{
time: '2021-08-08 00:00:00',
value: 30
}, {
time: '2021-08-09 00:10:00',
value: 36
}, {
time: '2021-08-10 00:12:00',
value: 38
}, {
time: '2021-08-11 10:32:00',
value: 40
}, {
time: '2021-08-13 12:30:00',
value: 40
}, {
time: '2021-08-14 11:02:00',
value: 41
}, {
time: '2021-08-15 10:02:00',
value: 41
}],
assetsList: [],
chainList: []
};
},
mounted() {
Promise.all([chain(), situation()]).then(res => {
this.chainList = res[0]
this.assetsList = res[1].assets
}).catch(err => {
uni.showToast({
icon: 'none',
title: 'err in chain/info.vue ' + err
})
})
this.$refs.chartChange.init(config => {
const chart = new F2.Chart(config);
chart.source(this.data, {
time: {
type: 'timeCat',
tickCount: 3,
range: [ 0, 1 ]
},
value: {
tickCount: 5,
min: 0
}
});
chart.axis('time', {
label: function label(text, index, total) {
const textCfg = {};
if (index === 0) {
textCfg.textAlign = 'left';
} else if (index === total - 1) {
textCfg.textAlign = 'right';
}
return textCfg;
}
});
chart.tooltip({
showCrosshairs: true
});
chart.area()
.position('time*value')
.color('l(90) 0:#009b69 1:#f7f7f7')
.shape('smooth');
chart.line()
.position('time*value')
.color('l(90) 0:#009b69 1:#f7f7f7')
.shape('smooth');
chart.render();
return chart;
})
},
methods: {
// 区块详情
chainInfo(e){
uni.navigateTo({
url: './deal?hash=' + e.hash
})
}
}
}
</script>
<style lang="scss">
// 背景
.info-back {
position: fixed;
top: 0;
left: 0;
z-index: -1;
width: 100vw;
height: 100vh;
background: linear-gradient(to bottom, #009B69, #00562d);
}
// 区块信息
.info-list {
padding: 0 $padding;
.flex {
margin: $margin * 2 $margin/2;
background-color: white;
border-radius: $radius;
padding: $padding * 2;
box-shadow: 0 0 2rpx 2rpx rgba($color: #000000, $alpha: .02);
display: flex;
justify-content: space-between;
.item-name {
width: 50%;
font-size: $title-size;
.icon {
width: 38rpx;
height: 38rpx;
vertical-align: middle;
margin-bottom: 5rpx;
margin-right: $margin;
}
}
.item-label {
width: 50%;
padding-left: $padding;
text-align: right;
.number {
font-weight: bold;
font-size: $title-size;
}
.unit {
font-size: $title-size-m;
}
}
}
}
// 区块链信息
.chain-record,
.movements {
padding: $padding;
.title {
font-weight: bold;
text-align: center;
color: white;
font-size: $title-size;
padding-bottom: $padding;
}
}
.movements {
.chart {
background-color: white;
margin: $margin/2;
height: 350rpx;
border-radius: $radius;
}
}
</style>

163
pages/index/kline.vue Normal file
View File

@@ -0,0 +1,163 @@
<template>
<view class="kline">
<l-f2 ref="chart"></l-f2>
</view>
</template>
<script>
import F2 from '@/uni_modules/lime-f2/components/lime-f2/f2.min.js'
import lF2 from '@/uni_modules/lime-f2/components/lime-f2/'
export default {
components: {
lF2,
},
data() {
return {
}
},
async mounted() {
let data = await this.getData()
// 绘制K线
this.$refs.chart.init(config => {
data = data.slice(0, 150);
const BASIC_PRICE = 6.95;
data.sort(function(obj1, obj2) {
return obj1.time > obj2.time ? 1 : -1;
});
data.forEach(function(obj) {
obj.range = [obj.start, obj.end, obj.max, obj.min];
obj.trend = obj.start <= obj.end ? 0 : 1;
});
const chart = new F2.Chart(Object.assign(config));
chart.source(data, {
range: {
tickCount: 5,
formatter: function formatter(val) {
return val.toFixed(2);
}
},
time: {
tickCount: 3
}
});
chart.tooltip({
showCrosshairs: true,
showXTip: true,
showYTip: true,
crosshairsType: 'xy',
custom: true,
yTip: function yTip(val) {
return {
text: val.toFixed(2),
fill: '#333',
fontSize: 10
};
},
xTip: {
fill: '#333',
fontSize: 10
},
xTipBackground: {
fill: '#EDF2FE'
},
yTipBackground: {
fill: '#EDF2FE'
},
crosshairsStyle: {
stroke: '#0F8DE8'
}
});
chart.axis('range', {
grid: {
stroke: '#ddd',
lineWidth: 1,
lineDash: null
},
label: {
fill: '#999'
}
});
chart.axis('time', {
label: function label(text, index, total) {
const textCfg = {
fill: '#999'
};
if (index === 0) {
textCfg.textAlign = 'left';
}
if (index === total - 1) {
textCfg.textAlign = 'right';
}
return textCfg;
},
grid: {
lineWidth: 1,
stroke: '#ddd'
}
});
chart.guide().line({
start: ['min', BASIC_PRICE],
end: ['max', BASIC_PRICE],
style: {
lineDash: [8],
stroke: '#F68300'
}
});
chart.guide().text({
position: ['min', BASIC_PRICE],
content: BASIC_PRICE,
style: {
fill: '#808080',
textAlign: 'start',
textBaseline: 'bottom',
fontSize: 10,
fontWeight: 'bold'
},
offsetX: 2
});
chart.guide().rect({
start: ['0%', '0%'],
end: ['100%', '100%'],
style: {
stroke: '#ddd',
lineWidth: 1,
fill: '#fff',
opacity: 1,
fillOpacity: 0
}
});
chart.schema()
.position('time*range')
.color('trend', function(trend) {
return ['#F4333C', '#1CA93D'][trend];
})
.shape('candle');
chart.render();
return chart;
});
},
methods: {
getData() {
// plus.screen.lockOrientation('landscape-primary')
return new Promise((resolve) => {
uni.request({
url: 'https://gw.alipayobjects.com/os/antfincdn/c4ROEPcthk/candle-sticks.json',
success: (res) => {
resolve(res.data)
}
})
})
}
},
onUnload() {
console.log('222')
}
}
</script>
<style lang="scss">
.kline{
}
</style>