Files
oa_app/pages/password/password.vue
T
2026-09-23 17:38:24 +08:00

62 lines
2.0 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>
<view class="page">
<fy-header title="修改密码" />
<view class="body">
<text class="hint">首次登录或管理员要求改密请设置新密码后继续</text>
<view class="field">
<text class="lab">新密码</text>
<view class="box"><input v-model="next" password placeholder="至少 6 位" /></view>
</view>
<view class="field">
<text class="lab">确认新密码</text>
<view class="box"><input v-model="confirm" password placeholder="再输入一次" /></view>
</view>
<view class="btn-primary" @click="ok">确认修改</view>
<text v-if="error" class="err">{{ error }}</text>
</view>
</view>
</template>
<script>
import FyHeader from '../../components/fy-header.vue'
import { store } from '../../utils/store.js'
import { toast } from '../../utils/format.js'
export default {
components: { FyHeader },
data() {
return { next: '', confirm: '', error: '', off: null, left: false }
},
onShow() {
if (this.off) this.off()
this.off = store.on(() => {
this.error = store.error
if (this.left || store.phase !== 'app') return
this.left = true
uni.switchTab({ url: '/pages/tabs/messages' })
})
},
onHide() {
if (this.off) this.off()
this.off = null
},
methods: {
async ok() {
if (!this.next || this.next.length < 6) return toast('密码至少 6 位')
if (this.next !== this.confirm) return toast('两次密码不一致')
await store.changePassword(this.next, this.confirm)
}
}
}
</script>
<style scoped>
.body { padding: 40rpx; }
.hint { font-size: 26rpx; color: #6B7280; display: block; margin-bottom: 32rpx; }
.field { margin-bottom: 24rpx; }
.lab { font-size: 24rpx; color: #4B5563; display: block; margin-bottom: 8rpx; }
.box { height: 96rpx; background: #fff; border-radius: 16rpx; padding: 0 24rpx; display: flex; align-items: center; }
.box input { flex: 1; }
.err { color: #DC2626; font-size: 24rpx; margin-top: 16rpx; display: block; }
</style>