<template>

  <div class="container-fluid mt-1">
    <div class="card">
      <div class="row">
        <div class="col-1">选择服务器</div>
        <div class="col-2">
          <el-select v-model="serverselected" placeholder="选择服务器" size="default">
            <el-option v-for="item in servers" :key="item.value" :label="item.value" :value="item.value">
            </el-option>
          </el-select>
        </div>
        <div class="col-1">玩家唯一ID</div>
        <div class="col-2">
          <el-input v-model="puid" placeholder="玩家唯一ID" size="default"></el-input>
        </div>
      </div>
    </div>
  </div>

  <div class="container-fluid mt-1">
    <div class="card">
      <el-row>
        <el-col :span="1" v-for="(text, index) of this.listPlayerQuery">
          <button type="button" class="btn btn-info btn-block" :value=text @click="onPlayerQuery($event)">{{ text
            }}</button>
        </el-col>
      </el-row>
      <el-input type="textarea" :rows="50" placeholder="查询结果" v-model="textPlayerQueryResult">
      </el-input>
    </div>
  </div>

</template>

<script>
import axios from 'axios';
import moment from 'moment';
export default {
  name: 'HelloWorld',
  props: {
    msg: String
  },
  data() {
    return {
      servers: [{
        value: '本机',
      }, {
        value: '内网测试服',
      }, {
        value: '审核服',
      }, {
        value: '正式服',
      }],
      serversDict: {
        '本机': 'http://localhost:9002/api/gm/action',
        '内网测试服': 'http://172.10.10.18:9002/api/gm/action',
        '审核服': 'http://152.136.44.171:40002/api/gm/action',
        '正式服': 'http://47.93.188.168:40002/api/gm/action',
      },
      serverselected: '本机',
      puid: '1215485',

      listPlayerQuery: [
        "基础数据",
        "临时数据",
        "杂项数据",
        "邮件数据",
        "背包数据",
        "建筑数据",
        "棋盘数据",
        "支付数据",
        "活动数据",
        "订单数据",
        "buff数据",
        "商城数据",
        "任务数据",
        "卡牌数据",
        "TopMini",
        "副本数据",
      ],
      textPlayerQueryResult: '',

    }
  },
  mounted: function () {
    console.log('1');
    console.log(this.$gvEnv);
    console.log('2');
  },
  methods: {
    OnPop(body, title) {
      this.$alert(body, title, {
        confirmButtonText: '确定',
      });
    },
    onGmPost: function (data) {
      data.Uid = this.puid
      axios.post(this.serversDict[this.serverselected], data)
        .then((response) => {
          console.log(response);
          let rsp = response.data;
          if (rsp.Action == "玩家数据查询") {
            this.textPlayerQueryResult = rsp.Result
          }
        })
        .catch(function (error) {
          console.log(error);
        });
    },
    onPlayerQuery(event) {
      let v = event.srcElement.value
      this.onGmPost({
        Action: '玩家数据查询',
        Args: [v]
      })
    },
  }
}
</script>
