替换图片并删掉本地图片,代码分包
This commit is contained in:
197
property-uniapp-project/pageSubPack/loginSub/change-pwd.vue
Normal file
197
property-uniapp-project/pageSubPack/loginSub/change-pwd.vue
Normal file
@@ -0,0 +1,197 @@
|
||||
<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="newPassword"
|
||||
placeholder="请输入密码" :inputBorder="false" :placeholderStyle="placeholderStyle">
|
||||
</uni-easyinput>
|
||||
</view>
|
||||
|
||||
<!-- 确认密码输入框 -->
|
||||
<view class="input-item">
|
||||
<uni-easyinput class="input-content" type="password" v-model="confirmPassword"
|
||||
placeholder="请再次输入密码" :inputBorder="false" :placeholderStyle="placeholderStyle">
|
||||
</uni-easyinput>
|
||||
</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 '/pages/api/api.js'
|
||||
|
||||
|
||||
// ========== 响应式数据 ==========
|
||||
// 新密码
|
||||
const newPassword = ref('');
|
||||
// 确认密码
|
||||
const confirmPassword = ref('');
|
||||
const placeholderStyle = ref('font-size:24rpx')
|
||||
// 定义接收上一页传来的参数
|
||||
const phone = ref('');
|
||||
const smsCode = ref('');
|
||||
|
||||
// ========== 计算属性 ==========
|
||||
// 是否可点击确定按钮(密码格式正确 + 两次输入一致)
|
||||
const canConfirm = computed(() => {
|
||||
// 密码格式规则:6-16位任意字符(可根据需求调整)
|
||||
const pwdReg = /^(?=.*[a-zA-Z])(?=.*\d).{6,16}$/;
|
||||
// 校验条件:新密码符合格式 + 确认密码和新密码一致 + 均不为空
|
||||
return 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
|
||||
// 用完删除缓存(避免下次跳转读取旧值)
|
||||
uni.removeStorageSync('tempChangePwdParams');
|
||||
});
|
||||
|
||||
// 检查表单状态(实时更新按钮状态)
|
||||
const checkForm = () => {};
|
||||
|
||||
// 处理确定按钮点击(修改密码逻辑)
|
||||
const handleConfirm = () => {
|
||||
if (!canConfirm.value) return
|
||||
let params = {
|
||||
phone:phone.value,
|
||||
smsCode:smsCode.value,
|
||||
newPassword:newPassword.value,
|
||||
confirmPassword:confirmPassword.value,
|
||||
scene:'reset'
|
||||
}
|
||||
getResetPassword(params).then(res =>{
|
||||
if(res.code === 200){
|
||||
//uni.setStorageSync('token', res.token); // 假设后端返回token字段
|
||||
uni.showToast({ title: '修改成功', icon: 'success' });
|
||||
setTimeout(() =>{
|
||||
uni.navigateTo({ url: '/pageSubPack/loginSub/pwd-login' });
|
||||
},1500)
|
||||
|
||||
}else{
|
||||
uni.showToast({ title: "修改失败", icon: 'error' });
|
||||
}
|
||||
}).catch(err =>{
|
||||
uni.showToast({
|
||||
title: '网络异常',
|
||||
icon: 'error'
|
||||
});
|
||||
})
|
||||
|
||||
// 模拟修改密码请求
|
||||
// uni.showLoading({
|
||||
// title: '修改中...'
|
||||
// });
|
||||
|
||||
// setTimeout(() => {
|
||||
// uni.hideLoading();
|
||||
// uni.showToast({
|
||||
// title: '密码修改成功',
|
||||
// icon: 'success'
|
||||
// });
|
||||
|
||||
// // 密码修改成功后返回上一页(或跳转到登录页)
|
||||
// uni.navigateTo({
|
||||
// url:"/pages/login/pwd-login"
|
||||
// });
|
||||
// }, 1500);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
/* 页面容器 */
|
||||
.reset-pwd-page {
|
||||
padding: 20rpx 40rpx 40rpx;
|
||||
min-height: 100vh;
|
||||
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%;
|
||||
}
|
||||
|
||||
/* 确定按钮 */
|
||||
.confirm-btn {
|
||||
width: 100%;
|
||||
height: 88rpx;
|
||||
line-height: 88rpx;
|
||||
background-color: #007aff;
|
||||
color: #fff;
|
||||
border-radius: 44rpx;
|
||||
font-size: 32rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
/* 确定按钮禁用状态 */
|
||||
.confirm-btn:disabled {
|
||||
background-color: #99c8ff;
|
||||
color: #fff;
|
||||
}
|
||||
/* 禁用按钮边框 */
|
||||
button:after{
|
||||
border-radius: 50px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user