<template>
  <div id="userInfo">
    <el-main>
      <div style="margin-bottom: 10px">
        <el-button size="medium" icon="el-icon-back" type="text" @click="back">返回</el-button>
        <span style="margin-left: 20px; font-size: 18px">个人中心</span>
      </div>

      <div style="padding: 10px;background-color: white">

        <div>

            姓名：{{ this.realname }}<br>
            账号：{{this.account}}<br>
            手机号：{{this.phone}}<br>
            关联角色：{{this.roleFlag}}<br>
            关联运营商：{{this.operatorNumber}}<br>
        </div>

      </div>

    </el-main>
  </div>

</template>

<script>
export default {
  name: 'userInfo',
  data() {
    return {
      realname: '',
      account: '',
      phone: '',
      password: '',
      roleFlag: '',
      operatorNumber: '',

      addOrEdit: 1,

      dialogFormVisible: false,
    }
  },

  mounted: function () {

    this.loadData();
  },

  methods: {

    //切换页码
    handleCurrentChange(index) {
      this.loadData(index)
    },

    loadData() {
      var data = this.$route.query.data;

      console.log(data.user.realname)

      this.realname = data.user.realname
      this.account = data.user.account
      this.phone = data.user.phone
      this.operatorNumber = data.user.operatorNumber
      this.roleFlag = data.user.roleFlag
    },


    showEdit(row) {

      this.dialogFormVisible = true;

      this.editRow = JSON.parse(JSON.stringify(row));
      this.formData = this.editRow

      this.addOrEdit = 2
    }
    ,


    addOrEditMehtond() {
      const vm = this;
      if (this.addOrEdit == 2) {
        vm.$http.get(vm.api.update, {
          params: {
            code: this.formData.code,
            realname: this.formData.realname,
            account: this.formData.account,
            roleFlag: this.formData.roleFlag,
            operatorNumber: this.formData.operatorNumber,
            phone: this.formData.phone,
            password: this.formData.password,
          }
        })
            .then((response) => {
              console.log(response)

              if (response.data.status == 200) {

                this.$message({
                  type: 'success',
                  showClose: true,
                  message: response.data.desc
                })
              }

              this.dialogFormVisible = false;

              this.loadData();

            })
            .catch(() => {
            });
      }

    },


    cancel() {
      this.$message({
        message: '操作取消',
        showClose: true,
        type: 'info'
      });

      this.dialogFormVisible = false;

    },
    back() {
      let vm = this;
      vm.$router.back()
    }

  }
}
</script>


<style scoped>
.el-form-item {
  margin-right: 10px;
  margin-left: 10px;
  margin-bottom: 10px;
  margin-top: 0px;
}

.el-row {
  margin-top: 10px;
}
</style>
