This commit is contained in:
Aiden 2024-10-17 17:46:46 +08:00
parent 511a73f92f
commit 16ca2ab84f
8 changed files with 97 additions and 35 deletions

View File

@ -1,2 +1,3 @@
VITE_APP_MODE = 'dev'
VITE_API_URL = http://114.218.158.24:9020
VITE_API_OA_URL=http://114.218.158.24:9020

View File

@ -1,3 +1,4 @@
mode = prod
VITE_APP_MODE = 'prod'
VITE_API_URL = https://erpapi.fontree.cn/
VITE_API_OA_URL=https://erp-out.szjixun.cn/

View File

@ -6,31 +6,31 @@ export const userLogin = (data) => {
method: "POST",
data,
});
};
//验证码
};
//验证码
export const userSend = (data) => {
return request({
url: "/user/send",
method: "POST",
data,
});
};
//扫码查看画桶详情
export const pbDetail = (data) => {
};
//扫码查看画桶详情
export const pbDetail = (data) => {
return request({
url: "/containeradm/v1/painting_bucket/get_by_id",
method: "POST",
data,
});
};
//查询可放画桶的空闲货架孔
export const freebox = (data) => {
};
//查询可放画桶的空闲货架孔
export const freebox = (data) => {
return request({
url: "/containeradm/v1/box_rel_bucket/freebox",
method: "POST",
data,
});
};
};
//出库
export const outbound = (data) => {
return request({
@ -79,3 +79,10 @@ export const cancel = (data) => {
data,
});
};
export const getRules = (data) => {
return request({
url: "/rule/rules",
method: "POST",
data,
});
};

View File

@ -3,12 +3,15 @@ import App from "./App.vue";
import uviewPlus from "uview-plus";
import globalComponents from "./components";
import VConsole from "vconsole";
import permission from "../utils/permission.js";
if (import.meta.env.VITE_APP_MODE === "dev") {
new VConsole();
}
export function createApp() {
const app = createSSRApp(App);
globalComponents(app);
permission(app);
app.use(uviewPlus);
return {
app,

View File

@ -103,7 +103,7 @@
import { ref, reactive } from "vue";
import useToast from "@/hooks/toast/useToast.js";
import { onLoad } from "@dcloudio/uni-app";
import { userLogin, userSend, pbDetail } from "@/api/login.js";
import { userLogin, userSend, pbDetail, getRules } from "@/api/login.js";
const state = reactive({
TelNum: "",
Password: "",
@ -125,6 +125,7 @@ onLoad((options) => {
//
if (token && userInfo) {
paintingDetail();
getBtngetRules();
}
}
@ -199,7 +200,7 @@ const paintingDetail = async () => {
// };
const toCode = () => {
isCode.value = true;
state.Password= "";
state.Password = "";
};
//
const obtainCode = async () => {
@ -237,9 +238,20 @@ const logining = async () => {
uni.setStorageSync("token", res.data.Token);
uni.setStorageSync("userInfo", res.data.AccountInfo);
await paintingDetail();
await getBtngetRules();
}
loading.value = false;
};
const getBtngetRules = async () => {
const res = await getRules();
if (res.status === 0) {
const ruleBtn =
res.data.data.MyButtonAuths?.map((button) => button.Url) || [];
uni.setStorageSync("ruleBtn", ruleBtn);
} else {
showMessage({ type: "error", message: res.msg });
}
};
</script>
<style lang="scss" scoped>

View File

@ -15,3 +15,12 @@ export const closeWebview = () => {
return () => {};
}
};
// 判断是oa还是墨册
export const OAorMc = () => {
try {
return plus.webview.currentWebview().type;
} catch (e) {
return "";
}
};

22
utils/permission.js Normal file
View File

@ -0,0 +1,22 @@
export default (app) => {
// 按钮权限/show-btn
app.directive("permission", {
beforeMount(el, binding) {
const btnList = uni.getStorageSync("ruleBtn")
? uni.getStorageSync("ruleBtn")
: [];
if (
(binding.value &&
btnList.length > 0 &&
!btnList.includes(binding.value)) ||
btnList.length == 0
) {
// 解决进入页面按钮会闪一下再消失问题
el.style.display = "none";
setTimeout(() => {
el.parentNode.removeChild(el);
}, 0);
}
},
});
};

View File

@ -1,8 +1,12 @@
import Request from "./request/index.js";
import useToast from "@/hooks/toast/useToast.js";
import { OAorMc } from "../index.js";
const { showMessage } = useToast();
const request = new Request({
baseURL: import.meta.env.VITE_API_URL,
baseURL:
OAorMc() === "MC"
? import.meta.env.VITE_API_URL
: import.meta.env.VITE_API_OA_URL,
timeout: 1000 * 60 * 5,
interceptors: {
//实例的请求拦截器
@ -12,7 +16,10 @@ const request = new Request({
? "application/x-www-form-urlencoded"
: "application/json";
const token = uni.getStorageSync("token") || "";
const token =
window?.plus?.storage.getItem("token") ||
uni.getStorageSync("token") ||
"";
if (config.isFormData) {
config.headers["Content-Type"] = "multipart/form-data";
config.headers["Authorization"] = token;