<template> <view class="myreport-box"> <cu-custom :isBack="true" bgColor="bg-blue"> <block slot="content">修改密码</block> </cu-custom> <view class="content-box"> <form> <view class="cu-form-group"> <view class="title">用户名</view> <input placeholder="请输入账号" v-model="userName" name="input" disabled="false"></input> </view> <view class="cu-form-group"> <view class="title">原密码</view> <input placeholder="请输入原密码" type="password" displayable v-model="oldPassword" name="input"></input> </view> <view class="cu-form-group"> <view class="title">新密码</view> <input placeholder="请输入新密码" type="password" displayable v-model="newPassword" name="input"></input> </view> <view class="cu-form-group"> <view class="title">确认密码</view> <input placeholder="请输入新密码" type="password" displayable v-model="checkPassword" name="input"></input> </view> </form> <view class="info">注意:新密码长度必须在6-16位,并且同时包含字母和数字</view> <button @click="bindModify" class="top-40 bg-gradual-blue shadow-blur round cu-btn block lg " >确认修改</button> </view> </view> </template> <script> import * as $auth from "@/common/auth.js" import loginService from "@/api/auth/loginService" import { mapActions } from 'vuex' export default { data() { return { newPassword: '', checkPassword: '', userName: '', oldPassword: '', } }, created() { this.userInfo = $auth.getUserInfo() this.userName = this.userInfo.name }, methods: { bindModify() { if (!this.oldPassword) { uni.showToast({ icon: 'none', title: '请输入原始密码' }); return; } if (this.checkPassword !== this.newPassword) { uni.showToast({ icon: 'none', title: '确认密码与新密码不一致' }); return; } else if (this.checkPassword && (this.checkPassword.length < 6 || this.checkPassword.length > 16)) { uni.showToast({ icon: 'none', title: '密码长度为6-16位' }); return; } else if (!(/\d/.test(this.checkPassword) && /[a-zA-Z]/.test(this.checkPassword))) { uni.showToast({ icon: 'none', title: '密码必须包含字母+数字' }); return; } loginService.savePwd({ 'oldPassword': this.oldPassword, 'newPassword': this.newPassword }).then(res => { // this.$store.commit('SET_TOKEN',data.token); // this.refreshUserInfo(); // uni.reLaunch({ // url: '../index/index', // }); uni.showToast({ icon: 'success', title: '修改密码成功' }); }).catch(e => { console.error(e) }) } } } </script> <style> .login-box { width: 100vw; height: 100vh; background-size: 100% 100%; display: flex; flex-direction: column; align-items: center; position: relative; } .info{ margin-top: 30rpx; font-size: 30rpx; color: #333; } .send-button-2 { font-size: 26rpx; color: gray; margin-top: 20rpx; width: 300rpx; height: 80rpx; background: #fff; box-shadow: 0rpx 2rpx 30rpx 0rpx rgba(0, 0, 0, 0.2); border-radius: 40rpx; text-align: center; line-height: 80rpx; text-shadow: 0rpx 0rpx 1rpx rgba(0, 0, 0, 0.35); align-self: flex-end; } .myreport-box { width: 100vw; height: 100vh; background-size: 100% 100%; overflow-x: hidden; overflow-y: auto; box-sizing: border-box; } .flex-center-box { display: flex; flex-direction: column; justify-content: center; align-items: center; padding-top: 50rpx; } .site-box { position: absolute; bottom: 30rpx; display: flex; justify-content: center; color: #fff; align-items: center; } .gh-icon { width: 32rpx; height: 32rpx; margin-right: 10rpx; } .logo-image { width: 626rpx; height: 144rpx; margin-top: 178rpx; } .circle-logo { width: 185rpx; height: 185rpx; margin-top: 75rpx; margin-bottom: 63rpx; } .send-button { margin-top: 20rpx; width: 300rpx; height: 100rpx; background: #fff; box-shadow: 0rpx 2rpx 30rpx 0rpx rgba(0, 0, 0, 0.2); border-radius: 50rpx; text-align: center; line-height: 100rpx; font-size: 30rpx; color: #1F94FE; text-shadow: 0rpx 0rpx 1rpx rgba(0, 0, 0, 0.35); align-self: flex-end; } .new-input-box { width: 600rpx; height: 100rpx; border-radius: 5rpx; background: #fff; display: flex; flex-direction: row; box-sizing: border-box; padding-left: 40rpx; align-items: center; border-bottom: 2rpx solid #ddd; } .input-icon { width: 32rpx; height: 32rpx; margin-right: 20rpx; } .login-button { margin-top: 60rpx; width: 600rpx; height: 80rpx; background: #fff; box-shadow: 0rpx 2rpx 30rpx 0rpx rgba(0, 0, 0, 0.2); border-radius: 40rpx; text-align: center; line-height: 80rpx; font-size: 36rpx; color: #1F94FE; text-shadow: 0rpx 0rpx 1rpx rgba(0, 0, 0, 0.35); } .info-box { margin-top: 24rpx; color: #fff; font-size: 26rpx; display: flex; justify-content: space-between; width: 500rpx; } .zai-box { padding: 0 50upx; position: relative; } .zai-logo { width: 100%; width: 100%; margin-top: 100upx; margin-bottom: 100upx; padding: 20px; height: 310upx; } .zai-title { position: absolute; top: 0; margin-top: 100upx; margin-bottom: 100upx; line-height: 340upx; font-size: 68upx; color: #fff; text-align: center; width: 100%; margin-left: -50upx; } .zai-form { margin-top: 300upx; } .zai-input { background: #e2f5fc; margin-top: 30upx; border-radius: 100upx; padding: 20upx 40upx; font-size: 36upx; } .input-placeholder, .zai-input { color: #94afce; } .zai-label { padding: 60upx 0; text-align: center; font-size: 30upx; color: #a7b6d0; } .zai-btn { background: #ff65a3; color: #fff; border: 0; border-radius: 100upx; font-size: 36upx; } .zai-btn:after { border: 0; } /*按钮点击效果*/ .zai-btn.button-hover { transform: translate(1upx, 1upx); } .cu-form-group .title { min-width: calc(4em + 15px); } .content-box{ width: 650rpx; margin-left: auto; margin-right: auto; margin-top: 60rpx; } .top-40{ margin-top: 60rpx; } </style>