巡检点上传图片修正

This commit is contained in:
Zy
2026-05-09 17:10:50 +08:00
parent e29e1c1346
commit b29e03ab4d
29 changed files with 2836 additions and 1189 deletions

View File

@@ -0,0 +1,285 @@
<template>
<view class="reset-pwd-page">
<!-- <view class="status_bar"></view> -->
<!-- 顶部导航栏 -->
<!-- <view class="nav-bar">
<uni-icons type="left" size="28" color="#333" @click="goBack"></uni-icons>
<view class="nav-title">修改密码</view>
</view> -->
<!-- 旧密码输入框 -->
<view class="input-item">
<uni-easyinput
class="input-content"
type="password"
v-model="oldPassword"
placeholder="请输入旧密码"
:inputBorder="false"
:placeholderStyle="placeholderStyle"
@input="checkForm"
>
</uni-easyinput>
</view>
<!-- 新密码输入框 -->
<view class="input-item">
<uni-easyinput
class="input-content"
type="password"
v-model="newPassword"
placeholder="请输入新密码(6-16位,含字母+数字)"
:inputBorder="false"
:placeholderStyle="placeholderStyle"
@input="checkForm"
>
</uni-easyinput>
</view>
<!-- 确认密码输入框 -->
<view class="input-item">
<uni-easyinput
class="input-content"
type="password"
v-model="confirmPassword"
placeholder="请再次输入新密码"
:inputBorder="false"
:placeholderStyle="placeholderStyle"
@input="checkForm"
>
</uni-easyinput>
</view>
<!-- 密码规则提示 -->
<view class="pwd-tip">
密码规则:6-16位字符,必须包含字母和数字
</view>
<!-- 确定按钮 -->
<button
class="confirm-btn"
:disabled="!canConfirm"
@click="handleConfirm"
>
确定
</button>
</view>
</template>
<script setup>
import { ref, computed } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app'
// import { getResetPassword } from '../api/api.js'
// ========== 响应式数据 ==========
// 旧密码
const oldPassword = ref('')
// 新密码
const newPassword = ref('');
// 确认密码
const confirmPassword = ref('');
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;
});
// ========== 方法 ==========
// 返回上一页
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)) {
// 密码格式错误提示(可选:显示在页面上,而不是toast)
// errorTip.value = '密码必须包含字母和数字,长度6-16位'
} else if (confirmPassword.value && newPassword.value !== confirmPassword.value) {
// errorTip.value = '两次输入的密码不一致'
} else {
// errorTip.value = ''
}
};
// 处理确定按钮点击(修改密码逻辑)
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;
}
// 构造请求参数(包含旧密码)
let params = {
phone: phone.value,
smsCode: smsCode.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);
// })
};
</script>
<style scoped>
/* 页面容器 */
.reset-pwd-page {
padding: 20rpx 40rpx 40rpx;
min-height: 100vh;
background-color: #F9F9F9;
/* background: repeating-linear-gradient(180deg, #E2F0FF, #F6FAFF ); */
}
.status_bar {
width: 100%;
height: 46px;
}
/* 顶部导航栏 */
.nav-bar {
display: flex;
align-items: center;
height: 88rpx;
margin-bottom: 60rpx;
}
.nav-title {
flex: 1;
text-align: center;
font-size: 36rpx;
font-weight: 500;
color: #333;
}
/* 输入框通用样式 */
.input-item {
background-color: #fff;
border-radius: 40rpx;
padding: 0 30rpx;
height: 88rpx;
margin-bottom: 30rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
display: flex;
align-items: center;
}
/* 输入框内容 */
.input-content {
flex: 1;
font-size: 32rpx;
color: #333;
height: 100%;
}
/* 密码规则提示 */
.pwd-tip {
font-size: 24rpx;
color: #999;
text-align: left;
margin: -20rpx 0 30rpx 10rpx;
line-height: 1.4;
}
/* 确定按钮 */
.confirm-btn {
width: 100%;
height: 88rpx;
line-height: 88rpx;
background-color: #4D5DFA;
color: #fff;
border-radius: 8rpx;
font-size: 28rpx;
margin-top: 20rpx;
border: none;
}
/* 确定按钮禁用状态 */
.confirm-btn:disabled {
background-color: #99c8ff;
color: #fff;
}
/* 禁用按钮边框重置 */
button:after {
border: none;
border-radius: 8rpx;
}
</style>