first commit
This commit is contained in:
124
金壶/appV1/common/tabBar/tabBar.vue
Normal file
124
金壶/appV1/common/tabBar/tabBar.vue
Normal file
@@ -0,0 +1,124 @@
|
||||
|
||||
|
||||
<template>
|
||||
<view class="tab-bar" >
|
||||
<view class= "tab-bar-item" v-for="(item,index) in list" @click="change(item,index)" :key='index' >
|
||||
<image class="barimg" v-if="item.pagePath == currentPage" :src="item.selectedIconPath" mode="">
|
||||
<image class="barimg" v-else :src="item.iconPath" mode="">
|
||||
<view class="wordcolor" :class="{'item-text':item.pagePath != currentPage, 'itme-text-active':item.pagePath == currentPage }">{{item.text}}</view>
|
||||
<view v-if="item.flag" class="car_GoodsNum" v-show="car_GoodsNum > 0">{{car_GoodsNum}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import X_goods from '../../utils/models/goods.js'
|
||||
import {
|
||||
Config
|
||||
} from '../../utils/config.js'
|
||||
export default {
|
||||
props: {
|
||||
currentPage: {
|
||||
type: String,
|
||||
default: 'index'
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
car_GoodsNum: 0,
|
||||
list:[{
|
||||
"pagePath": "../../pages/home/home",
|
||||
"iconPath": "../../static/tabbar/home.png",
|
||||
"selectedIconPath": "../../static/tabbar/home1.png",
|
||||
"text": "首页",
|
||||
"flag":false
|
||||
}, {
|
||||
"pagePath": "../../pages/classification/classification",
|
||||
"iconPath": "../../static/tabbar/fenlei2.png",
|
||||
"selectedIconPath": "../../static/tabbar/fenlei1.png",
|
||||
"text": "分类",
|
||||
"flag":false
|
||||
}, {
|
||||
"pagePath": "../../pages/shoppingCart/shoppingCart",
|
||||
"iconPath": "../../static/tabbar/car2.png",
|
||||
"selectedIconPath": "../../static/tabbar/car1.png",
|
||||
"text": "购物车",
|
||||
"flag":true
|
||||
}, {
|
||||
"pagePath": "../../pages/my/my",
|
||||
"iconPath": "../../static/tabbar/my2.png",
|
||||
"selectedIconPath": "../../static/tabbar/my1.png",
|
||||
"text": "我的",
|
||||
"flag":false
|
||||
}]
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.car_GoodsNum = Config.shooppingCar_num
|
||||
console.log(this.car_GoodsNum)
|
||||
},
|
||||
methods:{
|
||||
change(item,index){
|
||||
// console.log(this.GoodsNum);
|
||||
let _this = this;
|
||||
_this.list.forEach((currentValue)=>{
|
||||
currentValue.flag = false
|
||||
})
|
||||
uni.reLaunch({
|
||||
url: item.pagePath
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.tab-bar{
|
||||
display: flex;
|
||||
background-color: rgb(255, 255, 255);
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
box-shadow: 0 -1px 1px rgba(100,100,100,.2);
|
||||
|
||||
.tab-bar-item {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
height: 100upx;
|
||||
.barimg {
|
||||
width: 50upx;
|
||||
height: 50upx;
|
||||
margin-top: 10upx;
|
||||
vertical-align: middle;
|
||||
margin-bottom: 2upx;
|
||||
}
|
||||
.car_GoodsNum {
|
||||
background-color: #EB5159;
|
||||
color: #FFFFFF;
|
||||
position: absolute;
|
||||
top: -12upx;
|
||||
right: 120px;
|
||||
height: 40upx;
|
||||
width: 40upx;
|
||||
line-height: 40upx;
|
||||
font-size: 20upx;
|
||||
border-radius: 50%;
|
||||
}
|
||||
.item-text{
|
||||
color: rgb(193, 193, 193);
|
||||
font-size: 10px;
|
||||
}
|
||||
.wordcolor{
|
||||
color: rgb(193, 193, 193);
|
||||
font-size: 10px;
|
||||
}
|
||||
.itme-text-active{
|
||||
color: rgb(107, 104, 220);
|
||||
font-size: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user