| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- import { localGet, localSet } from "@/utils/index";
- import { ElMessage } from "element-plus";
- import { getUserByPhone, getDetail } from "@/api/modules/homeEntry";
- /**
- * @description 判断是否有操作权限
- * @returns {Boolean} 是否有权限
- */
- export async function usePermission(tip?: string) {
- let type = true;
- if (!localGet("createdId")) {
- let params = {
- phone: localGet("iphone") || "18641153170"
- };
- const res: any = await getUserByPhone(params);
- if (res.data && res.data.storeId) {
- localSet("createdId", res.data.storeId);
- const resD: any = await getDetail({
- id: res.data.storeId
- });
- if (resD.data && resD.data.commissionRate) {
- localSet("commissionRate", resD.data.commissionRate);
- }
- if (resD.data && resD.data.businessSection) {
- localSet("businessSection", resD.data.businessSection);
- }
- } else {
- type = false;
- if (tip) {
- ElMessage.warning(`请完成商家入驻后再进行${tip}`);
- }
- return type;
- }
- if (!localGet("businessSection")) {
- type = false;
- if (tip) {
- ElMessage.warning(`请完成商家入驻后重新登录再进行${tip}`);
- }
- return type;
- }
- }
- return type;
- }
|