# Conflicts:
#	property-uniapp-project/pageSubPack/api/apiSub.js
This commit is contained in:
wangyuxin
2026-05-13 17:31:31 +08:00
27 changed files with 1579 additions and 1914 deletions

View File

@@ -22,6 +22,10 @@ export const getResetPassword = (data) =>{
return post('/api/resident/auth/resetPassword',data)
}
// =========首页=======
// 获取bannar图
export const getBannarList = (data) =>{
return get('/resident/banner',data)
}
// 首页最新公告
export const getNoticeLatest = () =>{
return get('/api/resident/notice/latest')
@@ -131,11 +135,7 @@ export const addVisitorData = (data) =>{
return post("/api/visitor", data)
}
// 通用文件上传
export const uploadImage = () => {
return upload('');
}
// 上传单张图片
export const uploadFile = (filePath) => {
return upload(filePath, '');
return upload(filePath,'/api/resident/file/uploadImage');
}

View File

@@ -86,6 +86,42 @@ export const authLogout = (data) => {
// 编辑房屋
export const upDateMyHouse = (data) => {
return putMethod(`/api/resident/my/house/${data.id}`, data)
}
// =========问卷调查=========
// 问卷列表
export const getQuestionnaireList = (data) => {
return get('/api/resident/questionnaire/list',data)
}
// 问卷详情
export const getQuestionnaireDetail = (data) => {
return get('/api/resident/questionnaire/myAnswers',data)
}
// 提交问卷
export const submitQuestionnair = (id,data) => {
return post(`/api/resident/questionnaire/${id}/submit`, data)
}
// =====投诉意见=======
// 获取投诉类型
export const getComplainType = () => {
return get('/complain/getComplainType')
}
// 获取投诉列表
export const getComplainList = (data) => {
return get('/complain/getComplainList',data)
}
// 提交投诉建议
export const addComplain = (data) => {
return post('/complain/add',data)
}
// 投诉详情
export const getComplainDetail = (data) => {
return get('/complain/detail',data)
}
// 联系物业
export const getManagePhoneData = (data) => {
return get('/api/manage/banner/getManagePhone',data)
}
// 修改身份证照片

View File

@@ -1,7 +1,5 @@
let baseUrl = '';
if (process.env.NODE_ENV === 'development') {
// http://192.168.1.215
// http://192.168.0.224
baseUrl = 'http://192.168.0.239:8080'; // 开发环境
} else {
baseUrl = 'http://192.168.0.224:8080'; // 生产环境
@@ -9,7 +7,6 @@ if (process.env.NODE_ENV === 'development') {
export default function request(url, data = {}, method = "GET") {
return new Promise((resolve, reject) => {
// 加载中提示(提升用户体验)
uni.showLoading({
title: '请求中...',
mask: true
@@ -24,87 +21,51 @@ export default function request(url, data = {}, method = "GET") {
"clientid": "resident",
'content-type': 'application/json'
},
// header: {
// "token": uni.getStorageSync("token") || '',
// 'content-type': 'application/json'
// },
success: (res) => {
uni.hideLoading(); // 关闭加载提示
uni.hideLoading();
// 处理HTTP状态码(网络层面)
// HTTP 失败
if (res.statusCode !== 200) {
const errMsg = `请求失败(${res.statusCode}`;
uni.showToast({
title: errMsg,
icon: "none",
duration: 2000
});
reject(errMsg);
reject({ msg: `请求异常 ${res.statusCode}`, code: res.statusCode });
return;
}
// 处理业务状态码后端返回的data里
const resData = res.data || {}; // 兼容后端返回空的情况
const resData = res.data || {};
// 优先处理token过期401
// token 过期
if (resData.code === 401) {
uni.showToast({
title: '登录过期,请重新登录',
icon: 'none',
duration: 2000
});
uni.showToast({ title: '登录过期,请重新登录', icon: 'none' });
uni.clearStorageSync('token');
setTimeout(() => {
uni.reLaunch({
url: '/pageSubPack/loginSub/pwd-login'
});
uni.reLaunch({ url: '/pageSubPack/loginSub/pwd-login' });
}, 1500);
reject('token 过期');
reject({ msg: '登录过期', code: 401 });
return;
}
// 业务成功code=200
// 成功
if (resData.code === 200) {
resolve(resData); // 只返回核心数据,简化页面调用
resolve(resData);
}
// 业务失败code=500
else if (resData.code === 500) {
const errMsg = resData.msg || '请求失败';
uni.showToast({
title: errMsg,
icon: "none",
duration: 2000
});
// resolve(null)
reject(errMsg);
} else {
const errMsg = resData.msg || '业务异常';
uni.showToast({
title: errMsg,
icon: "none",
duration: 2000
});
reject(errMsg);
// 业务失败
else {
reject({ msg: resData.msg || '请求失败', code: resData.code, data: resData });
}
},
fail: (err) => {
uni.hideLoading(); // 关闭加载提示
const errMsg = err.msg || '网络请求失败';
uni.showToast({
title: errMsg,
icon: "none",
duration: 2000
});
reject(err);
uni.hideLoading();
reject({ msg: '网络异常', code: -1, raw: err });
}
});
});
}
export const get = (url, data) => request(url, data, 'GET');
export const post = (url, data) => request(url, data, 'POST');
export const deleteMethod = (url, data) => request(url, data, 'DELETE');
export const putMethod = (url, data) => request(url, data, 'PUT');
// 通用文件上传
// 上传
export const upload = (filePath, url) => {
return new Promise((resolve, reject) => {
uni.uploadFile({
@@ -116,16 +77,12 @@ export const upload = (filePath, url) => {
"clientid": "resident"
},
success: (res) => {
if (res.statusCode === 200) {
const data = JSON.parse(res.data);
if (data.code === 200) {
resolve(data);
} else {
reject(data.msg || '上传失败');
try {
const data = JSON.parse(res.data);
resolve(data.data || ''); // 直接返回图片地址
} catch (e) {
resolve('');
}
} else {
reject('上传失败');
}
},
fail: (err) => {
reject(err);