dingdong-master/pages/index/index.vue

59 lines
1.3 KiB
Vue

<template>
<view>
<index v-if="curPageCode === 'indexPage'"></index>
<my-home v-else-if="curPageCode === 'myPage'"></my-home>
<msg-home v-else-if="curPageCode === 'msgPage'"></msg-home>
<module-bar :moduleBarInfos="moduleBarInfos"></module-bar>
</view>
</template>
<script>
import moduleBar from '@/components/custom-bar/module-bar.vue';
import index from '@/pages/index/index-home.vue';
import myHome from '@/pages/index/my-home.vue';
import msgHome from '@/pages/index/msg-home.vue';
export default {
components: {
moduleBar,
index,
myHome,
msgHome
},
data() {
return {
moduleBarInfos: [],
curPageCode: 'indexPage'
}
},
onLoad() {
this.loadData();
this.bindEvent();
},
onUnload() {
this.offEvent();
},
methods: {
async loadData() {
this.moduleBarInfos = await this.$api.data('moduleBarInfos');
},
bindEvent() {
uni.$on('getCurPageInfo', function(data) {
if (data.curPageCode === 'publishPage') {
this.isShowPublish = true;
} else {
this.isShowPublish = false;
this.curPageCode = data.curPageCode;
}
}.bind(this));
},
offEvent() {
uni.$off('getCurPageInfo')
}
}
}
</script>
<style scoped>
</style>