Browse Source

修改成一个组件

layui
liaoxinyu 2 years ago
parent
commit
53532508ff
  1. 37
      src/components/GqlUsdt.vue
  2. 37
      src/components/OigeUsdt.vue
  3. 17
      src/components/PytnUsdt.vue
  4. 37
      src/components/RpnUsdt.vue
  5. 21
      src/router/index.js
  6. 54
      src/views/HomeView.vue

37
src/components/GqlUsdt.vue

@ -1,37 +0,0 @@
<template>
<div>
<div id="kc-container"></div>
</div>
</template>
<script>
// import $ from 'jquery';
export default {
name: "GqlUsdt",
props: ["title"],
data() {
return {
loadingIndex: null
}
},
mounted() {
this.init()
},
methods: {
init() {
kcStart({
containerId: 'kc-container',
symbol: this.title,
coinScale: parseInt('5'), //
volumeScale: parseInt('5'), //
interval: '15',
timezone: "America/Toronto",
language: 'zh_TW'
})
}
},
};
</script>
<style scoped>
</style>

37
src/components/OigeUsdt.vue

@ -1,37 +0,0 @@
<template>
<div>
<div id="kc-container"></div>
</div>
</template>
<script>
// import $ from 'jquery';
export default {
name: "OigeUsdt",
props: ["title"],
data() {
return {
loadingIndex: null
}
},
mounted() {
this.init()
},
methods: {
init() {
kcStart({
containerId: 'kc-container',
symbol: this.title,
coinScale: parseInt('5'), //
volumeScale: parseInt('5'), //
interval: '15',
timezone: "America/Toronto",
language: 'zh_TW'
})
}
},
};
</script>
<style scoped>
</style>

17
src/components/PytnUsdt.vue

@ -8,7 +8,6 @@
// import $ from 'jquery';
export default {
name: "HelloWorld",
props: ["title"],
data() {
return {
loadingIndex: null
@ -17,14 +16,26 @@
mounted() {
this.init()
},
watch: {
'$route'(to, from) {
// 访tofrom
if(to.query.symbol!=from.query.symbol){
location.reload()
setTimeout(()=>{
this.init()
},1000)
}
}
},
methods: {
init() {
kcStart({
containerId: 'kc-container',
symbol: this.title,
symbol: this.$route.query.symbol,
coinScale: parseInt('5'), //
volumeScale: parseInt('5'), //
interval: '15',
interval: sessionStorage.getItem('interval')|this.$route.query.interval,
timezone: "America/Toronto",
language: 'zh_TW'
})

37
src/components/RpnUsdt.vue

@ -1,37 +0,0 @@
<template>
<div>
<div id="kc-container"></div>
</div>
</template>
<script>
// import $ from 'jquery';
export default {
name: "RpnUsdt",
props: ["title"],
data() {
return {
loadingIndex: null
}
},
mounted() {
this.init()
},
methods: {
init() {
kcStart({
containerId: 'kc-container',
symbol: this.title,
coinScale: parseInt('5'), //
volumeScale: parseInt('5'), //
interval: '15',
timezone: "America/Toronto",
language: 'zh_TW'
})
}
},
};
</script>
<style scoped>
</style>

21
src/router/index.js

@ -7,34 +7,17 @@ Vue.use(VueRouter);
const routes = [
{
path: "",
redirect: "/PytnUsdt",
redirect: "/KlineView",
},
{
path: "/",
// name: "home",
component: HomeView,
children: [
// {
// path: '',
// name: 'PyttnUsdt', // 默认子路由名称
// redirect: 'PyttnUsdt'
// },
{
path: 'PytnUsdt',
path: 'KlineView',
// name: 'PyttnUsdt', // 默认子路由名称
component: () => import("../components/PytnUsdt.vue")
},
{
path: 'OigeUsdt',
component: () => import("../components/OigeUsdt.vue")
},
{
path: 'GqlUsdt',
component: () => import("../components/GqlUsdt.vue")
},
{
path: 'RpnUsdt',
component: () => import("../components/RpnUsdt.vue")
}
]
}

54
src/views/HomeView.vue

@ -61,12 +61,12 @@
import $ from 'jquery';
// import 'layui-src/src/layui.js';
// import 'layui-src/src/css/layui.css';
import PytnUsdt from '@/components/PytnUsdt.vue';
import KlineView from '@/components/PytnUsdt.vue';
// import '../../static/kline/src/klineCharts.js';
export default {
name: "HomeView",
components: {
PytnUsdt
KlineView
},
data() {
return {
@ -78,6 +78,9 @@
return window.innerWidth <= 768; //
}
},
created() {
this.$router.replace({ path: '/KlineView', query: { symbol: this.title, interval: kcCurrentData.interval}});
},
mounted() {
$('.interval_btn').on('click', function() {
if (kcChart != null || kcChart != undefined) {
@ -130,10 +133,10 @@
});
window.addEventListener('resize', this.handleResize);
const title = sessionStorage.getItem('title');
if (!title&&this.$route.path !== '/PytnUsdt') {
this.$router.replace({ path: '/PytnUsdt' });
}
// const title = sessionStorage.getItem('title');
// if (!title&&this.$route.path !== '/KlineView') {
// this.$router.replace({ path: '/KlineView' });
// }
},
destroyed() {
window.removeEventListener('resize', this.handleResize);
@ -147,29 +150,22 @@
handleClick(name) {
this.title = name
sessionStorage.setItem('title',name)
switch (name) {
case 'PYTN':
this.$router.replace({
path: '/PytnUsdt'
});
break;
case 'OIGE':
this.$router.replace({
path: '/OigeUsdt'
});
break;
case 'GQL':
this.$router.replace({
path: '/GqlUsdt'
});
break;
default:
this.$router.replace({
path: '/RpnUsdt'
});
break;
}
sessionStorage.setItem('interval',kcCurrentData.interval)
this.$router.replace({ path: '/KlineView', query: { symbol: this.title, interval: kcCurrentData.interval}});
// switch (name) {
// case 'PYTN':
// break;
// case 'OIGE':
// this.$router.replace({ path: '/KlineView', query: { symbol: this.title, interval: kcCurrentData.interval }});
// break;
// case 'GQL':
// this.$router.replace({ path: '/KlineView', query: { symbol: this.title, interval: kcCurrentData.interval }});
// break;
// default:
// this.$router.replace({ path: '/KlineView', query: { symbol: this.title, interval: kcCurrentData.interval }});
// break;
// }
}
}
};

Loading…
Cancel
Save