mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-11-06 17:09:08 +08:00
- 新增 `getStoreById` 接口方法,用于获取包含评分在内的店铺信息 - `Search.vue` 新增搜索建议面板,展示搜索历史和热词,优化搜索体验 - 新增 `SearchSuggest.vue` 组件,用于展示搜索建议和搜索历史 - `App.vue` 根据路由元信息按条件设置页面标题 - 优化多个组件的布局与样式,让整体风格更统一 - 重构多个组件的跳转逻辑,改用路由跳转(`router.push`)替代新开窗口(`window.open`),提升用户体验
159 lines
3.8 KiB
Vue
159 lines
3.8 KiB
Vue
<template>
|
|
<div>
|
|
<div class="wrapper" :style="{right:handleDrawer ? '300px' : '0px'}">
|
|
|
|
<div class="barItem" @mouseenter="showCartNum(item)" @click="clickBar(item)" v-for="(item,index) in resetConfig.menuList" :key="index">
|
|
<el-tooltip placement="left" :content="item.title">
|
|
<el-icon :size="20"><component :is="resolveIcon(item.icon)" /></el-icon>
|
|
<p class="barTitle" v-if="item.titleShow"> {{item.title}}</p>
|
|
<div class="circle" v-if="item.title === '购物车'">
|
|
{{ Number(cartNum) > 99 ? '99+' : cartNum }}
|
|
</div>
|
|
</el-tooltip>
|
|
</div>
|
|
|
|
</div>
|
|
<el-drawer width="300" class="popup" :title="drawerData.title" :modal="resetConfig.mask" :show-close="resetConfig.closable"
|
|
v-model="handleDrawer">
|
|
<drawerPage :title="drawerData.title" />
|
|
</el-drawer>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { Modal } from "@/utils/message";
|
|
import Storage from '@/plugins/storage.js';
|
|
import Configuration from './config';
|
|
import drawerPage from './Drawer'
|
|
import {cartCount} from '@/api/cart.js'
|
|
import { resolveIcon } from '@/utils/iconMap'
|
|
export default {
|
|
name: 'Main',
|
|
data () {
|
|
return {
|
|
resetConfig: Configuration, // 菜单项
|
|
handleDrawer: false, // 是否可展开
|
|
drawerData: '' // 菜单基础数据
|
|
}
|
|
},
|
|
components: {drawerPage},
|
|
computed: {
|
|
// 用户信息
|
|
userInfo () {
|
|
return Storage.getItem('userInfo');
|
|
},
|
|
// 购物车商品数量
|
|
cartNum () {
|
|
return this.$store.state.cartNum
|
|
}
|
|
},
|
|
methods: {
|
|
resolveIcon,
|
|
showCartNum (item) { // 获取购物车数量
|
|
if (this.userInfo && item.title === '购物车') {
|
|
this.getCartList()
|
|
}
|
|
},
|
|
clickBar (val) { // tabbar点击操作
|
|
if (!this.userInfo) {
|
|
Modal.confirm({
|
|
title: '请登录',
|
|
content: '请登录后执行此操作',
|
|
okText: '立即登录',
|
|
cancelText: '继续浏览',
|
|
onOk: () => {
|
|
this.$router.push({
|
|
path: '/login',
|
|
query: {
|
|
rePath: this.$route.path,
|
|
query: JSON.stringify(this.$route.query || {}),
|
|
},
|
|
});
|
|
}
|
|
});
|
|
} else {
|
|
if (val.display) {
|
|
this.handleDrawer = true
|
|
this.drawerData = val
|
|
} else {
|
|
this.handleDrawer = false
|
|
switch (val.title) {
|
|
case '会员中心':
|
|
this.$router.push('/home')
|
|
break;
|
|
case '我的资产':
|
|
this.$router.push('/home/MoneyManagement')
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
},
|
|
getCartList () { // 获取购物车列表
|
|
cartCount().then(res => {
|
|
this.$store.commit('SET_CARTNUM', res.result)
|
|
this.Cookies.setItem('cartNum', res.result)
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.wrapper {
|
|
background-color: #000!important;
|
|
}
|
|
.barItem {
|
|
text-align: center;
|
|
padding: 13px 0;
|
|
|
|
cursor: pointer;
|
|
color: #fff;
|
|
&:hover{
|
|
background-color: $theme_color;
|
|
.circle{
|
|
color: $theme_color;
|
|
background-color: #fff;
|
|
}
|
|
}
|
|
}
|
|
|
|
.barTitle {
|
|
writing-mode: vertical-lr;
|
|
letter-spacing: 2px;
|
|
padding: 4px 0;
|
|
|
|
}
|
|
|
|
.circle {
|
|
min-width: 20px;
|
|
height: 20px;
|
|
padding: 0 4px;
|
|
border-radius: 10px;
|
|
color: #fff;
|
|
background: $theme_color;
|
|
font-size: 12px;
|
|
line-height: 20px;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.wrapper {
|
|
width: 40px;
|
|
position: fixed;
|
|
transition: .35s;
|
|
height: 100%;
|
|
z-index: 9999;
|
|
background: $dark_background_color;
|
|
top: 0;
|
|
display: flex;
|
|
justify-content: center;
|
|
flex-direction: column;
|
|
}
|
|
:deep(.popup .el-drawer__body) {
|
|
padding: 0 !important;
|
|
background-color: #eee;
|
|
}
|
|
:deep(.popup) {
|
|
z-index: 3001;
|
|
}
|
|
</style>
|