2023-12-07 17:48:36 +08:00
|
|
|
<script setup lang="ts">
|
2024-11-20 11:16:18 +08:00
|
|
|
import $bus from "@/utils/bus";
|
|
|
|
|
import { mainStore } from "store/main";
|
|
|
|
|
import { ElMessage, ElMessageBox } from "element-plus";
|
|
|
|
|
const store = mainStore();
|
2023-12-09 17:00:58 +08:00
|
|
|
|
2024-11-20 11:16:18 +08:00
|
|
|
const route = useRoute();
|
|
|
|
|
const router = useRouter();
|
2023-12-07 17:48:36 +08:00
|
|
|
|
2023-12-09 17:00:58 +08:00
|
|
|
// 是否显示退出登录
|
|
|
|
|
const isShowLogout = computed(() => {
|
2024-11-20 11:16:18 +08:00
|
|
|
return store.token;
|
|
|
|
|
});
|
2023-12-09 17:00:58 +08:00
|
|
|
|
2024-11-20 11:16:18 +08:00
|
|
|
const placeholderText = ref("请输入关键字");
|
2023-12-09 17:00:58 +08:00
|
|
|
|
|
|
|
|
// 退出登录
|
|
|
|
|
const handlerLogout = () => {
|
2024-11-20 11:16:18 +08:00
|
|
|
ElMessageBox.confirm("是否确定退出登录", {
|
|
|
|
|
confirmButtonText: "确定",
|
|
|
|
|
cancelButtonText: "取消",
|
|
|
|
|
type: "warning",
|
2023-12-09 17:00:58 +08:00
|
|
|
})
|
|
|
|
|
.then(() => {
|
2024-11-20 11:16:18 +08:00
|
|
|
router.push("/login");
|
|
|
|
|
store.cleanUpToken("");
|
2023-12-09 17:00:58 +08:00
|
|
|
ElMessage({
|
2024-11-20 11:16:18 +08:00
|
|
|
type: "success",
|
|
|
|
|
message: "已退出登录",
|
|
|
|
|
});
|
2023-12-09 17:00:58 +08:00
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
ElMessage({
|
2024-11-20 11:16:18 +08:00
|
|
|
type: "info",
|
|
|
|
|
message: "已取消",
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
2023-12-09 17:00:58 +08:00
|
|
|
|
2023-12-07 17:48:36 +08:00
|
|
|
// 搜索查询绑定值
|
2024-11-20 11:16:18 +08:00
|
|
|
const keywordIptValue = ref("");
|
2023-12-07 17:48:36 +08:00
|
|
|
|
|
|
|
|
// 输入框 dom
|
2024-11-20 11:16:18 +08:00
|
|
|
const inputRef: any = ref(null);
|
2023-12-07 17:48:36 +08:00
|
|
|
|
|
|
|
|
// 输入框下方历史搜索记录
|
2023-12-09 22:58:48 +08:00
|
|
|
// const searchHistoryList = computed(() => {
|
|
|
|
|
// return store.searchHistoryList.slice(0, 1)
|
|
|
|
|
// })
|
2023-12-07 17:48:36 +08:00
|
|
|
|
|
|
|
|
// 搜索按钮
|
|
|
|
|
const searchKeywordBtn = () => {
|
2023-12-09 17:00:58 +08:00
|
|
|
/* 去除空格 */
|
2024-11-20 11:16:18 +08:00
|
|
|
keywordIptValue.value = keywordIptValue.value.replace(/\s*/g, "");
|
2023-12-09 17:00:58 +08:00
|
|
|
|
2024-11-20 11:16:18 +08:00
|
|
|
store.addHistoryRecord(keywordIptValue.value);
|
|
|
|
|
if (route.path == "/equipList") {
|
|
|
|
|
$bus.emit("search", keywordIptValue.value);
|
2023-12-07 17:48:36 +08:00
|
|
|
} else {
|
|
|
|
|
router.push({
|
2024-11-20 11:16:18 +08:00
|
|
|
name: "equipList",
|
|
|
|
|
state: { keyWord: keywordIptValue.value },
|
|
|
|
|
});
|
2023-12-07 17:48:36 +08:00
|
|
|
}
|
2024-11-20 11:16:18 +08:00
|
|
|
};
|
2023-12-07 17:48:36 +08:00
|
|
|
|
|
|
|
|
// 点击下方搜索记录时
|
|
|
|
|
const handleHistory = (hisValue: any) => {
|
2024-11-20 11:16:18 +08:00
|
|
|
keywordIptValue.value = hisValue;
|
|
|
|
|
searchKeywordBtn();
|
2023-12-09 17:00:58 +08:00
|
|
|
// inputRef.value.focus()
|
2024-11-20 11:16:18 +08:00
|
|
|
};
|
2023-12-07 17:48:36 +08:00
|
|
|
//页面刷新回显模糊搜索词
|
2024-11-20 11:16:18 +08:00
|
|
|
$bus.on("callBackText", (val) => {
|
2023-12-07 17:48:36 +08:00
|
|
|
nextTick(() => {
|
2024-11-20 11:16:18 +08:00
|
|
|
keywordIptValue.value = val;
|
|
|
|
|
});
|
|
|
|
|
});
|
2023-12-07 17:48:36 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<!-- 头部个人信息 收藏夹 手机版等图标 -->
|
|
|
|
|
<div class="header-container">
|
|
|
|
|
<div class="header-user-info">
|
|
|
|
|
<div class="header-box wapper">
|
|
|
|
|
<div class="header-item">
|
2023-12-09 17:00:58 +08:00
|
|
|
<span v-if="!isShowLogout">
|
2024-11-20 11:16:18 +08:00
|
|
|
<a class="a-border-none" @click="$router.push('/login')"
|
|
|
|
|
>登录</a
|
|
|
|
|
>
|
2023-12-09 17:00:58 +08:00
|
|
|
<span style="margin: 0 3px">/</span>
|
2023-12-12 09:23:09 +08:00
|
|
|
<a @click="$router.push('/register')">注册</a>
|
2023-12-09 17:00:58 +08:00
|
|
|
</span>
|
|
|
|
|
<span v-else>
|
|
|
|
|
<a @click="handlerLogout">退出登录</a>
|
|
|
|
|
</span>
|
2023-12-07 17:48:36 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="header-item">
|
|
|
|
|
<a @click="$router.push({ name: 'myuser' })">个人中心</a>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="header-item">
|
2024-11-20 13:32:00 +08:00
|
|
|
<img src="../assets/img/home/star.png" alt="" />
|
2023-12-07 17:48:36 +08:00
|
|
|
<a @click="$router.push('/collect')">收藏夹</a>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="header-item last-item">
|
2024-11-20 13:32:00 +08:00
|
|
|
<img src="../assets/img/home/phone.png" alt="" />
|
2023-12-07 17:48:36 +08:00
|
|
|
<a class="a-border-none">手机版</a>
|
|
|
|
|
|
|
|
|
|
<!-- 二维码弹框 -->
|
|
|
|
|
<div class="qr-code">
|
|
|
|
|
<el-image
|
|
|
|
|
src="https://img.xjishu.com/img/zl/2017/10/212257159687020.gif"
|
|
|
|
|
fit="cover" />
|
|
|
|
|
|
|
|
|
|
扫二维码查看xxx
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- 中间logo 部分 -->
|
|
|
|
|
|
|
|
|
|
<div class="logo-ipt-container wapper">
|
|
|
|
|
<img
|
2024-11-20 11:16:18 +08:00
|
|
|
src="@/assets/img/home//机械化装备平台.png"
|
2023-12-07 17:48:36 +08:00
|
|
|
alt="首页"
|
|
|
|
|
title="首页"
|
|
|
|
|
@click="$router.push('/home')" />
|
|
|
|
|
|
|
|
|
|
<input
|
2023-12-09 17:00:58 +08:00
|
|
|
:placeholder="placeholderText"
|
2023-12-07 17:48:36 +08:00
|
|
|
type="text"
|
2023-12-09 17:00:58 +08:00
|
|
|
v-model.trim="keywordIptValue"
|
2023-12-07 17:48:36 +08:00
|
|
|
@keydown.enter="searchKeywordBtn"
|
2023-12-09 17:00:58 +08:00
|
|
|
ref="inputRef"
|
|
|
|
|
@focus="placeholderText = ''"
|
|
|
|
|
@blur="placeholderText = '请输入关键字'" />
|
2023-12-07 17:48:36 +08:00
|
|
|
<button class="search-btn" @click="searchKeywordBtn">搜索</button>
|
|
|
|
|
|
|
|
|
|
<div class="ipt-down">
|
2023-12-09 22:58:48 +08:00
|
|
|
<a
|
|
|
|
|
v-for="item in store.searchHistoryList.slice(0, 4)"
|
|
|
|
|
:key="item"
|
|
|
|
|
@click="handleHistory(item)"
|
|
|
|
|
class="history-box">
|
2023-12-09 17:00:58 +08:00
|
|
|
{{ item }}
|
2023-12-07 17:48:36 +08:00
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.header-container {
|
|
|
|
|
position: sticky;
|
|
|
|
|
top: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
z-index: 999;
|
|
|
|
|
|
|
|
|
|
.header-user-info {
|
|
|
|
|
background-color: #f5f5f5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 头部个人信息部分 */
|
|
|
|
|
.header-box {
|
|
|
|
|
height: 37px;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.header-item {
|
|
|
|
|
margin-left: 15px;
|
|
|
|
|
height: 37px;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
padding-left: 18px;
|
|
|
|
|
color: #6d6d6d;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
|
|
img {
|
|
|
|
|
vertical-align: middle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
a {
|
|
|
|
|
border-right: 1px solid #666655;
|
|
|
|
|
padding-right: 33px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
a:hover {
|
2024-11-20 11:16:18 +08:00
|
|
|
color: #3cb4a6;
|
2023-12-07 17:48:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.a-border-none {
|
|
|
|
|
border: none;
|
|
|
|
|
padding: 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.last-item {
|
|
|
|
|
position: relative;
|
|
|
|
|
z-index: 998;
|
|
|
|
|
.qr-code {
|
|
|
|
|
position: absolute;
|
|
|
|
|
left: -70px;
|
|
|
|
|
top: -140px;
|
|
|
|
|
width: 140px;
|
|
|
|
|
height: 140px;
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
visibility: hidden;
|
|
|
|
|
padding: 10px;
|
|
|
|
|
box-shadow: 0 2px 2px 2px #ccc;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
color: #333;
|
|
|
|
|
.el-image {
|
|
|
|
|
width: 120px;
|
|
|
|
|
height: 120px;
|
|
|
|
|
margin-bottom: 5px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.last-item:hover > .qr-code {
|
|
|
|
|
visibility: visible;
|
|
|
|
|
transform: translateY(177px);
|
|
|
|
|
transition: all 0.6s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 中间logo 搜索框部分 */
|
|
|
|
|
.logo-ipt-container {
|
|
|
|
|
position: relative;
|
|
|
|
|
display: flex;
|
|
|
|
|
background-color: #eeeff6;
|
|
|
|
|
padding: 30px 0;
|
|
|
|
|
|
|
|
|
|
img {
|
2024-11-20 11:16:18 +08:00
|
|
|
width: 240px;
|
2023-12-07 17:48:36 +08:00
|
|
|
height: 58px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
input {
|
|
|
|
|
width: 700px;
|
|
|
|
|
height: 45px;
|
2024-11-20 11:16:18 +08:00
|
|
|
border: 1px solid #3cb4a6;
|
2023-12-07 17:48:36 +08:00
|
|
|
border-radius: 45px;
|
|
|
|
|
margin-left: 70px;
|
|
|
|
|
line-height: 45px;
|
2023-12-09 17:00:58 +08:00
|
|
|
color: #333;
|
2023-12-07 17:48:36 +08:00
|
|
|
text-shadow: 0 0 0 #333;
|
|
|
|
|
padding-left: 30px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
input:focus {
|
2024-11-20 11:16:18 +08:00
|
|
|
outline: 1px solid #3cb4a6;
|
2023-12-07 17:48:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
input::-webkit-input-placeholder {
|
|
|
|
|
color: #949494;
|
|
|
|
|
}
|
|
|
|
|
.search-btn {
|
|
|
|
|
width: 100px;
|
|
|
|
|
height: 39px;
|
|
|
|
|
transform: translate(-110px, 4px);
|
|
|
|
|
border-radius: 39px;
|
2024-11-20 11:16:18 +08:00
|
|
|
background: linear-gradient(132deg, #22ab9b 0%, #0d7462 100%);
|
2023-12-07 17:48:36 +08:00
|
|
|
box-shadow: 0px 2px 4px 0px rgba(20, 175, 255, 0.5);
|
|
|
|
|
border: none;
|
|
|
|
|
color: #fff;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.ipt-down {
|
|
|
|
|
position: absolute;
|
2023-12-09 22:58:48 +08:00
|
|
|
bottom: 15px;
|
|
|
|
|
left: 22%;
|
2023-12-07 17:48:36 +08:00
|
|
|
overflow: hidden;
|
|
|
|
|
|
|
|
|
|
a {
|
2023-12-09 22:58:48 +08:00
|
|
|
max-width: 140px;
|
2023-12-07 17:48:36 +08:00
|
|
|
padding: 0 10px;
|
|
|
|
|
color: #727272;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
cursor: pointer;
|
2023-12-09 22:58:48 +08:00
|
|
|
overflow: hidden;
|
|
|
|
|
display: inline-block;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
text-overflow: ellipsis;
|
2023-12-07 17:48:36 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|