<template>
|
<uni-base-page :title="navTitle" :footer="false">
|
<view slot="page">
|
<view v-if="loginInfo.hasLogin">
|
<view class="example-body">
|
<uni-grid :column="col">
|
<uni-grid-item v-for="(item, index) in userMenu" :index="index" :key="index">
|
<!-- 目录 -->
|
<navigator v-if="item.menuType" class="grid-item-box" hover-class="none" :url="`/pages/BasePages/menuContainer?PRA001=${item.PRA001}&title=${item.PRA003}&parentTitle=${myName}`">
|
<image class="imgMenu" :src="'../../static/img/imgMenu/'+item.PRA009+'.png'" ></image>
|
<uni-notice-bar class="text" v-if="item.titleLength>6" :speed="30" style="padding:0;margin-bottom:0;" textSize="11px" background-color="#ffffff" color="#000000" :scrollable="item.titleLength>6" :single="true" :text="item.PRA003" />
|
<text v-else class="text">{{ item.PRA003 }}</text>
|
</navigator>
|
<!-- 程序 -->
|
<navigator v-if="!item.menuType" navigateTo class="grid-item-box" hover-class="none" :url="`..${item.PRA009}?title=${item.PRA003}`">
|
<image class="imgMenu" :src="'../../static/img/imgMenu/'+item.pic+'.png'" ></image>
|
<uni-notice-bar class="text" v-if="item.titleLength>=6" style="padding:0;margin-bottom:0;" textSize="11px" background-color="#ffffff" color="#000000" :speed="30" :scrollable="true" :single="true" :text="item.PRA003" />
|
<text v-else class="text">{{ item.PRA003 }}</text>
|
</navigator>
|
</uni-grid-item>
|
</uni-grid>
|
</view>
|
</view>
|
<view v-if="!loginInfo.hasLogin" >
|
<view class="title">
|
您好 游客。
|
</view>
|
<view class="ul">
|
<view>这是 XXMES 首页。</view>
|
<view>在 “我的” 中点击 “登录” 可以 “登录您的账户”</view>
|
</view>
|
</view>
|
</view>
|
</uni-base-page>
|
</template>
|
|
<script>
|
export default {
|
|
data() {
|
return {
|
loginInfo:this.$loginInfo,
|
userMenu:this.$userMenu,
|
color:this.$defaultColor,
|
PRA001:'',
|
navTitle:'',//标题
|
col:4,//菜单列数
|
c:['#00007f','#ff0000','#ffff7f','#0055ff'],
|
myName:''
|
|
};
|
},
|
methods: {
|
getMenu(isShowMask){
|
if(isShowMask) uni.showLoading({mask:true,title:"加载中..."});
|
this.$getUserMenu({
|
programId: this.PRA001,
|
success:(res)=>{
|
this.userMenu = res;
|
uni.stopPullDownRefresh();
|
},
|
fail:(err)=>{
|
|
},complete(){
|
if(isShowMask) uni.hideLoading();
|
}
|
});
|
},
|
getMyName(){
|
var pages = getCurrentPages();
|
var page = pages[pages.length - 1];
|
var currentPageTitle = page.$holder.navigationBarTitleText;
|
this.myName = currentPageTitle;
|
console.log(this.myName);
|
}
|
},
|
onLoad(option) {
|
this.$setTitle(option);
|
if (!this.loginInfo.hasLogin) {
|
uni.showModal({
|
title: '未登录',
|
content: '您未登录,需要登录后才能继续',
|
/**
|
* 如果需要强制登录,不显示取消按钮
|
*/
|
showCancel: !this.loginInfo.forcedLogin,
|
success: (res) => {
|
if (res.confirm) {
|
/**
|
* 如果需要强制登录,使用reLaunch方式
|
*/
|
if (this.loginInfo.forcedLogin) {
|
uni.reLaunch({
|
url: 'login'
|
});
|
} else {
|
uni.navigateTo({
|
url: 'login'
|
});
|
}
|
}
|
}
|
});
|
}else{
|
this.PRA001 = option.PRA001 || '';
|
this.navTitle= option.PRA003 ||'';
|
this.getMenu();
|
}
|
},
|
mounted:function(){
|
// if(this.$route.query.title){ //页面传参,需继承uni-base-page自定义组件
|
// //设置标题信息
|
// alert(this.$route.query.title);
|
// //console.log("页面传参");
|
// uni.setNavigationBarTitle({
|
// title: this.$route.query.title
|
// });
|
// }
|
// else if(this.$thistitle){ //通过全局参数配置的当前模块的标题,需继承uni-base-page自定义组件
|
// //设置标题信息
|
// //console.log("通过全局参数配置的当前模块的标题");
|
// alert(this.$route.query.title);
|
// uni.setNavigationBarTitle({
|
// title: this.$thistitle
|
// });
|
// }else{//默认调用pages.json,无需继承uni-base-page自定义组件
|
// alert("没有标题");
|
// //console.log("默认调用pages.json");
|
// }
|
},
|
onBackPress(options) {
|
//返回的时候清空当前菜单分组,防止下次打开别的分组时候界面会展示上一次的菜单分组
|
if (options.from === 'navigateBack') {
|
return false;
|
}
|
uni.navigateBack({
|
delta: 1
|
});
|
return true;
|
},
|
onPullDownRefresh() {
|
if (this.loginInfo.hasLogin)
|
this.getMenu(true);
|
},
|
}
|
</script>
|
|
<style>
|
.text{
|
/* color: #ffffff; */
|
/* font-size: 15px; */
|
font-weight: 900;
|
}
|
|
.example-body {
|
flex-direction: row;
|
flex-wrap: wrap;
|
justify-content: center;
|
padding: 0;
|
font-size: 14px;
|
background-color: #ffffff;
|
width: 100%;
|
height: 100%;
|
}
|
|
.grid-item-box {
|
flex: 1;
|
/* position: relative; */
|
/* #ifndef APP-NVUE */
|
display: flex;
|
/* #endif */
|
flex-direction: column;
|
align-items: center;
|
justify-content: center;
|
padding: 5px 0;
|
}
|
|
.imgMenu{
|
width: 100rpx;
|
height: 100rpx;
|
}
|
|
image,
|
swiper,
|
.img-view {
|
width: 100%;
|
height: 300rpx;
|
margin-bottom: 10rpx;
|
}
|
</style>
|