|
@@ -1,15 +1,27 @@
|
|
|
<template>
|
|
|
<div id="password">
|
|
|
<el-row>
|
|
|
- <el-col :span="24">
|
|
|
- <p>password</p>
|
|
|
+ <el-col :span="24" style="padding:50px">
|
|
|
+ <el-form ref="form" :model="form" label-position="left" label-width="120px">
|
|
|
+ <el-form-item label="新密码" prop="password" :rules="[{ required: true, message: '请输入新密码', trigger: 'blur' }]">
|
|
|
+ <el-input v-model="form.password" placeholder="请输入新密码" type="password" show-password></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-row type="flex" justify="center">
|
|
|
+ <el-col :span="4">
|
|
|
+ <el-button type="primary" @click="toSubmit">修改密码</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+const _ = require('lodash');
|
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
+const { mapActions: personal } = createNamespacedHelpers('personal');
|
|
|
+const { mapActions: organization } = createNamespacedHelpers('organization');
|
|
|
export default {
|
|
|
metaInfo() {
|
|
|
return { title: this.$route.meta.title };
|
|
@@ -18,10 +30,39 @@ export default {
|
|
|
props: {},
|
|
|
components: {},
|
|
|
data: function() {
|
|
|
- return {};
|
|
|
+ return {
|
|
|
+ form: {},
|
|
|
+ };
|
|
|
},
|
|
|
created() {},
|
|
|
- methods: {},
|
|
|
+ methods: {
|
|
|
+ ...personal({ pPassword: 'updatePassword' }),
|
|
|
+ ...organization({ oPassword: 'updatePassword' }),
|
|
|
+ toSubmit() {
|
|
|
+ this.$refs.form.validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ this.toUpdate();
|
|
|
+ } else {
|
|
|
+ console.log('error submit!!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ async toUpdate() {
|
|
|
+ let dup = _.cloneDeep(this.form);
|
|
|
+ dup.id = _.get(this.user, 'id');
|
|
|
+ // 用is_expert字段区分是个人/专家 还是 企业
|
|
|
+ const r = Object.keys(this.user).find(f => f === 'is_expert');
|
|
|
+ let res;
|
|
|
+ if (r) res = await this.pPassword(dup);
|
|
|
+ else res = await this.oPassword(dup);
|
|
|
+ if (this.$checkRes(res, '修改成功', '修改失败')) {
|
|
|
+ localStorage.removeItem('token');
|
|
|
+ localStorage.removeItem('type');
|
|
|
+ this.$router.push('/');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
computed: {
|
|
|
...mapState(['user']),
|
|
|
},
|