123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- <template>
- <view class="user-content">
- <!-- 自定义导航 -->
- <view class="navbar-box">
- <u-navbar
- title="修改密码"
- @leftClick="leftClick"
- :safeAreaInsetTop="true"
- >
- </u-navbar>
- </view>
-
- <!-- 修改表单 -->
- <view class="from-box">
- <u-form
- labelPosition="left"
- :model="form"
- :rules="rules"
- ref="uForm">
- <!-- <u-form-item prop="password" leftIcon="lock-open" labelWidth="40rpx">
- <u-input
- v-model="form.password"
- type="text"
- placeholder="原密码"
- :border="true"
- clearable
- ></u-input>
- </u-form-item> -->
- <u-form-item prop="newPassword" leftIcon="lock-fill" labelWidth="40rpx">
- <u-input
- v-model="form.newPassword"
- type="password"
- placeholder="新密码"
- :border="true"
- :password="newPassword"
- clearable
- ></u-input>
- </u-form-item>
- <u-form-item prop="repNewPassword" leftIcon="lock-fill" labelWidth="40rpx">
- <u-input
- v-model="form.repNewPassword"
- type="password"
- placeholder="验证新密码"
- :border="true"
- :password="repNewPassword"
- clearable
- ></u-input>
- </u-form-item>
- </u-form>
- <view class="btn-box">
- <u-button @click="submit" type="error">修改</u-button>
- </view>
- </view>
-
- <!-- 请求加载框 -->
- <!-- <u-overlay :show="overlayShow">
- <view class="warp">
- <view class="rect">
- <u-loading-icon color="#fff"></u-loading-icon>
- </view>
- </view>
- </u-overlay> -->
- <u-mask :show="overlayShow">
- <view class="warp">
- <view class="rect">
- <u-loading mode="circle" size="120"></u-loading>
- </view>
- </view>
- </u-mask>
-
- <u-modal
- :show="userShow"
- title="错误提示"
- @confirm="confirm"
- :content='content' ></u-modal>
- </view>
- </template>
- <script>
- export default {
- data () {
- return {
- useId:'',
- password: true,
- newPassword: true,
- repNewPassword: true,
- content: '登录错误',
- overlayShow: false,
- tipShow: false,
- userShow: false,
- content: '',
- form: {
- password: '',
- newPassword: '',
- repNewPassword: '',
- },
- rules: {
- 'password': [
- {
- type: 'string',
- required: true,
- message: '请填写密码',
- trigger: ['blur', 'change']
- },
- {
- min: 6,
- max: 12,
- message: '密码在6-12个字符之间'
- },
- ],
- 'newPassword': [
- {
- type: 'string',
- required: true,
- message: '请填写新密码',
- trigger: ['blur', 'change']
- },
- {
- min: 6,
- max: 12,
- message: '密码在6-12个字符之间'
- },
- ],
- 'repNewPassword': [
- {
- type: 'string',
- required: true,
- message: '请填写验证新密码',
- trigger: ['blur', 'change']
- },
- {
- min: 6,
- max: 12,
- message: '密码在6-12个字符之间'
- },
- {
- validator: (rule, value, callback) => {
- return this.form.newPassword === this.form.repNewPassword
- },
- message: '两次密码不一致'
- },
- ]
- },
- }
- },
- onReady() {
- // 设置表单校验规则
- this.$refs.uForm.setRules(this.rules);
- },
- methods:{
- // 返回事件
- leftClick() {
- let canNavBack = getCurrentPages();
- if(canNavBack && canNavBack.length>1) {
- uni.navigateBack({
- delta: 1
- });
- } else {
- history.back();
- }
- },
- // 密码查看事件
- passwordEven(type) {
- this[type] = !this[type]
- },
- // 登录表单提交验证
- submit() {
- this.$refs.uForm.validate(valid => {
- if (valid) {
- this.overlayShow = true
- this.resetPassWord()
- } else {
- uni.$u.toast('校验失败')
- }
- });
- },
-
- confirm() {
- this.userShow = false
- },
-
- // 修改登录密码接口
- async resetPassWord() {
- let passwordMap = {
- // password: this.form.password,
- id:this.user_info?.id,
- organPassword: this.form.newPassword
- }
- const {code, data, msg} = await this.$u.api.resetPassWord(passwordMap)
- this.overlayShow = false
- if (code === 200) {
- uni.$u.toast('密码修改成功,3s后跳转登录页!')
- setTimeout(() => {
- uni.navigateTo({
- url: '/pages/login/login'
- });
- }, 3000)
- } else {
- this.userShow = true
- this.content = msg
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .user-content{
- padding-top: 120rpx;
- .from-box{
- padding: 0 20rpx;
- .u-form-item{
- margin-top: 20rpx;
- }
- .u-form-item /deep/ .u-form-item__body{
- padding: 20rpx 15rpx;
- }
- .u-input{
-
- }
- .u-form-item /deep/ .u-form-item__body__right__message{
- margin-left: 54rpx !important;
- margin-top: 10rpx;
- }
-
- }
- .btn-box{
- width: 80%;
- margin: auto;
- margin-top: 120rpx;
-
- }
- .btn-box /deep/ .u-button--error{
- background-color: #E32F2F;
- border-radius: 0;
- border-radius: 10rpx;
- }
-
- .warp {
- display: flex;
- align-items: center;
- justify-content: center;
- height: 100%;
- }
-
- .rect {
- width: 120rpx;
- height: 120rpx;
- }
- }
- </style>
|