180 lines
3.4 KiB
Vue
180 lines
3.4 KiB
Vue
<template>
|
|
<view class="change-password-page">
|
|
<image class="bg-image" src="/static/images/home_bg.png" mode="aspectFill" />
|
|
|
|
<view class="content">
|
|
<!-- 顶部导航栏 -->
|
|
<view class="nav-bar" :style="{ paddingTop: statusBarHeight + 'px' }">
|
|
<view class="nav-bar-inner">
|
|
<image
|
|
class="nav-icon"
|
|
src="/static/images/ic_back.png"
|
|
mode="aspectFit"
|
|
@click="goBack"
|
|
/>
|
|
<text class="nav-title">修改密码</text>
|
|
<view class="nav-icon-placeholder" />
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 密码输入 -->
|
|
<view class="form-area">
|
|
<view class="input-wrap">
|
|
<input
|
|
class="input-field"
|
|
v-model="oldPassword"
|
|
placeholder="请输入旧密码"
|
|
placeholder-class="placeholder"
|
|
password
|
|
/>
|
|
</view>
|
|
|
|
<view class="input-wrap">
|
|
<input
|
|
class="input-field"
|
|
v-model="newPassword"
|
|
placeholder="请输入新密码"
|
|
placeholder-class="placeholder"
|
|
password
|
|
/>
|
|
</view>
|
|
|
|
<view class="submit-btn" @click="handleSubmit">
|
|
<text class="submit-btn-text">确认修改</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref } from 'vue'
|
|
import { updatePassword } from '@/services/auth'
|
|
|
|
const statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 0
|
|
|
|
const oldPassword = ref('')
|
|
const newPassword = ref('')
|
|
|
|
function goBack() {
|
|
uni.navigateBack()
|
|
}
|
|
|
|
async function handleSubmit() {
|
|
if (!oldPassword.value) {
|
|
uni.showToast({ title: '请输入旧密码!', icon: 'none' })
|
|
return
|
|
}
|
|
if (!newPassword.value) {
|
|
uni.showToast({ title: '请输入新密码!', icon: 'none' })
|
|
return
|
|
}
|
|
const res = await updatePassword(oldPassword.value, newPassword.value)
|
|
if (res.code === 200) {
|
|
uni.showToast({ title: '修改成功', icon: 'none' })
|
|
setTimeout(() => {
|
|
uni.navigateBack()
|
|
}, 1500)
|
|
} else if (res.code === 110) {
|
|
uni.showToast({ title: res.msg, icon: 'none' })
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.change-password-page {
|
|
position: relative;
|
|
min-height: 100vh;
|
|
background-color: #F5F5F5;
|
|
}
|
|
|
|
.bg-image {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 500rpx;
|
|
z-index: 0;
|
|
}
|
|
|
|
.content {
|
|
position: relative;
|
|
z-index: 1;
|
|
}
|
|
|
|
.nav-bar {
|
|
width: 100%;
|
|
}
|
|
|
|
.nav-bar-inner {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
height: 88rpx;
|
|
padding: 0 24rpx;
|
|
}
|
|
|
|
.nav-icon {
|
|
width: 44rpx;
|
|
height: 44rpx;
|
|
}
|
|
|
|
.nav-icon-placeholder {
|
|
width: 44rpx;
|
|
height: 44rpx;
|
|
}
|
|
|
|
.nav-title {
|
|
font-size: 34rpx;
|
|
font-weight: 600;
|
|
color: #fff;
|
|
}
|
|
|
|
.form-area {
|
|
padding: 40rpx 24rpx;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
}
|
|
|
|
.input-wrap {
|
|
width: 560rpx;
|
|
height: 90rpx;
|
|
background-color: #ECEFF3;
|
|
border: 1rpx solid rgba(0, 0, 0, 0.08);
|
|
border-radius: 20rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 0 24rpx;
|
|
box-sizing: border-box;
|
|
margin-bottom: 30rpx;
|
|
}
|
|
|
|
.input-field {
|
|
width: 100%;
|
|
height: 100%;
|
|
font-size: 28rpx;
|
|
color: #333;
|
|
}
|
|
|
|
.placeholder {
|
|
color: #999;
|
|
}
|
|
|
|
.submit-btn {
|
|
margin-top: 60rpx;
|
|
width: 560rpx;
|
|
height: 90rpx;
|
|
background-color: #1A73EC;
|
|
border-radius: 20rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.submit-btn-text {
|
|
font-size: 32rpx;
|
|
color: #fff;
|
|
}
|
|
</style>
|