<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">
      <div class="row">
        <div class="col-3">
          <div class="card">
            <el-form ref="form" :model="formAddMoney" label-width="80px" size="default">
              <el-form-item label="货币类型">
                <el-select v-model="formAddMoney.tp" placeholder="请选择货币类型">
                  <el-option v-for="(obj, index) of this.listAddMoney" :label=obj.text :value=obj.v></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="添加值">
                <el-input v-model="formAddMoney.count"></el-input>
              </el-form-item>
            </el-form>
            <el-button type="primary" size="default" @click="onAddMoney">货币添加</el-button>
          </div>
        </div>
        <div class="col-3">
          <div class="card">
            <el-form ref="form" :model="formAddTool" label-width="80px" size="default">
              <el-form-item label="工具ID">
                <el-select v-model="formAddTool.id" placeholder="请选择工具ID">
                  <el-option v-for="(text, index) of this.listAddTool" :label=text :value=text></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="添加值">
                <el-input v-model="formAddTool.count"></el-input>
              </el-form-item>
            </el-form>
            <el-button type="primary" size="default" @click="onAddTool">工具添加</el-button>
          </div>
        </div>
        <div class="col-3">
          <div class="card">
            <el-form ref="form" :model="formSetProp" label-width="80px" size="default">
              <el-form-item label="属性类型">
                <el-select v-model="formSetProp.tp" placeholder="请选择属性类型">
                  <el-option v-for="(text, index) of this.listSetProp" :label=text :value=text></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="设置值">
                <el-input v-model="formSetProp.count"></el-input>
              </el-form-item>
            </el-form>
            <el-button type="primary" size="default" @click="onSetProp">属性设置</el-button>
          </div>
        </div>
        <div class="col-3">
          <div class="card">
            <el-form ref="form" :model="formAddOther" label-width="80px" size="default">
              <el-form-item label="属性类型">
                <el-select v-model="formAddOther.tp" placeholder="请选择属性类型">
                  <el-option v-for="(text, index) of this.listAddOther" :label=text :value=text></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="添加值">
                <el-input v-model="formAddOther.count"></el-input>
              </el-form-item>
            </el-form>
            <el-button type="primary" size="default" @click="onAddOther">其他添加</el-button>
          </div>
        </div>
      </div>
    </div>
  </div>

  <div class="container-fluid mt-1">
    <div class="card">
      <div class="row">
        <div class="col-3">
          <div class="card">
            <el-form ref="form" :model="formSimPay" label-width="80px" size="default">
              <el-form-item label="支付ID">
                <el-input v-model="formSimPay.id"></el-input>
              </el-form-item>
            </el-form>
            <button type="button" class="btn btn-warning btn-block" v-for="(text, index) of this.listPayTypes"
              :value=text @click="onSimPay($event)">{{ text }}</button>
          </div>
        </div>
        <div class="col-3">
          <div class="card">
            <el-form ref="form" :model="formClearActFlag" label-width="80px" size="default">
              <el-form-item label="活动ID">
                <el-select v-model="formClearActFlag.id" placeholder="活动ID">
                  <el-option v-for="(obj, index) of this.listActUid" :label=obj.text :value=obj.v></el-option>
                </el-select>
              </el-form-item>
            </el-form>
            <el-button type="primary" size="default" @click="onClearActFlag">删除活动标记</el-button>
          </div>
        </div>
        <div class="col-3">
          <div class="card">
            <el-form ref="form" :model="formEditBoard" label-width="80px" size="default">
              <el-form-item label="物品Index">
                <el-input v-model="formEditBoard.id"></el-input>
              </el-form-item>
            </el-form>
            <button type="button" class="btn btn-success btn-block" v-for="(text, index) of this.listEditBoard"
              :value=text @click="onEditBoard($event)">{{ text }}</button>
          </div>
        </div>
        <div class="col-3">
          <div class="card">
          </div>
        </div>
      </div>
    </div>
  </div>

  <div id="output">
    <!-- <el-button round type="primary" class="btn-block" v-on:click="ontest">测试</el-button> -->
    选择的服务器是: {{ serverselected }} puid: {{ puid }}
  </div>
</template>

