luohairen
2024-11-01 ff8a05baaf7418378909ea9cddc526b4a04e70d1
教师修改密码
2个文件已修改
1个文件已添加
52 ■■■■■ 已修改文件
src/api/user.js 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/profile/components/EditPassword.vue 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/profile/index.vue 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/user.js
@@ -15,4 +15,5 @@
  updatePassword: (data) => post('/api/common/user/update/password', data),
  uploadImg: (data) => post('/api/admin/upload/img', data),
  resetUserPassword: (id) => post('/api/admin/user/reset/password/' + id),
  editPassword:(data) => post('/api/admin/user/edit/password', data),
}
src/views/profile/components/EditPassword.vue
New file
@@ -0,0 +1,45 @@
<template>
  <el-form>
    <el-form-item label="请输入新密码">
      <el-input v-model="form.newPassword" />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="submit">更新</el-button>
    </el-form-item>
  </el-form>
</template>
<script>
import userApi from '@/api/user'
export default {
  props: ['userInfo'],
  data () {
    return {
      form: {
        id: undefined,
        newPassword: ''
      }
    }
  },
  methods: {
    submit () {
      this.form.id = this.userInfo.id
      let _this = this
      userApi.editPassword(this.form).then(re => {
        if (re.code === 1) {
          _this.$message.success(re.message)
        } else {
          _this.$message.error(re.message)
        }
      })
      this.resetForm()
    },
    resetForm () {
      this.form = {
        id: undefined,
        newPassword: ''
      }
    }
  }
}
</script>
src/views/profile/index.vue
@@ -16,6 +16,9 @@
              <el-tab-pane label="账号" name="account">
                <account :user-info="userInfo"  />
              </el-tab-pane>
              <el-tab-pane label="修改密码" name="editPassword">
                <editPassword :user-info="userInfo" />
              </el-tab-pane>
            </el-tabs>
          </el-card>
        </el-col>
@@ -29,6 +32,7 @@
import UserCard from './components/UserCard'
import Timeline from './components/Timeline'
import Account from './components/Account'
import EditPassword from './components/EditPassword'
import userApi from '@/api/user'
export default {
@@ -45,7 +49,7 @@
      }
    }
  },
  components: { UserCard, Timeline, Account },
  components: { UserCard, Timeline, Account, EditPassword },
  created () {
    let _this = this
    userApi.getCurrentUser().then(re => {