完成助教端 页面
This commit is contained in:
parent
80c472c1b7
commit
2caaffc581
@ -34,7 +34,6 @@ function toHome(data: any) {
|
||||
}
|
||||
}
|
||||
onLoad(async (data: any) => {
|
||||
console.log(data);
|
||||
if (data && data.openId) {
|
||||
setGlobal(data);
|
||||
checkOpenId({
|
||||
|
||||
@ -96,7 +96,6 @@ import {
|
||||
updateUserApi,
|
||||
} from "@/api/system/login";
|
||||
import { useUserStore } from "@/store/modules/user";
|
||||
import pages from "@/pages.json";
|
||||
const { getGlobal } = useDataStore();
|
||||
const formData = reactive({
|
||||
loginName: "",
|
||||
@ -179,30 +178,34 @@ const handleVerify = async () => {
|
||||
appCode: getGlobal.type == 1 ? "ZB" : "JS",
|
||||
});
|
||||
if (result.resultCode == 1) {
|
||||
afterLoginAction(result.result);
|
||||
uni.showToast({ title: "验证成功", icon: "success" });
|
||||
if (getGlobal.type == 1) {
|
||||
toHome(getGlobal);
|
||||
} else {
|
||||
const findJsByPhoneResult = await findJsByPhoneApi({
|
||||
phone: formData.phone,
|
||||
});
|
||||
if (findJsByPhoneResult.resultCode == 1) {
|
||||
if (findJsByPhoneResult.result) {
|
||||
if (findJsByPhoneResult.result["confirmStatus"] == "A") {
|
||||
toHome(getGlobal);
|
||||
if (result.result) {
|
||||
afterLoginAction(result.result);
|
||||
uni.showToast({ title: "验证成功", icon: "success" });
|
||||
if (getGlobal.type == 1) {
|
||||
toHome(getGlobal);
|
||||
} else {
|
||||
const findJsByPhoneResult = await findJsByPhoneApi({
|
||||
phone: formData.phone,
|
||||
});
|
||||
if (findJsByPhoneResult.resultCode == 1) {
|
||||
if (findJsByPhoneResult.result) {
|
||||
if (findJsByPhoneResult.result["confirmStatus"] == "A") {
|
||||
toHome(getGlobal);
|
||||
} else {
|
||||
setFile(findJsByPhoneResult.result);
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
url: "/pages/view/hr/teacherProfile/index",
|
||||
});
|
||||
}, 1500);
|
||||
}
|
||||
} else {
|
||||
setFile(findJsByPhoneResult.result);
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
url: "/pages/view/hr/teacherProfile/index",
|
||||
});
|
||||
}, 1500);
|
||||
toHome(getGlobal);
|
||||
}
|
||||
} else {
|
||||
toHome(getGlobal);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
uni.showToast({ title: result.message || "验证失败", icon: "none" });
|
||||
}
|
||||
} else {
|
||||
uni.showToast({ title: result.message || "验证失败", icon: "none" });
|
||||
|
||||
@ -1,133 +1,189 @@
|
||||
import {AUTH_KEY, BASE_URL, HOMEAGENT, RESULT_CODE_NOT_LOGIN} from "@/config";
|
||||
import {useUserStore} from "@/store/modules/user";
|
||||
import {getLogin} from "../permission";
|
||||
import {request} from "@/utils/request/request";
|
||||
import {showToast} from "@/utils/uniapp";
|
||||
import { AUTH_KEY, BASE_URL, HOMEAGENT, RESULT_CODE_NOT_LOGIN } from "@/config";
|
||||
import { useUserStore } from "@/store/modules/user";
|
||||
import { getLogin } from "../permission";
|
||||
import { request } from "@/utils/request/request";
|
||||
import { showToast } from "@/utils/uniapp";
|
||||
|
||||
let count: boolean = false;
|
||||
|
||||
function _loginExpiredModal() {
|
||||
const store = useUserStore();
|
||||
store.logout()
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '登录过期,请重新登录',
|
||||
showCancel: false,
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
count = false
|
||||
getLogin()
|
||||
} else if (res.cancel) {
|
||||
count = false
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
fail: (err) => {
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
const store = useUserStore();
|
||||
store.logout();
|
||||
uni.showModal({
|
||||
title: "提示",
|
||||
content: "登录过期,请重新登录",
|
||||
showCancel: false,
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
count = false;
|
||||
getLogin();
|
||||
} else if (res.cancel) {
|
||||
count = false;
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
fail: (err) => {
|
||||
console.log(err);
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export const config = {
|
||||
baseUrl: process.env.NODE_ENV == 'development' ? HOMEAGENT ? '/base' : BASE_URL : BASE_URL,
|
||||
header: {}
|
||||
}
|
||||
baseUrl:
|
||||
process.env.NODE_ENV == "development"
|
||||
? HOMEAGENT
|
||||
? "/base"
|
||||
: BASE_URL
|
||||
: BASE_URL,
|
||||
header: {},
|
||||
};
|
||||
export const interceptor = {
|
||||
request: (config: UniNamespace.UploadFileOption | UniNamespace.RequestOptions) => {
|
||||
const store = useUserStore();
|
||||
if (store.getToken) {
|
||||
config.header = {
|
||||
[AUTH_KEY]: store.getToken
|
||||
};
|
||||
}
|
||||
},
|
||||
response: (response: any) => {
|
||||
if (response.data && RESULT_CODE_NOT_LOGIN == response.data.resultCode) {
|
||||
if (!count) {
|
||||
_loginExpiredModal()
|
||||
}
|
||||
count = true;
|
||||
return;
|
||||
}
|
||||
if (response.config.name === "files") {
|
||||
return JSON.parse(response.data);
|
||||
}
|
||||
if (response.data) {
|
||||
return response.data;
|
||||
} else {
|
||||
console.log('接口无返回值', response)
|
||||
}
|
||||
request: (
|
||||
config: UniNamespace.UploadFileOption | UniNamespace.RequestOptions
|
||||
) => {
|
||||
const store = useUserStore();
|
||||
if (store.getToken) {
|
||||
config.header = {
|
||||
[AUTH_KEY]: store.getToken,
|
||||
};
|
||||
}
|
||||
},
|
||||
response: (response: any) => {
|
||||
if (response.data && RESULT_CODE_NOT_LOGIN == response.data.resultCode) {
|
||||
if (!count) {
|
||||
_loginExpiredModal();
|
||||
}
|
||||
count = true;
|
||||
return;
|
||||
}
|
||||
if (response.config.name === "files") {
|
||||
return JSON.parse(response.data);
|
||||
}
|
||||
if (response.data) {
|
||||
return response.data;
|
||||
} else {
|
||||
console.log("接口无返回值", response);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export function get<T = any>(
|
||||
url: string,
|
||||
data?: any,
|
||||
options?: UniNamespace.RequestOptions
|
||||
): Promise<Requests<T>> {
|
||||
return new Promise((resolve, reject) => {
|
||||
request(
|
||||
Object.assign(
|
||||
{},
|
||||
{
|
||||
url,
|
||||
data,
|
||||
method: "GET",
|
||||
dataType: "json",
|
||||
responseType: "text",
|
||||
},
|
||||
options
|
||||
)
|
||||
).then((res) => {
|
||||
if (res.resultCode == 1) {
|
||||
resolve(res);
|
||||
} else {
|
||||
if (res.resultCode) {
|
||||
if (res.resultCode != RESULT_CODE_NOT_LOGIN) {
|
||||
showToast(res.message || "接口异常");
|
||||
reject(res);
|
||||
}
|
||||
} else {
|
||||
if (res.rows) {
|
||||
resolve(res);
|
||||
} else {
|
||||
showToast(res.message || "接口异常");
|
||||
reject(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function get<T = any>(url: string, data?: any, options?: UniNamespace.RequestOptions): Promise<Requests<T>> {
|
||||
return new Promise((resolve, reject) => {
|
||||
request(Object.assign({}, {
|
||||
url,
|
||||
data,
|
||||
method: 'GET',
|
||||
dataType: 'json',
|
||||
responseType: 'text',
|
||||
}, options)).then(res => {
|
||||
if (res.resultCode == 1) {
|
||||
resolve(res)
|
||||
} else {
|
||||
if (res.resultCode) {
|
||||
if (res.resultCode != RESULT_CODE_NOT_LOGIN) {
|
||||
showToast(res.message || '接口异常')
|
||||
reject(res)
|
||||
}
|
||||
} else {
|
||||
if (res.rows) {
|
||||
resolve(res)
|
||||
} else {
|
||||
showToast(res.message || '接口异常')
|
||||
reject(res)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
export function post<T = any>(
|
||||
url: string,
|
||||
data?: any,
|
||||
options?: UniNamespace.RequestOptions
|
||||
): Promise<Requests<T>> {
|
||||
return new Promise((resolve, reject) => {
|
||||
request(
|
||||
Object.assign(
|
||||
{},
|
||||
{
|
||||
url,
|
||||
data,
|
||||
method: "POST",
|
||||
dataType: "json",
|
||||
responseType: "text",
|
||||
},
|
||||
options
|
||||
)
|
||||
).then((res) => {
|
||||
if (res.resultCode == 1) {
|
||||
resolve(res);
|
||||
} else {
|
||||
if (res.resultCode) {
|
||||
if (res.resultCode != RESULT_CODE_NOT_LOGIN) {
|
||||
showToast(res.message || "接口异常");
|
||||
reject(res);
|
||||
}
|
||||
} else {
|
||||
if (res.rows) {
|
||||
resolve(res);
|
||||
} else {
|
||||
showToast(res.message || "接口异常");
|
||||
reject(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export function post<T = any>(url: string, data?: any, options?: UniNamespace.RequestOptions): Promise<Requests<T>> {
|
||||
return new Promise((resolve, reject) => {
|
||||
request(Object.assign({}, {
|
||||
url,
|
||||
data,
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
responseType: 'text',
|
||||
}, options)).then(res => {
|
||||
if (res.resultCode == 1) {
|
||||
resolve(res)
|
||||
} else {
|
||||
if (res.resultCode) {
|
||||
if (res.resultCode != RESULT_CODE_NOT_LOGIN) {
|
||||
showToast(res.message || '接口异常')
|
||||
reject(res)
|
||||
}
|
||||
} else {
|
||||
if (res.rows) {
|
||||
resolve(res)
|
||||
} else {
|
||||
showToast(res.message || '接口异常')
|
||||
reject(res)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
export function file(
|
||||
url: string,
|
||||
data: Blob,
|
||||
options?: UniNamespace.UploadFileOption
|
||||
) {
|
||||
return new Promise((resolve, reject) => {
|
||||
request(
|
||||
Object.assign(
|
||||
{},
|
||||
{
|
||||
url,
|
||||
filePath: data,
|
||||
name: "files",
|
||||
},
|
||||
options
|
||||
),
|
||||
true
|
||||
).then((res) => {
|
||||
if (res.resultCode == 1) {
|
||||
resolve(res);
|
||||
} else {
|
||||
if (res.resultCode) {
|
||||
if (res.resultCode != RESULT_CODE_NOT_LOGIN) {
|
||||
showToast(res.message || "接口异常");
|
||||
reject(res);
|
||||
}
|
||||
} else {
|
||||
if (res.rows) {
|
||||
resolve(res);
|
||||
} else {
|
||||
showToast(res.message || "接口异常");
|
||||
reject(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function file(url: string, data: Blob, options?: UniNamespace.UploadFileOption) {
|
||||
return request(Object.assign({}, {
|
||||
url,
|
||||
filePath: data,
|
||||
name: 'files',
|
||||
}, options), true)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user