AppHeader.vue
9.35 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
<template>
<div class="topNav forPc">
<router-link to="/">
<img class="logo" src="@/assets/v1/nav_logo.png">
</router-link>
<div class="home-menu">
<el-menu
v-if="language==0"
router :default-active="activeIndex" mode="horizontal" :ellipsis="false"
popper-effect="dark" @select="handleSelect"
>
<el-menu-item index="/">首页</el-menu-item>
<el-menu-item index="/news">新闻资讯</el-menu-item>
<el-menu-item index="/notice">通知公告</el-menu-item>
<el-menu-item index="/match/list/0">大赛报名</el-menu-item>
<el-menu-item index="/saiC">赛程安排</el-menu-item>
<el-menu-item index="/meta">媒体中心</el-menu-item>
<el-menu-item index="/guide">参赛指南</el-menu-item>
<el-sub-menu index="/about">
<template #title>关于我们</template>
<el-menu-item index="/about/wuDao">舞蹈节</el-menu-item>
<el-menu-item index="/about/culture">地方文化</el-menu-item>
</el-sub-menu>
</el-menu>
<el-menu
v-if="language==1"
router :default-active="activeIndex" mode="horizontal" :ellipsis="false"
popper-effect="dark" @select="handleSelect"
>
<el-menu-item index="/">HOME</el-menu-item>
<el-menu-item index="/news">NEWS</el-menu-item>
<el-menu-item index="/notice">NOTICEBOARD</el-menu-item>
<el-menu-item index="/match/list/0">SIGN UP</el-menu-item>
<el-menu-item index="/saiC">COMPETITIONS</el-menu-item>
<el-menu-item index="/meta">MEDIA</el-menu-item>
<el-menu-item index="/guide">GUIDELINE</el-menu-item>
<el-sub-menu index="/about">
<template #title>ABOUT US</template>
<el-menu-item index="/about/wuDao">舞蹈节</el-menu-item>
<el-menu-item index="/about/culture">地方文化</el-menu-item>
</el-sub-menu>
</el-menu>
</div>
<div class="flex-right">
<div class="search mr20">
<el-button :icon="Search" circle @click="searchNews" />
</div>
<div class="languageBtn">
<span :class="language==0?'active':''" @click="changeLanguage(0)">中文</span>
<span :class="language==1?'active':''" @click="changeLanguage(1)">EN</span>
</div>
<div class="ml20">
<el-button v-if="!isLogin" style="border-radius: 20px;" class="loginBtn">
<span v-if="language==0" @click="goLogin">登录</span>
<span v-if="language==1" @click="goLogin">LOGIN</span>
<!-- | <span @click="goRegister">注册</span>-->
</el-button>
<el-button v-else style="border-radius: 20px;" class="loginBtn"><span @click="router.push('/center/myInfo')">个人中心</span>
| <span @click="logout()">退出</span></el-button>
</div>
</div>
</div>
<div class="forWei ">
<div class="weitop">
<img src="@/assets/v1/nav_logo.png" style="height: 40px;margin: 10px">
<a class="ropenbtn" @click="showDrawer">
<img src="@/assets/v1/menu.png">
</a>
</div>
</div>
<el-drawer
v-model="drawer"
:style="{'--el-drawer-padding-primary':0}" direction="ltr" :with-header="false" title="菜单"
>
<el-menu
:style="{'--el-menu-hover-bg-color':'#faeeed'}"
class="weiMenu"
router :default-active="activeIndex" mode="vertical" :ellipsis="false"
popper-effect="dark" @select="handleSelect"
>
<el-menu-item index="/">首页</el-menu-item>
</el-menu>
</el-drawer>
<LoginDialog ref="pcloginDialog" @submitForm="reFlash" />
<el-dialog
v-model="registerVisible"
title="用户注册"
width="30%"
>
<el-form
ref="loginRef"
:model="loginForm"
>
<el-form-item prop="telNo" style="height: 40px">
<el-input
v-model="loginForm.telNo"
type="text"
auto-complete="off"
placeholder="请输入手机号"
>
<template #prefix><svg-icon icon-class="phone" class="el-input__icon input-icon" /></template>
</el-input>
</el-form-item>
<el-form-item prop="captcha" style="height: 40px">
<captcha ref="codeRef" v-model="loginForm.captcha" v-model:uuid="loginForm.uuid" style="height: 40px" @keyup.enter="handleLogin" />
</el-form-item>
<el-form-item prop="code" style="height: 40px">
<captcha-sms v-model="loginForm.code" style="height: 40px" :verify="checkCaptchaSms" @keyup.enter="handleLogin" @error="getCode" />
</el-form-item>
<el-form-item style="width: 100%;height: 40px">
<el-button
:loading="loading"
size="large"
type="primary"
style="width: 100%;border: 0;"
>
<span>注册</span>
</el-button>
</el-form-item>
</el-form>
</el-dialog>
<SearchPop v-if="language==0" ref="searchDialog" />
<SearchPop_en v-if="language==1" ref="searchDialog" />
</template>
<script setup>
import { computed, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import useUserStore from '@/store/modules/user'
import { Search } from '@element-plus/icons-vue'
import { getCurrentInstance, onMounted } from '@vue/runtime-core'
import _ from 'lodash'
import LoginDialog from '@/viewsPc/login'
import SearchPop from './indexSearch'
import SearchPop_en from './indexSearch_en'
import Captcha from './captcha'
import CaptchaSms from './captchaSms'
import cache from '@/plugins/cache'
import locale from 'element-plus/lib/locale/lang/zh-cn'
const router = useRouter()
const route = useRoute()
const { proxy } = getCurrentInstance()
const isLogin = ref(false)
const activeIndex = ref('/')
const registerVisible = ref(false)
const loginForm = ref({})
const drawer = ref(false)
const language = ref(cache.local.get('language') || 0)
onMounted(() => {
if (useUserStore().perId) {
isLogin.value = true
}
if (route.fullPath.indexOf('news') > -1) {
activeIndex.value = '/news'
} else if (route.fullPath.indexOf('notice') > -1) {
activeIndex.value = '/notice'
} else if (route.fullPath.indexOf('about') > -1) {
activeIndex.value = '/about'
} else if (route.fullPath.indexOf('teen') > -1) {
activeIndex.value = '/teen'
} else if (route.fullPath.indexOf('fitness') > -1) {
activeIndex.value = '/fitness'
} else if (route.fullPath.indexOf('dope') > -1) {
activeIndex.value = '/dope'
}
// console.log(activeIndex.value)
})
function changeLanguage(n) {
// language.value = n
cache.local.set('language', n)
location.reload()
}
function showDrawer() {
drawer.value = true
}
function handleSelect(key, keyPath) {
// console.log(key)
activeIndex.value = key
drawer.value = false
}
const logout = () => {
proxy.$modal.confirm('确定退出?').then(function() {
return useUserStore().logOut()
}).then(() => {
isLogin.value = true
location.reload()
})
}
const goLogin = (flag) => {
let param = null
if (_.isBoolean(flag)) {
param = {
notShowClose: flag
}
}
proxy.$refs['pcloginDialog'].open(param)
}
const goRegister = () => {
registerVisible.value = true
}
const reFlash = () => {
// 刷新
location.reload()
}
watch(() => useUserStore().reLogin, (val) => {
if (val) {
goLogin()
}
})
function searchNews() {
proxy.$refs['searchDialog'].open()
}
function getCode() {
proxy.$refs['codeRef'].getCode()
}
</script>
<style scoped lang="scss">
.loginBtn {color: #fff;margin-right: 15px;border: none;
background: linear-gradient(-90deg, #8623FC, #453DEA);box-shadow:0 0 10px #fff;
&:active {
color: #fff;
background:linear-gradient(0deg, #8623FC, #453DEA);
border:none;
}
&:hover {
box-shadow:0 0 10px var(--el-color-primary);border: none;
color:#fff;
}
}
.quickNav {
a {
padding: 0 25px;
line-height: 1;
border-right: 1px solid #DCDCDC;
font-size: 14px;
color: #9D630F;
&:last-child {
border-right: none;
}
&:hover{font-weight: bold;text-decoration: underline;}
}
}
.topNav {
box-shadow: 0px 0px 13px rgba(113,113,113);
display: flex;
justify-content: space-between;
height: 80px;
align-items: center;
.logo {
height: 60px;
margin-left: 40px;
}
.flex-right {
display: flex;
align-items: center;
}
.search {
position: relative;
.el-button.is-circle:hover {
color:var(--el-color-primary);
border-color: var(--el-color-primary);
}
.el-button.is-circle:active {
background: var(--el-color-primary);
color: #fff;
border-color: var(--el-color-primary);
}
.el-button.is-circle:focus {
border-color: var(--el-color-primary)
}
:deep(.el-input .el-input__wrapper) {
box-shadow: none;
border-radius: 18px;
background: #F4F4F4;
}
.el-icon {
position: absolute;
right: 5px;
}
}
}
.menuBox {
height: 60px;
background: var(--el-color-primary);
}
@media (max-width: 1000px) {
.box {
width: 100%
}
.flex-right {
.quickNav a {
padding: 0 4px;
border: none;
}
}
}
@media (max-width: 750px) {
.search {
display: none
}
}
@media (max-width: 500px) {
.forPc {
display: none;
}
}
.weitop{display: flex;justify-content: space-between;
.ropenbtn{padding: 10px}
}
:deep(.el-input){height: 100%}
:deep(.el-form-item){height: 40px;}
.weiMenu.el-menu{
border: none;
:deep(.el-menu-item.is-active){color: var(--el-color-primary);}
}
</style>