10.10综合交易所原始源码-管理后台
admin
2026-01-06 a3cc41349752d6fb067df2a58e4e4b723a915f21
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<template>
  <!-- 用户密码修改组件 -->
  <div class="lum-dialog-mask" v-show="isShow">
    <el-container class="lum-dialog-box">
      <el-header class="header" height="50px">
        <p>修改密码</p>
        <p class="tools">
          <i class="el-icon-close" @click="close" />
        </p>
      </el-header>
      <el-main class="main">
        <el-form ref="form" :model="form" :rules="rules" label-position="top" >
          <el-form-item prop="old_password" label="旧密码">
            <el-input
              v-model="form.old_password"
              class="cuborder-radius no-border"
              type="password"
              size="medium"
              placeholder="请填写旧密码"
              @keyup.enter.native="onSubmit('form')"
            />
          </el-form-item>
          <el-form-item prop="new_password" label="新密码">
            <el-input
              v-model="form.new_password"
              class="cuborder-radius no-border"
              type="password"
              size="medium"
              placeholder="请填写新的密码"
              @keyup.enter.native="onSubmit('form')"
            />
          </el-form-item>
          <el-form-item prop="new_password2" label="重复密码">
            <el-input
              v-model="form.new_password2"
              class="cuborder-radius no-border"
              size="medium"
              type="password"
              placeholder="请再次填写新密码"
              @keyup.enter.native="onSubmit('form')"
            />
          </el-form-item>
          <el-form-item style="margin-top: 40px">
            <el-button
              class="submit-btn"
              type="primary"
              size="medium"
              :loading="loading"
              @click="onSubmit('form')"
              >提交
            </el-button>
          </el-form-item>
        </el-form>
      </el-main>
    </el-container>
  </div>
</template>
<script>
import { ServeUpdatePassword } from '@/api/user'
 
export default {
  name: 'UserEditPassword',
  data() {
    var validatePass2 = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请再次输入密码'))
      } else if (value !== this.form.new_password) {
        callback(new Error('两次输入密码不一致!'))
      } else {
        callback()
      }
    }
 
    return {
      loading: false,
      form: {
        old_password: '',
        new_password: '',
        new_password2: '',
      },
      rules: {
        old_password: [
          {
            required: true,
            message: '旧密码不能为空!',
            trigger: 'blur',
          },
        ],
        new_password: [
          {
            required: true,
            message: '新密码不能为空!',
            trigger: 'blur',
          },
        ],
        new_password2: [
          {
            required: true,
            validator: validatePass2,
            trigger: 'blur',
          },
        ],
      },
 
      isShow: false,
    }
  },
  methods: {
    // 显示窗口
    open() {
      this.$refs['form'].resetFields()
      this.isShow = true
    },
 
    // 关闭窗口
    close() {
      this.isShow = false
    },
 
    // 表单验证
    onSubmit(formName) {
      this.$refs[formName].validate(valid => {
        if (!valid) return false
        this.changePassword()
      })
    },
 
    // 提交修改手机号
    changePassword() {
      this.loading = true
      ServeUpdatePassword({
        old_password: this.form.old_password,
        new_password: this.form.new_password,
      })
        .then(res => {
          if (res.code == 200) {
            this.$refs['form'].resetFields()
            this.$notify({
              title: '成功',
              message: '密码修改成功...',
              type: 'success',
            })
          } else {
            this.$message(res.message)
          }
 
          this.loading = false
        })
        .catch(() => {
          this.loading = false
        })
    },
  },
}
</script>
<style lang="less" scoped>
.lum-dialog-box {
  width: 450px;
  max-width: 450px;
}
 
/deep/.el-form--label-top .el-form-item__label{
  padding: 0;
  line-height: 30px;
}
</style>