<template>
  <div id="playPhoto">
    <!-- 播放和拍照设置 -->
    <el-dialog
      :visible.sync="dialogPhoto"
      width="980px"
      :show-close="false"
      :close-on-click-modal="false"
    >
      <div slot="title" class="hearders">
        <div class="leftTitle">播放和拍照设置</div>
        <div class="rightBoxs">
          <img
            src="@/assets/images/Close@2x.png"
            alt=""
            @click="dialogPhoto = false"
          />
        </div>
      </div>
      <div class="dis_f">
        <div>
          <h4>视频播放</h4>
          <div>
            <span class="w_zq">自动播放</span
            ><el-radio-group v-model="photoVideoList.playConfig.autoPlay">
              <el-radio :label="1">开启</el-radio>
              <el-radio :label="0">禁止</el-radio>
            </el-radio-group>
          </div>
          <div>
            <span class="w_zq">进度条拖拉</span
            ><el-radio-group v-model="photoVideoList.playConfig.drag">
              <el-radio :label="1">开启</el-radio>
              <el-radio :label="0">禁止</el-radio>
            </el-radio-group>
          </div>
          <div>
            <span class="w_zq">快进慢进</span
            ><el-radio-group v-model="photoVideoList.playConfig.speed">
              <el-radio :label="1">开启</el-radio>
              <el-radio :label="0">禁止</el-radio>
            </el-radio-group>
          </div>
        </div>
        <div style="width: 1px; background-color: #666; margin: 0px 14px"></div>
        <div>
          <h4>课程节-点播拍照</h4>
          <div>
            <el-radio-group
              v-model="photoVideoList.photographConfig.photograph"
            >
              <el-radio :label="1">是</el-radio>
              <el-radio
                :label="0"
                @change="photoVideoList.photographConfig.photoNum = ''"
                >否</el-radio
              >
            </el-radio-group>
          </div>
          <div
            v-if="photoVideoList.photographConfig.photograph === 1"
            style="margin-top: 14px"
          >
            拍照数量：
            <el-radio-group v-model="photoVideoList.photographConfig.photoNum">
              <el-radio :label="1">1张</el-radio>
              <el-radio :label="3">3张</el-radio>
            </el-radio-group>
          </div>
        </div>
        <div style="width: 1px; background-color: #666; margin: 0px 14px"></div>
        <div>
          <h4>课程节-直播拍照</h4>
          <div>
            <el-radio-group
              v-model="photoVideoList.photographConfig.livephotograph"
            >
              <el-radio :label="1">是</el-radio>
              <el-radio :label="0">否</el-radio>
            </el-radio-group>
          </div>
          <div
            v-if="photoVideoList.photographConfig.livephotograph === 1"
            style="margin-top: 14px"
          >
            学习开始，就拍照，只拍1张照片
          </div>
        </div>
        <div style="width: 1px; background-color: #000; margin: 0px 14px"></div>
        <div>
          <h4>课程章节-章测试卷-拍照</h4>
          <div>
            <el-radio-group
              v-model="photoVideoList.goodsPhotographExamConfig.photograph"
            >
              <el-radio :label="1">是</el-radio>
              <el-radio :label="0">否</el-radio>
            </el-radio-group>
          </div>
          <div
            v-if="photoVideoList.goodsPhotographExamConfig.photograph === 1"
            style="margin-top: 14px"
          >
            学习开始，就拍照，只拍1张照片
          </div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogPhoto = false">取消</el-button>
        <el-button type="primary" @click="submitPhoto">确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      dialogPhoto: false,
      photoVideoList: {
        playConfig: {
          autoPlay: 0,
          drag: 0,
          speed: 0,
        },
        photographConfig: {
          photograph: 0,
          photoNum: "",
          livephotograph: 0,
        },
        goodsPhotographExamConfig: {
          photograph: 0,
        },
      }, //播放和拍照设置---暂存
    };
  },
  methods: {
    /**
     * 初始进入
     */
    openBox(obj) {
      if (obj.playConfig) {
        this.photoVideoList.playConfig = JSON.parse(
          JSON.stringify(obj.playConfig)
        );
      } else {
        this.photoVideoList.playConfig = {
          autoPlay: 1,
          drag: 0,
          speed: 0,
        };
      }
      if (obj.photographConfig) {
        this.photoVideoList.photographConfig = JSON.parse(
          JSON.stringify(obj.photographConfig)
        );
      } else {
        this.photoVideoList.photographConfig = {
          photograph: 0,
          photoNum: "",
          livephotograph: 0,
        };
      }
      if (obj.goodsPhotographExamConfig) {
        this.photoVideoList.goodsPhotographExamConfig = JSON.parse(
          JSON.stringify(obj.goodsPhotographExamConfig)
        );
      } else {
        this.photoVideoList.goodsPhotographExamConfig = {
          photograph: 0,
        };
      }
      this.dialogPhoto = true;
    },
    //提交播放和拍照设置
    submitPhoto() {
      if (
        this.photoVideoList.photographConfig.photograph === 1 &&
        !this.photoVideoList.photographConfig.photoNum
      ) {
        this.$message.warning("请输入拍照数量");
        return;
      }
      let obj = {
        playConfig: this.photoVideoList.playConfig,
        photographConfig: this.photoVideoList.photographConfig,
        goodsPhotographExamConfig:
          this.photoVideoList.goodsPhotographExamConfig,
      };
      this.dialogPhoto = false;
      this.$emit("backData", obj);
    },
  },
};
</script>

<style lang="less" scoped>
.dis_f {
  display: flex;
  justify-content: space-around;
  & h4 {
    margin: 10px 0px;
  }
}
.w_zq {
  display: inline-block;
  width: 88px;
}
</style>
