fix: 更新菜单项属性名称为label,并调整权限判断逻辑
This commit is contained in:
parent
627d0b006a
commit
685bcc76a8
|
|
@ -4,9 +4,9 @@
|
||||||
<text class="date"> 数据更新时间:{{ date }} </text>
|
<text class="date"> 数据更新时间:{{ date }} </text>
|
||||||
</view>
|
</view>
|
||||||
<u-grid class="menu" :col="5" :border="false" align="center">
|
<u-grid class="menu" :col="5" :border="false" align="center">
|
||||||
<u-grid-item v-for="menu in menus" @click="goto(menu.path, menu.auth)">
|
<u-grid-item v-for="menu in menus" @click="goto(menu)">
|
||||||
<image :src="menu.icon" class="menu-icon"></image>
|
<image :src="menu.icon" class="menu-icon"></image>
|
||||||
<text class="menu-text">{{ menu.name }}</text>
|
<text class="menu-text">{{ menu.label }}</text>
|
||||||
</u-grid-item>
|
</u-grid-item>
|
||||||
</u-grid>
|
</u-grid>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -24,33 +24,33 @@ import { useUserStore } from "@/stores/user";
|
||||||
|
|
||||||
const menus = reactive([
|
const menus = reactive([
|
||||||
{
|
{
|
||||||
name: "海外先机",
|
label: "海外先机",
|
||||||
|
name: "hwxj",
|
||||||
icon: MENUICON1,
|
icon: MENUICON1,
|
||||||
// auth: "menu1",
|
|
||||||
path: "/pages/foreign/index",
|
path: "/pages/foreign/index",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "编辑精选",
|
label: "编辑精选",
|
||||||
|
name: "bjjx",
|
||||||
icon: MENUICON2,
|
icon: MENUICON2,
|
||||||
// auth: "menu2",
|
|
||||||
path: "/pages/recommend/index",
|
path: "/pages/recommend/index",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "宏观知微",
|
label: "宏观知微",
|
||||||
|
name: "hgzw",
|
||||||
icon: MENUICON3,
|
icon: MENUICON3,
|
||||||
// auth: "menu3",
|
|
||||||
path: "/pages/macroscopic/index",
|
path: "/pages/macroscopic/index",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "热门行业",
|
label: "热门行业",
|
||||||
|
name: "rthx",
|
||||||
icon: MENUICON4,
|
icon: MENUICON4,
|
||||||
// auth: "menu4",
|
|
||||||
path: "/pages/industry/index",
|
path: "/pages/industry/index",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "风口概念",
|
label: "风口概念",
|
||||||
|
name: "fkgn",
|
||||||
icon: MENUICON5,
|
icon: MENUICON5,
|
||||||
// auth: "menu5",
|
|
||||||
path: "/pages/concept/index",
|
path: "/pages/concept/index",
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
@ -61,7 +61,7 @@ const userInfos = computed(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(["onShow"]);
|
const emit = defineEmits(["onShow"]);
|
||||||
const goto = (path: string, auth: string) => {
|
const goto = (menu: any) => {
|
||||||
if (!userStore.isLogin) {
|
if (!userStore.isLogin) {
|
||||||
emit("onShow");
|
emit("onShow");
|
||||||
return;
|
return;
|
||||||
|
|
@ -76,8 +76,17 @@ const goto = (path: string, auth: string) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isAuth = userInfos.value?.auth?.findIndex((item) => item.name === menu.name);
|
||||||
|
if (isAuth === -1 || userInfos.value?.auth[isAuth]?.enabled === 0) {
|
||||||
|
uni.showToast({
|
||||||
|
title: "暂未开通本栏目",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: path,
|
url: menu.path,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,14 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getTopNews } from "@/api/newsInfo";
|
import { getTopNews } from "@/api/newsInfo";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { onMounted, reactive, ref } from "vue";
|
import { computed, onMounted, reactive, ref } from "vue";
|
||||||
import { useUserStore } from "@/stores/user";
|
import { useUserStore } from "@/stores/user";
|
||||||
|
|
||||||
const emit = defineEmits(["onShow"]);
|
const emit = defineEmits(["onShow"]);
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
const userInfos = computed(() => {
|
||||||
|
return userStore.getUserInfos();
|
||||||
|
});
|
||||||
// 获取数据
|
// 获取数据
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const newsListAll = ref([]); // 全部新闻
|
const newsListAll = ref([]); // 全部新闻
|
||||||
|
|
@ -78,6 +81,16 @@ const navigateTo = () => {
|
||||||
emit("onShow");
|
emit("onShow");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isAuth = userInfos.value?.auth?.findIndex((item) => item.name === 'znzx');
|
||||||
|
if (isAuth === -1 || userInfos.value?.auth[isAuth]?.enabled === 0) {
|
||||||
|
uni.showToast({
|
||||||
|
title: "暂未开通本栏目",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: "/pages/topNews/index",
|
url: "/pages/topNews/index",
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,10 @@ type IUserInfos = {
|
||||||
id?: string;
|
id?: string;
|
||||||
phone: string;
|
phone: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
auth: string[];
|
auth: any[];
|
||||||
role: string[];
|
role: string[];
|
||||||
accountType: number;
|
accountType: number;
|
||||||
|
permissions?: any[];
|
||||||
};
|
};
|
||||||
|
|
||||||
const storeSetup = () => {
|
const storeSetup = () => {
|
||||||
|
|
@ -23,7 +24,36 @@ const storeSetup = () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const setUserInfos = (payload: Partial<IUserInfos>) => {
|
const setUserInfos = (payload: Partial<IUserInfos>) => {
|
||||||
userInfos.value = { ...userInfos.value, ...payload };
|
// 权限暂时写死,后续根据接口返回的权限进行调整
|
||||||
|
const auth = [
|
||||||
|
{
|
||||||
|
name: "hwxj",
|
||||||
|
enabled: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "bjjx",
|
||||||
|
enabled: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "hgzw",
|
||||||
|
enabled: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "znzx",
|
||||||
|
enabled: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "rthx",
|
||||||
|
enabled: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "fkgn",
|
||||||
|
enabled: 1,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
// 获取权限
|
||||||
|
// const auth = payload.permissions || [];
|
||||||
|
userInfos.value = { ...userInfos.value, ...payload, auth };
|
||||||
Session.set("userInfos", userInfos.value);
|
Session.set("userInfos", userInfos.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -53,10 +83,10 @@ const storeSetup = () => {
|
||||||
// 试用 | 正式
|
// 试用 | 正式
|
||||||
const isUserType = computed(() => {
|
const isUserType = computed(() => {
|
||||||
// 0:测试 ,1:正式 判断账号类型
|
// 0:测试 ,1:正式 判断账号类型
|
||||||
return getUserInfos()?.accountType === 1 ? true : false;
|
// return getUserInfos()?.accountType === 1 ? true : false;
|
||||||
|
|
||||||
// 为了兼容之前的版本,暂时不区分账号类型,先放开正式账号和测试账号的限制
|
// 为了兼容之前的版本,暂时不区分账号类型,先放开正式账号和测试账号的限制
|
||||||
// return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 登录
|
// 登录
|
||||||
|
|
@ -86,7 +116,7 @@ const storeSetup = () => {
|
||||||
});
|
});
|
||||||
setToken(result.data.token);
|
setToken(result.data.token);
|
||||||
setUserInfos({ ...result.data });
|
setUserInfos({ ...result.data });
|
||||||
|
|
||||||
// 为了兼容之前的版本,暂时保留 userPhone 字段
|
// 为了兼容之前的版本,暂时保留 userPhone 字段
|
||||||
Session.set("userPhone", data.phone);
|
Session.set("userPhone", data.phone);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue