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_APP_MODE = 'dev'
VITE_API_URL = http://114.218.158.24:9020 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 mode = prod
VITE_APP_MODE = 'prod' VITE_APP_MODE = 'prod'
VITE_API_URL = https://erpapi.fontree.cn/ 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", method: "POST",
data, data,
}); });
}; };
//验证码 //验证码
export const userSend = (data) => { export const userSend = (data) => {
return request({ return request({
url: "/user/send", url: "/user/send",
method: "POST", method: "POST",
data, data,
}); });
}; };
//扫码查看画桶详情 //扫码查看画桶详情
export const pbDetail = (data) => { export const pbDetail = (data) => {
return request({ return request({
url: "/containeradm/v1/painting_bucket/get_by_id", url: "/containeradm/v1/painting_bucket/get_by_id",
method: "POST", method: "POST",
data, data,
}); });
}; };
//查询可放画桶的空闲货架孔 //查询可放画桶的空闲货架孔
export const freebox = (data) => { export const freebox = (data) => {
return request({ return request({
url: "/containeradm/v1/box_rel_bucket/freebox", url: "/containeradm/v1/box_rel_bucket/freebox",
method: "POST", method: "POST",
data, data,
}); });
}; };
//出库 //出库
export const outbound = (data) => { export const outbound = (data) => {
return request({ return request({
@ -79,3 +79,10 @@ export const cancel = (data) => {
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 uviewPlus from "uview-plus";
import globalComponents from "./components"; import globalComponents from "./components";
import VConsole from "vconsole"; import VConsole from "vconsole";
import permission from "../utils/permission.js";
if (import.meta.env.VITE_APP_MODE === "dev") { if (import.meta.env.VITE_APP_MODE === "dev") {
new VConsole(); new VConsole();
} }
export function createApp() { export function createApp() {
const app = createSSRApp(App); const app = createSSRApp(App);
globalComponents(app); globalComponents(app);
permission(app);
app.use(uviewPlus); app.use(uviewPlus);
return { return {
app, app,

View File

@ -103,7 +103,7 @@
import { ref, reactive } from "vue"; import { ref, reactive } from "vue";
import useToast from "@/hooks/toast/useToast.js"; import useToast from "@/hooks/toast/useToast.js";
import { onLoad } from "@dcloudio/uni-app"; 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({ const state = reactive({
TelNum: "", TelNum: "",
Password: "", Password: "",
@ -125,6 +125,7 @@ onLoad((options) => {
// //
if (token && userInfo) { if (token && userInfo) {
paintingDetail(); paintingDetail();
getBtngetRules();
} }
} }
@ -199,7 +200,7 @@ const paintingDetail = async () => {
// }; // };
const toCode = () => { const toCode = () => {
isCode.value = true; isCode.value = true;
state.Password= ""; state.Password = "";
}; };
// //
const obtainCode = async () => { const obtainCode = async () => {
@ -237,9 +238,20 @@ const logining = async () => {
uni.setStorageSync("token", res.data.Token); uni.setStorageSync("token", res.data.Token);
uni.setStorageSync("userInfo", res.data.AccountInfo); uni.setStorageSync("userInfo", res.data.AccountInfo);
await paintingDetail(); await paintingDetail();
await getBtngetRules();
} }
loading.value = false; 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> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -15,3 +15,12 @@ export const closeWebview = () => {
return () => {}; 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 Request from "./request/index.js";
import useToast from "@/hooks/toast/useToast.js"; import useToast from "@/hooks/toast/useToast.js";
import { OAorMc } from "../index.js";
const { showMessage } = useToast(); const { showMessage } = useToast();
const request = new Request({ 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, timeout: 1000 * 60 * 5,
interceptors: { interceptors: {
//实例的请求拦截器 //实例的请求拦截器
@ -12,7 +16,10 @@ const request = new Request({
? "application/x-www-form-urlencoded" ? "application/x-www-form-urlencoded"
: "application/json"; : "application/json";
const token = uni.getStorageSync("token") || ""; const token =
window?.plus?.storage.getItem("token") ||
uni.getStorageSync("token") ||
"";
if (config.isFormData) { if (config.isFormData) {
config.headers["Content-Type"] = "multipart/form-data"; config.headers["Content-Type"] = "multipart/form-data";
config.headers["Authorization"] = token; config.headers["Authorization"] = token;