2023-12-07 17:48:36 +08:00
|
|
|
<script setup lang="ts">
|
2024-11-22 15:35:30 +08:00
|
|
|
import $bus from '@/utils/bus'
|
|
|
|
|
import { mainStore } from 'store/main'
|
2024-11-26 09:11:25 +08:00
|
|
|
import { useStore } from 'store/user'
|
2024-11-22 15:35:30 +08:00
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
2024-11-23 16:31:54 +08:00
|
|
|
import { getHotSearchListApi } from '../http/api/home/index'
|
2024-11-22 15:35:30 +08:00
|
|
|
const store: any = mainStore()
|
2024-11-26 09:11:25 +08:00
|
|
|
const userStore = useStore()
|
|
|
|
|
|
|
|
|
|
userStore.editMenuList(1)
|
2024-11-22 15:35:30 +08:00
|
|
|
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
const isRolesSelect = ref<boolean>(false)
|
2024-11-27 18:22:35 +08:00
|
|
|
const rolesName = ref<any>('1')
|
|
|
|
|
|
2024-11-29 09:27:46 +08:00
|
|
|
rolesName.value = localStorage.getItem('rolesType')
|
2024-11-22 15:35:30 +08:00
|
|
|
|
|
|
|
|
// 是否显示退出登录
|
|
|
|
|
const isShowLogout = computed(() => {
|
|
|
|
|
return store.token
|
|
|
|
|
})
|
|
|
|
|
|
2024-11-25 18:00:42 +08:00
|
|
|
const placeholderText = ref('搜索设备关键词')
|
2024-11-22 15:35:30 +08:00
|
|
|
|
|
|
|
|
// 退出登录
|
|
|
|
|
const handlerLogout = () => {
|
|
|
|
|
ElMessageBox.confirm('是否确定退出登录', {
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
type: 'warning',
|
|
|
|
|
})
|
|
|
|
|
.then(() => {
|
|
|
|
|
router.push('/login')
|
|
|
|
|
store.cleanUpToken('')
|
|
|
|
|
store.clearUserInfo('')
|
|
|
|
|
ElMessage({
|
|
|
|
|
type: 'success',
|
|
|
|
|
message: '已退出登录',
|
|
|
|
|
})
|
2023-12-09 17:00:58 +08:00
|
|
|
})
|
2024-11-22 15:35:30 +08:00
|
|
|
.catch(() => {
|
|
|
|
|
ElMessage({
|
|
|
|
|
type: 'info',
|
|
|
|
|
message: '已取消',
|
2023-12-09 17:00:58 +08:00
|
|
|
})
|
2024-11-22 15:35:30 +08:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 搜索查询绑定值
|
|
|
|
|
const keywordIptValue = ref('')
|
|
|
|
|
|
|
|
|
|
// 输入框 dom
|
|
|
|
|
const inputRef: any = ref(null)
|
|
|
|
|
|
|
|
|
|
// 输入框下方历史搜索记录
|
|
|
|
|
// const searchHistoryList = computed(() => {
|
|
|
|
|
// return store.searchHistoryList.slice(0, 1)
|
|
|
|
|
// })
|
|
|
|
|
|
2024-11-23 16:31:54 +08:00
|
|
|
const searchHistoryList = ref<any>(['挖掘机', '塔式起重机', '挖掘机', '吊机'])
|
|
|
|
|
|
|
|
|
|
// 获取热词
|
|
|
|
|
const getHotSearchListData = async () => {
|
|
|
|
|
const { data: res }: any = await getHotSearchListApi()
|
|
|
|
|
|
|
|
|
|
searchHistoryList.value = res
|
|
|
|
|
console.log(res, '热词')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getHotSearchListData()
|
2024-11-22 18:03:09 +08:00
|
|
|
|
2024-11-22 15:35:30 +08:00
|
|
|
// 搜索按钮
|
|
|
|
|
const searchKeywordBtn = () => {
|
|
|
|
|
/* 去除空格 */
|
|
|
|
|
keywordIptValue.value = keywordIptValue.value.replace(/\s*/g, '')
|
|
|
|
|
|
|
|
|
|
store.addHistoryRecord(keywordIptValue.value)
|
|
|
|
|
if (route.path == '/equipList') {
|
|
|
|
|
$bus.emit('search', keywordIptValue.value)
|
|
|
|
|
} else {
|
|
|
|
|
router.push({
|
|
|
|
|
name: 'equipList',
|
2024-11-25 18:00:42 +08:00
|
|
|
query: { keyWord: keywordIptValue.value },
|
2024-11-22 15:35:30 +08:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 点击下方搜索记录时
|
|
|
|
|
const handleHistory = (hisValue: any) => {
|
|
|
|
|
keywordIptValue.value = hisValue
|
|
|
|
|
searchKeywordBtn()
|
|
|
|
|
// inputRef.value.focus()
|
|
|
|
|
}
|
|
|
|
|
//页面刷新回显模糊搜索词
|
|
|
|
|
$bus.on('callBackText', (val) => {
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
keywordIptValue.value = val
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 角色切换按钮
|
|
|
|
|
const onRolesCheck = () => {
|
|
|
|
|
isRolesSelect.value = true
|
|
|
|
|
}
|
|
|
|
|
// 选择角色
|
|
|
|
|
const onSelectRoles = (type: number) => {
|
|
|
|
|
if (type === 1) {
|
2024-11-29 09:27:46 +08:00
|
|
|
rolesName.value = '1'
|
2024-11-26 09:11:25 +08:00
|
|
|
userStore.editMenuList(1)
|
2024-11-27 15:16:53 +08:00
|
|
|
userStore.editUserMenuList(1)
|
2024-11-27 18:22:35 +08:00
|
|
|
localStorage.setItem('rolesType', '1')
|
2024-11-22 15:35:30 +08:00
|
|
|
} else {
|
2024-11-29 09:27:46 +08:00
|
|
|
rolesName.value = '2'
|
2024-11-26 09:11:25 +08:00
|
|
|
userStore.editMenuList(2)
|
2024-11-27 15:16:53 +08:00
|
|
|
userStore.editUserMenuList(2)
|
2024-11-27 18:22:35 +08:00
|
|
|
localStorage.setItem('rolesType', '2')
|
2024-11-22 15:35:30 +08:00
|
|
|
}
|
|
|
|
|
isRolesSelect.value = false
|
|
|
|
|
}
|
2024-11-23 16:31:54 +08:00
|
|
|
|
|
|
|
|
// 查看预约车
|
|
|
|
|
const onCarts = () => {
|
|
|
|
|
console.log('跳转预约车页面')
|
|
|
|
|
router.push({
|
|
|
|
|
name: 'cart',
|
|
|
|
|
})
|
|
|
|
|
}
|
2023-12-07 17:48:36 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<!-- 头部个人信息 收藏夹 手机版等图标 -->
|
|
|
|
|
<div class="header-container">
|
|
|
|
|
<div class="header-user-info">
|
|
|
|
|
<div class="header-box wapper">
|
2024-11-22 18:03:09 +08:00
|
|
|
<div class="header-item" v-if="isShowLogout">
|
2024-11-22 15:35:30 +08:00
|
|
|
<!-- <img src="../assets/img/home/star.png" alt="" /> -->
|
|
|
|
|
<a class="user-name">{{ store.userInfo.nickName }}</a>
|
|
|
|
|
</div>
|
2023-12-07 17:48:36 +08:00
|
|
|
<div class="header-item">
|
2024-11-22 18:03:09 +08:00
|
|
|
<a v-if="!isShowLogout" class="a-border-none" @click="$router.push('/login')"
|
|
|
|
|
>登录</a
|
|
|
|
|
>
|
|
|
|
|
<span v-if="!isShowLogout" style="margin: 0 3px">/</span>
|
|
|
|
|
<a
|
|
|
|
|
v-if="!isShowLogout"
|
|
|
|
|
style="padding: 0 20px 0 0"
|
|
|
|
|
@click="$router.push('/register')"
|
|
|
|
|
>注册</a
|
|
|
|
|
>
|
|
|
|
|
<a v-else @click="handlerLogout">退出登录</a>
|
2023-12-07 17:48:36 +08:00
|
|
|
</div>
|
2024-11-22 18:03:09 +08:00
|
|
|
<div class="header-item roles-check" @click="onRolesCheck" v-if="isShowLogout">
|
2024-11-22 15:35:30 +08:00
|
|
|
<!-- <img src="../assets/img/home/star.png" alt="" /> -->
|
|
|
|
|
<a style="display: flex; justify-content: center; padding-right: 10px">
|
2024-11-27 18:22:35 +08:00
|
|
|
{{ rolesName == 1 ? '出租方' : '承租方' }}
|
2024-11-22 15:35:30 +08:00
|
|
|
<el-icon style="margin-left: 10px"><ArrowDownBold /></el-icon>
|
|
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
<div class="select-list" v-if="isRolesSelect">
|
|
|
|
|
<div
|
|
|
|
|
style="border-top-left-radius: 6px; border-top-right-radius: 6px"
|
|
|
|
|
@click.stop="onSelectRoles(1)"
|
|
|
|
|
>
|
|
|
|
|
出租方
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
style="border-bottom-left-radius: 6px; border-bottom-right-radius: 6px"
|
|
|
|
|
@click.stop="onSelectRoles(2)"
|
|
|
|
|
>
|
|
|
|
|
承租方
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-12-07 17:48:36 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="header-item">
|
2024-11-29 09:27:46 +08:00
|
|
|
<a
|
|
|
|
|
@click="
|
|
|
|
|
() => {
|
|
|
|
|
rolesName == 1
|
|
|
|
|
? router.push({ name: 'my-lease' })
|
|
|
|
|
: router.push({ name: 'my-lessee' })
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
>个人中心</a
|
|
|
|
|
>
|
2023-12-07 17:48:36 +08:00
|
|
|
</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"
|
2024-11-22 15:35:30 +08:00
|
|
|
fit="cover"
|
|
|
|
|
/>
|
2023-12-07 17:48:36 +08:00
|
|
|
|
|
|
|
|
扫二维码查看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="首页"
|
2024-11-22 15:35:30 +08:00
|
|
|
@click="$router.push('/home')"
|
|
|
|
|
/>
|
2023-12-07 17:48:36 +08:00
|
|
|
<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 = ''"
|
2024-11-25 18:00:42 +08:00
|
|
|
@blur="placeholderText = '搜索设备关键词'"
|
2024-11-22 15:35:30 +08:00
|
|
|
/>
|
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
|
2024-11-23 16:31:54 +08:00
|
|
|
v-for="item in searchHistoryList"
|
|
|
|
|
:key="item.maId"
|
|
|
|
|
@click="handleHistory(item.deviceName)"
|
2024-11-22 15:35:30 +08:00
|
|
|
class="history-box"
|
|
|
|
|
>
|
2024-11-23 16:31:54 +08:00
|
|
|
{{ item.deviceName }}
|
2023-12-07 17:48:36 +08:00
|
|
|
</a>
|
|
|
|
|
</div>
|
2024-11-22 18:03:09 +08:00
|
|
|
|
2024-11-23 16:31:54 +08:00
|
|
|
<div class="cart-icon" @click="onCarts">
|
|
|
|
|
<svg class="icon" aria-hidden="true" style="width: 30px; height: 30px">
|
|
|
|
|
<use xlink:href="#icon-gouwuche2"></use>
|
|
|
|
|
</svg>
|
|
|
|
|
<span> 预约车 </span>
|
2024-11-22 18:03:09 +08:00
|
|
|
</div>
|
2023-12-07 17:48:36 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2024-11-22 15:35:30 +08:00
|
|
|
.header-container {
|
|
|
|
|
position: sticky;
|
|
|
|
|
top: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
z-index: 999;
|
|
|
|
|
|
|
|
|
|
.header-user-info {
|
|
|
|
|
background-color: #f5f5f5;
|
|
|
|
|
}
|
2023-12-07 17:48:36 +08:00
|
|
|
|
2024-11-22 15:35:30 +08:00
|
|
|
/* 头部个人信息部分 */
|
|
|
|
|
.header-box {
|
|
|
|
|
height: 37px;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.header-item {
|
|
|
|
|
height: 37px;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
color: #6d6d6d;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
|
|
.user-name:hover {
|
|
|
|
|
color: #6d6d6d;
|
2023-12-07 17:48:36 +08:00
|
|
|
}
|
|
|
|
|
|
2024-11-22 15:35:30 +08:00
|
|
|
img {
|
|
|
|
|
vertical-align: middle;
|
2023-12-07 17:48:36 +08:00
|
|
|
}
|
|
|
|
|
|
2024-11-22 15:35:30 +08:00
|
|
|
a {
|
|
|
|
|
padding: 0 20px;
|
|
|
|
|
border-right: 1px solid #666655;
|
|
|
|
|
}
|
2023-12-07 17:48:36 +08:00
|
|
|
|
2024-11-22 15:35:30 +08:00
|
|
|
a:hover {
|
|
|
|
|
color: #3cb4a6;
|
|
|
|
|
}
|
2023-12-07 17:48:36 +08:00
|
|
|
|
2024-11-22 15:35:30 +08:00
|
|
|
.a-border-none {
|
|
|
|
|
border: none;
|
|
|
|
|
padding: 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-07 17:48:36 +08:00
|
|
|
|
2024-11-22 15:35:30 +08:00
|
|
|
.roles-check {
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
.roles-check .select-list {
|
|
|
|
|
height: 50px;
|
|
|
|
|
// display: none;
|
|
|
|
|
position: absolute;
|
|
|
|
|
left: 1%;
|
|
|
|
|
bottom: -46px;
|
|
|
|
|
width: 98%;
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
border-radius: 6px;
|
|
|
|
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
|
|
|
|
|
z-index: 999;
|
|
|
|
|
transition: all 1s linear;
|
2023-12-07 17:48:36 +08:00
|
|
|
|
2024-11-22 15:35:30 +08:00
|
|
|
div {
|
|
|
|
|
height: 25px;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
line-height: 25px;
|
|
|
|
|
text-align: center;
|
|
|
|
|
letter-spacing: 1px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
div:hover {
|
|
|
|
|
color: #fff;
|
|
|
|
|
background-color: #1967d2;
|
2023-12-07 17:48:36 +08:00
|
|
|
}
|
2024-11-22 15:35:30 +08:00
|
|
|
}
|
2023-12-07 17:48:36 +08:00
|
|
|
|
2024-11-22 15:35:30 +08:00
|
|
|
// .roles-check:hover .select-list {
|
|
|
|
|
// display: block;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
.last-item {
|
|
|
|
|
position: relative;
|
|
|
|
|
z-index: 998;
|
|
|
|
|
padding-left: 20px;
|
|
|
|
|
.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;
|
2023-12-07 17:48:36 +08:00
|
|
|
}
|
|
|
|
|
}
|
2024-11-22 15:35:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.last-item:hover > .qr-code {
|
|
|
|
|
visibility: visible;
|
|
|
|
|
transform: translateY(177px);
|
|
|
|
|
transition: all 0.6s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 中间logo 搜索框部分 */
|
|
|
|
|
.logo-ipt-container {
|
|
|
|
|
position: relative;
|
|
|
|
|
display: flex;
|
2024-11-22 18:03:09 +08:00
|
|
|
align-items: center;
|
2024-11-22 15:35:30 +08:00
|
|
|
background-color: #eeeff6;
|
|
|
|
|
padding: 30px 0;
|
2023-12-07 17:48:36 +08:00
|
|
|
|
2024-11-22 15:35:30 +08:00
|
|
|
img {
|
2024-11-22 18:03:09 +08:00
|
|
|
width: 210px;
|
|
|
|
|
height: 48px;
|
2024-11-22 15:35:30 +08:00
|
|
|
cursor: pointer;
|
2023-12-07 17:48:36 +08:00
|
|
|
}
|
|
|
|
|
|
2024-11-22 15:35:30 +08:00
|
|
|
input {
|
|
|
|
|
width: 700px;
|
|
|
|
|
height: 45px;
|
|
|
|
|
border: 1px solid #3cb4a6;
|
|
|
|
|
border-radius: 45px;
|
|
|
|
|
margin-left: 70px;
|
|
|
|
|
line-height: 45px;
|
|
|
|
|
color: #333;
|
|
|
|
|
text-shadow: 0 0 0 #333;
|
|
|
|
|
padding-left: 30px;
|
|
|
|
|
}
|
2023-12-07 17:48:36 +08:00
|
|
|
|
2024-11-22 15:35:30 +08:00
|
|
|
input:focus {
|
|
|
|
|
outline: 1px solid #3cb4a6;
|
|
|
|
|
}
|
2023-12-07 17:48:36 +08:00
|
|
|
|
2024-11-22 15:35:30 +08:00
|
|
|
input::-webkit-input-placeholder {
|
|
|
|
|
color: #949494;
|
|
|
|
|
}
|
|
|
|
|
.search-btn {
|
|
|
|
|
width: 100px;
|
|
|
|
|
height: 39px;
|
2024-11-22 18:03:09 +08:00
|
|
|
transform: translate(-110px, 0);
|
2024-11-22 15:35:30 +08:00
|
|
|
border-radius: 39px;
|
|
|
|
|
background: linear-gradient(132deg, #22ab9b 0%, #0d7462 100%);
|
|
|
|
|
box-shadow: 0px 2px 4px 0px rgba(20, 175, 255, 0.5);
|
|
|
|
|
border: none;
|
|
|
|
|
color: #fff;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
}
|
2023-12-07 17:48:36 +08:00
|
|
|
|
2024-11-22 15:35:30 +08:00
|
|
|
.ipt-down {
|
|
|
|
|
position: absolute;
|
2024-11-22 18:03:09 +08:00
|
|
|
bottom: 5px;
|
2024-11-22 15:35:30 +08:00
|
|
|
left: 22%;
|
|
|
|
|
overflow: hidden;
|
2023-12-07 17:48:36 +08:00
|
|
|
|
2024-11-22 15:35:30 +08:00
|
|
|
a {
|
|
|
|
|
max-width: 140px;
|
|
|
|
|
padding: 0 10px;
|
|
|
|
|
color: #727272;
|
|
|
|
|
font-size: 14px;
|
2023-12-07 17:48:36 +08:00
|
|
|
cursor: pointer;
|
|
|
|
|
overflow: hidden;
|
2024-11-22 15:35:30 +08:00
|
|
|
display: inline-block;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
text-overflow: ellipsis;
|
2023-12-07 17:48:36 +08:00
|
|
|
}
|
|
|
|
|
}
|
2024-11-23 16:31:54 +08:00
|
|
|
|
|
|
|
|
.cart-icon {
|
|
|
|
|
width: 10%;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
|
|
span {
|
|
|
|
|
margin-left: 10px;
|
|
|
|
|
color: #1abc9c;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-07 17:48:36 +08:00
|
|
|
}
|
2024-11-22 15:35:30 +08:00
|
|
|
}
|
2023-12-07 17:48:36 +08:00
|
|
|
</style>
|