<template>
  <div>
    <!--标题-->
    <div class="top-bar">
      <div @click="_back">
        <img src="../../../../static/image/back.png">
      </div>
      <div>{{title}}</div>
      <div @click="_save">完成</div>
    </div>
    <!--提示信息-->
    <div class="result-cont" style="margin-top: 60px">
      <div class="phone_edit">
        <group>
          <x-input title="真实姓名" v-model="realname" placeholder="请输入真实姓名"></x-input>
        </group>
      </div>
    </div>
  </div>
</template>

<script>
  import {XInput, Group} from 'vux'
  import Global from '../../../api/config'

  export default {
    components: {
      XInput,
      Group,
    },
    data() {
      return {
        title: '修改真实姓名',
        id: this.$route.query.id,
        realname: this.$route.query.data.realname,
      }
    },
    methods: {
      //保存信息
      _save() {
        if (this.realname) {
          let data = {
            realname: this.realname
          };
          this.$store.dispatch('SystemManage/userEdit', {id: this.id, obj: data}).then(() => {
            if (this.$store.state.SystemManage.success) {
              this._back();
            }
          });
        } else {
          this._msg('真实姓名不能为空！');
        }
      },
      //提示
      _msg(msg) {
        this.$vux.toast.show({
          type: 'text',
          width: '10em',
          text: msg,
          time: 1000
        });
      },
      _back() {
        this.$router.go(-1);
      },
    }
  }
</script>
