dingdong-mall/components/custom-bar/module-bar.vue

62 lines
1.5 KiB
Vue
Raw Normal View History

2022-04-23 23:13:29 +08:00
<template>
2022-03-15 17:38:58 +08:00
<!-- 底部fixed操作条包含发布选项普通文字加icon加标签选项 -->
<view class="cu-bar tabbar margin-bottom-xl bg-white fixed-bottom-bar">
2022-04-23 23:13:29 +08:00
<view class="action add-action"
v-for="(item, index) in moduleBarInfos" :key="index"
v-if="item.action === 'add'"
:data-cur="item.pageCode"
:class="[curPageCode===item.pageCode ? 'text-main-color' : 'text-gray']"
@click="navChange($event, false)">
<button class="cu-btn shadow bg-main-color"
:class="['cuIcon-' + item.cuIcon]">
</button>
2022-03-15 17:38:58 +08:00
{{item.name}}
</view>
2022-04-23 23:13:29 +08:00
<view class="action" v-else
:data-cur="item.pageCode"
:class="curPageCode===item.pageCode ? 'text-main-color' : 'text-gray'"
@click="navChange($event, true)">
2022-03-15 17:38:58 +08:00
<view :class="'cuIcon-' + item.cuIcon">
<view class="cu-tag badge" v-if="item.countTag">{{item.countTag > 99 ? '99+' : item.countTag}}</view>
</view>
{{item.name}}
</view>
</view>
</template>
<script>
export default {
name: "module-bar",
emits: ['getCurPageInfo'],
2022-03-15 17:38:58 +08:00
props: {
moduleBarInfos: {
type: Array,
default: []
}
},
data() {
2022-04-23 23:13:29 +08:00
return {
curPageCode: ''
};
},
onReady() {
this.loadData();
2022-03-15 17:38:58 +08:00
},
2022-04-23 23:13:29 +08:00
methods: {
loadData() {
this.curPageCode = this.moduleBarInfos[0].pageCode;
},
navChange(e, isChangeFocus) {
let cur = e.currentTarget.dataset.cur;
this.curPageCode = isChangeFocus ? cur : this.curPageCode;
this.$emit('getCurPageInfo', {
2022-04-23 23:13:29 +08:00
curPageCode: cur
});
}
2022-03-15 17:38:58 +08:00
}
}
</script>
<style>
2022-03-15 17:38:58 +08:00
</style>