Commit acc12d13 by zhanghui1

dashboard相关修改未完

parent cdd10fb4
import Vue from 'vue';
import Vuex from 'vuex';
Vue.filter('date422', function(value) {
Vue.filter('date422', function (value) {
if (!value) { return '' }
value = value.toString()
return value.slice(0, 4) + '-' + value.slice(4, 6) + '-' + value.slice(6, 8);
})
Vue.filter('uppercase', function(value) {
Vue.filter('uppercase', function (value) {
if (!value) { return '' }
value = value.toString()
return value.toUpperCase();
})
Vue.filter('lowercase', function(value) {
Vue.filter('lowercase', function (value) {
if (!value) { return '' }
value = value.toString()
return value.toLowerCase();
})
Vue.filter('formatPercent', function(value) {
Vue.filter('formatPercent', function (value) {
if (value == 0) {
return '--'
};
return (value * 100).toFixed(2) + "%"
})
Vue.filter('formatPercent2', function(value) {
Vue.filter('formatPercent2', function (value) {
return (value * 100).toFixed(2) + "%"
})
Vue.filter('formatStar', function(str) {
Vue.filter('formatStar', function (str) {
return str.slice(0, 3) + "******" + str.slice(str.length - 3, str.length);
})
Vue.filter('formatDate', function(time) {
Vue.filter('formatDate', function (time) {
var date = new Date(time * 1000);
return formatDate(date, "yyyy-MM-dd hh:mm");
})
Vue.filter('formatDate2', function(time) {
Vue.filter('formatDate2', function (time) {
if (!time) return '';
var date = parseInt((new Date().getTime()) / 1000 - time);
if (localStorage.getItem('language') == 'zh-cn') {
......@@ -77,6 +77,11 @@ Vue.filter('formatDate2', function(time) {
}
})
Vue.filter('formatDate3', function (time) {
var date = new Date(time * 1000);
return formatDate(date, "yyyy-MM-dd hh:mm:ss");
})
function formatDate(date, fmt) {
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
......@@ -181,12 +186,12 @@ export default {
* @return {[type]} [description]
*/
getSubAccountById(puid) {
return new Promise(function(relsove, reject) {
return new Promise(function (relsove, reject) {
if (!$store.state.SubAccount) $store.state.SubAccount = {};
if ($store.state.SubAccount['SubAccount' + puid]) {
relsove($store.state.SubAccount['SubAccount' + puid])
} else {
$axios($store.state.common_url + "/subaccount/" + puid).then(function(res) {
$axios($store.state.common_url + "/subaccount/" + puid).then(function (res) {
$store.state.SubAccount['SubAccount' + puid] = res;
relsove($store.state.SubAccount['SubAccount' + puid])
})
......@@ -238,8 +243,22 @@ export default {
*/
getAllRegions() {
//console.log("getAllRegions")
// return new Promise((resolve, reject) => {
// resolve($store.state.init_url.regions)
// })
let coin_type = localStorage.getItem('coin_type');
let regions = [];
let obj = {};
return new Promise((resolve, reject) => {
resolve($store.state.init_url.regions)
_.each($store.state.init_url.regions, function (v, k) {
_.each(v.supported_coin_types, function (v1, k1) {
if (v1.coin_type == coin_type) {
obj = { region_id: v.region_id, text_en: v.text_en, 'text_zh-cn': v['text_zh-cn'] }
regions.push(obj)
}
})
});
resolve(regions);
})
},
/**
......@@ -253,7 +272,7 @@ export default {
//console.log("getRegionInfo")
return new Promise((resolve, reject) => {
let cur_region;
_.each($store.state.init_url.regions, function(v, k) {
_.each($store.state.init_url.regions, function (v, k) {
if (v.region_id == region_id) {
cur_region = v;
}
......@@ -295,8 +314,8 @@ export default {
getZonglanList(url, cointype) {
//console.log("getZonglanList")
let list = [];
_.each(url.regions, function(v, i) {
_.each(v.supported_coin_types, function(v1, i1) {
_.each(url.regions, function (v, i) {
_.each(v.supported_coin_types, function (v1, i1) {
if (v1.coin_type == cointype) {
list.push({ 'region_id': v.region_id, 'text_en': v.text_en, 'text_zh-cn': v['text_zh-cn'], 'coin_type': cointype, 'api_base_url': v1.api_base_url, 'coins': url.coins[cointype] })
}
......@@ -317,9 +336,9 @@ export default {
// console.log("getApiBaseUrl")
return new Promise((resolve, reject) => {
let api_base_url = '';
_.each($store.state.init_url.regions, function(v, k) {
_.each($store.state.init_url.regions, function (v, k) {
if (v.region_id == region_id) {
_.each(v.supported_coin_types, function(v1, k1) {
_.each(v.supported_coin_types, function (v1, k1) {
if (v1.coin_type == cointype) {
api_base_url = v1.api_base_url;
}
......@@ -399,7 +418,7 @@ export default {
getPaymentHistoryReason(tableData) {
//console.log("getPaymentHistoryReason")
let reason = [];
_.each(tableData, function(v, i) {
_.each(tableData, function (v, i) {
if (v.payment_status == 'DELAYED') {
if (v.unpaid_reason.code == 'ERR_EMPTY_ADDRESS') {
if (localStorage.getItem("language") == "zh-cn") reason.push('未设定收款地址')
......@@ -554,9 +573,9 @@ export default {
*/
getRegionCoins(region_id) {
let arr_coins = [];
_.map($store.state.init_url.regions, function(v, i, o) {
_.map($store.state.init_url.regions, function (v, i, o) {
if (v.region_id == region_id) {
_.map(v.supported_coin_types, function(v1, i1, o1) {
_.map(v.supported_coin_types, function (v1, i1, o1) {
arr_coins.push(v1.coin_type)
})
}
......@@ -586,9 +605,9 @@ export default {
getStratumUrl(region_id, coin_type) {
return new Promise((resolve, reject) => {
let stratum_url = '';
_.each($store.state.init_url.regions, function(v, k) {
_.each($store.state.init_url.regions, function (v, k) {
if (v.region_id == region_id) {
_.each(v.supported_coin_types, function(v1, k1) {
_.each(v.supported_coin_types, function (v1, k1) {
if (v1.coin_type == coin_type) {
stratum_url = v1.stratum_url;
}
......@@ -611,8 +630,8 @@ export default {
let data = [];
return new Promise((resolve, reject) => {
let stratum_url = '';
_.each($store.state.init_url.regions, function(v, k) {
_.each(v.supported_coin_types, function(v1, k1) {
_.each($store.state.init_url.regions, function (v, k) {
_.each(v.supported_coin_types, function (v1, k1) {
if (v1.coin_type == coin_type) {
data.push({ region_id: v.region_id, text_en: v.text_en, 'text_zh-cn': v['text_zh-cn'], coin_info: v1 })
}
......@@ -633,23 +652,62 @@ export default {
return $axios($store.state.common_url + "/subaccount/summary?puid=" + puid + "&coin_type=" + coin_type)
},
/**
* [getApiBaseUrls 根据币种获取到所有节点的api_base_url]
* [getAllRegionByCoin 根据币种获取到所有节点所支持的所有节点]
* @Author Zhanghui
* @DateTime 2017-12-27
* @param {[type]} coin_type [description]
* @return {[type]} [description]
*/
getApiBaseUrls(coin_type) {
let apiBaseUrls = [];
getAllRegionByCoin(coin_type) {
let regions = [];
let obj = {};
return new Promise((resolve, reject) => {
_.each($store.state.init_url.regions, function(v, k) {
_.each(v.supported_coin_types, function(v1, k1) {
_.each($store.state.init_url.regions, function (v, k) {
_.each(v.supported_coin_types, function (v1, k1) {
if (v1.coin_type == coin_type) {
apiBaseUrls.push(v1.api_base_url)
obj = { region_id: v.region_id, text_en: v.text_en, 'text_zh-cn': v['text_zh-cn'] }
regions.push(obj)
}
})
});
resolve(apiBaseUrls);
resolve(regions);
})
},
/**
* 创建 token
*/
createToken(puid, params) {
return $axios.post($store.state.common_url + '/watcher/token/create?puid=' + puid, params)
},
/**
* 列出 token
*/
listToken(puid, coin) {
return $axios($store.state.common_url + '/watcher/token?puid=' + puid + '&coin_type=' + coin)
},
/**
* 获取 token 详情
*/
getTokenInfo(token) {
return $axios($store.state.common_url + '/watcher/token/info?token=' + token)
},
/**
* 移除 token
*/
delToken(puid, params) {
return $axios.post($store.state.common_url + '/watcher/token/delete?puid=' + puid, params)
},
/**
* 获取所支持币种
*/
getCoinsOnly(obj) {
let arr_coins = [];
_.map(obj.regions, function (v, i, o) {
_.map(v.supported_coin_types, function (v1, i1, o1) {
arr_coins.push(v1.coin_type)
})
});
return _.uniq(arr_coins)
}
}
<template>
<div class="my-popup">
<ul>
<li class="list-coin" v-for="(cur_coin,index) in $store.state['cur_coins']" :key="cur_coin" @click="coinAcitve(cur_coin,index)" :class="{active:coin==cur_coin}">
<b :class="cur_coin">{{cur_coin|uppercase}}</b>
<i class="iconfont icon-dui"></i>
</li>
</ul>
<ul>
<li class="list-coin" v-for="cur_coin in $store.state['cur_coins']" :key="cur_coin" @click="coinAcitve(cur_coin)" :class="cur_coin==coin_type?'active':''">
<b :class="cur_coin">{{cur_coin|uppercase}}{{$store.state.init_url.coins[cur_coin]['text_zh-cn']}}</b>
<i class="iconfont icon-dui"></i>
</li>
</ul>
</div>
</template>
<script>
export default {
name:'coin',
props: ['coin'],
data(){
return {
}
},
methods: {
coinAcitve(info,index){
this.$emit('childCoin',info)
},
}
export default {
name: 'coin',
data() {
return {
puid: this.$route.params.puid,
coin_type: this.$route.params.coin_type,
region_id: this.$route.params.region_id,
language: localStorage.getItem('language'),
}
},
methods: {
coinAcitve(cur_coin) {
this.$emit('childCoin', cur_coin)
this.$store.commit('setCoinType', cur_coin)
this.coin_type=cur_coin
}
}
}
</script>
<template>
<div class="page dashboard">
<div class="page-header" :class="hasZIndex==true?'zIndexAuto':''" flex="main:justify cross:center">
<div class="side" @click="getSide"><i class="iconfont icon-mulu"></i></div>
<div class="title" @click="getRegion">{{account_name}} - {{region_name}}<i class="iconfont icon-down"></i></div>
<div class="btn-choose-coin" @click="getCoin"><span :class="coin_type"></span><i class="iconfont icon-down"></i></div>
</div>
<div class="page-content">
<!-- 切换币种 -->
<mt-popup v-model="showCoin" position="top" class='top show-top'>
<coin v-on:childCoin="fromCoin"></coin>
</mt-popup>
<!-- 切换区域 -->
<mt-popup v-model="showRegion" position="top" class='top show-top'>
<region v-on:childRegion="fromRegion"></region>
</mt-popup>
<!-- 切换子账户 -->
<mt-popup v-model="showSide" position="left" class="left show-left">
<subaccount v-on:childSubAccount="fromSubAccount"></subaccount>
</mt-popup>
<div>
无节点,无算力页
</div>
</div>
<tabbar></tabbar>
</div>
</template>
<script>
import fn from "@/assets/js/function.js";
import coin from "@/components/Dashboard/coin";
import region from "@/components/Dashboard/region";
import subaccount from "@/components/Dashboard/subaccount";
import animatedNum from "@/components/Common/AnimatedNum";
import dashboardChart from "@/components/Dashboard/dashboardChart.vue";
import tabbar from "@/components/Common/Tabbar.vue";
export default {
name: "no",
components: {
coin,
region,
subaccount,
animatedNum,
dashboardChart,
tabbar
},
data() {
return {
puid: '',
coin_type: '',
region_id: '',
language: '',
hasZIndex: false, //侧栏滑出的zindex调整
showCoin: false,
showRegion: false,
showSide: false,
regions: [], //当前币种对应的支持节点(子组件下拉区域)
cur_region: {
"region_id": "",
"text_en": "",
"text_zh-cn": "",
},
region_name: '', //中英文切换对应的text_en/text_zh-cn
account_name: '', //当前帐户对应的名字
demoData: [{
region_id: '',
text_en: "",
"text_zh-cn": "",
coin_info: {
"coin_type": "",
"stratum_url": [],
"api_base_url": "",
"merge_mining_coins": [{
"coin_type": ""
}]
}
}],
};
},
mounted() {
this.pageInit();
},
methods: {
pageInitInterval() {
let self = this;
clearInterval(window.dingshiqi)
self.pageInit();
window.dingshiqi = setInterval(function() {
self.pageInit();
}, $store.state.refresh_time)
},
pageInit() {
let self = this;
this.puid = this.$route.params.puid || localStorage.getItem('puid'); //相关路由参数
this.coin_type = this.$route.params.coin_type || localStorage.getItem('coin_type');
this.region_id = this.$route.params.region_id || localStorage.getItem('region_id');
this.language = localStorage.getItem('language');
//获取userName
fn.getSubAccountById(this.puid).then(res => {
if (res.data.err_no == 0) {
this.account_name = res.data.data.name;
}
});
//获取当前节点信息
fn.getRegionInfo(this.region_id).then(res => {
if (this.language == 'zh-cn') {
this.region_name = res['text_zh-cn'];
}
if (this.language == 'en') {
this.region_name = res['text_en'];
}
});
//获取支持当前币种的节点信息和当前币种信息
fn.getStratumUrls(this.coin_type).then(res => {
self.demoData = res;
});
},
getSide() {
this.hasZIndex = true;
this.showSide = !this.showSide;
this.showRegion = false;
this.showCoin = false;
},
getRegion() {
this.hasZIndex = false;
this.showRegion = !this.showRegion;
this.showCoin = false;
this.showSide = false;
},
getCoin() {
this.hasZIndex = false;
this.showCoin = !this.showCoin;
this.showRegion = false;
this.showSide = false;
},
fromSubAccount(obj) {
this.$store.commit('setPuid', obj.puid)
this.$store.commit('setCoinType', obj.default_coin_type)
this.showSide = false;
this.$route.params.puid = obj.puid;
this.$route.params.coin_type = obj.default_coin_type;
this.$router.replace({
name: 'dashboard',
params: this.$route.params
})
},
fromRegion(msg) {
this.$store.commit('setRegionId', msg)
this.showRegion = false;
this.$route.params.region_id = msg;
this.$router.replace({
name: 'dashboard',
params: this.$route.params
})
},
fromCoin(msg) {
this.$store.commit('setCoinType', msg)
this.showCoin = false;
this.$route.params.coin_type = msg;
this.$router.replace({
name: 'dashboard',
params: this.$route.params
})
},
},
watch: {
'$route' (to, from) {
this.pageInit();
},
}
};
</script>
<template>
<div class="my-popup">
<ul>
<li v-for="(items, index) in regionDate" :key="items.text" :class="{active:region==items.text}" v-on:click="regionAcitve(items, index)" >
<span>{{items.text}}</span>
<li v-for="(region, index) in regions" :key="region.region_id" :class="region_id==region.region_id?'active':''" v-on:click="regionAcitve(region, index)">
<span>{{region['text_zh-cn']}}</span>
<i class="iconfont icon-dui"></i>
</li>
</ul>
</div>
</template>
<script>
import fn from '@/assets/js/function.js'
export default {
name: 'region',
props: ['region'],
data() {
return {
regionDate: [{
text: '南方电信'
}, {
text: '北方联通'
}, {
text: '美国旧金山'
}, {
text: '德国法兰克福'
}],
puid: this.$route.params.puid,
coin_type: this.$route.params.coin_type,
region_id: this.$route.params.region_id,
language: localStorage.getItem('language'),
regions: []
}
},
mounted() {
this.getAllRegionByCoin()
},
methods: {
regionAcitve(items, index) {
this.$emit('childRegion', items.text)
getAllRegionByCoin() {
let coin_type=this.$route.params.coin_type;
fn.getAllRegionByCoin(coin_type).then(res => {
this.regions = res;
})
},
regionAcitve(regionObj, index) {
this.$emit('childRegion', regionObj.region_id);
this.region_id=regionObj.region_id;
}
},
watch: {
'$route' (to, from) {
console.log("region.vue watch")
this.getAllRegionByCoin()
}
}
}
......
......@@ -7,9 +7,9 @@
<h2>选择子账户</h2>
</div>
<div class="list-item">
<div class="list" v-for="(items, index) in subaccountDate" :key="items" @click="subaccountActive(items, index)" :class="index==i?'active':''">
<span>{{items}}</span>
<i v-show="index == i" class="iconfont icon-dui"></i>
<div class="list" v-for="subaccount in subaccountList" :key="subaccount.puid" @click="subaccountActive(subaccount)" :class="subaccount.puid==puid?'active':''">
<span>{{subaccount.name}}</span>
<i v-show="puid == subaccount.puid" class="iconfont icon-dui"></i>
</div>
<div class="subAdd" @click="goCreate">
<b class="iconfont icon-jiantou"></b>创建子账户
......@@ -17,56 +17,158 @@
</div>
</div>
</template>
<script>
import fn from '@/assets/js/function.js'
export default {
name: 'subaccount',
data() {
return {
infoUser: 'xuzhiyuan@163.com',
subaccountDate: ['wakuang1', 'wakuang2', 'wakuang3', 'wakuang4'],
i: 0
puid: this.$route.params.puid,
coin_type: this.$route.params.coin_type,
region_id: this.$route.params.region_id,
language: localStorage.getItem('language'),
subaccountList: [],
cur_account_info:{},
}
},
mounted() {
this.getSubAccount();
this.getSubAccountById();
},
methods: {
subaccountActive(items, index) {
this.i = index
console.log(items)
subaccountActive(obj) {
this.puid = obj.puid
this.$emit('childSubAccount', obj)
},
goCreate(){
goCreate() {
this.$router.replace('/create')
},
getSubAccount() {
fn.getSubAccount().then(res => {
if (res.data.err_no == 0) {
this.subaccountList = res.data.data
} else {
alert("接口错误!")
}
})
},
getSubAccountById(){
fn.getSubAccountById(this.puid).then(res=>{
if(res.data.err_no==0){
this.cur_account_info=res.data.data
}else{
alert("错误")
}
})
}
}
}
</script>
<style lang="less">
//仿原生线
.line(){
&.xb{left: 0; right: 0;height: 1px;width: 100%; background: #ccc;content: '';position: absolute;bottom:0;transform: scaleY(0.33) translateY(1px);}
.line() {
&.xb {
left: 0;
right: 0;
height: 1px;
width: 100%;
background: #ccc;
content: '';
position: absolute;
bottom: 0;
transform: scaleY(0.33) translateY(1px);
}
}
.show-left,
.subaccount {
width: 5.9rem;
background-color: #fff;
}
.show-left {
height: 100%;
}
.show-left,.subaccount{width:5.9rem;background-color: #fff;}
.show-left{height: 100%;}
.subaccount{height: 100%;
.subtop{position: fixed;margin:auto;top: 0;left: 0;right: 0;height: .88rem;z-index: 999;}
.logo{height: 2rem;padding:1.1rem .30rem 0;line-height: .9rem;background-color: #103f73;color: #Fff;box-sizing: border-box;font-size: .32rem;
i{font-size: .50rem;color: #Fff;float: right;}
.subaccount {
height: 100%;
.subtop {
position: fixed;
margin: auto;
top: 0;
left: 0;
right: 0;
height: .88rem;
z-index: 999;
}
.logo {
height: 2rem;
padding: 1.1rem .30rem 0;
line-height: .9rem;
background-color: #103f73;
color: #Fff;
box-sizing: border-box;
font-size: .32rem;
i {
font-size: .50rem;
color: #Fff;
float: right;
}
}
h2 {
padding: .20rem .30rem 0;
font-size: .28rem;
color: #727272;
line-height: .68rem;
background: #ededf2;
}
h2{padding:.20rem .30rem 0;font-size: .28rem;color: #727272;line-height: .68rem;background: #ededf2;}
.list-item{padding-top:2.88rem;box-sizing: border-box;height: 100%;overflow: auto;
.list{line-height: .90rem;height: .90rem;position: relative;padding: 0 .30rem;
&:after{.line.xb;}
i{font-size: .50rem;color: #1c5fa9;float: right;}
&.active{color: #1c5fa9;}
&:active{background-color: #e6e6e6;}
.list-item {
padding-top: 2.88rem;
box-sizing: border-box;
height: 100%;
overflow: auto;
.list {
line-height: .90rem;
height: .90rem;
position: relative;
padding: 0 .30rem;
&:after {
.line.xb;
}
i {
font-size: .50rem;
color: #1c5fa9;
float: right;
}
&.active {
color: #1c5fa9;
}
&:active {
background-color: #e6e6e6;
}
}
}
.subAdd{text-align: center;font-size: .32rem;color:#1c5fa9;line-height: .90rem;height: .90rem;position: relative;
b{font-size: .40rem;font-weight: 400;}
&:after{.line.xb;}
&:active{background-color: #e6e6e6;}
.subAdd {
text-align: center;
font-size: .32rem;
color: #1c5fa9;
line-height: .90rem;
height: .90rem;
position: relative;
b {
font-size: .40rem;
font-weight: 400;
}
&:after {
.line.xb;
}
&:active {
background-color: #e6e6e6;
}
}
}
</style>
</style>
......@@ -7,36 +7,36 @@
<router-link to="/create">1.跳转到新建子账户页</router-link>
</li>
<!-- <li>
<router-link to="/subaccount">2.跳转到账户列表</router-link>
</li> -->
<router-link to="/subaccount">2.跳转到账户列表</router-link>
</li> -->
<li>
<router-link to="/welcome">2.跳转到欢迎页,即列表页精简版</router-link>
</li>
<li @click="goDashboard" style="cursor:pointer">3.跳转到子账户面板</li>
<li>
<router-link to="/my/7/ltc/shenzhen/dashboard">4.跳入用户面板页面</router-link>
</li>
<router-link to="/my/7/ltc/shenzhen/dashboard">4.跳入用户面板页面</router-link>
</li>
</ul>
</div>
</template>
<script>
export default {
name: 'jump',
data() {
return {
msg: '判断跳转中...'
}
},
mounted() {},
methods: {
goDashboard() {
this.$router.replace("/my/puid/coin_type/region_id/dashboard")
export default {
name: 'jump',
data() {
return {
msg: '判断跳转中...',
}
},
mounted() {},
methods: {
goDashboard() {
this.$router.replace("/my/78/" + localStorage.getItem('coin_type') + "/" + localStorage.getItem('region_id') + "/dashboard")
}
}
}
}
</script>
<style>
<style scoped>
li {
margin-top: 20px;
}
</style>
......@@ -37,7 +37,7 @@ axios.interceptors.request.use(config => {
function checkToken() {
return new Promise((resolve, reject) => {
resolve("eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IlEwTTBNRUl4UVRVME5qazJNa0ZFT0RCRk56WkJNVGc0TmtFd09UWkNOakZGTlRFMFEwVTJOdyJ9.eyJpc3MiOiJodHRwczovL2Jsb2NraW4uYXV0aDAuY29tLyIsInN1YiI6ImF1dGgwfDU5ZjE3OTc5ZDljMGM1MzZiZjRhMzVjMSIsImF1ZCI6WyJodHRwczovL3d3dy5wb29saW4uY29tL2FwaSIsImh0dHBzOi8vYmxvY2tpbi5hdXRoMC5jb20vdXNlcmluZm8iXSwiaWF0IjoxNTE2NzYzNTQ4LCJleHAiOjE1MTY3NzA3NDgsImF6cCI6IkZhczI5dWJNNW52NElFMlZUQ3ZEWU5iaWtIeTF0bDBkIiwic2NvcGUiOiJvcGVuaWQgcHJvZmlsZSByZWFkIHdyaXRlIn0.szk9htUCmgk43W5kPVcIQiMZxmVSCdKsoPwYjGp63elPdfu7DrUxWY8xLFbSZ-4ynTlH9z8jEEH_mGgtVDP-00TDqO3aXQRjqr2PSfl6wYp3YWXTK1eBIb3khJbPT0MCgFidm3KJJrZXbvs5JdEEWK1uATrro0F7c_DKHG19KluIkJpYobEYcCanCvHbxAIISQKAIBJ9Fjj0FmAABSoe0N_U1qaXVS6HDMQKVVWHymAmVDE0agO2SvW7f6_mYYX17Nyt0zhxJ41tl5GRZANpr4agXYS27QnjwHkRgLWeWZ0ZHBDJHy_GA2ZapuKVltm5EHszlrYLWzYILSsSNfpFoA");
resolve("eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IlEwTTBNRUl4UVRVME5qazJNa0ZFT0RCRk56WkJNVGc0TmtFd09UWkNOakZGTlRFMFEwVTJOdyJ9.eyJpc3MiOiJodHRwczovL2Jsb2NraW4uYXV0aDAuY29tLyIsInN1YiI6ImF1dGgwfDVhMzM4MWE2ZjczMzNjNjdkMzMxOWZiYyIsImF1ZCI6WyJodHRwczovL3d3dy5wb29saW4uY29tL2FwaSIsImh0dHBzOi8vYmxvY2tpbi5hdXRoMC5jb20vdXNlcmluZm8iXSwiaWF0IjoxNTE2OTU3ODMwLCJleHAiOjE1MTY5NjUwMzAsImF6cCI6IkZhczI5dWJNNW52NElFMlZUQ3ZEWU5iaWtIeTF0bDBkIiwic2NvcGUiOiJvcGVuaWQgcHJvZmlsZSByZWFkIHdyaXRlIn0.tl_zchdcoQe1k6CqgJPR_vRinzig1n5mvKJHfzz0iNLxwv47OGLUGvo5-1tTphzO7Y5DAI4saeu6oGpb4QHXCDCj_HiSQSAqVLNauBlmJJdoacbYJUFik7hJ9SSzkVVDY8Y1wHjU9-0QEg2Z7kLz9lER3zTRf2nipHRLpJPet0ysE8C-aQyF0bmiVMM_0LW4ujQAmNSyemjo_GXULZno8_kpTOge0PMFykMc2grt7YG_Ol87M2XMCJgtiZxtnQS2eaovGmNKSTTZQKWOKEUtK3tq2TgH0hc-mUQUKuWsHNgNhcvjIk-uIkJlk49dRP__C6FiUwO_8V9ESUeWmg9-JQ");
})
}
window.$axios = Vue.prototype.$axios = axios;
......
import Vue from 'vue'
import Router from 'vue-router'
import fn from '@/assets/js/function.js'
Vue.use(Router)
import Home from '@/components/Home'
......@@ -8,6 +9,8 @@ import Jump from '@/components/Jump'
import Login from '@/components/Login/'
import Reg from '@/components/Reg/'
import no from '@/components/Dashboard/no'
import Dashboard from '@/components/Dashboard/'
import Miners from '@/components/Miners/'
......@@ -30,177 +33,193 @@ import NoticeShow from '@/components/Notice/detail'
const router = new Router({
routes: [{
path: '/',
name: 'home',
component: Home,
meta: {
title: 'Home.vue'
}
}, {
path: '/login',
name: 'login',
component: Login,
meta: {
title: 'Login.vue'
}
}, {
path: '/reg',
name: 'reg',
component: Reg,
meta: {
title: 'Reg.vue'
}
}, {
path: '/jump',
name: 'jump',
component: Jump,
meta: {
title: 'Jump.vue'
}
}, {
path: '/create',
name: 'create',
component: Create,
meta: {
title: 'Create.vue'
}
}, {
path: '/welcome',
name: 'welcome',
component: Welcome,
meta: {
title: 'Welcome.vue'
}
}, {
path: '/subaccount',
name: 'subaccount',
component: Subaccount,
meta: {
title: 'Subaccount.vue'
}
}, {
path: '/my/:puid/:coin_type/:region_id/dashboard',
name: 'dashboard',
component: Dashboard,
meta: {
title: 'Dashboard.vue'
}
}, {
path: '/my/:puid/:coin_type/:region_id/miners',
name: 'miners',
component: Miners,
meta: {
title: 'Miners.vue'
}
}, {
path: '/my/:puid/:coin_type/:region_id/miners/:worker_id',
name: 'minershow',
component: MinerShow,
meta: {
title: 'MinerShow.vue'
}
}, {
path: '/my/:puid/:coin_type/:region_id/payments',
name: 'payments',
component: Payments,
meta: {
title: 'Payments.vue'
}
}, {
path: '/settings',
name: 'settings',
component: Settings,
meta: {
title: 'Settings.vue'
}
}, {
path: '/defaultCoin',
name: 'defaultCoin',
component: DefaultCoin,
meta: {
title: 'DefaultCoin.vue'
}
}, {
path: '/language',
name: 'language',
component: Language,
meta: {
title: 'Language.vue'
}
},{
path: '/account',
name: 'account',
component: Account,
meta: {
title: 'Account.vue'
}
},{
path: '/notice',
name: 'notice',
component: Notice,
meta: {
title: 'Notice.vue'
}
}, {
path: '/noticeList',
name: 'noticeList',
component: NoticeList,
meta: {
title: 'NoticeList.vue'
}
}, {
path: '/noticeShow',
name: 'noticeShow',
component: NoticeShow,
meta: {
title: 'NoticeShow.vue'
}
},
path: '/',
name: 'home',
component: Home,
meta: {
title: 'Home.vue'
}
}, {
path: '/login',
name: 'login',
component: Login,
meta: {
title: 'Login.vue'
}
}, {
path: '/reg',
name: 'reg',
component: Reg,
meta: {
title: 'Reg.vue'
}
}, {
path: '/jump',
name: 'jump',
component: Jump,
meta: {
title: 'Jump.vue'
}
}, {
path: '/create',
name: 'create',
component: Create,
meta: {
title: 'Create.vue'
}
}, {
path: '/welcome',
name: 'welcome',
component: Welcome,
meta: {
title: 'Welcome.vue'
}
}, {
path: '/subaccount',
name: 'subaccount',
component: Subaccount,
meta: {
title: 'Subaccount.vue'
}
}, {
path: '/my/:puid/:coin_type',
name: 'no',
component: no,
meta: {
title: 'no.vue'
}
}, {
path: '/my/:puid/:coin_type/:region_id/dashboard',
name: 'dashboard',
component: Dashboard,
meta: {
title: 'Dashboard.vue'
}
}, {
path: '/my/:puid/:coin_type/:region_id/miners',
name: 'miners',
component: Miners,
meta: {
title: 'Miners.vue'
}
}, {
path: '/my/:puid/:coin_type/:region_id/miners/:worker_id',
name: 'minershow',
component: MinerShow,
meta: {
title: 'MinerShow.vue'
}
}, {
path: '/my/:puid/:coin_type/:region_id/payments',
name: 'payments',
component: Payments,
meta: {
title: 'Payments.vue'
}
}, {
path: '/settings',
name: 'settings',
component: Settings,
meta: {
title: 'Settings.vue'
}
}, {
path: '/defaultCoin',
name: 'defaultCoin',
component: DefaultCoin,
meta: {
title: 'DefaultCoin.vue'
}
}, {
path: '/language',
name: 'language',
component: Language,
meta: {
title: 'Language.vue'
}
}, {
path: '/account',
name: 'account',
component: Account,
meta: {
title: 'Account.vue'
}
}, {
path: '/notice',
name: 'notice',
component: Notice,
meta: {
title: 'Notice.vue'
}
}, {
path: '/noticeList',
name: 'noticeList',
component: NoticeList,
meta: {
title: 'NoticeList.vue'
}
}, {
path: '/noticeShow',
name: 'noticeShow',
component: NoticeShow,
meta: {
title: 'NoticeShow.vue'
}
},
]
})
router.beforeEach((to, from, next) => {
// if (localStorage.getItem('enter_panel') == "true") {
// $store.commit('setEnterPannel', true);
// }
function getCoins(obj) {
let arr_coins = [];
_.map(obj.regions, function (v, i, o) {
_.map(v.supported_coin_types, function (v1, i1, o1) {
arr_coins.push(v1.coin_type)
})
});
return _.uniq(arr_coins)
//console.log(to)
var arr = ['home', 'jump'];
if (localStorage.getItem('enter_panel') == null) {
$store.commit('setEnterPannel', $store.state.enter_panel);
}
if (localStorage.getItem('puid') == null) {
$store.commit('setPuid', '');
} else {
if (to.params.puid) {
$store.commit('setPuid', to.params.puid)
}
}
if (localStorage.getItem('enter_panel') == "true") {
$store.commit('setEnterPannel', true);
}
var arr = ['home', 'jump'];
if (localStorage.getItem('language') == null) {
$store.commit('setLanguage', $store.state.language)
}
//最先执行的初始数据
if ($store.state.cur_coins.length == 0) {
$axios($store.state.base_url)
.then(res => {
$store.commit('setInitUrl', res.data);
$store.commit('setCurCoins', getCoins(res.data));
if (localStorage.coin_type) {
$store.commit('setCoinType', localStorage.coin_type);
$axios($store.state.base_url).then(res => {
$store.commit('setInitUrl', res.data);
$store.commit('setCurCoins', fn.getCoinsOnly(res.data));
if (localStorage.getItem('coin_type') == null) {
$store.commit('setCoinType', $store.state.cur_coins[0]);
} else {
if (to.params.coin_type) {
$store.commit('setCoinType', to.params.coin_type);
} else {
$store.commit('setCoinType', $store.state.cur_coins[0]);
$store.commit('setCoinType', localStorage.getItem('coin_type'));
}
if (localStorage.region_id) {
$store.commit('setRegionId', localStorage.region_id)
}
if (localStorage.getItem("region_id") == null) {
$store.commit('setRegionId', res.data.regions[0].region_id);
} else {
if (to.params.region_id) {
$store.commit('setRegionId', to.params.region_id);
} else {
$store.commit('setRegionId', res.data.regions[0].region_id);
$store.commit('setRegionId', localStorage.getItem('region_id'));
}
if (!localStorage.puid) {
$store.commit('setPuid', '')
}
if (!localStorage.language) {
$store.commit('setLanguage', $store.state.language)
}
next();
})
}
modeSwitch(to, from, next)
})
} else {
next();
modeSwitch(to, from, next)
}
})
......@@ -211,3 +230,44 @@ router.afterEach((to, from) => {
})
export default router
function modeSwitch(to, from, next) {
if (to.query.read_token != undefined || to.query.read_token != null) {
// alert("进入观察者模式")
let token = to.query.read_token;
localStorage.setItem('read_token', token);
$store.state.is_login = false;
fn.getTokenInfo(token).then(res => {
if (res.data.err_no == 0) {
if (res.data.data != null) {
let data = res.data.data;
localStorage.setItem('read_expires_at', data.expired_at * 1000)
localStorage.setItem('read_name', data.name);
localStorage.setItem('read_subaccount_name', data.subaccount_name);
localStorage.setItem('puid', data.puid);
$store.state.read_token = token;
next();
} else {
alert("参数错误!")
$router.replace('/index')
}
} else {
alert("字段类型错误或为空");
}
})
} else {
// alert("进入正常模式")
localStorage.removeItem('read_token');
$store.state.read_token = '';
next();
// var arr = ['index', 'stats', 'callback', 'jump'];
// if ($auth.isAuthenticated() || arr.indexOf(to.name) > -1) {
// next()
// } else {
// localStorage.removeItem('access_token')
// localStorage.removeItem('id_token')
// localStorage.removeItem('expires_at')
// $auth.login();
// }
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment