feat: 点击吸顶栏搜索滚动到顶部并且输入框聚焦

merge-requests/92/head
xiaoguang 3 years ago
parent 15b7867528
commit 4bdf753c6e

@ -170,6 +170,9 @@ export default {
border-radius: 4px;
border: 1px solid #eeeeee;
cursor: pointer;
&:hover {
background: #eeeeee;
}
.wrap-right-cart__tip {
width: 16px;
height: 16px;

@ -214,8 +214,8 @@ export default {
height: 42px;
font-size: 14px;
img {
width: 8px;
height: 14px;
width: 6px;
height: 12px;
}
}
.menu-item__wrap {

@ -27,7 +27,7 @@
<div class="bar-header-wrap__icons flex flex-middle">
<img
src="~/assets/img/layout/icon-search-sticky.png"
@click="$router.push('/goods/list')"
@click="onEnterSearch"
/>
<div class="header-wrap-icons__shop" @click="onOpenCartPage">
<img src="~/assets/img/layout/icon-shop-sticky.png" />
@ -69,6 +69,7 @@
<div class="box-wrap-right__search flex">
<div class="search-input">
<el-input
ref="searchInput"
v-model="searchContent"
clearable
placeholder="请输入商品名称"
@ -174,6 +175,12 @@ export default {
this.getSeckillData();
},
methods: {
onEnterSearch() {
document.querySelector("body").scrollIntoView({ behavior: "smooth" });
setTimeout(() => {
this.$refs.searchInput.focus();
}, 500);
},
async getSeckillData() {
const { result } = await ApiGetHomeSeckill();
if (result && result.activityTimeVO) {
@ -197,6 +204,9 @@ export default {
});
},
onOpenCartPage() {
if (!this.$isLoginValidate()) {
return;
}
window.open(`${location.origin}/cart`);
},
onOpenHomePage() {

Loading…
Cancel
Save