2025-03-19 13:15:34 +08:00
|
|
|
|
import { http } from '@/utils/request';
|
|
|
|
|
|
2025-05-14 20:54:01 +08:00
|
|
|
|
|
2025-05-21 10:51:27 +08:00
|
|
|
|
/**
|
|
|
|
|
* 获取微信授权 URL
|
|
|
|
|
* @param {string} baseUrl - 授权后跳转的 URL(需后端处理)
|
|
|
|
|
* @param {string} scope - 授权作用域(如 snsapi_userinfo)
|
|
|
|
|
* @returns {Promise<string>} 返回微信授权 URL
|
|
|
|
|
*/
|
|
|
|
|
export async function getCode(baseUrl = window.location.href, scope = 'snsapi_userinfo') {
|
|
|
|
|
try {
|
|
|
|
|
const response = await http.get('/h5/wechat/code', {
|
|
|
|
|
params: { baseUrl, scope } // 传递参数给后端
|
|
|
|
|
});
|
|
|
|
|
console.log(response)
|
|
|
|
|
// 处理可能的 redirect: 前缀(兼容后端直接返回 URL 或 redirect:URL)
|
|
|
|
|
let authUrl = response.result;
|
|
|
|
|
if (typeof authUrl === 'string' && authUrl.startsWith('redirect:')) {
|
|
|
|
|
authUrl = authUrl.substring('redirect:'.length).trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 直接返回授权 URL,由前端控制跳转
|
|
|
|
|
return authUrl;
|
|
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('获取微信授权 URL 失败:', error);
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
export async function getUserInfo(code,state) {
|
|
|
|
|
try {
|
|
|
|
|
const response = await http.get('/h5/wechat/auth', {
|
|
|
|
|
params: { code,state } // 传递参数给后端
|
|
|
|
|
});
|
|
|
|
|
console.log(response)
|
|
|
|
|
// 处理可能的 redirect: 前缀(兼容后端直接返回 URL 或 redirect:URL)
|
|
|
|
|
//let authUrl = response.result;
|
|
|
|
|
//if (typeof authUrl === 'string' && authUrl.startsWith('redirect:')) {
|
|
|
|
|
// authUrl = authUrl.substring('redirect:'.length).trim();
|
|
|
|
|
//}
|
|
|
|
|
return response;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('获取微信授权 URL 失败:', error);
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
export async function AutocheckUser(openId) {
|
|
|
|
|
try {
|
|
|
|
|
const response = await http.post('/h5/wechat/AutocheckUser',
|
|
|
|
|
{ openId }, // JSON 数据
|
|
|
|
|
{
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json' // 明确指定 JSON 格式
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
return response.result;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('用户检查失败:', error);
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-14 20:54:01 +08:00
|
|
|
|
// 获取访问时间段
|
|
|
|
|
export async function getAccessTime() {
|
|
|
|
|
const response = await http.get('/h5/cees/ceesUser/getH5Time');
|
|
|
|
|
return response;
|
|
|
|
|
}
|
2025-03-19 13:15:34 +08:00
|
|
|
|
/**
|
|
|
|
|
* 账号密码登录
|
|
|
|
|
* @returns UseAxiosReturn
|
|
|
|
|
*/
|
|
|
|
|
export function loginPassword() {
|
|
|
|
|
return http.post(`/api/login`, {
|
|
|
|
|
data: { name: '123' },
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取专业
|
|
|
|
|
export async function getMajor(code) {
|
|
|
|
|
const response = await http.post('/h5/cees/ceesUser/getMajor', {
|
|
|
|
|
userId: code,
|
|
|
|
|
});
|
|
|
|
|
// 如果响应成功,返回专业信息
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
//检查用户身份
|
|
|
|
|
export async function checkUser(code) {
|
|
|
|
|
const response = await http.post('/h5/cees/ceesUser/checkUser', {
|
|
|
|
|
userId: code,
|
|
|
|
|
});
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 研究生保存数据
|
|
|
|
|
export function save(data) {
|
|
|
|
|
return http.post('/h5/cees/ceesStudent/save', {
|
|
|
|
|
userName: data.userName,
|
|
|
|
|
studentId: data.studentId,
|
|
|
|
|
phone: data.phone,
|
|
|
|
|
checked: data.checked,
|
|
|
|
|
userId: data.userId,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取用户身份
|
|
|
|
|
export async function getUser(userId) {
|
|
|
|
|
const response = await http.get('/h5/cees/ceesUser/getUser', {
|
|
|
|
|
params: {
|
|
|
|
|
userId: userId,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
// 根据groupId获取分组名
|
|
|
|
|
export async function getGroupName(groupId) {
|
|
|
|
|
const response = await http.get('/h5/cees/ceesUser/getGroupName', {
|
|
|
|
|
params: {
|
|
|
|
|
groupId: groupId,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-24 19:32:41 +08:00
|
|
|
|
// 根据dormitoryId获取分组名
|
|
|
|
|
export async function getDormitoryName(dormitoryId) {
|
|
|
|
|
const response = await http.get('/h5/cees/ceesWaiTeacher/getDormitoryName', {
|
|
|
|
|
params: {
|
|
|
|
|
dormitoryId: dormitoryId,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-19 13:15:34 +08:00
|
|
|
|
// 本校老师保存数据
|
|
|
|
|
export function localTeacherSave(data) {
|
|
|
|
|
return http.post('/h5/cees/ceesLocalTeacher/save', {
|
|
|
|
|
userName: data.userName,
|
|
|
|
|
teacherId: data.teacherId,
|
|
|
|
|
phone: data.phone,
|
|
|
|
|
checked: data.checked,
|
|
|
|
|
userId: data.userId,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 外校老师保存数据
|
|
|
|
|
export function waiTeacherSave(data) {
|
2025-04-24 19:32:41 +08:00
|
|
|
|
if (data.sex == '男') {
|
|
|
|
|
data.sex = 0;
|
|
|
|
|
}
|
|
|
|
|
if (data.sex == '女') {
|
|
|
|
|
data.sex = 1;
|
|
|
|
|
}
|
2025-03-19 13:15:34 +08:00
|
|
|
|
return http.post('/h5/cees/ceesWaiTeacher/save', {
|
|
|
|
|
age: data.age,
|
|
|
|
|
bankAddress: data.bankAddress,
|
|
|
|
|
bankName: data.bankName,
|
|
|
|
|
carNumber: data.carNumber,
|
|
|
|
|
carStatus: data.carStatus,
|
|
|
|
|
dormitoryStatus: data.dormitoryStatus,
|
|
|
|
|
identityId: data.identityId,
|
|
|
|
|
jobTitle: data.jobTitle,
|
|
|
|
|
office: data.office,
|
|
|
|
|
pyCard: data.pyCard,
|
|
|
|
|
sex: data.sex,
|
|
|
|
|
userCardId: data.userCardId,
|
|
|
|
|
workName: data.workName,
|
|
|
|
|
workPhone: data.workPhone,
|
|
|
|
|
userName: data.userName,
|
|
|
|
|
phone: data.phone,
|
|
|
|
|
userId: data.userId,
|
2025-05-21 10:51:27 +08:00
|
|
|
|
openId: data.openId,
|
2025-03-19 13:15:34 +08:00
|
|
|
|
});
|
|
|
|
|
}
|