对接首页消息通知、巡检点 切换小区获取最新数据

This commit is contained in:
zhouyanli
2026-05-15 16:06:32 +08:00
parent 8324d096c0
commit 856f36455c
17 changed files with 425 additions and 770 deletions

View File

@@ -55,11 +55,7 @@
</view>
<!-- 确定按钮 -->
<button
class="confirm-btn"
:disabled="!canConfirm"
@click="handleConfirm"
>
<button class="confirm-btn" @click="handleConfirm">
确定
</button>
</view>
@@ -68,7 +64,7 @@
<script setup>
import { ref, computed } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app'
// import { getResetPassword } from '../api/api.js'
import { changePassword } from '../../api/api.js'
// ========== 响应式数据 ==========
// 旧密码
@@ -83,22 +79,6 @@ const placeholderStyle = ref('font-size:24rpx;color:#999')
const phone = ref('');
const smsCode = ref('');
// ========== 计算属性 ==========
// 是否可点击确定按钮(包含旧密码必填校验)
const canConfirm = computed(() => {
// 密码格式规则:6-16位,必须包含字母+数字
const pwdReg = /^(?=.*[a-zA-Z])(?=.*\d).{6,16}$/;
// 校验条件:
// 1. 旧密码不为空
// 2. 新密码符合格式
// 3. 确认密码和新密码一致
// 4. 所有密码输入框不为空
return oldPassword.value.trim()
&& pwdReg.test(newPassword.value)
&& newPassword.value === confirmPassword.value
&& newPassword.value && confirmPassword.value;
});
// ========== 方法 ==========
// 返回上一页
@@ -106,30 +86,8 @@ const goBack = () => {
uni.navigateBack();
};
// 页面显示时读取缓存参数
onShow(() => {
// 从缓存读取参数
const params = uni.getStorageSync('tempChangePwdParams') || {};
// 赋值
phone.value = params.phoneNumber || ''
smsCode.value = params.verifyCode || ''
// 校验参数是否完整
// if (!phone.value || !smsCode.value) {
// uni.showToast({
// title: '参数异常,请重新操作',
// icon: 'error'
// })
// setTimeout(() => {
// goBack()
// }, 1500)
// }
// 用完删除缓存(避免下次跳转读取旧值)
uni.removeStorageSync('tempChangePwdParams');
});
// 实时检查表单状态(可扩展自定义提示)
// 实时检查表单状态
const checkForm = () => {
// 可在这里添加实时的表单错误提示,比如:
if (newPassword.value && !/^(?=.*[a-zA-Z])(?=.*\d).{6,16}$/.test(newPassword.value)) {
@@ -142,60 +100,48 @@ const checkForm = () => {
}
};
// 处理确定按钮点击(修改密码逻辑)
// 处理确定按钮点击
const handleConfirm = () => {
// 二次校验,防止异常点击
if (!canConfirm.value) {
// 给出具体的错误提示
if (!oldPassword.value) {
uni.showToast({ title: '请输入旧密码', icon: 'none' });
} else if (!/^(?=.*[a-zA-Z])(?=.*\d).{6,16}$/.test(newPassword.value)) {
uni.showToast({ title: '新密码格式错误(需6-16位,含字母+数字)', icon: 'none' });
} else if (newPassword.value !== confirmPassword.value) {
uni.showToast({ title: '两次输入的密码不一致', icon: 'none' });
}
return;
}
// 1. 表单校验
if (!oldPassword.value) {
uni.showToast({ title: '请输入旧密码', icon: 'none' });
return;
}
if (!/^(?=.*[a-zA-Z])(?=.*\d).{6,16}$/.test(newPassword.value)) {
uni.showToast({ title: '新密码格式错误(需6-16位,含字母+数字)', icon: 'none' });
return;
}
if (newPassword.value !== confirmPassword.value) {
uni.showToast({ title: '两次输入的密码不一致', icon: 'none' });
return;
}
// 构造请求参数(包含旧密码)
let params = {
phone: phone.value,
smsCode: smsCode.value,
oldPassword: oldPassword.value, // 新增旧密码参数
oldPassword: oldPassword.value,
newPassword: newPassword.value,
confirmPassword: confirmPassword.value,
scene: 'reset'
}
// 显示加载中
uni.showLoading({ title: '修改中...' });
setTimeout(() =>{
uni.navigateTo({
url:`/pageSubPack/setting/setting?newPassword=${confirmPassword.value}`
})
})
// 调用修改密码接口
// getResetPassword(params).then(res => {
// uni.hideLoading();
// if (res.code === 200) {
// uni.showToast({ title: '修改成功', icon: 'success' });
// setTimeout(() => {
// // 跳转到登录页(替换为你的实际登录页路径)
// uni.redirectTo({ url: '/pageSubPack/loginSub/pwd-login' });
// }, 1500)
// } else {
// uni.showToast({ title: res.msg || "修改失败", icon: 'error' });
// }
// }).catch(err => {
// uni.hideLoading();
// uni.showToast({
// title: '网络异常,请稍后重试',
// icon: 'none'
// });
// console.error('修改密码失败:', err);
// })
changePassword(params).then(res => {
uni.hideLoading();
if (res.code === 200) {
uni.showToast({ title: '修改成功', icon: 'success' });
setTimeout(() => {
uni.navigateBack()
}, 1500)
} else {
uni.showToast({ title: res.msg || "修改失败", icon: 'error' });
}
}).catch(err => {
uni.hideLoading();
uni.showToast({
title: err.msg || '网络异常,请稍后重试',
icon: 'none'
});
})
};
</script>

View File

@@ -8,7 +8,7 @@
<!-- 手机号输入框 -->
<view class="input-item">
<view class="input-icon">
<image src="http://47.104.199.163:9090/images/login/phone.png" mode="" style="height: 100%;width: 100%;"></image>
<image src="https://wuyeadmin.bugtc.com/images/login/phone.png" mode="" style="height: 100%;width: 100%;"></image>
</view>
<uni-easyinput class="input-content" type="number" v-model="phoneNumber" trim="all"
placeholder="请输入手机号" :inputBorder="false" maxlength="11" :placeholderStyle="placeholderStyle">
@@ -17,7 +17,7 @@
<!-- 验证码输入 + 获取验证码按钮 -->
<view class="input-item verify-item">
<view class="input-icon">
<image src="http://47.104.199.163:9090/images/login/code.png" mode="" style="height: 100%;width: 100%;"></image>
<image src="https://wuyeadmin.bugtc.com/images/login/code.png" mode="" style="height: 100%;width: 100%;"></image>
<!-- <uni-icons type="locked" size="24" color="#999"></uni-icons> -->
</view>
<uni-easyinput class="input-content verify-input" type="number" v-model="verifyCode" trim="all"

View File

@@ -29,7 +29,7 @@
<!-- 退出登录按钮 -->
<view class="logout-btn-wrap">
<button class="logout-btn" :disabled="!phoneNumber || !passwordNumber" @tap="handleLogout">
<button class="logout-btn" :disabled="!phoneNumber" @tap="handleLogout">
退出登录
</button>
</view>
@@ -41,7 +41,7 @@ import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
// 响应式数据
const phoneNumber = ref('15699991212') // 绑定手机号
const phoneNumber = ref('') // 绑定手机号
const passwordNumber = ref('')
// 页面加载时可从接口获取用户信息
@@ -99,9 +99,6 @@ const confirmLogout = () => {
uni.hideLoading()
// 清除本地存储的token等信息
uni.clearStorageSync()
// uni.removeStorageSync('token')
// uni.removeStorageSync('userInfo')
// uni.removeStorageSync('tempChangePwdParams')
// 提示并跳转到登录页
uni.showToast({