<template>
  <div class="scenicSpotInfoManage">
    <div class="resource-list">
      <div class="resource-imglist clearfix">
        <div class="re-img" v-for="(item, index) in ImageList" :key="index">
          <img v-if="!item" src="../assets/img/bg_c3@3x.png">
          <img :src="item" :onerror='defaultImg' />
          <div class="imgzhe">
            <!-- <div class="re-delte"><i @click.stop="showImg(item)" class="iconfont icon-img_cz"></i></div> -->
            <div class="re-delte" @click="delImg(index)"><i class="iconfont icon-xingzhuang"></i></div>
            <div class="re-delte" @click.stop="ExchangeImg(index, 0)" v-if="index != 0 && item">
              <i class="iconfont icon-zuoyi"></i>
            </div>
            <div class="re-delte" @click.stop="ExchangeImg(index, 1)" v-if="index != ImageList.length - 1 && item">
              <i class="iconfont icon-youyi"></i>
            </div>
          </div>
        </div>
        <div class="add-img" v-show="showAdd">
          <div class="reimg-add">
            <i class="iconfont icon-img_haha bigAdd"></i>
            <div class="ad-one">
              <div class="re-upload">
                <el-upload :file-list="fileList" :http-request="UploadAttachment" :multiple="true"
                  accept="image/jpeg,image/gif,image/png,image/bmp" :show-file-list="false" action="">
                  <i class="iconfont icon-img_bdsc"></i>
                </el-upload>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<style>
  .addlist {
    position: absolute;
    right: 158px;
    top: 6px;
    cursor: pointer;
    color: #E95252;
    width: 30px;
    height: 30px;
    display: inline-block;
    text-align: center;
    line-height: 30px;
    border-radius: 50%;
    font-size: 22px;
  }

  .scenicSpotInfoManage .resourceImgAdd {
    width: 620px;
    margin: auto;
  }

  .scenicSpotInfoManage .clearfix:after {
    content: "\0020";
    display: block;
    height: 0;
    clear: both;
  }

  .scenicSpotInfoManage .resource-content {
    width: 100%;
    margin-top: 30px;
    font-size: 12px;
    min-width: 1200px;
  }

  .scenicSpotInfoManage .resource-baseinfo {
    float: left;
    height: auto;
    width: 600px;
    margin: 0 0 20px 30px;
  }

  .scenicSpotInfoManage .resource-imginfo {
    float: left;
    width: 510px;
    margin-top: 35px;
  }

  .scenicSpotInfoManage .resource-lititle {
    display: block;
    border-left: 4px solid #e95252;
    padding-left: 10px;
    margin-bottom: 20px;
  }

  .scenicSpotInfoManage .resource-baseinfo span {
    display: inline-block;
  }

  .scenicSpotInfoManage .resource-name {
    width: 300px;
    height: 34px;
    background: rgba(255, 255, 255, 1);
    border-radius: 17px;
    outline: none;
    border: 1px solid #d6d6d6;
    padding-left: 10px;
  }

  .scenicSpotInfoManage .common-lefttit {
    width: 80px;
    text-align: right;
    margin: 0 7px 0 8px;
    display: inline-block;
  }

  .scenicSpotInfoManage .resource-net {
    position: relative;
  }

  .scenicSpotInfoManage .resource-http {
    position: absolute;
    color: #999999;
    width: 70px !important;
    background-color: #f5f7fa;
    border-right: 1px solid #d1d1d1;
    height: 32px;
    border-top-left-radius: 17px;
    border-bottom-left-radius: 17px;
    top: 5px;
    left: 1px;
    text-align: center;
    line-height: 32px;
    text-align: center;
  }

  .scenicSpotInfoManage .R1 {
    width: 300px;
    padding: 0 15px 0 80px;
    transition: all 0.3s ease-in-out;
  }

  .scenicSpotInfoManage .areaInput {
    width: 300px;
    padding-right: 120px;
  }

  .scenicSpotInfoManage .areaInput:focus {
    border: 1px solid #e95252;
  }

  .scenicSpotInfoManage .map-icon {
    position: absolute;
    right: 1px;
    top: 1px;
    line-height: 32px;
    text-align: center;
    border-left: 1px solid #cccccc;
    border-top-right-radius: 17px;
    border-bottom-right-radius: 17px;
    padding-right: 15px;
    padding-left: 10px;
    cursor: pointer;
    display: inline-block;
    height: 32px;
    background-color: #f5f7fa;
  }

  .scenicSpotInfoManage .map-icon i {
    margin: 0 5px;
    position: relative;
    top: 1px;
  }

  .scenicSpotInfoManage .save-Btn {
    width: 90px;
    height: 30px;
    background: rgba(233, 82, 82, 1);
    border-radius: 15px;
    color: #fff;
    outline: none;
    cursor: pointer;
    margin-right: 20px;
  }

  .scenicSpotInfoManage .cancel-Btn,
  .save-Btn:hover {
    opacity: 0.8;
  }

  .scenicSpotInfoManage .cancel-Btn {
    width: 90px;
    height: 30px;
    background: rgba(255, 255, 255, 1);
    border-radius: 15px;
    color: #e95252;
    outline: none;
    cursor: pointer;
    border: 1px solid #e95252;
  }

  .scenicSpotInfoManage .re-img {
    width: 140px;
    height: 93px;
    border-radius: 10px;
    float: left;
    margin: 0 30px 30px 0;
    position: relative;
  }

  .scenicSpotInfoManage .re-img:first-child {
    margin-left: 0;
  }

  .scenicSpotInfoManage .resource-imglist {
    width: 100%;
    height: auto;
    margin-top: 20px;
  }

  .scenicSpotInfoManage .resource-imglist img {
    width: 100%;
    height: 100%;
    border-radius: 10px;
  }

  .scenicSpotInfoManage .add-img {
    /* margin-top: 20px; */
    width: 140px;
    height: 93px;
    background: rgba(236, 236, 236, 1);
    border-radius: 10px;
    position: relative;
    cursor: pointer;
    float: left;
    margin: 0 30px 30px 0;
  }

  .scenicSpotInfoManage .reimg-add {
    width: 140px;
    height: 93px;
    background: rgba(236, 236, 236, 1);
    border-radius: 10px;
    position: relative;
    cursor: pointer;
  }

  .scenicSpotInfoManage .ad-one {
    display: none;
    background: rgba(0, 0, 0, 0.4);
    width: 100%;
    height: 100%;
    border-radius: 10px;
    position: absolute;
    top: 0;
    z-index: 999;
  }

  .scenicSpotInfoManage .bigAdd {
    font-size: 50px;
    color: #d1d1d1;
    position: absolute;
    left: 45px;
    top: 25px;
  }

  .scenicSpotInfoManage .imgzhe {
    display: none;
    background: rgba(0, 0, 0, 0.4);
    width: 100%;
    height: 100%;
    text-align: center;
    line-height: 93px;
    border-radius: 10px;
    position: absolute;
    top: 0;
  }

  .scenicSpotInfoManage .reimg-add:hover .ad-one {
    display: block;
  }

  .scenicSpotInfoManage .re-img:hover .imgzhe {
    display: block;
  }

  .scenicSpotInfoManage .ad-one div {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    line-height: 32px;
    text-align: center;
    background: gray;
    color: #fff;
  }

  .scenicSpotInfoManage .ad-one div:hover {
    background-color: #fff;
    color: #e95252;
  }

  .scenicSpotInfoManage .re-upload {
    position: absolute;
    top: 30px;
    left: 55px;
  }

  .scenicSpotInfoManage .re-find {
    position: absolute;
    top: 30px;
    right: 30px;
  }

  .scenicSpotInfoManage .search-imgicon {
    padding-right: 20px;
    margin-left: -40px;
  }

  .scenicSpotInfoManage .resAddImg {
    width: 520px;
    padding-right: 45px;
  }

  .scenicSpotInfoManage .addimgContent {
    height: 290px;
    overflow: auto;
    margin: 30px 0 30px 25px;
    width: 545px;
  }

  .scenicSpotInfoManage .addimgDiv {
    width: 160px;
    height: 155px;
    float: left;
    margin: 0 20px 15px 0;
    overflow: hidden;
  }

  .scenicSpotInfoManage .addimgContent div:first-child {
    margin-left: 0;
  }

  .addimgContent div:nth-child(3n) {
    margin-right: 0;
  }

  .scenicSpotInfoManage .itemImgdiv {
    width: 160px;
    height: 106px;
    position: relative;
  }

  .scenicSpotInfoManage .itemImgdiv img {
    width: 100%;
    height: 100%;
    border-radius: 10px;
  }

  .scenicSpotInfoManage .imgseclet {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    position: absolute;
    top: 0;
    text-align: center;
    line-height: 106px;
    color: #e95252;
  }

  .icon-dagouyouquan {
    font-size: 25px;
  }

  .scenicSpotInfoManage .test-1::-webkit-scrollbar {
    width: 0px;
    height: 0px;
    background-color: #f5f5f5;
  }

  .scenicSpotInfoManage .test-1::-webkit-scrollbar-track {
    background-color: #f5f5f5;
  }

  .scenicSpotInfoManage .test-1::-webkit-scrollbar-thumb {
    border-radius: 20px;
    background-color: #aaa;
    margin-bottom: 24px;
  }

  .scenicSpotInfoManage .test-1:hover::-webkit-scrollbar {
    width: 4px;
    height: 4px;
    background-color: #f5f5f5;
  }

  .scenicSpotInfoManage .addimg-btnlist {
    text-align: center;
  }

  .scenicSpotInfoManage .addimg-select {
    font-size: 14px;
    color: #999999;
    float: right;
    margin-bottom: 10px;
    position: relative;
    bottom: 20px;
  }

  .scenicSpotInfoManage .re-delte {
    width: 32px;
    height: 32px;
    background: gray;
    border-radius: 50%;
    text-align: center;
    display: inline-block;
    line-height: 32px;
    color: #fff;
    cursor: pointer;
  }

  .scenicSpotInfoManage .re-delte:hover {
    color: #e95252;
    background: #fff;
  }

  .scenicSpotInfoManage .imgDescription {
    font-size: 12px;
    margin-top: 12px;
    color: #333333;
    width: 100%;
    line-height: 20px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .scenicSpotInfoManage .el-upload-dragger {
    border: none;
  }

  .scenicSpotInfoManage .res-span span:last-child {
    display: inline;
  }

  .scenicSpotInfoManage .resourcerightTop span {
    display: inline-block;
  }

  .scenicSpotInfoManage .resourcerightTop span.width62 {
    width: 62px;
  }

  .scenicSpotInfoManage .sheshi {
    margin-bottom: 20px;
  }

  .scenicSpotInfoManage .dialog-footer {
    padding-bottom: 30px;
  }

  .scenicSpotInfoManage .btn-list {
    margin: 0 0 40px 30px;
  }

  .scenicSpotInfoManage .input-with-select .el-input-group__prepend {
    background-color: #fff;
  }

  .scenicSpotInfoManage .el-textarea__inner {
    resize: none;
    height: 120px;
    font-family: "微软雅黑";
  }

  .scenicSpotInfoManage .R1:focus {
    border: 1px solid #e95252;
  }

  .scenicSpotInfoManage .el-form-item__label {
    width: 105px;
    font-size: 12px;
  }

  .scenicSpotInfoManage .el-form-item__error {
    left: 100px;
  }

  .scenicSpotInfoManage .hotelDay {
    margin-left: 10px;
  }

  .scenicSpotInfoManage .searchImgIcon {
    cursor: pointer;
  }

  .scenicSpotInfoManage .el-dialog--center .el-dialog__body {
    padding: 25px 25px 0;
  }

  .scenicSpotInfoManage .addressInput .el-input-group__append {
    border-top-right-radius: 17px;
    border-bottom-right-radius: 17px;
  }

  .scenicSpotInfoManage ::-webkit-input-placeholder {
    color: #d1d1d1;
  }

  .scenicSpotInfoManage :-moz-placeholder {
    color: #d1d1d1;
  }

  .scenicSpotInfoManage ::-moz-placeholder {
    color: #d1d1d1;
  }

  .scenicSpotInfoManage :-ms-input-placeholder {
    color: #d1d1d1;
  }

  .scenicSpotInfoManage .el-switch.is-checked .el-switch__core {
    border-color: #4bca81;
    background-color: #4bca81;
  }

  .scenicSpotInfoManage .orderAdd {
    position: relative;
    width: 340px;
  }

  .scenicSpotInfoManage .minus:hover {
    background-color: #cccccc;
    cursor: pointer;
  }

  .scenicSpotInfoManage .minus {
    width: 34px;
    height: 32px;
    border: #dcdfe6;
    color: #fff;
    text-align: center;
    line-height: 34px;
    position: absolute;
    left: 101px;
    border-radius: 50%;
    z-index: 999;
    top: 4px;
    background-color: #dcdfe6;
  }

  .scenicSpotInfoManage .addPeople {
    width: 34px;
    height: 32px;
    top: 4px;
    background-color: #dcdfe6;
    color: #fff;
    text-align: center;
    line-height: 34px;
    position: absolute;
    right: 41px;
    border-radius: 50%;
    z-index: 999;
  }

  .scenicSpotInfoManage .addPeople:hover {
    background-color: #cccccc;
    cursor: pointer;
  }

  .scenicSpotInfoManage .orderAdd .el-input__inner {
    padding-left: 90px;
  }

  .scenicSpotInfoManage .littleadd {
    font-size: 12px !important;
    color: #fff;
    display: inline-block;
  }

  .scenicSpotInfoManage .footabs {
    width: 286px;
    min-height: 34px;
    border: 1px solid #d1d1d1;
    margin-left: 10px;
    display: inline-block;
    background-color: #fff;
    padding: 5px 10px;
    display: flex;
    flex-wrap: wrap;
  }

  .scenicSpotInfoManage .foodtips {
    display: inline-block;
    padding: 3px 5px;
    background-color: #efefef;
    margin: 3px;
    position: relative;
  }

  .scenicSpotInfoManage .toolOne {
    margin: 0 0 28px 38px;
    display: flex;
  }

  .scenicSpotInfoManage .foodTipsDiv {
    max-width: 200px;
    display: inline;
  }

  .scenicSpotInfoManage .wInput {
    border: none;
    height: 30px;
  }

  .scenicSpotInfoManage .wInput .el-input__inner {
    border: none !important;
    height: 28px;
    padding: 0;
    border-radius: 0;
    margin-top: 2px;
  }

  .scenicSpotInfoManage .delTips {
    position: absolute;
    right: -5px;
    top: -5px;
    cursor: pointer;
    color: #999;
    font-size: 14px;
  }

  .scenicSpotInfoManage .delTips:hover {
    color: #e95252;
  }

  .scenicSpotInfoManage .fanyong {
    font-size: 12px;
    color: #666666;
    margin-right: 10px;
  }

  .scenicSpotInfoManage .footabs .el-tag {
    margin: 0 5px 5px 0;
  }

  .scenicSpotInfoManage .footabs .el-input__inner {
    height: 30px;
    position: relative;
  }

  .scenicSpotInfoManage .button-new-tag {
    height: 30px;
    line-height: 30px;
    padding-top: 0;
    padding-bottom: 0;
  }

  .scenicSpotInfoManage .input-new-tag {
    width: 90px;
    margin-left: 10px;
    vertical-align: bottom;
  }

  .scenicSpotInfoManage .el-dialog--center .el-dialog__body {
    padding: 15px 25px 0 !important;
  }

  .scenicSpotInfoManage .mapList {
    width: 850px !important;
    height: 510px !important;
  }

  .scenicSpotInfoManage .fanbili {
    margin-top: 8px;
  }

  .scenicSpotInfoManage .RabateDiv {
    margin-left: 10px;
  }

  .scenicSpotInfoManage .RebateCount {
    height: 34px;
    border-radius: 17px;
    float: left;
  }

  .scenicSpotInfoManage .reOne,
  .scenicSpotInfoManage .reTwo,
  .scenicSpotInfoManage .dayNum {
    position: relative;
  }

  .scenicSpotInfoManage .leftPnum {
    float: left;
    width: 50px;
    height: 32px;
    line-height: 32px;
    text-align: center;
    border-right: 1px solid #cccccc;
    position: absolute;
    left: 1px;
    top: 1px;
    border-top-left-radius: 17px;
    border-bottom-left-radius: 17px;
  }

  .scenicSpotInfoManage .toolInput {
    height: 34px;
    padding-left: 5px;
    border: none;
  }

  .scenicSpotInfoManage .inpuOne {
    width: 135px;
    padding-left: 55px;
    border: 1px solid #d1d1d1;
    border-right: none;
  }

  .scenicSpotInfoManage .inpuTwo {
    width: 166px;
    padding: 0 45px 0 55px;
    border: 1px solid #d1d1d1;
  }

  .scenicSpotInfoManage .percentCon {
    float: right;
    width: 40px;
    height: 32px;
    text-align: center;
    border-left: 1px solid #cccccc;
    line-height: 32px;
    border-top-right-radius: 17px;
    border-bottom-right-radius: 17px;
    position: absolute;
    right: 1px;
    top: 1px;
  }

  .scenicSpotInfoManage .fanNum {
    float: left;
    width: 50px;
    height: 32px;
    line-height: 32px;
    text-align: center;
    border-right: 1px solid #cccccc;
    position: absolute;
    left: 1px;
    top: 1px;
  }

  .scenicSpotInfoManage .fdTag {
    margin-top: 13px;
  }

  .scenicSpotInfoManage .addAddress .el-input__inner {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border: 1px solid #d1d1d1 !important;
  }

  .scenicSpotInfoManage .el-input-group__append {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
  }

</style>

<script>
  export default {
    props: {
      maxNum: {
        default: 0
      }
    },
    data() {
      return {
        defaultImg: 'this.src="' + require("../assets/img/bg_z1@2x.png") + '"',
        fileList: [],
        ImageList: []
      }
    },
    mounted() {},
    computed: {
      showAdd: function () {
        return !this.maxNum || (this.ImageList.length < this.maxNum)
      }
    },
    methods: {
      //上传图片
      UploadAttachment(file) {
        let newArr = [];
        newArr.push(file.file);
        let fileName = file.file.name;
        var path = "/Upload/DMC/";
        this.UploadSelfFileT(path, newArr, x => {
          //统一图片处理
          var obj = this.$DMCUtils.DMCImageObj();
          var str = x.data.FilePath;
          var imgUrl = this.domainManager().ViittoFileUrl + x.data.FilePath;
          obj.Path = str;
          obj.ShowPath = imgUrl;
          this.ImageList.push(obj.ShowPath)
        });
      },

      //图片左移右移
      ExchangeImg(index, IsMove) {
        var imgItem = this.ImageList[index];
        //左移
        if (IsMove == 0) {
          var upItem = this.ImageList[index - 1];
          this.$set(this.ImageList, index - 1, imgItem);
          this.$set(this.ImageList, index, upItem);
        } else {
          //右移动
          var downItem = this.ImageList[index + 1];
          this.$set(this.ImageList, index + 1, imgItem);
          this.$set(this.ImageList, index, downItem);
        }
      },
      //删除图片
      delImg(index) {
        //更新图片
        var item = this.ImageList[index];
        this.ImageList.splice(index, 1);
      },
    }
  }

</script>