完成助教端 页面

This commit is contained in:
Net 2025-05-30 15:06:49 +08:00
parent 80c472c1b7
commit 2caaffc581
3 changed files with 199 additions and 141 deletions

View File

@ -34,7 +34,6 @@ function toHome(data: any) {
} }
} }
onLoad(async (data: any) => { onLoad(async (data: any) => {
console.log(data);
if (data && data.openId) { if (data && data.openId) {
setGlobal(data); setGlobal(data);
checkOpenId({ checkOpenId({

View File

@ -96,7 +96,6 @@ import {
updateUserApi, updateUserApi,
} from "@/api/system/login"; } from "@/api/system/login";
import { useUserStore } from "@/store/modules/user"; import { useUserStore } from "@/store/modules/user";
import pages from "@/pages.json";
const { getGlobal } = useDataStore(); const { getGlobal } = useDataStore();
const formData = reactive({ const formData = reactive({
loginName: "", loginName: "",
@ -179,6 +178,7 @@ const handleVerify = async () => {
appCode: getGlobal.type == 1 ? "ZB" : "JS", appCode: getGlobal.type == 1 ? "ZB" : "JS",
}); });
if (result.resultCode == 1) { if (result.resultCode == 1) {
if (result.result) {
afterLoginAction(result.result); afterLoginAction(result.result);
uni.showToast({ title: "验证成功", icon: "success" }); uni.showToast({ title: "验证成功", icon: "success" });
if (getGlobal.type == 1) { if (getGlobal.type == 1) {
@ -207,6 +207,9 @@ const handleVerify = async () => {
} else { } else {
uni.showToast({ title: result.message || "验证失败", icon: "none" }); uni.showToast({ title: result.message || "验证失败", icon: "none" });
} }
} else {
uni.showToast({ title: result.message || "验证失败", icon: "none" });
}
}; };
async function afterRead(event: any) { async function afterRead(event: any) {

View File

@ -1,52 +1,59 @@
import {AUTH_KEY, BASE_URL, HOMEAGENT, RESULT_CODE_NOT_LOGIN} from "@/config"; import { AUTH_KEY, BASE_URL, HOMEAGENT, RESULT_CODE_NOT_LOGIN } from "@/config";
import {useUserStore} from "@/store/modules/user"; import { useUserStore } from "@/store/modules/user";
import {getLogin} from "../permission"; import { getLogin } from "../permission";
import {request} from "@/utils/request/request"; import { request } from "@/utils/request/request";
import {showToast} from "@/utils/uniapp"; import { showToast } from "@/utils/uniapp";
let count: boolean = false; let count: boolean = false;
function _loginExpiredModal() { function _loginExpiredModal() {
const store = useUserStore(); const store = useUserStore();
store.logout() store.logout();
uni.showModal({ uni.showModal({
title: '提示', title: "提示",
content: '登录过期,请重新登录', content: "登录过期,请重新登录",
showCancel: false, showCancel: false,
success: function (res) { success: function (res) {
if (res.confirm) { if (res.confirm) {
count = false count = false;
getLogin() getLogin();
} else if (res.cancel) { } else if (res.cancel) {
count = false count = false;
uni.navigateBack({ uni.navigateBack({
delta: 1, delta: 1,
fail: (err) => { fail: (err) => {
console.log(err) console.log(err);
} },
}) });
}
} }
},
}); });
} }
export const config = { export const config = {
baseUrl: process.env.NODE_ENV == 'development' ? HOMEAGENT ? '/base' : BASE_URL : BASE_URL, baseUrl:
header: {} process.env.NODE_ENV == "development"
} ? HOMEAGENT
? "/base"
: BASE_URL
: BASE_URL,
header: {},
};
export const interceptor = { export const interceptor = {
request: (config: UniNamespace.UploadFileOption | UniNamespace.RequestOptions) => { request: (
config: UniNamespace.UploadFileOption | UniNamespace.RequestOptions
) => {
const store = useUserStore(); const store = useUserStore();
if (store.getToken) { if (store.getToken) {
config.header = { config.header = {
[AUTH_KEY]: store.getToken [AUTH_KEY]: store.getToken,
}; };
} }
}, },
response: (response: any) => { response: (response: any) => {
if (response.data && RESULT_CODE_NOT_LOGIN == response.data.resultCode) { if (response.data && RESULT_CODE_NOT_LOGIN == response.data.resultCode) {
if (!count) { if (!count) {
_loginExpiredModal() _loginExpiredModal();
} }
count = true; count = true;
return; return;
@ -57,77 +64,126 @@ export const interceptor = {
if (response.data) { if (response.data) {
return response.data; return response.data;
} else { } else {
console.log('接口无返回值', response) console.log("接口无返回值", response);
} }
} },
} };
export function get<T = any>(url: string, data?: any, options?: UniNamespace.RequestOptions): Promise<Requests<T>> { export function get<T = any>(
url: string,
data?: any,
options?: UniNamespace.RequestOptions
): Promise<Requests<T>> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
request(Object.assign({}, { request(
Object.assign(
{},
{
url, url,
data, data,
method: 'GET', method: "GET",
dataType: 'json', dataType: "json",
responseType: 'text', responseType: "text",
}, options)).then(res => { },
options
)
).then((res) => {
if (res.resultCode == 1) { if (res.resultCode == 1) {
resolve(res) resolve(res);
} else { } else {
if (res.resultCode) { if (res.resultCode) {
if (res.resultCode != RESULT_CODE_NOT_LOGIN) { if (res.resultCode != RESULT_CODE_NOT_LOGIN) {
showToast(res.message || '接口异常') showToast(res.message || "接口异常");
reject(res) reject(res);
} }
} else { } else {
if (res.rows) { if (res.rows) {
resolve(res) resolve(res);
} else { } else {
showToast(res.message || '接口异常') showToast(res.message || "接口异常");
reject(res) reject(res);
} }
} }
} }
}) });
}) });
} }
export function post<T = any>(
export function post<T = any>(url: string, data?: any, options?: UniNamespace.RequestOptions): Promise<Requests<T>> { url: string,
data?: any,
options?: UniNamespace.RequestOptions
): Promise<Requests<T>> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
request(Object.assign({}, { request(
Object.assign(
{},
{
url, url,
data, data,
method: 'POST', method: "POST",
dataType: 'json', dataType: "json",
responseType: 'text', responseType: "text",
}, options)).then(res => { },
options
)
).then((res) => {
if (res.resultCode == 1) { if (res.resultCode == 1) {
resolve(res) resolve(res);
} else { } else {
if (res.resultCode) { if (res.resultCode) {
if (res.resultCode != RESULT_CODE_NOT_LOGIN) { if (res.resultCode != RESULT_CODE_NOT_LOGIN) {
showToast(res.message || '接口异常') showToast(res.message || "接口异常");
reject(res) reject(res);
} }
} else { } else {
if (res.rows) { if (res.rows) {
resolve(res) resolve(res);
} else { } else {
showToast(res.message || '接口异常') showToast(res.message || "接口异常");
reject(res) reject(res);
} }
} }
} }
}) });
}) });
} }
export function file(url: string, data: Blob, options?: UniNamespace.UploadFileOption) { export function file(
return request(Object.assign({}, { url: string,
data: Blob,
options?: UniNamespace.UploadFileOption
) {
return new Promise((resolve, reject) => {
request(
Object.assign(
{},
{
url, url,
filePath: data, filePath: data,
name: 'files', name: "files",
}, options), true) },
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);
}
}
}
});
});
} }