<template> <view> <view class="content"> <view class="flex item"> <view>旧密码</view> <view><input class="uni-input" :password="show" maxlength="16" v-model="pwd.oldPassword" placeholder="请输入旧密码" /></view> <view class="label show"><view class="icon" :class="{ active: !show }" @click="show = !show"></view></view> </view> <view class="flex item"> <view>新密码</view> <view><input class="uni-input" :password="newPwd" maxlength="16" v-model="pwd.newPassword" placeholder="请输入新密码" /></view> <view class="label show"><view class="icon" :class="{ active: !newPwd }" @click="newPwd = !newPwd"></view></view> </view> <view class="flex item"> <view>确认密码</view> <view><input class="uni-input" :password="reNewPwd" maxlength="16" v-model="pwd.rePassword" placeholder="请再次输入新密码" /></view> <view class="label show"><view class="icon" :class="{ active: !reNewPwd }" @click="reNewPwd = !newPwd"></view></view> </view> <view class="item"> <text style="color: gray;">密码必须是8-16位英文字母、数字、字符组合(不能是纯数字)</text> </view> <view class="item"> <button class="btn" @click="edit()">确认修改</button> </view> </view> </view> </template> <script> export default { data() { return { user: this.getUser(), pwd: {}, show: true, newPwd: true, reNewPwd: true, } }, methods: { edit(){ console.log(this.pwd) let rule = [ { name: 'newPassword', checkType: 'notnull', errorMsg: '请输入新密码' }, { name: 'rePassword', checkType: 'same', checkRule: this.pwd.newPassword, errorMsg: '两次输入不一致' }, ]; if (!this.verify.check(this.pwd, rule)) { uni.showModal({ content: this.verify.error, showCancel: false }); return false; } this.http.request({ url: '/sp-admin/app/AppUser/modifyPassword', data: this.pwd, success: res => { uni.showModal({ content: '修改成功,请重新登录', showCancel: false }); this.exitLogin() } }); }, exitLogin() { let param = { appUserId: this.getUser().id } this.http.request({ url: '/sp-admin/app/AppUser/logout', data: param, success: res => { uni.removeStorageSync('token'); uni.removeStorageSync('info'); uni.removeStorageSync('menu'); uni.redirectTo({ url: '/pages/login/login' }); } }); } } } </script> <style lang="scss"> page { background-color: $pg; } .content { padding: 20px 10px; } .item{ height: 60px; display: flex; align-items: center; border-top: 1px solid #DCDCDC; } .btn{ margin-top: 40px; width: 200px; } .show{ position: relative; left: 100px; } </style>