修改页面样式

This commit is contained in:
zhouyanli
2026-04-21 18:25:00 +08:00
parent b8fcaff48c
commit 244048985a
9 changed files with 201 additions and 321 deletions

View File

@@ -1,28 +0,0 @@
import request,{get,post} from "/pages/api/request.js"
// =======账号密码登录========
export const getLoginPassword = (data) =>{
return post('/api/resident/auth/loginByPassword',data)
}
// 注册新用户获取验证码
export const getSendCode = (data) =>{
return post('/api/resident/auth/sendSmsCode',data)
}
// 注册新用户
export const getRegisterUser = (data) =>{
return post('/api/resident/auth/register',data)
}
// 短信验证码登录
export const getLoginBySms = (data) =>{
return post('/api/resident/auth/register',data)
}
// 忘记密码接口
export const getResetPassword = (data) =>{
return post('/api/resident/auth/resetPassword',data)
}
// =========首页=======
// 首页最新公告
export const getNoticeList = () =>{
return get('/api/resident/notice/latest')
}

View File

@@ -1,80 +0,0 @@
let baseUrl = '';
if (process.env.NODE_ENV === 'development') {
baseUrl = 'http://192.168.0.224:8080'; // 开发环境
} else {
baseUrl = 'http://192.168.1.224:8080'; // 生产环境
}
export default function request(url, data = {}, method = "GET") {
return new Promise((resolve, reject) => {
// 加载中提示(提升用户体验)
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'
},
// header: {
// "token": uni.getStorageSync("token") || '',
// 'content-type': 'application/json'
// },
success: (res) => {
uni.hideLoading(); // 关闭加载提示
// 处理HTTP状态码网络层面
if (res.statusCode !== 200) {
const errMsg = `请求失败(${res.statusCode}`;
uni.showToast({ title: errMsg, icon: "none", duration: 2000 });
reject(errMsg);
return;
}
// 处理业务状态码后端返回的data里
const resData = res.data || {}; // 兼容后端返回空的情况
// 优先处理token过期401
if (resData.code === 401) {
uni.showToast({ title: '登录过期,请重新登录', icon: 'none', duration: 2000 });
uni.clearStorageSync('token');
setTimeout(() => {
uni.reLaunch({ url: '/pages/login/login' });
}, 1500);
reject('token 过期');
return;
}
// 业务成功code=200
if (resData.code === 200) {
resolve(resData.data); // 只返回核心数据,简化页面调用
}
// 业务失败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);
}
},
fail: (err) => {
uni.hideLoading(); // 关闭加载提示
uni.showToast({ title: '网络连接失败', icon: "none", duration: 2000 });
reject(err);
}
});
});
}
export const get = (url, data) => request(url, data, 'GET');
export const post = (url, data) => request(url, data, 'POST');

View File

@@ -158,7 +158,7 @@
<script setup>
import { ref } from 'vue'
import {onLoad,onUnload} from '@dcloudio/uni-app'
import {getNoticeList} from "/pages/api/api.js"
import {getNoticeList} from "/pageSubPack/api/api.js"
@@ -198,7 +198,7 @@ const noticeText = ref('公告公告本小区今天安装了摄像头')
const getNoticeMore = () =>{
uni.setStorageSync('sourcePage',"index")
uni.navigateTo({
url:"/pages/notice-list/noticeList"
url:"/pageSubPack/notice-list/noticeList"
})
}
// 接收选择小区返回的参数
@@ -249,7 +249,29 @@ const payMentClick =() =>{
url:"/pages/payment-list/paymentIndex"
})
}
// 点击小区选择
// const navigateToPage = () => {
// // 获取登录状态 / token
// const token = uni.getStorageSync('token') || '';
// // 获取是否已经认证
// const userInfo = uni.getStorageSync('userInfo') || {};
// // 未登录 / 未认证 → 去我的页面(去认证)
// // 已登录 / 已认证 → 去选择小区
// if (!token || !userInfo.isAuth) {
// uni.showToast({
// title: '请先完成实名认证',
// icon: 'none'
// });
// // 跳转到我的页面
// uni.switchTab({
// url: '/pages/myIndex/myIndex'
// });
// } else {
// uni.navigateTo({
// url: '/pageSubPack/notice-list/selectHome'
// });
// }
// };
const navigateToPage = () => {
uni.navigateTo({
url: '/pageSubPack/notice-list/selectHome'