function_list.vue
2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<template>
<div class="function_list">
<x-header title="功能列表" :left-options="{showBack: false}"></x-header>
<ul class="list">
<li v-for="(item, index) in fun_list" :key="index" @click="goHandler(index)">
<span>{{item.name}}</span>
</li>
</ul>
<bottomBtn :btnText="'返回登录'" @btnClick="btnClick"></bottomBtn>
</div>
</template>
<script>
import { XHeader } from 'vux'
import bottomBtn from 'components/bottomBtn/index'
export default {
components: { XHeader, bottomBtn },
beforeRouteEnter (to, from, next) {
function getFunctionList () {
return axios.get('b/auth/getFunctions')
}
axios.all([getFunctionList()])
.then(axios.spread(fun => {
to.params.fun = fun.data.content
console.warn(fun.data.content);
next();
}))
},
data () {
return {
fun_list: this.$route.params.fun
}
},
mounted () {
let lis = document.getElementsByTagName('li');
for (let i = 0; i < lis.length; i++) {
lis[i].style.height = lis[i].offsetWidth + 'px';
}
},
methods: {
goHandler (i) {
let url = this.$route.params.fun[i].boh_url.split('boh');
let loc = window.location;
console.warn(loc);
if (loc.hostname === 'localhost') {
let res = url[1] ? loc.origin + url[1] : url[0];
window.location.href = res;
} else {
let host = loc.hostname;
if (!isNaN(Number(host.split('.')[0]))) {
let res = url[1] ? loc.origin + url[1] : url[0];
window.location.href = res;
} else {
window.location.href = this.$route.params.fun[i].boh_url;
}
}
},
btnClick () {
this.$router.push('/');
}
}
}
</script>
<style lang="less" scoped>
.function_list {
.list {
margin: 0;
margin-top: 3rem;
list-style: none;
li {
float: left;
text-align: center;
border: 1px solid #ccc;
width: 32.5%;
background: #fff;
position: relative;
span {
position: absolute;
width: 100%;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
}
&:after {
display: block;
content: '';
clear: both;
}
}
}
</style>