<!-- 高清变焦相机 -->
<!-- 高清变焦相机原版 -->
<template>
  <div class="ofh waibi">
    <div class="wih00 h40 fix mountControllerTitle">
      <div class="flexs">
        <div class="xian"></div>
        <div class="fl lh40 mr30 cfc fw700">高清变焦相机</div>
      </div>
    </div>
    <div class="jcsb mt10">
      <div class="ml20">
        <div class="form">
          <div class="form_item">
            <span class="form_item_title" style="line-height: 26px"
              >控制速度:</span
            >
            <!-- <el-select
              v-model="speed"
              clearable
              placeholder="请选择控制速度"
              @change="cameraChangeFn"
            >
              <el-option
                v-for="item in 5"
                :key="item"
                :label="item"
                :value="item"
              >
              </el-option>
            </el-select> -->
            <div class="sudu">
              <div
                v-for="(item, index) in num"
                :key="index"
                class="num"
                @click="cameraChangeFn(item, index)"
                :class="{ act: index == activeId }"
              >
                {{ item }}
              </div>
            </div>
          </div>
          <div class="form_item">
            <span class="form_item_title">云台模式：</span>
            <div>
              <div class="mono-long">
                <div
                  class="mono-left mono_box"
                  :class="{ active: holderModelDom == 0 }"
                  @click="handleClick(2, 0)"
                ></div>
                <div
                  class="mono-middle mono_box"
                  :class="{ active: holderModelDom == 1 }"
                  @click="handleClick(2, 1)"
                ></div>
                <div
                  class="mono-right mono_box"
                  :class="{ active: holderModelDom == 2 }"
                  @click="handleClick(2, 2)"
                ></div>
              </div>
              <div class="text">
                <div class="text-left">锁定</div>
                <div class="text-right">跟随</div>
                <div class="text-right">回中</div>
              </div>
            </div>
          </div>
          <div class="form_item">
            <span class="form_item_title mt5">变焦：</span>
            <div class="jcsb">
              <div
                class="symbol mr10 mt5"
                @mousedown="backFn"
                @mouseup="zoomStop(1)"
              >
                -
              </div>
              <el-slider
                class="w100"
                :max="2"
                :min="0"
                :show-tooltip="false"
                v-model="value1"
                @change="zoomStop(1)"
                @input="mousemoveFn"
              ></el-slider>
              <div
                class="symbol ml10 mt5"
                @mousedown="nextFn"
                @mouseup="zoomStop(1)"
              >
                +
              </div>
            </div>
          </div>
          <div class="form_item">
            <span class="form_item_title mt5">聚焦：</span>
            <div class="jcsb">
              <div
                class="symbol mr10 mt5"
                @mousedown="camerafocusFn(0)"
                @mouseup="camerafocus(1)"
              >
                -
              </div>
              <el-slider
                class="w100"
                :max="2"
                :min="0"
                :show-tooltip="false"
                v-model="value2"
                @change="camerafocus(1)"
                @input="mousemoveFn"
              ></el-slider>
              <div
                class="symbol ml10 mt5"
                @mousedown="camerafocusFn(2)"
                @mouseup="camerafocus(1)"
              >
                +
              </div>
            </div>
          </div>
          <div class="form_item">
            <span class="form_item_title">俯仰：</span>
            <el-input v-model="pitch"></el-input>
            <el-button @click="change_pitch_angle">设置</el-button>
          </div>
          <div class="form_item">
            <span class="form_item_title">航向：</span>
            <el-input v-model="yaw"></el-input>
            <el-button @click="change_yaw_angle">设置</el-button>
          </div>
        </div>
      </div>
      <div class="">
        <div class="form">
          <div class="mb15 f14 dib">相机模式：</div>
          <div class="form_item">
            <div>
              <div class="mono-short">
                <div
                  class="mono-left mono_box"
                  :class="{ active: activeBox3 == 0 }"
                  @click="handleClick(3, 0)"
                ></div>
                <div
                  class="mono-right mono_box"
                  :class="{ active: activeBox3 == 2 }"
                  @click="handleClick(3, 2)"
                ></div>
              </div>
              <div class="jcsb cf">
                <div class="text-left">录像</div>
                <div class="text-right">拍照</div>
              </div>
            </div>
          </div>
        </div>

        <div class="form_item mb20">
          <div class="">
            <div class="ml20 mt10">
              <img
                class="dib cp w32 h32 mr40"
                :class="recordFlag ? 'recordBG' : ''"
                src="~../assets/video.png"
                @click="record()"
              />
              <img
                class="dib cp w32 h32"
                src="~../assets/photo.png"
                @click="take_photo()"
              />
            </div>
          </div>
          <div class="caozuoImg w150 mt10 h150 pr">
            <div class="rocker">
              <div id="static"></div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import data from "./data/index.js";
