perry-mall/components/foot-tab.vue

188 lines
5.0 KiB
Vue
Raw Normal View History

2022-02-12 11:33:47 +00:00
<template>
<view>
<view class="foot-boxtwo"
:style="{
background: isGradualChange ? `linear-gradient( to ${direction}, ${colorOne} 0%, ${colorTwo} 20%, ${colorThree} 80%, ${colorFour} 100%)` : `url(${backgroundImage}) ${backgroundColor} `,
boxShadow: `-10rpx 0rpx 20rpx rgba( 0, 0, 0, ${boxShadowNum})`
}">
<!-- 后台动态改变的icon与标题 start -->
2022-02-12 11:33:47 +00:00
<!-- tab-图标列表 -->
<view class="item-box" :style="{marginBottom: marginBottomNum +'px'}">
2022-02-24 03:21:51 +00:00
<view @tap="choosefoot(index)" class="foot-icon"
2022-02-12 11:33:47 +00:00
:style="{width: 100 / imgList.length +'%'}"
:class="index == isIcon ? 'centerBox' : ''"
v-for="(itemi,index) in imgList" :key="index">
<view class="posir" :class="index == isIcon ? 'centerBox-item':''">
2022-02-23 11:08:25 +00:00
<image :class="index == isIcon ? 'centerImg':'moImg'" v-if="newcurrent == index" :src="itemi.selectedIconPath" :style="{width: [39,41,32,120][index]+'rpx',height: [40,41,38,120][index]+'rpx'}"></image>
<image :class="index == isIcon ? 'centerImg':'moImg'" v-else :src="itemi.iconPath" :style="{width: [39,41,32,120][index]+'rpx',height: [40,41,38,120][index]+'rpx'}"></image>
2022-02-12 11:33:47 +00:00
<button v-if="index == isIcon && isCustomerService" class="fon24 posia" style="opacity: 0;top: 0;left: 0;right: 0;bottom: 0;" open-type="contact"></button>
</view>
</view>
</view>
<!-- tab-标题列表 -->
<view class="item-box">
2022-02-23 11:08:25 +00:00
<view @tap="choosefoot(index)" class="foot-title"
2022-02-12 11:33:47 +00:00
:style="{width:100 / imgList.length +'%', color:newcurrent == index ? colorActive : colorMo}"
v-for="(itemt,index) in titleList" :key="index">{{itemt}}</view>
</view>
<!-- 后台动态改变的icon图 end -->
2022-02-12 11:33:47 +00:00
</view>
</view>
</template>
<script>
export default {
name:'foot-tab',
props:{
// 当前选中项
newcurrent:{
type:Number,
default:0
},
// 标题内容
titleList:{
type:Array,
default:function(){
return uni.getStorageSync('footTitle')
}
},
// icon图标
imgList:{
type:Array,
default:function(){
return uni.getStorageSync('imgList');
}
},
// 默认哪个图标突出
isIcon:{
type:Number,
default:3
2022-02-12 11:33:47 +00:00
},
// 底部导航背景图片
backgroundImage:{
type:String,
2022-02-23 11:08:25 +00:00
default:'https://s6.jpg.cm/2022/02/14/L4oDhy.jpg'
2022-02-12 11:33:47 +00:00
},
// 背景颜色
backgroundColor:{
type:String,
default:'#FFFFFF'
},
// 是否开启背景颜色渐变
isGradualChange:{
type:Boolean,
default:true
},
// 渐变方向
direction:{
type:String,
default:'right top'
},
// 第一种颜色
colorOne:{
type:String,
default:'#FFFFFF'
},
// 第二种颜色
colorTwo:{
type:String,
default:'#FFFFFF'
},
// 第三种颜色
colorThree:{
type:String,
default:'#FFFFFF'
},
// 第四种颜色
colorFour:{
type:String,
default:'#FFFFFF'
},
// 阴影大小0~1之间 0表示没有阴影
boxShadowNum:{
type:Number,
default:0
},
// 图标与文字的间距
marginBottomNum:{
type:Number,
2022-02-23 11:08:25 +00:00
default:0
2022-02-12 11:33:47 +00:00
},
// 默认的标题颜色
colorMo:{
type:String,
default:'#999999'
},
// 选中的标题颜色
colorActive:{
type:String,
default:'#000000'
}
},
data() {
return {
isCustomerService:false,//是否存在客服 默认不存在客服
};
},
mounted() {
},
methods:{
choosefoot(index){
2022-02-23 11:08:25 +00:00
if(index==0){
2022-02-12 11:33:47 +00:00
uni.reLaunch({url:'/pages/tabbar/pagehome/pagehome'})
2022-02-23 11:08:25 +00:00
return
} else {
2022-02-25 09:24:06 +00:00
if(uni.getStorageSync('phone_active')) {
2022-02-23 11:08:25 +00:00
switch (index){
case 1:
uni.reLaunch({url:'/pages/tabbar/cate/cate'})
break;
case 2:
uni.reLaunch({url:'/pages/tabbar/my/my'})
break;
case 3:
uni.reLaunch({url:'/pages/tabbar/cart/cart'})
break;
}
} else {
uni.navigateTo({
url:'/pages/login/login',
animationType:'slide-in-bottom'
})
}
2022-02-12 11:33:47 +00:00
}
}
}
}
</script>
2022-02-23 11:08:25 +00:00
<style scoped>
2022-02-12 11:33:47 +00:00
/* 外框样式 start */
.foot-boxtwo{
2022-02-23 11:08:25 +00:00
height: 120rpx;
2022-02-12 11:33:47 +00:00
font-size: 24rpx;
position: fixed;bottom: 0;left: 0;right: 0;z-index: 10;
display: flex;flex-direction: column;justify-content: center;
background-repeat: no-repeat;background-size: 100% 100%;
}
/* 外框样式 end */
/* 公共 start*/
2022-02-23 11:08:25 +00:00
.moImg{width: 64rpx;height: 64rpx;vertical-align: bottom;}
2022-02-12 11:33:47 +00:00
/* 公共 end*/
/* 图标-文字外框样式 start */
.item-box{display: flex;justify-content: space-around;align-items: center;}
2022-02-24 03:21:51 +00:00
.item-box .foot-icon,.item-box .foot-title{text-align: center;box-sizing: border-box;}
2022-02-12 11:33:47 +00:00
/* 图标-文字外框样式 end */
/* 突出的图标样式 start */
2022-02-23 11:08:25 +00:00
.centerBox{display: flex;justify-content: center;align-items: center;vertical-align: bottom;}
.centerBox-item{margin-top: -80rpx;vertical-align: bottom;margin-left: -50rpx;}
.centerImg{width: 140rpx;height: 140rpx;vertical-align: bottom;}
2022-02-12 11:33:47 +00:00
/* 突出的图标样式 end */
2022-02-23 11:08:25 +00:00
.item-box .foot-title{padding-top: 16rpx;}
.item-box .foot-title:last-child{text-align: left;padding-left: 40rpx;}
2022-02-12 11:33:47 +00:00
</style>