2024-10-27 00:26:19 +08:00
|
|
|
<template>
|
|
|
|
<view>
|
2024-11-12 17:34:05 +08:00
|
|
|
<view class="u-page upage">
|
|
|
|
<Home ref="home" :moduleList="moduleList" @changeLoading="changeLoading" :bgColor="getBgColor" v-show="current===0" />
|
|
|
|
<PolicyList :moduleList="moduleList" ref="policy" style="height: 100vh" v-show="current===1" />
|
|
|
|
<ActivityList :moduleList="moduleList" ref="activity" v-show="current===2" />
|
2024-10-31 21:24:54 +08:00
|
|
|
<My ref="my" v-show="current===3" />
|
2024-10-27 00:26:19 +08:00
|
|
|
</view>
|
2024-10-31 21:24:54 +08:00
|
|
|
<u-tabbar @change="beforeSwitch" :value="current" activeColor="#94ceff" :list="list"></u-tabbar>
|
|
|
|
<Loading :show="loading" />
|
2024-10-27 00:26:19 +08:00
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import Home from '@/pages/home/home.vue';
|
|
|
|
import PolicyList from '@/pages/policy/policyList.vue';
|
|
|
|
import ActivityList from '@/pages/activity/activityList.vue';
|
|
|
|
import My from '@/pages/my/my.vue';
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
Home,PolicyList,ActivityList,My
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
list: [{
|
|
|
|
iconPath: "home",
|
|
|
|
selectedIconPath: "home-fill",
|
|
|
|
text: '首页',
|
|
|
|
customIcon: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
iconPath: "chat",
|
|
|
|
selectedIconPath: "chat-fill",
|
|
|
|
text: '最新政策',
|
|
|
|
customIcon: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
iconPath: "grid",
|
|
|
|
selectedIconPath: "grid-fill",
|
2024-11-12 17:34:05 +08:00
|
|
|
text: '人才服务',
|
2024-10-27 00:26:19 +08:00
|
|
|
customIcon: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
iconPath: "account",
|
|
|
|
selectedIconPath: "account-fill",
|
|
|
|
text: '我的',
|
|
|
|
customIcon: false,
|
|
|
|
}
|
|
|
|
],
|
|
|
|
menuHeight:uni.getMenuButtonBoundingClientRect(),
|
|
|
|
current: 0,// 当前页
|
|
|
|
topLevel: 0,// 页面是否滚动到顶
|
2024-10-31 21:24:54 +08:00
|
|
|
loading: true,// 加载
|
2024-11-12 17:34:05 +08:00
|
|
|
moduleList: [],
|
2024-10-27 00:26:19 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed:{
|
|
|
|
getBgColor(){
|
|
|
|
return `rgba(75, 170, 251,${this.topLevel})`;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onPageScroll(e) {
|
|
|
|
const level = e.scrollTop/this.menuHeight.height;
|
|
|
|
if(level<=1) this.topLevel = level;
|
|
|
|
else this.topLevel = 1;
|
|
|
|
},
|
2024-11-12 17:34:05 +08:00
|
|
|
async onLoad() {
|
|
|
|
await this.getModule();
|
|
|
|
this.beforeSwitch(this.current);
|
|
|
|
},
|
2024-10-31 21:24:54 +08:00
|
|
|
onShow() {
|
|
|
|
let index = uni.getStorageSync('pageIndex');
|
|
|
|
this.current = index?index:0;
|
|
|
|
this.beforeSwitch(this.current);
|
|
|
|
},
|
|
|
|
onHide(){
|
|
|
|
uni.setStorageSync('pageIndex',this.current);
|
|
|
|
},
|
2024-11-12 17:34:05 +08:00
|
|
|
// 上拉刷新
|
|
|
|
onPullDownRefresh() {
|
|
|
|
try{
|
|
|
|
if(this.current === 0){
|
|
|
|
this.$refs['home'].getHomeData();
|
|
|
|
} else if(this.current === 1){
|
|
|
|
this.$refs['policy'].onRefresh();
|
|
|
|
} else if(this.current === 2){
|
|
|
|
this.$refs['activity'].onRefresh();
|
|
|
|
}
|
|
|
|
}catch(e){}
|
|
|
|
finally{
|
|
|
|
uni.stopPullDownRefresh();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// 滑动到底
|
|
|
|
onReachBottom() {
|
|
|
|
if(this.current === 1){
|
|
|
|
this.$refs['policy'].onreachBottom();
|
|
|
|
} else if(this.current === 2){
|
|
|
|
this.$refs['activity'].onreachBottom();
|
|
|
|
}
|
|
|
|
},
|
2024-10-27 00:26:19 +08:00
|
|
|
methods: {
|
2024-11-12 17:34:05 +08:00
|
|
|
// 获取模块
|
|
|
|
async getModule(){
|
|
|
|
// 获取文章模块
|
|
|
|
let moduleRes = await this.$api.getAllModule();
|
|
|
|
if(moduleRes.success){
|
|
|
|
this.moduleList = moduleRes.data;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async beforeSwitch(index){
|
2024-10-31 21:24:54 +08:00
|
|
|
try{
|
|
|
|
this.current = index;
|
2024-11-12 17:34:05 +08:00
|
|
|
// this.loading = true;
|
2024-10-31 21:24:54 +08:00
|
|
|
uni.setNavigationBarTitle({
|
|
|
|
title: this.list[index].text
|
|
|
|
});
|
|
|
|
switch(index){
|
|
|
|
case 0:
|
2024-11-12 17:34:05 +08:00
|
|
|
await this.$refs['home'].getHomeData();
|
2024-10-31 21:24:54 +08:00
|
|
|
break;
|
|
|
|
case 1:
|
2024-11-12 17:34:05 +08:00
|
|
|
await this.$refs['policy'].init();
|
2024-10-31 21:24:54 +08:00
|
|
|
break;
|
|
|
|
case 2:
|
2024-11-12 17:34:05 +08:00
|
|
|
await this.$refs['activity'].init();
|
2024-10-31 21:24:54 +08:00
|
|
|
break;
|
|
|
|
case 3:
|
2024-11-12 17:34:05 +08:00
|
|
|
await this.$refs['my'].refresh();
|
2024-10-31 21:24:54 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}catch(e){
|
|
|
|
}finally{
|
|
|
|
this.loading = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
changeLoading(show){
|
|
|
|
this.loading = show;
|
|
|
|
}
|
2024-10-27 00:26:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2024-11-12 17:34:05 +08:00
|
|
|
.upage{
|
|
|
|
width: 100%;
|
|
|
|
height: calc(100% - 50px);
|
|
|
|
}
|
2024-10-27 00:26:19 +08:00
|
|
|
</style>
|