import methods from "./methods/index.js";

export default {
  inject: ["mountControllerThis"],
  data() {
    return {
      ...data,
      value1: 1,
      value2: 1,
      count: 50,
      recordFlag: true,
      // 控制挂载信息体
      controInfor: {
        type: 200,
        systemCode: "mmc",
        state: 1, //0 地面站（无人机），1 客户端或者web ，2 HTTP接口
        username: "",
        height: 0,
        idlingTime: 0,
        data: {
          // this.accident_This.mountList.mountType>1024?
          cmdControlType: 7000,
          cmdFunction: null,
          cmdState: null,
          cmdValue: null,
          cmdBuffer: "",
          cmdName: "MMC_Gimbal_Z40",
          //
        },
        deviceHardId: "",
      },
      num: [1, 2, 3, 4, 5],
    };
  },
  mounted() {
    this.controInfor.username = this.user_info && this.user_info.username;
    this.joystickFn();
  },
  computed: {
    ...mapGetters(["user_info"]),
  },
  methods: {
    ...methods,
    abc(id) {
      this.activeId = id;
    },
    mousemoveFn() {
      if (this.value1 > 1) {
        this.zoomFn(2);
      } else if (this.value1 < 1) {
        this.zoomFn(0);
      }
    },
    joystickFn() {
      let _this = this;
      joystick({
        zone: document.getElementById("static"),
        mode: "static",
        position: { left: "50%", top: "50%" },
        color: "#9bacbe",
        onstart: function (type) {
          switch (type) {
            case "up":
              _this.gimbal_pitch_ctrl(1);
              break;
            case "right":
              _this.gimbal_yaw_ctrl(1);
              break;
            case "left":
              _this.gimbal_yaw_ctrl(-1);
              break;
            case "down":
              _this.gimbal_pitch_ctrl(-1);
          }
        },
        onend: function () {
          _this.gimbal_pitch_ctrl(0);
          _this.gimbal_yaw_ctrl(0);
        },
      });
    },
    nextFn() {
      this.value1 = 2;
      this.zoomFn(2);
    },
    backFn() {
      this.value1 = 0;
      this.zoomFn(0);
    },
    set_take_photo() {
      this.$emit("set_take_photoFn");
    },
  },
};
</script>

