123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- <template>
- <view class="category-container clearfix">
- <!-- 头部轮播 -->
- <tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading ="true" :loadingType="5"></tui-skeleton>
- <view class="category-list tui-skeleton">
- <!--顶部搜索导航栏-->
- <!-- <view class="'search-input-fixed">
- <bt-search :clickPath="clickPath" :toestText='hotSearchText'></bt-search>
- </view> -->
- <!-- 左侧分类导航 -->
- <scroll-view class="left-aside" scroll-y="true" scroll-with-animation :scroll-top="verticalNavTop" style="height:calc(100vh - 202rpx)" :style="{top:CustomBar+'px'}">
- <view class="row" v-if="m.smalltypeList.length > 0" v-for="(m, index) in categoryList" :key="index" :class="[index==showCategoryIndex?'on':'']" @tap="showCategory($event,index)" :data-id="index">
- <view class="text tui-skeleton-fillet">
- {{m.name}}
- </view>
- <view class="block"></view>
- </view>
- </scroll-view>
- <!--右侧子导航-->
- <scroll-view scroll-y="true" class="right-aside" style="height:calc(100vh - 202rpx)" :style="{top:CustomBar+'px'}">
- <view class="category" v-if="n.smalltypeList.length > 0" v-for="(n,index) in categoryList" :key="index" v-show="index==showCategoryIndex" >
- <view class="category-box" v-for="(o,oIndex) in n.smalltypeList" :key="oIndex">
- <view class="title tui-skeleton-fillet">{{o.name}}</view>
- <view class="list" v-if="o.tinytypeList.length > 0">
- <view class="box" v-for="(pro,proIndex) in o.tinytypeList" :key="proIndex" @click.stop="navToListPage(pro,proIndex)">
- <image :src="pro.icon" class="tui-skeleton-fillet"></image>
- <view class="text tui-skeleton-fillet">{{pro.name}}</view>
- </view>
- </view>
- <view v-else class="no-data">
- 该栏目暂无分类~
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- </template>
- <script>
- import btSearch from '@/components/uni-search/bt-search.vue'
- import { queryGoodscategory } from "@/api/product.js"
- export default {
- components: {
- btSearch,
- },
- data() {
- return {
- skeletonShow: true,
- headerShow:true,
- hotSearchText: '你想要的这里都有',
- clickPath:'/pages/search/search',
- showCategoryIndex: 0,
- categoryList: [],//分类列表
- search: '',
- cateTop: {},
- verticalNavTop: 0,
- CustomBar:this.CustomBar,// 顶部导航栏高度
- }
- },
- created() {
- this.getProductCate();
- },
- methods: {
- // 跳转至商品列表
- navToList(id){
- this.$api.navigateTo(`/pages/product/list?cate_id=${id}`)
- },
- // 获取商品分类列表
- getProductCate () {
- queryGoodscategory().then(res =>{
- this.categoryList = res.data
- // 查询第一个拥有二级菜单的子菜单
- for (let i = 0; i < this.categoryList.length; i++) {
- if (this.categoryList[i].smalltypeList.length > 0) {
- this.showCategoryIndex = i;
- break;
- }
- }
- this.skeletonShow = false;
- }).catch(res =>{
- this.$util.msg(res.msg,2000);
- })
- },
- showCategory(e,index){//分类切换显示
- this.showCategoryIndex = index;
- this.verticalNavTop = (e.currentTarget.dataset.id - 1) * 50
- },
- toSearch () {// 跳转至搜索详情页
- uni.navigateTo({
- url: `/pages/search/search?search=${JSON.stringify(this.search)}`
- })
- },
- navToListPage(pro,index){//分类导航跳转
- let self = this;
- uni.setStorage({
- key: 'commodity_id',
- data: pro.tinyTypeID,
- success: function () {
- self.$api.navToListPage({type:'4',value:pro.name,id:pro.tinyTypeID});
- }
- })
- }
- }
- }
- </script>
- <style scoped lang="scss">
- page {
- background-color: #fff;
- }
- .search-input-fixed{
- width: 100%;
- height:auto;
- position: fixed;
- top: 0;
- left: 0;
- z-index: 1000;
- background: #FFFFFF;
- border-bottom: 1px solid #F7F7F7;
- }
- .category-container{
- height: 100%;
- }
- /*模块分类*/
- .category-list{
- width: 100%;
- background-color: #fff;
- display: flex;
-
- .left-aside,.right-aside{
- position: absolute;
- /* #ifdef APP-PLUS */
- top: calc(100rpx + var(--status-bar-height));
- /* #endif */
- bottom: 0rpx;
- }
- .left-aside{
- width: 200rpx;
- left: 0rpx;
- background-color: #f2f2f2;
- .row{
- width: 100%;
- height: 100rpx;
- display: flex;
- align-items: center;
- position: relative;
- .text{
- width: 100%;
- position: relative;
- font-size: $font-size-28;
- display: flex;
- justify-content: center;
- color: $text-color;
- /* transition: transform 0.3s ease;*/
- transition-property: transform;
- transition-duration: 0.2s;
- transition-timing-function: ease;
- }
- .block{
- position: absolute;
- width: 0rpx;
- left: 0;
- /* transition: transform 0.3s ease;*/
- transition-property: transform;
- transition-duration: 0.2s;
- transition-timing-function: ease;
- }
- &.on{
- height: 100rpx;
- background-color: #fff;
- .text{
- font-size: $font-size-28;
- color: $color-system;
- }
- .block{
- width: 10rpx;
- height: 60rpx;
- top: 20rpx;
- background-color: $color-system;
- border-radius: 0 15rpx 15rpx 0;
- }
- }
- }
- }
- .right-aside{
- width: 550rpx;
- left: 200rpx;
- background: #FFFFFF;
- .category{
- width: calc(100%);
- padding: 0 15rpx 20rpx 0;
- background: #F7F7F7;
- .category-box{
- background: #FFFFFF;
- margin-bottom: 20rpx;
- .title{
- padding: 0 24rpx;
- line-height: 80rpx;
- height: 80rpx;
- text-align: left;
- color: $text-color;
- font-size: $font-size-26;
- border-bottom: 1px solid #F7F7F7;
- font-weight: 600;
- }
- .list{
- margin-top: 24rpx;
- width: 100%;
- display: flex;
- flex-wrap: wrap;
- .box{
- width: calc(71.44vw / 3);
- margin-bottom: 40rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- flex-wrap: wrap;
- image{
- width: 140rpx;
- height: 140rpx;
- }
- .text{
- margin-top: 8rpx;
- width: 100%;
- display: flex;
- justify-content: center;
- font-size: $font-size-24;
- }
- }
- }
- .no-data {
- text-align: center;
- margin: 30rpx 0;
- color: #999999;
- font-size: 24rpx;
- line-height: 80rpx;
- }
- }
- }
- }
- }
- </style>
|