我的房屋流程对接接口,缴费页面功能修改一版

This commit is contained in:
wangyuxin
2026-04-30 08:24:22 +08:00
parent d569bbc8e1
commit 2c528b7973
19 changed files with 2675 additions and 2553 deletions

View File

@@ -1,25 +1,29 @@
let baseUrl = '';
let baseUrl = '';
if (process.env.NODE_ENV === 'development') {
// http://192.168.1.215
// http://192.168.0.224
baseUrl = 'http://192.168.0.224:8080'; // 开发环境
} else {
baseUrl = 'http://192.168.1.224:8080'; // 生产环境
baseUrl = 'http://192.168.0.224:8080'; // 生产环境
}
export default function request(url, data = {}, method = "GET") {
return new Promise((resolve, reject) => {
// 加载中提示(提升用户体验)
uni.showLoading({ title: '请求中...', mask: true });
uni.showLoading({
title: '请求中...',
mask: true
});
uni.request({
url: baseUrl + url,
data: data,
method: method,
header: {
"Authorization": "Bearer " + (uni.getStorageSync("token") || ''),
"clientid": "resident",
'content-type': 'application/json'
},
"Authorization": "Bearer " + (uni.getStorageSync("token") || ''),
"clientid": "resident",
'content-type': 'application/json'
},
// header: {
// "token": uni.getStorageSync("token") || '',
// 'content-type': 'application/json'
@@ -30,9 +34,13 @@ export default function request(url, data = {}, method = "GET") {
// 处理HTTP状态码网络层面
if (res.statusCode !== 200) {
const errMsg = `请求失败(${res.statusCode}`;
uni.showToast({ title: errMsg, icon: "none", duration: 2000 });
uni.showToast({
title: errMsg,
icon: "none",
duration: 2000
});
reject(errMsg);
return;
return;
}
// 处理业务状态码后端返回的data里
@@ -40,10 +48,16 @@ export default function request(url, data = {}, method = "GET") {
// 优先处理token过期401
if (resData.code === 401) {
uni.showToast({ title: '登录过期,请重新登录', icon: 'none', duration: 2000 });
uni.showToast({
title: '登录过期,请重新登录',
icon: 'none',
duration: 2000
});
uni.clearStorageSync('token');
setTimeout(() => {
uni.reLaunch({ url: '/pageSubPack/loginSub/pwd-login' });
uni.reLaunch({
url: '/pageSubPack/loginSub/pwd-login'
});
}, 1500);
reject('token 过期');
return;
@@ -56,20 +70,31 @@ export default function request(url, data = {}, method = "GET") {
// 业务失败code=500
else if (resData.code === 500) {
const errMsg = resData.msg || '请求失败';
uni.showToast({ title: errMsg, icon: "none", duration: 2000 });
uni.showToast({
title: errMsg,
icon: "none",
duration: 2000
});
// resolve(null)
reject(errMsg);
}
else {
} else {
const errMsg = resData.msg || '业务异常';
uni.showToast({ title: errMsg, icon: "none", duration: 2000 });
uni.showToast({
title: errMsg,
icon: "none",
duration: 2000
});
reject(errMsg);
}
},
fail: (err) => {
uni.hideLoading(); // 关闭加载提示
const errMsg = err.msg || '网络请求失败';
uni.showToast({ title: errMsg, icon: "none", duration: 2000 });
uni.showToast({
title: errMsg,
icon: "none",
duration: 2000
});
reject(err);
}
});
@@ -77,5 +102,5 @@ export default function request(url, data = {}, method = "GET") {
}
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');