<style lang="scss" scoped>
.mountControllerTitle {
  background: rgba(16, 65, 215, 0.2);
  box-shadow: inset 0 0 15px 0 rgba(0, 182, 255, 0.6);
  border-radius: 10px 10px 0 0;
}
.recordBG {
  opacity: 7 !important;
}
.form {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  color: #dce9ff;
  letter-spacing: 1px;
  box-sizing: border-box;
  .form_item {
    display: flex;
    margin-bottom: 15px;
    .form_item_title {
      width: 85px;
    }

    .mono_box {
      width: 28px;
      height: 13px;
      border-radius: 3px;
      margin-top: 2px;
      cursor: pointer;
    }

    .active {
      background: url("~../assets/mono_box.svg") no-repeat !important;
      background-size: 100% 100%;
    }

    .mono-short,
    .mono-long,
    .slider,
    .text {
      display: flex;
      justify-content: space-between;
      font-size: 14px;
    }

    .mono-left {
      margin-left: 2px;
    }

    .mono-right {
      margin-right: 2px;
    }

    .mono-short {
      width: 111px;
      height: 17px;
      background: url("~../assets/mount_short.png") no-repeat;
      background-size: 100%;
      margin-bottom: 5px;
    }

    .mono-long {
      width: 168px;
      height: 17px;
      background: url("~../assets/mount_long.png") no-repeat;
      background-size: 100%;
      margin-bottom: 5px;
    }

    .imgs {
      margin-top: 10px;
      display: flex;
      justify-content: space-between;

      & > img {
        cursor: pointer;
        width: 32px;
        height: 32px;

        &:hover {
          opacity: 0.7;
        }
      }
    }

    .slider_box {
      width: 140px;
      margin: -7px 5px 0;
    }

    .symbol {
      box-sizing: border-box;
      border-radius: 50%;
      border: 1px solid #08c2d1;
      width: 24px;
      height: 24px;
      line-height: 20px;
      text-align: center;
      cursor: pointer;
      font-size: 20px;
      padding-left: 1px;

      &:hover {
        opacity: 0.7;
      }
    }
  }

  .img_bottom {
    display: flex;
    width: 320px;
    justify-content: space-between;

    & > img {
      cursor: pointer;
      width: 130px;
      height: 130px;
    }
  }

  ::v-deep {
    .el-select,
    .el-input {
      width: 170px;
      height: 26px;
    }

    .el-input__inner {
      width: 170px;
      height: 26px;
      background: #000000;
      border: 1px solid #08c2d1;
      color: #dce9ff;
    }

    .el-select .el-input .el-select__caret {
      line-height: 26px;
    }

    // 修改input清除按钮样式
    .el-input__suffix {
      .el-input__suffix-inner {
        .el-icon-circle-close:before {
          line-height: 16px;
          position: absolute;
          top: 5px;
          right: 3px;
        }
      }
    }

    .el-button {
      margin-left: 10px;
      padding: 0;
      background: #2aefed;
      border-radius: 2px;
      width: 43px;
      height: 24px;
      outline: none;
      color: #000000;
      border: none;

      &:hover {
        opacity: 0.7;
      }
    }
  }
}
.caozuoImg {
  background-image: url("~../assets/caozuo.png");
  background-repeat: no-repeat;
  background-size: 100%;
}
::v-deep .el-slider__runway {
  background-color: #409eff;
}
.waibi {
  width: 524px;
  margin: 114px 0 0 118px;
  background: rgba(0, 39, 121, 0.5);
  box-shadow: 0px 2px 8px 0px rgba(1, 162, 255, 0.7),
    inset 0px 0px 64px 0px rgba(26, 138, 227, 0.35),
    inset 0px 0px 8px 0px #019aff;
  border: 1px solid #43deff;
  backdrop-filter: blur(2px);
  pointer-events: auto;
}
.flexs {
  display: flex;
  align-items: center;
}
.xian {
  width: 3px;
  height: 15px;
  background: #ffbd36;
  margin: 0 5px 0 16px;
}
.sudu {
  width: 203px;
  height: 24px;
  background: rgba(13, 34, 79, 0.65);
  border-radius: 12px;
  border: 1px solid #43deff;
  display: flex;
  justify-content: space-between;
  line-height: 24px;
  padding: 0 20px 0 20px;
}
.num {
  cursor: pointer;
}
.act {
  width: 41px;
  height: 22px;
  background: #ffffff;
  border-radius: 12px;
  color: #000000;
  text-align: center;
  margin: 1px 0 0 0;
}
.symbol {
  background-color: #000 !important;
  color: #43deff !important;
}
</style>