<template>
  <div id="detail">
    <el-row>
      <el-col :span="24" class="debt">
        <el-col :span="24" class="top">
          <!-- <topInfo :topTitle="topTitle" :display="display"></topInfo> -->
          <detailTopInfo :topTitle="topTitle" :display="display"></detailTopInfo>
        </el-col>
        <el-col :span="24" class="main">
          <uppasswdForm :form="form" :formTitle="formTitle" @submitForm="submitForm" @resetForm="resetForm"></uppasswdForm>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import topInfo from '@/layout/custom/topInfo.vue';
import detailTopInfo from '@/layout/custom/detailTopInfo.vue';
import uppasswdForm from '@/layout/uppasswd/uppasswdForm.vue';
import { mapState, mapMutations, createNamespacedHelpers, mapGetters } from 'vuex';
const { mapActions: otheruser } = createNamespacedHelpers('otheruser');
export default {
  name: 'detail',
  props: {},
  components: {
    detailTopInfo, //头部导航
    uppasswdForm, //头部返回
  },
  data: () => ({
    topTitle: '账号设置',
    display: 'block',

    formTitle: '修改密码',
    form: {},
  }),
  created() {},
  computed: {
    id() {
      return this.user.uid;
    },
    ...mapState(['user']),
  },
  methods: {
    ...otheruser(['query', 'fetch', 'update', 'create', 'updates']),
    // 提交
    async submitForm({ data }) {
      const uid = this.user.uid;
      let res = await this.updates({ ...data, uid });
      if (res.errcode === 0) {
        this.$router.push({ path: '/login' });
        this.$message({
          message: '修改密码成功',
          type: 'success',
        });
      }
    },
    // 取消
    resetForm() {
      this.$router.push({ path: '/index' });
    },
    // 返回
    goBack() {
      this.$router.go(-1);
    },
  },
};
</script>

<style lang="less" scoped>
.top {
  height: 50px;
  margin: 0 0 10px 0;
}
.main {
  min-height: 765px;
  background: #ffffff;
  padding: 20px;
}
</style>
