index.vue
4.11 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<!--
* @Date: 2022-05-11 11:19:14
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-12-03 15:07:53
* @FilePath: /tswj/src/components/ShortcutFixed/index.vue
* @Description: 文件描述
-->
<template>
<div class="shortcut-page" :style="customStyle">
<van-image v-if="isHome" class="icon-box" :src="icon_home" @click="toHome" />
<van-image v-if="isMe" class="icon-box" :src="icon_me" @click="toMe" />
<van-image v-if="isRank" class="icon-box" :src="icon_rank" @click="toRank" />
<van-popover v-model:show="showPopover" placement="left">
<div class="contact-content">
<div class="text-tel">固话联系</div>
<div>
<a style="color: #C2915F;"
:href="`tel:${tel}`"
>
{{ tel }}
</a>
</div>
</div>
<div class="contact-content" style="padding-top: 0;">
<div class="text-tel">邮箱联系</div>
<div>
<a style="color: #C2915F;"
:href="`mailto:${mail}`"
>
{{ mail }}
</a>
</div>
</div>
<template #reference>
<div class="wrapper">
<van-image class="icon-box" :src="icon_contact" />
</div>
</template>
</van-popover>
<van-image v-if="isSearch" class="icon-box" :src="icon_search" @click="toSearch" />
</div>
</template>
<script setup>
import Cookies from 'js-cookie'
import { icon_me, icon_home, icon_rank, icon_contact, icon_search } from '@/utils/generateIcons.js'
import { useRoute, useRouter } from 'vue-router'
import { killPages, store } from '@/hooks/useKeepAlive';
// 删除所有的 keep-alive 缓存
killPages();
// 清空记录位置
store.changeScrollTop(0);
const $route = useRoute();
const $router = useRouter();
const toSearch = () => {
// 清空记录位置
store.changeScrollTop(0);
$router.push({
path: '/client/searchPage',
query: {
book_id: $route.query.id,
kg_id: $route.query.kg_id
}
});
}
</script>
<script>
// FIXME: VUE2写法
export default {
props: ['type', 'item', 'customStyle'],
data() {
return {
userType: Cookies.get('userType') ? Cookies.get('userType') : '',
showPopover: false,
tel: '021-61517073',
mail: 'cxwa@allforlove.org.cn'
}
},
computed: {
isHome() {
return this.item.indexOf('home') !== -1 ? true : false
},
isMe() {
return this.item.indexOf('me') !== -1 ? true : false
},
isRank() {
return this.item.indexOf('rank') !== -1 ? true : false
},
isSearch() {
return this.item.indexOf('search') !== -1 ? true : false
},
},
mounted() {
},
methods: {
toHome() {
// 返回首页
if (this.type === 'B') { // 服务端判断
this.$router.push({
path: '/business/index'
});
} else {
// C 端返回首页需要判断是否,访客或客户
switch (this.userType) {
case 'visitor':
this.$router.push({
path: '/client/chooseBook'
});
break;
case 'client':
this.$router.push({
path: '/client/chooseSchool'
});
break;
default:
this.$router.push({
path: '/client/index'
});
break;
}
}
},
toMe() {
if (this.type === 'B') { // 服务端判断
this.$router.push({
path: '/business/me'
});
} else {
this.$router.push({
path: '/me/index'
});
}
},
toRank () {
this.$router.push({
path: '/client/rankList',
query: {
kg_id: this.$route.query.kg_id
}
});
},
}
}
</script>
<style lang="less" scoped>
.shortcut-page {
position: fixed;
bottom: 18rem;
right: 1rem;
overflow: auto;
z-index: 999;
width: 3rem;
}
.icon-box {
width: 3rem;
height: 3rem;
margin-bottom: 0.5rem;
}
.contact-content {
padding: 1rem 0.85rem;
text-align: center;
.text-tel {
color: gray;
font-size: 0.9rem;
margin-bottom: 0.5rem;
}
}
</style>