|
@@ -1,73 +1,95 @@
|
|
|
<template>
|
|
|
<div
|
|
|
class="category-container">
|
|
|
- <!--商家-->
|
|
|
- <div class="business-list">
|
|
|
- <van-tabs
|
|
|
- v-model="businessValue"
|
|
|
- :color="'#ee0a24'"
|
|
|
- :title-active-color="'#FFF'"
|
|
|
- :title-inactive-color="'#8A8A8A'"
|
|
|
- :background="'#fff'"
|
|
|
- @click="fetchCateList"
|
|
|
- ref="fbtBusinessList">
|
|
|
- <van-tab
|
|
|
- :name="item.value"
|
|
|
- v-for="item in sourceList"
|
|
|
- :key="item.value">
|
|
|
- <template #title>
|
|
|
- <i>{{ item.name }}</i>
|
|
|
- </template>
|
|
|
- </van-tab>
|
|
|
- </van-tabs>
|
|
|
- </div>
|
|
|
- <!--分类-->
|
|
|
- <div
|
|
|
- class="cate-header">
|
|
|
- <van-tabs
|
|
|
- v-model="catId"
|
|
|
- :color="'#F09E38'"
|
|
|
- :title-active-color="'#333333'"
|
|
|
- :title-inactive-color="'#515151'"
|
|
|
- :background="'#fff'"
|
|
|
- @click="selectCateId"
|
|
|
- ref="fbtCateList">
|
|
|
- <van-tab
|
|
|
- :name="item.id"
|
|
|
- v-for="item in cateList"
|
|
|
- :key="item.id">
|
|
|
- <template #title>{{ item.name }}</template>
|
|
|
- </van-tab>
|
|
|
- </van-tabs>
|
|
|
- <van-dropdown-menu
|
|
|
- class="fbt-van-dropdown-menu">
|
|
|
- <van-dropdown-item
|
|
|
- ref="fbtCateDropdownMenu">
|
|
|
- <template #title>
|
|
|
- <van-icon name="arrow-down"/>
|
|
|
- </template>
|
|
|
- <ul>
|
|
|
- <li
|
|
|
- :class="{'active': item.id === catId}"
|
|
|
+ <transition name="fade">
|
|
|
+ <div
|
|
|
+ class="header-wrap"
|
|
|
+ v-show="showHeader">
|
|
|
+ <!--模拟搜索-->
|
|
|
+ <div class="jump-search">
|
|
|
+ <van-search
|
|
|
+ :shape="'round'"
|
|
|
+ v-model="searchValue"
|
|
|
+ placeholder="搜索商品标题 领优惠券拿返现"/>
|
|
|
+ <router-link
|
|
|
+ :to="{name: 'Search'}">去搜索页
|
|
|
+ </router-link>
|
|
|
+ </div>
|
|
|
+ <!--商家-->
|
|
|
+ <div class="business-list">
|
|
|
+ <van-tabs
|
|
|
+ v-model="businessValue"
|
|
|
+ :color="'#ee0a24'"
|
|
|
+ :title-active-color="'#FFF'"
|
|
|
+ :title-inactive-color="'#8A8A8A'"
|
|
|
+ :background="'#fff'"
|
|
|
+ @click="fetchCateList"
|
|
|
+ ref="fbtBusinessList">
|
|
|
+ <van-tab
|
|
|
+ :name="item.value"
|
|
|
+ v-for="item in sourceList"
|
|
|
+ :key="item.value">
|
|
|
+ <template #title>
|
|
|
+ <i>{{ item.name }}</i>
|
|
|
+ </template>
|
|
|
+ </van-tab>
|
|
|
+ </van-tabs>
|
|
|
+ </div>
|
|
|
+ <!--分类-->
|
|
|
+ <div
|
|
|
+ class="cate-header">
|
|
|
+ <van-tabs
|
|
|
+ v-model="catId"
|
|
|
+ :color="'#F09E38'"
|
|
|
+ :title-active-color="'#333333'"
|
|
|
+ :title-inactive-color="'#515151'"
|
|
|
+ :background="'#fff'"
|
|
|
+ @click="selectCateId"
|
|
|
+ ref="fbtCateList">
|
|
|
+ <van-tab
|
|
|
+ :name="item.id"
|
|
|
v-for="item in cateList"
|
|
|
- :key="item.id"
|
|
|
- @click="onConfirm(item)">{{ item.name }}
|
|
|
- </li>
|
|
|
- </ul>
|
|
|
- </van-dropdown-item>
|
|
|
- </van-dropdown-menu>
|
|
|
- </div>
|
|
|
+ :key="item.id">
|
|
|
+ <template #title>{{ item.name }}</template>
|
|
|
+ </van-tab>
|
|
|
+ </van-tabs>
|
|
|
+ <van-dropdown-menu
|
|
|
+ class="fbt-van-dropdown-menu">
|
|
|
+ <van-dropdown-item
|
|
|
+ ref="fbtCateDropdownMenu">
|
|
|
+ <template #title>
|
|
|
+ <van-icon name="arrow-down"/>
|
|
|
+ </template>
|
|
|
+ <ul>
|
|
|
+ <li
|
|
|
+ :class="{'active': item.id === catId}"
|
|
|
+ v-for="item in cateList"
|
|
|
+ :key="item.id"
|
|
|
+ @click="onConfirm(item)">{{ item.name }}
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </van-dropdown-item>
|
|
|
+ </van-dropdown-menu>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </transition>
|
|
|
<!--商品列表-->
|
|
|
<Main
|
|
|
:source="this.businessValue"
|
|
|
:catId="catId"
|
|
|
+ @setShowHeader="setShowHeader"
|
|
|
ref="myMain"/>
|
|
|
+ <!--回到顶部-->
|
|
|
+ <BSScrollTop
|
|
|
+ @handleScrollTop="handleScrollTop"
|
|
|
+ v-show="!showHeader"/>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { Tab, Tabs, DropdownMenu, DropdownItem, Icon, Toast } from 'vant'
|
|
|
+import { Tab, Tabs, DropdownMenu, DropdownItem, Icon, Toast, Search } from 'vant'
|
|
|
import Main from './child/main'
|
|
|
+import BSScrollTop from '../../common/BSScrollTop'
|
|
|
import { apiCateList } from './api/api'
|
|
|
|
|
|
export default {
|
|
@@ -78,10 +100,13 @@ export default {
|
|
|
'van-dropdown-menu': DropdownMenu,
|
|
|
'van-dropdown-item': DropdownItem,
|
|
|
'van-icon': Icon,
|
|
|
- Main
|
|
|
+ 'van-search': Search,
|
|
|
+ Main,
|
|
|
+ BSScrollTop
|
|
|
},
|
|
|
data () {
|
|
|
return {
|
|
|
+ searchValue: '',
|
|
|
sourceList: [
|
|
|
{
|
|
|
name: '京东',
|
|
@@ -107,14 +132,17 @@ export default {
|
|
|
businessValue: 'jd',
|
|
|
catId: '',
|
|
|
cateList: [], // 分类列表
|
|
|
- numPositionY: 0 // BS纵轴坐标
|
|
|
+ numPositionY: 0, // BS纵轴坐标
|
|
|
+ showHeader: true // 是否展示顶部模块:搜索、商家筛选、类别筛选
|
|
|
}
|
|
|
},
|
|
|
activated () {
|
|
|
if (!this.$route.meta.isUseCache) {
|
|
|
+ this.searchValue = ''
|
|
|
this.businessValue = this.sourceList[0].value
|
|
|
this.catId = ''
|
|
|
this.numPositionY = 0
|
|
|
+ this.showHeader = true
|
|
|
this.fetchCateList()
|
|
|
} else {
|
|
|
this.$nextTick(() => {
|
|
@@ -156,10 +184,16 @@ export default {
|
|
|
this.$refs.fbtCateDropdownMenu.toggle()
|
|
|
this.$refs.myMain.init()
|
|
|
})
|
|
|
+ },
|
|
|
+ setShowHeader (val) {
|
|
|
+ this.showHeader = val
|
|
|
+ },
|
|
|
+ handleScrollTop () {
|
|
|
+ this.$refs.myMain.scroll && this.$refs.myMain.scroll.scrollTo(0, 0)
|
|
|
}
|
|
|
},
|
|
|
beforeRouteLeave (to, from, next) {
|
|
|
- if (['CategoryDetail'].findIndex(item => item === to.name) > -1) {
|
|
|
+ if (['MarketingSave', 'Invite', 'Mine', 'Search', 'CategoryDetail'].findIndex(item => item === to.name) > -1) {
|
|
|
from.meta.isUseCache = true
|
|
|
}
|
|
|
this.numPositionY = this.$refs.myMain.scroll ? this.$refs.myMain.scroll.y : 0
|
|
@@ -174,10 +208,56 @@ export default {
|
|
|
left: 0;
|
|
|
top: 0;
|
|
|
right: 0;
|
|
|
- bottom: 0;
|
|
|
+ bottom: 50px;
|
|
|
width: 100%;
|
|
|
}
|
|
|
|
|
|
+.fade-enter-active,
|
|
|
+.fade-leave-active {
|
|
|
+ transition: all 0.6s;
|
|
|
+}
|
|
|
+
|
|
|
+.fade-enter,
|
|
|
+.fade-leave-to {
|
|
|
+ transform: translate3d(0, -136px, 0);
|
|
|
+}
|
|
|
+
|
|
|
+.header-wrap {
|
|
|
+ position: absolute;
|
|
|
+ left: 0;
|
|
|
+ top: 0;
|
|
|
+ z-index: 10;
|
|
|
+ width: 100%;
|
|
|
+}
|
|
|
+
|
|
|
+.jump-search {
|
|
|
+ ::v-deep .van-search {
|
|
|
+ padding-bottom: 0;
|
|
|
+
|
|
|
+ input {
|
|
|
+ &::-webkit-input-placeholder {
|
|
|
+ -webkit-text-fill-color: #999;
|
|
|
+ opacity: 1;
|
|
|
+ color: #999;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ position: relative;
|
|
|
+ left: 0;
|
|
|
+ top: 0;
|
|
|
+ overflow: hidden;
|
|
|
+
|
|
|
+ a {
|
|
|
+ position: absolute;
|
|
|
+ left: 12px;
|
|
|
+ top: 10px;
|
|
|
+ right: 12px;
|
|
|
+ bottom: 0;
|
|
|
+ opacity: 0;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
.business-list {
|
|
|
position: relative;
|
|
|
left: 0;
|