update: sass接口联调
This commit is contained in:
parent
ae35122c7e
commit
f0e850159c
|
@ -3,7 +3,8 @@ const development = {
|
||||||
// VITE_APP_BASE_URL: 'http://47.100.31.83:8081',
|
// VITE_APP_BASE_URL: 'http://47.100.31.83:8081',
|
||||||
// VITE_APP_BASE_URL: 'https://47.100.31.83:8081',
|
// VITE_APP_BASE_URL: 'https://47.100.31.83:8081',
|
||||||
// appid: '',
|
// appid: '',
|
||||||
VITE_APP_BASE_URL: 'http://cloud.52zaisheng.cn/test/saas',
|
// VITE_APP_BASE_URL: 'http://cloud.52zaisheng.cn/test/saas',
|
||||||
|
VITE_APP_BASE_URL: 'https://ifanda.52zaisheng.cn/prod',
|
||||||
appid: 'wx9251d74fe0e87028',
|
appid: 'wx9251d74fe0e87028',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +14,8 @@ const test = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const production = {
|
const production = {
|
||||||
VITE_APP_BASE_URL: 'http://cloud.52zaisheng.cn/test/saas',
|
VITE_APP_BASE_URL: 'https://ifanda.52zaisheng.cn/prod',
|
||||||
|
// VITE_APP_BASE_URL: 'http://cloud.52zaisheng.cn/test/saas',
|
||||||
appid: 'wx9251d74fe0e87028',
|
appid: 'wx9251d74fe0e87028',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -236,18 +236,40 @@ const submit = () => {
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ProfileApi.loginByAccount(model1.userInfo).then((res: any) => {
|
console.log('获取货场信息')
|
||||||
if (res.code === 200) {
|
// 获取货场信息
|
||||||
if(checkGroup.rememberCheck.length === 1) {
|
ProfileApi.getCommonDbPhone({ phone: model1.userInfo.userName }).then(
|
||||||
uni.setStorageSync('catchLoginInfo', model1.userInfo);
|
(res: any) => {
|
||||||
} else {
|
if (res.code === 200) {
|
||||||
uni.setStorageSync('catchLoginInfo', {});
|
if (res.data.length === 0) {
|
||||||
|
uni.showToast({
|
||||||
|
icon: "none",
|
||||||
|
title: "当前用户暂未分配货场,请联系管理员",
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
store.setCode(res.data[0].mechanismCode);
|
||||||
|
if (store.code) {
|
||||||
|
loginByAccount();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
store.setProfile(res.data);
|
|
||||||
uni.reLaunch({
|
|
||||||
url: "/pagesHome/index", // 要跳转到的页面路径
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const loginByAccount = () => {
|
||||||
|
ProfileApi.loginByAccount(model1.userInfo).then((res: any) => {
|
||||||
|
if (res.code === 200) {
|
||||||
|
if (checkGroup.rememberCheck.length === 1) {
|
||||||
|
uni.setStorageSync("catchLoginInfo", model1.userInfo);
|
||||||
|
} else {
|
||||||
|
uni.setStorageSync("catchLoginInfo", {});
|
||||||
|
}
|
||||||
|
store.setProfile(res.data);
|
||||||
|
uni.reLaunch({
|
||||||
|
url: "/pagesHome/index", // 要跳转到的页面路径
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -319,14 +341,12 @@ const state = reactive({
|
||||||
// });
|
// });
|
||||||
|
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
if (uni.getStorageSync('catchLoginInfo')) {
|
if (uni.getStorageSync("catchLoginInfo")) {
|
||||||
const {userName, password} = uni.getStorageSync('catchLoginInfo')
|
const { userName, password } = uni.getStorageSync("catchLoginInfo");
|
||||||
model1.userInfo.userName = userName
|
model1.userInfo.userName = userName;
|
||||||
model1.userInfo.password = password
|
model1.userInfo.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
|
@ -5,6 +5,17 @@
|
||||||
import type { User } from "@/types/user";
|
import type { User } from "@/types/user";
|
||||||
import { http } from "@/utils/http";
|
import { http } from "@/utils/http";
|
||||||
// console.log(store.profile.childPath)
|
// console.log(store.profile.childPath)
|
||||||
|
|
||||||
|
//查询手机号绑定货场
|
||||||
|
|
||||||
|
export const getCommonDbPhone = (data: {phone: string}) => {
|
||||||
|
return http({
|
||||||
|
method: "GET",
|
||||||
|
url: "/api/db/getCommonDbPhone",
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// 登陆
|
// 登陆
|
||||||
export const loginByAccount = (data: {
|
export const loginByAccount = (data: {
|
||||||
userName: string;
|
userName: string;
|
||||||
|
|
|
@ -15,25 +15,23 @@ export const useMemberStore = defineStore(
|
||||||
},
|
},
|
||||||
menusList: [],
|
menusList: [],
|
||||||
menusNameList: [],
|
menusNameList: [],
|
||||||
childPath: '/test/sh0001',
|
childPath: "/test/sh0001",
|
||||||
err: null
|
err: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 保存会员信息,登录时使用
|
// 保存会员信息,登录时使用
|
||||||
const setProfile = (val: any) => {
|
const setProfile = (val: any) => {
|
||||||
profile.value = {...profile.value, ...val};
|
profile.value = { ...profile.value, ...val };
|
||||||
profile.value.menusNameList = _.pluck(val.menusList, "name");
|
profile.value.menusNameList = _.pluck(val.menusList, "name");
|
||||||
};
|
};
|
||||||
|
|
||||||
const setChildPath= (v: string) => {
|
const setChildPath = (v: string) => {
|
||||||
profile.value.childPath = v
|
profile.value.childPath = v;
|
||||||
}
|
};
|
||||||
|
|
||||||
const setErr= (v: any) => {
|
|
||||||
profile.value.err = v
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
const setErr = (v: any) => {
|
||||||
|
profile.value.err = v;
|
||||||
|
};
|
||||||
|
|
||||||
// 清理会员信息,退出时使用
|
// 清理会员信息,退出时使用
|
||||||
const clearProfile = () => {
|
const clearProfile = () => {
|
||||||
|
@ -45,9 +43,14 @@ export const useMemberStore = defineStore(
|
||||||
},
|
},
|
||||||
menusList: [],
|
menusList: [],
|
||||||
menusNameList: [],
|
menusNameList: [],
|
||||||
childPath: ''
|
childPath: "",
|
||||||
};
|
};
|
||||||
|
code.value = ''
|
||||||
|
};
|
||||||
|
|
||||||
|
const code = ref<string>();
|
||||||
|
const setCode = (val: any) => {
|
||||||
|
code.value = val
|
||||||
};
|
};
|
||||||
|
|
||||||
// 记得 return
|
// 记得 return
|
||||||
|
@ -56,7 +59,9 @@ export const useMemberStore = defineStore(
|
||||||
setProfile,
|
setProfile,
|
||||||
setChildPath,
|
setChildPath,
|
||||||
setErr,
|
setErr,
|
||||||
clearProfile
|
clearProfile,
|
||||||
|
code,
|
||||||
|
setCode
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,7 +11,6 @@ let baseUrl = "";
|
||||||
const store = useMemberStore(pinia);
|
const store = useMemberStore(pinia);
|
||||||
baseUrl = (process.env as any).config[(process.env as any).NODE_ENV]
|
baseUrl = (process.env as any).config[(process.env as any).NODE_ENV]
|
||||||
.VITE_APP_BASE_URL;
|
.VITE_APP_BASE_URL;
|
||||||
|
|
||||||
const obj = {
|
const obj = {
|
||||||
// 拦截前触发
|
// 拦截前触发
|
||||||
invoke(options: UniApp.RequestOptions) {
|
invoke(options: UniApp.RequestOptions) {
|
||||||
|
@ -32,7 +31,14 @@ const obj = {
|
||||||
if (token) {
|
if (token) {
|
||||||
options.header["x-userToken"] = token;
|
options.header["x-userToken"] = token;
|
||||||
}
|
}
|
||||||
options.header["code"] = 'hoe-cs';
|
// db/getCommonDbPhone 接口code必须是common
|
||||||
|
if (options.url.indexOf("db/getCommonDbPhone") !== -1) {
|
||||||
|
options.header["code"] = 'common';
|
||||||
|
} else {
|
||||||
|
if (store.code) {
|
||||||
|
options.header["code"] = store.code;
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
// 请求拦截器
|
// 请求拦截器
|
||||||
|
@ -68,7 +74,7 @@ export const http = <T>(options: UniApp.RequestOptions) => {
|
||||||
// #endif
|
// #endif
|
||||||
},
|
},
|
||||||
timeout: 1800000,
|
timeout: 1800000,
|
||||||
url: baseUrl + options.url,//仅为示例,非真实的接口地址
|
url: baseUrl + options.url, //仅为示例,非真实的接口地址
|
||||||
fileType: "image",
|
fileType: "image",
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
files: (options as any).data.files,
|
files: (options as any).data.files,
|
||||||
|
@ -153,9 +159,7 @@ export const http = <T>(options: UniApp.RequestOptions) => {
|
||||||
let res1: any = JSON.parse(json1);
|
let res1: any = JSON.parse(json1);
|
||||||
console.log(res1);
|
console.log(res1);
|
||||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||||
if (
|
if ([1001, 1002, 1003, 1004].indexOf(res1.code) > -1) {
|
||||||
[1001,1002,1003,1004].indexOf(res1.code) > -1
|
|
||||||
) {
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon: "none",
|
icon: "none",
|
||||||
title: (res1 as Data<T>).message || "请求失败",
|
title: (res1 as Data<T>).message || "请求失败",
|
||||||
|
@ -165,7 +169,7 @@ export const http = <T>(options: UniApp.RequestOptions) => {
|
||||||
url: "/pagesLogin/login/index",
|
url: "/pagesLogin/login/index",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
} else if ([500,5001,10001].indexOf(res1.code) > -1) {
|
} else if ([500, 5001, 10001].indexOf(res1.code) > -1) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon: "none",
|
icon: "none",
|
||||||
title: (res1 as Data<T>).message || "请求失败",
|
title: (res1 as Data<T>).message || "请求失败",
|
||||||
|
|
Loading…
Reference in New Issue