<script>
import axios from 'axios';
export default {
  name: 'HelloWorld',
  props: {
    msg: String
  },
  data() {
    return {
      servers: [{
        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',
      },
      serverselected: '本机',
      input1: '',
      puid: '1215485',

      listAddMoney: [
        { text: '金币', v: '2' },
        { text: '钻石', v: '3' },
        { text: '体力', v: '4' },
        { text: '经验值', v: '1' },
      ],
      listAddTool: ["1", "2", "3", "4"],
      listSetProp: ["等级设置", "玩家游戏天数设置", "猜谜活动等级设置"],
      listAddOther: ["猜谜活动代币", "星星商店代币", "破茧成蝶代币", "装修代币", "挖宝箱积分"],
      listPayTypes: ["模拟支付", "支付补单"],
      listEditBoard: ["删除棋盘物件", "删除仓库物件", "删除暂存区物件"],
      listPlayerData: ["存档玩家", "高级号", "复制其他玩家数据"],

      listActUid: [
        { text: '新手礼包', v: '20001' },
        { text: '每日礼包', v: '20002' },
        { text: '体力礼包', v: '20005' },
        { text: '工具礼包', v: '20003' },
        { text: '卡牌礼包', v: '20006' },
        { text: '无尽礼包六格', v: '20004' },
        { text: '无尽礼包三格', v: '20007' },
        { text: 'Solo积分活动', v: '10002' },
        { text: '挖沙子活动', v: '10005' },
        { text: '卡牌活动', v: '10008' },
        { text: '50人排行榜活动', v: '30002' },
        { text: '水晶球活动', v: '10006' },
        { text: '限时订单', v: '40000' },
        { text: '阶段任务订单', v: '40001' },
        { text: '大逃杀订单', v: '40002' },
        { text: '猜谜', v: '10011' },
        { text: '副本', v: '50001' },
        { text: '副本礼包', v: '50101' },
        { text: '破茧成蝶', v: '10021' },
        { text: '装修', v: '10031' },
        { text: '挖宝箱', v: '10041' },
      ],

      formAddMoney: {
        tp: '',
        count: 0,
      },
      formAddTool: {
        id: '1',
        count: 0,
      },
      formSetProp: {
        tp: '等级设置',
        count: 20,
      },
      formAddOther: {
        tp: '猜谜活动代币',
        count: 0,
      },
      formSimPay: {
        id: 201,
      },
      formClearActFlag: {
        id: 20001,
      },
      formEditBoard: {
        id: 0,
      },

    }
  },
  methods: {
    onGmPost: function (data) {
      data.Uid = this.puid
      axios.post(this.serversDict[this.serverselected], data)
        .then(function (response) {
          console.log(response);
        })
        .catch(function (error) {
          console.log(error);
        });
    },
    ontest: function (event) {
      axios.post(this.serverselected, {
        Action: '服务器操作',
        Args: ["服务器信息"]
      })
        .then(function (response) {
          console.log(response);
        })
        .catch(function (error) {
          console.log(error);
        });
    },
    onAddMoney(event) {
      this.onGmPost({
        Action: '玩家数据修改',
        Args: ["货币添加", this.formAddMoney.tp, this.formAddMoney.count.toString()]
      })
    },
    onAddTool(event) {
      this.onGmPost({
        Action: '玩家数据修改',
        Args: ["工具添加", this.formAddTool.id, this.formAddTool.count.toString()]
      })
    },
    onSetProp(event) {
      this.onGmPost({
        Action: '玩家数据修改',
        Args: ["属性设置", this.formSetProp.tp, this.formSetProp.count.toString()]
      })
    },
    onAddOther(event) {
      this.onGmPost({
        Action: '玩家数据修改',
        Args: ["其他添加", this.formAddOther.tp, this.formAddOther.count.toString()]
      })
    },
    onSimPay(event) {
      let v = event.srcElement.value
      this.onGmPost({
        Action: '玩家数据修改',
        Args: [v, this.formSimPay.id.toString()]
      })
    },
    onClearActFlag(event) {
      this.onGmPost({
        Action: '玩家数据修改',
        Args: ["删除活动标记", this.formClearActFlag.id.toString()]
      })
    },
    onEditBoard(event) {
      let v = event.srcElement.value
      this.onGmPost({
        Action: '玩家数据修改',
        Args: [v, this.formEditBoard.id.toString()]
      })
    },
  }
}
</script>
