hldy_app/component/public/reset.vue

243 lines
5.5 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<!-- 通过 v-show 控制显隐并根据 show 添加 is-active 类触发 CSS 过渡 -->
<view :class="['neuro-wrapper', donghua ? 'is-active' : '']" v-show="show">
<!-- 遮罩层点击触发关闭 -->
<view class="neuro-mask" @click="handleClose"></view>
<!-- 拟态框阻止冒泡点击 -->
<view class="neuro-box" @click.stop>
<view class="button-father">
<!-- <view class="button-white" @click="handleClose">取消</view> -->
<view class="button" @click="go">确定</view>
</view>
<view class="title">修改账号登录密码</view>
<view class="password-father" style="margin-top: 50rpx;">
<input class="password" :password="false" v-model="form.oldpassword" maxlength="15"
placeholder="请输入旧密码" />
</view>
<view class="password-father">
<input class="password" :password="false" v-model="form.password" maxlength="15" placeholder="请输入新密码" />
</view>
<view class="password-father">
<input class="password" :password="false" v-model="form.confirmpassword" maxlength="15"
placeholder="请再次输入新密码" />
</view>
<view class="card-font">
<!-- 确定要退出155******76账户吗 -->
</view>
</view>
</view>
</template>
<script setup>
import {
ref,
reactive,
watch
} from 'vue'
import {
updatePassword
} from '@/pages/Initialization/api.js'
// 接收 show 属性并支持 update:show 事件
const props = defineProps({
show: {
type: Boolean,
default: true
},
});
const form = reactive({
username: uni.getStorageSync('username'),
oldpassword: "",
password: "",
confirmpassword: ""
})
// 区分首次渲染与动态添加
const donghua = ref(false);
watch(
() => props.show,
(newVal, oldVal) => {
if (!oldVal && newVal) {
donghua.value = false
setTimeout(() => donghua.value = true, 50)
}
}
)
const emit = defineEmits(["close"]);
// 关闭方法,通知父组件更新 show
function handleClose() {
emit('close');
}
const go = () => {
if (!form.username || !form.oldpassword || !form.password || !form.confirmpassword) {
uni.showToast({
title: '请完善信息',
icon: 'error', // 无图标,表示普通文本
duration: 2000
})
return
}
if (form.password.length < 6 || form.confirmpassword.length < 6) {
uni.showToast({
title: '密码要多于六位',
icon: 'none', // 无图标,表示普通文本
duration: 2000
})
return
}
if (form.password !== form.confirmpassword) {
uni.showToast({
title: '新密码与确认密码不一致',
icon: 'none', // 无图标,表示普通文本
duration: 2000
})
return
}
// plus.runtime.quit();
updatePassword(form).then(res => {
console.log("res", res)
if (res.success) {
uni.showToast({
title: res.message,
icon: 'none', // 无图标,表示普通文本
duration: 2000
})
// uni.clearStorageSync();
setTimeout(() => {
// 1. 清除缓存
uni.setStorageSync('token', 1);
// 2. 跳转到登录页(使用 reLaunch 关闭所有页面栈)
uni.reLaunch({
url: '/pages/login/login' // 请根据你项目的路径修改
});
}, 1000)
} else {
uni.showToast({
title: res.message,
icon: 'none', // 无图标,表示普通文本
duration: 2000
})
}
})
}
</script>
<style lang="scss" scoped>
/* 容器默认隐藏,透明度为 0不接受点击 */
.neuro-wrapper {
position: fixed;
inset: 0;
display: flex;
justify-content: center;
align-items: center;
z-index: 999;
opacity: 0;
pointer-events: none;
transition: opacity 0.3s ease;
}
/* 显示时透明度过渡到 1可接受点击 */
.neuro-wrapper.is-active {
opacity: 1;
pointer-events: auto;
}
/* 遮罩层,半透明黑色 */
.neuro-mask {
position: absolute;
inset: 0;
background-color: rgba(0, 0, 0, 0.3);
}
/* 拟态框 固定尺寸 + 阴影样式 + 相对定位于 wrapper */
.neuro-box {
position: relative;
width: 750rpx;
height: 700rpx;
border-radius: 30rpx;
background-color: #fff;
display: flex;
flex-direction: column;
// justify-content: center;
align-items: center;
background-image: url('https://www.focusnu.com/media/directive/index/whitepeople.png');
// background-size: 100% auto;
background-position: top center;
background-repeat: no-repeat;
z-index: 1;
padding: 0 10%;
}
.button {
width: 100%;
background: linear-gradient(to left, #00C9FF, #0076FF);
display: flex;
justify-content: center;
align-items: center;
color: #fff;
font-size: 25rpx;
border-radius: 35rpx;
margin-left: 20rpx;
}
.title {
margin-top: 70rpx;
font-weight: 600;
font-size: 35rpx;
}
.card-font {
margin-top: 70rpx;
width: 600rpx;
justify-content: center;
display: flex;
}
.button-white {
width: 47%;
border: 2rpx solid #c3cacd;
background: linear-gradient(to bottom, #f3f3f5, #dee4e9);
display: flex;
justify-content: center;
align-items: center;
font-size: 25rpx;
border-radius: 30rpx;
}
.button-father {
position: absolute;
bottom: 70rpx;
left: 50%;
transform: translateX(-50%);
width: 100%;
height: 80rpx;
display: flex;
justify-content: center;
padding: 0 110rpx;
}
.password-father {
margin-top: 30rpx;
width: 750rpx;
padding: 0 120rpx;
height: 80rpx;
.password {
width: 100%;
background-color: #edf0f9;
border-radius: 23rpx;
height: 80rpx;
padding-left: 20rpx;
// margin-left: -20rpx;
font-size: 27rpx;
}
}
</style>