2024-02-19 10:44:33 +08:00
|
|
|
|
<template>
|
|
|
|
|
<view>
|
|
|
|
|
<!-- #ifdef MP || APP-PLUS -->
|
|
|
|
|
<view style="visibility: hidden;" :style="{ height: navHeight + 'rpx' }" v-if="isFixed"></view>
|
|
|
|
|
<!-- #endif -->
|
2024-05-10 16:32:04 +08:00
|
|
|
|
<view class="navTabBox tabNav" :class="{isFixed:isFixed}"
|
|
|
|
|
:style="'background:'+bgColor+';margin-top:'+mbConfig+'rpx;color:'+txtColor+';top:'+isTop">
|
2024-02-19 10:44:33 +08:00
|
|
|
|
<view class="longTab" :style='"width:"+mainWidth+"px"'>
|
2024-05-10 16:32:04 +08:00
|
|
|
|
<scroll-view scroll-x="true" style="white-space: nowrap; display: flex;" scroll-with-animation
|
|
|
|
|
:scroll-left="tabLeft" show-scrollbar="true">
|
|
|
|
|
<view class="longItem"
|
|
|
|
|
:style="'width:'+isWidth+'px;color:'+(index===tabClick ? activeColor : txtColor)"
|
|
|
|
|
:data-index="index" :class="index===tabClick?'click':''" v-for="(item,index) in tabTitle"
|
|
|
|
|
:key="index" :id="'id'+index" @click="longClick(index,item.store_category_id,item.pid)">
|
|
|
|
|
{{item.cate_name}}</view>
|
2024-02-19 10:44:33 +08:00
|
|
|
|
<view class="underlineBox" :style='"transform:translateX("+isLeft+"px);width:"+isWidth+"px"'>
|
|
|
|
|
<view class="underline" :style="'background-color:'+activeColor"></view>
|
|
|
|
|
</view>
|
|
|
|
|
</scroll-view>
|
|
|
|
|
</view>
|
2024-05-10 16:32:04 +08:00
|
|
|
|
<navigator v-if="merId" :url="'/pages/store/home/index?id='+merId+'&type=2'" class="category"
|
|
|
|
|
hover-class="none" :style="'background-color:'+bgColor+';color:'+txtColor">
|
2024-02-19 10:44:33 +08:00
|
|
|
|
<text class="iconfont icon-fenlei3"></text>分类
|
|
|
|
|
</navigator>
|
2024-05-10 16:32:04 +08:00
|
|
|
|
<navigator v-else open-type='switchTab' url="/pages/goods_cate/goods_cate" class="category"
|
|
|
|
|
hover-class="none" :style="'background-color:'+bgColor+';color:'+txtColor">
|
2024-02-19 10:44:33 +08:00
|
|
|
|
<text class="iconfont icon-fenlei3"></text>分类
|
|
|
|
|
</navigator>
|
2024-05-10 16:32:04 +08:00
|
|
|
|
</view>
|
2024-02-19 10:44:33 +08:00
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | Author: CRMEB Team <admin@crmeb.com>
|
|
|
|
|
// +----------------------------------------------------------------------
|
2024-05-10 16:32:04 +08:00
|
|
|
|
import {
|
|
|
|
|
getCateData
|
|
|
|
|
} from '@/api/api.js';
|
2024-02-19 10:44:33 +08:00
|
|
|
|
let app = getApp();
|
|
|
|
|
export default {
|
|
|
|
|
name: 'navTab',
|
|
|
|
|
props: {
|
|
|
|
|
// tabTitle: {
|
|
|
|
|
// type: Array,
|
|
|
|
|
// default: []
|
|
|
|
|
// },
|
|
|
|
|
dataConfig: {
|
|
|
|
|
type: Object,
|
|
|
|
|
default: () => {}
|
|
|
|
|
},
|
|
|
|
|
isFixed: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: false
|
|
|
|
|
},
|
|
|
|
|
merId: {
|
|
|
|
|
type: String || Number,
|
|
|
|
|
default: ''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
tabTitle: [],
|
|
|
|
|
tabClick: 0, //导航栏被点击
|
|
|
|
|
isLeft: 0, //导航栏下划线位置
|
|
|
|
|
isWidth: 0, //每个导航栏占位
|
|
|
|
|
mainWidth: 0,
|
2024-05-10 16:32:04 +08:00
|
|
|
|
tabLeft: 0,
|
|
|
|
|
swiperIndex: 0,
|
|
|
|
|
childIndex: 0,
|
|
|
|
|
childID: 0,
|
|
|
|
|
bgColor: this.dataConfig.bgColor.color[0].item,
|
|
|
|
|
mbConfig: this.dataConfig.mbConfig.val * 2,
|
|
|
|
|
txtColor: this.dataConfig.txtColor.color[0].item,
|
2024-02-19 10:44:33 +08:00
|
|
|
|
activeColor: this.dataConfig.activeColor.color[0].item,
|
|
|
|
|
fixedTop: 0,
|
|
|
|
|
isTop: 0,
|
|
|
|
|
navHeight: 38,
|
|
|
|
|
diy_id: this.dataConfig.did,
|
|
|
|
|
unique: this.dataConfig.timestamp,
|
|
|
|
|
};
|
|
|
|
|
},
|
2024-05-10 16:32:04 +08:00
|
|
|
|
watch: {
|
2024-02-19 10:44:33 +08:00
|
|
|
|
// #ifdef MP || APP-PLUS
|
2024-05-10 16:32:04 +08:00
|
|
|
|
isFixed(nVal, oVal) {
|
|
|
|
|
if (nVal) {
|
2024-02-19 10:44:33 +08:00
|
|
|
|
this.isTop = (uni.getSystemInfoSync().statusBarHeight + 43) + 'px'
|
2024-05-10 16:32:04 +08:00
|
|
|
|
} else {
|
2024-02-19 10:44:33 +08:00
|
|
|
|
this.isTop = 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// #endif
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
var that = this
|
|
|
|
|
that.getCateData()
|
|
|
|
|
// 获取设备宽度
|
|
|
|
|
uni.getSystemInfo({
|
2024-05-10 16:32:04 +08:00
|
|
|
|
success(e) {
|
2024-02-19 10:44:33 +08:00
|
|
|
|
that.mainWidth = e.windowWidth
|
2024-05-10 16:32:04 +08:00
|
|
|
|
that.isWidth = (e.windowWidth - 65) / 4
|
2024-02-19 10:44:33 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
setTimeout((e) => {
|
|
|
|
|
const query = uni.createSelectorQuery().in(this);
|
|
|
|
|
query.select('.navTabBox').boundingClientRect(data => {
|
|
|
|
|
that.navHeight = data.height * 2
|
|
|
|
|
that.$emit('bindHeight', data)
|
|
|
|
|
}).exec();
|
|
|
|
|
}, 300)
|
|
|
|
|
that.$nextTick(function() {
|
|
|
|
|
uni.getSystemInfo({
|
|
|
|
|
success: function(res) {
|
|
|
|
|
that.windowHeight = res.windowHeight;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
// #ifdef MP || APP-PLUS
|
|
|
|
|
// this.isTop = (uni.getSystemInfoSync().statusBarHeight + 43) + 'px'
|
|
|
|
|
// #endif
|
|
|
|
|
// #ifdef H5
|
|
|
|
|
this.isTop = 0
|
|
|
|
|
// #endif
|
2024-05-10 16:32:04 +08:00
|
|
|
|
|
2024-02-19 10:44:33 +08:00
|
|
|
|
},
|
|
|
|
|
methods: {
|
2024-05-10 16:32:04 +08:00
|
|
|
|
getCateData() {
|
2024-02-19 10:44:33 +08:00
|
|
|
|
getCateData({
|
|
|
|
|
diy_id: this.diy_id,
|
|
|
|
|
unique: this.unique,
|
2024-05-10 16:32:04 +08:00
|
|
|
|
}).then(res => {
|
2024-02-19 10:44:33 +08:00
|
|
|
|
res.data.unshift({
|
|
|
|
|
cate_name: '首页'
|
|
|
|
|
});
|
|
|
|
|
this.$set(this, 'tabTitle', res.data);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
// 导航栏点击
|
2024-05-10 16:32:04 +08:00
|
|
|
|
longClick(index, id, fid) {
|
2024-02-19 10:44:33 +08:00
|
|
|
|
app.globalData.fid = fid;
|
|
|
|
|
this.childIndex = 0;
|
2024-05-10 16:32:04 +08:00
|
|
|
|
if (this.tabTitle.length > 3) {
|
2024-02-19 10:44:33 +08:00
|
|
|
|
var tempIndex = index - 2;
|
2024-05-10 16:32:04 +08:00
|
|
|
|
tempIndex = tempIndex <= 0 ? 0 : tempIndex;
|
|
|
|
|
this.tabLeft = (index - 2) * this.isWidth //设置下划线位置
|
2024-02-19 10:44:33 +08:00
|
|
|
|
}
|
|
|
|
|
this.tabClick = index //设置导航点击了哪一个
|
|
|
|
|
this.isLeft = index * this.isWidth //设置下划线位置
|
|
|
|
|
let obj = {
|
2024-05-10 16:32:04 +08:00
|
|
|
|
index: index,
|
|
|
|
|
pid: id //自己的id
|
2024-02-19 10:44:33 +08:00
|
|
|
|
}
|
2024-05-10 16:32:04 +08:00
|
|
|
|
if (!this.merId) {
|
2024-02-19 10:44:33 +08:00
|
|
|
|
this.parentEmit(obj);
|
2024-05-10 16:32:04 +08:00
|
|
|
|
} else {
|
|
|
|
|
if (id) {
|
2024-02-19 10:44:33 +08:00
|
|
|
|
uni.navigateTo({
|
2024-05-10 16:32:04 +08:00
|
|
|
|
url: '/pages/store/list/index?id=' + id + '&mer_id=' + this.merId
|
2024-02-19 10:44:33 +08:00
|
|
|
|
});
|
2024-05-10 16:32:04 +08:00
|
|
|
|
} else {
|
2024-02-19 10:44:33 +08:00
|
|
|
|
uni.navigateTo({
|
2024-05-10 16:32:04 +08:00
|
|
|
|
url: '/pages/store/home/index?id=' + this.merId
|
2024-02-19 10:44:33 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
2024-05-10 16:32:04 +08:00
|
|
|
|
|
|
|
|
|
}
|
2024-02-19 10:44:33 +08:00
|
|
|
|
},
|
2024-05-10 16:32:04 +08:00
|
|
|
|
parentEmit(obj) {
|
2024-02-19 10:44:33 +08:00
|
|
|
|
this.$emit('changeTab', obj);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.tabNav {
|
|
|
|
|
padding-top: 10rpx;
|
|
|
|
|
}
|
2024-05-10 16:32:04 +08:00
|
|
|
|
|
2024-02-19 10:44:33 +08:00
|
|
|
|
.navTabBox {
|
|
|
|
|
width: 100%;
|
|
|
|
|
color: rgba(255, 255, 255, 1);
|
|
|
|
|
position: relative;
|
|
|
|
|
padding-bottom: 10rpx;
|
2024-05-10 16:32:04 +08:00
|
|
|
|
|
2024-02-19 10:44:33 +08:00
|
|
|
|
&.isFixed {
|
|
|
|
|
z-index: 10;
|
|
|
|
|
position: fixed;
|
|
|
|
|
left: 0;
|
|
|
|
|
width: 100%;
|
|
|
|
|
/* #ifdef H5 */
|
|
|
|
|
top: 0;
|
|
|
|
|
/* #endif */
|
|
|
|
|
}
|
2024-05-10 16:32:04 +08:00
|
|
|
|
|
2024-02-19 10:44:33 +08:00
|
|
|
|
.click {
|
|
|
|
|
color: white;
|
|
|
|
|
}
|
2024-05-10 16:32:04 +08:00
|
|
|
|
|
2024-02-19 10:44:33 +08:00
|
|
|
|
.longTab {
|
|
|
|
|
/* #ifdef H5 */
|
|
|
|
|
padding-right: 106rpx;
|
|
|
|
|
/* #endif */
|
|
|
|
|
/* #ifdef MP || APP-PLUS */
|
|
|
|
|
padding-right: 116rpx;
|
2024-05-10 16:32:04 +08:00
|
|
|
|
|
2024-02-19 10:44:33 +08:00
|
|
|
|
/* #endif */
|
2024-05-10 16:32:04 +08:00
|
|
|
|
.longItem {
|
|
|
|
|
height: 50upx;
|
2024-02-19 10:44:33 +08:00
|
|
|
|
display: inline-block;
|
|
|
|
|
line-height: 50upx;
|
|
|
|
|
text-align: center;
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
color: #333333;
|
|
|
|
|
max-width: 160rpx;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
2024-05-10 16:32:04 +08:00
|
|
|
|
|
|
|
|
|
&.click {
|
2024-02-19 10:44:33 +08:00
|
|
|
|
font-weight: bold;
|
|
|
|
|
font-size: 30rpx;
|
|
|
|
|
color: #E93323;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-10 16:32:04 +08:00
|
|
|
|
|
2024-02-19 10:44:33 +08:00
|
|
|
|
.underlineBox {
|
|
|
|
|
height: 3px;
|
|
|
|
|
width: 20%;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-content: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
transition: .5s;
|
2024-05-10 16:32:04 +08:00
|
|
|
|
|
2024-02-19 10:44:33 +08:00
|
|
|
|
.underline {
|
|
|
|
|
width: 33rpx;
|
|
|
|
|
height: 4rpx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-10 16:32:04 +08:00
|
|
|
|
|
|
|
|
|
.category_wrap {
|
|
|
|
|
transition: height .4s;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.category {
|
2024-02-19 10:44:33 +08:00
|
|
|
|
position: absolute;
|
|
|
|
|
right: 0;
|
|
|
|
|
top: 10rpx;
|
|
|
|
|
/* #ifdef H5 */
|
|
|
|
|
width: 132rpx;
|
|
|
|
|
/* #endif */
|
|
|
|
|
/* #ifdef MP */
|
|
|
|
|
width: 120rpx;
|
|
|
|
|
/* #endif */
|
|
|
|
|
/* #ifdef APP-PLUS */
|
|
|
|
|
width: 150rpx;
|
|
|
|
|
/* #endif */
|
|
|
|
|
height: 50upx;
|
|
|
|
|
line-height: 50upx;
|
|
|
|
|
z-index: 3;
|
|
|
|
|
padding: 0 15rpx 0 25rpx;
|
2024-05-10 16:32:04 +08:00
|
|
|
|
|
|
|
|
|
.iconfont {
|
2024-02-19 10:44:33 +08:00
|
|
|
|
font-size: 30rpx;
|
2024-05-10 16:32:04 +08:00
|
|
|
|
margin-right: 6rpx;
|
2024-02-19 10:44:33 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-10 16:32:04 +08:00
|
|
|
|
|
|
|
|
|
.child-box {
|
2024-02-19 10:44:33 +08:00
|
|
|
|
width: 100%;
|
|
|
|
|
position: relative;
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
/* #ifdef H5 */
|
|
|
|
|
box-shadow: 0 2px 5px 1px rgba(0, 0, 0, 0.02);
|
|
|
|
|
/* #endif */
|
|
|
|
|
/* #ifdef MP */
|
|
|
|
|
box-shadow: 0 2rpx 3rpx 1rpx #f9f9f9;
|
2024-05-10 16:32:04 +08:00
|
|
|
|
|
2024-02-19 10:44:33 +08:00
|
|
|
|
/* #endif */
|
2024-05-10 16:32:04 +08:00
|
|
|
|
.wrapper {
|
2024-02-19 10:44:33 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
padding: 20rpx 0;
|
|
|
|
|
background: #fff;
|
|
|
|
|
}
|
2024-05-10 16:32:04 +08:00
|
|
|
|
|
|
|
|
|
.child-item {
|
2024-02-19 10:44:33 +08:00
|
|
|
|
flex-shrink: 0;
|
2024-05-10 16:32:04 +08:00
|
|
|
|
width: 140rpx;
|
2024-02-19 10:44:33 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
margin-left: 10rpx;
|
2024-05-10 16:32:04 +08:00
|
|
|
|
|
|
|
|
|
image {
|
2024-02-19 10:44:33 +08:00
|
|
|
|
width: 90rpx;
|
|
|
|
|
height: 90rpx;
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
}
|
2024-05-10 16:32:04 +08:00
|
|
|
|
|
|
|
|
|
.txt {
|
2024-02-19 10:44:33 +08:00
|
|
|
|
font-size: 24rpx;
|
|
|
|
|
color: #282828;
|
|
|
|
|
text-align: center;
|
|
|
|
|
margin-top: 10rpx;
|
|
|
|
|
}
|
2024-05-10 16:32:04 +08:00
|
|
|
|
|
|
|
|
|
&.on {
|
|
|
|
|
image {
|
2024-02-19 10:44:33 +08:00
|
|
|
|
border: 1px solid $theme-color-opacity;
|
|
|
|
|
}
|
2024-05-10 16:32:04 +08:00
|
|
|
|
|
|
|
|
|
.txt {
|
2024-02-19 10:44:33 +08:00
|
|
|
|
color: $theme-color;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-10 16:32:04 +08:00
|
|
|
|
</style>
|