<template>
  <div class="userSlider">
    <div class="title">用户城市排名</div>
    <div class="sex">
      <div class="sexbox">
        <div class="sexColor"></div>
        <div class="sexTitle">男</div>
      </div>
      <div class="sexbox">
        <div class="sexColor"></div>
        <div class="sexTitle">女</div>
      </div>
    </div>
    <!-- 进度条 -->
    <div class="slider">
      <div class="sliderBox" v-for="(item, idx) in userData" :key="idx">
        <div class="sliderOne">
          <div class="order">{{ idx + 1 }}.</div>
          <div class="city">{{ item.city }}</div>
          <div class="line">
            <div
              class="line_left"
              :style="{
                width: `${(item.menMore / item.more) * 100}%`,
              }"
            ></div>
          </div>
          <div class="num">{{ item.menMore }}</div>
        </div>
        <div class="sliderTwo">
          <div class="line">
            <div
              class="line_left"
              :style="{
                width: `${(item.womenMore / item.more) * 100}%`,
              }"
            ></div>
          </div>
          <div class="num">{{ item.womenMore }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      userData: [
        {
          city: '广州',
          man: 23465,
          women: 20,
          sum: 254
        }

      ]
    }
  },
  created() {
    this.getValue()
  },
  methods: {
    async getValue() {
      //  城市统计
      const res = await this.$get(this.$api.userAnalysis.cityQuery)
      if (res.code == 0) {
        this.userData = res.data.data
        this.userData.forEach((item, index) => {
          if (item.city == '' || item.city == '未知') {
            this.userData.splice(index, 1)
          }

        });

      }

    }
  }
}
</script>

<style lang='scss' scoped>
.userSlider {
  padding: 20px 0px 20px 24px;
}
.title {
  color: #222222;
  font-size: 24px;
  font-weight: bolder;
  margin-bottom: 14px;
  text-align: left;
}
.sex {
  display: flex;
  .sexbox {
    margin-right: 24px;
    display: flex;
    .sexColor {
      width: 28px;
      height: 19px;
      background-color: #0575f4;
      border-radius: 13.5px;
      margin-right: 12px;
    }
    .sexTitle {
      font-size: 17px;
      color: #666666;
    }
    &:nth-child(2) {
      .sexColor {
        background-color: #f4057b;
      }
    }
  }
}

.slider {
  .sliderBox {
    margin-bottom: 15px;
    .sliderOne {
      display: flex;
      align-items: center;
      font-size: 18px;
      color: #222222;
      .order {
        width:30px;
        text-align:center;
        font-weight: bolder;
        // margin-right: 5px;
      }
      .city {
        font-weight: bolder;
        margin-right: 5px;
      }
      .line {
        width: 99px;
        height: 5px;
        background-color: #f1f1f1;
        border-radius: 13.5px;
        overflow: hidden;
        margin-right: 5px;
        .line_left {
          background-color: #0575f4;
          height: 100%;
        }
      }
      .num {
        font-size: 12px;
        color: #999999;
      }
    }
    .sliderTwo {
      display: flex;
      align-items: center;
      .line {
        width: 99px;
        height: 5px;
        background-color: #f1f1f1;
        border-radius: 13.5px;
        overflow: hidden;
        margin-right: 5px;
        margin-left:70px;
        .line_left {
          background-color: #f4057b;
          height: 100%;
        }
      }
      .num {
        font-size: 14px;
        color: #999999;
      }
    }

    &:nth-child(1) {
      margin-top: 15px;
      .order {
        color: #8b05f4;
      }
      .city {
        color: #8b05f4;
      }
    }
    &:nth-child(2) {
      .order {
        color: #f48905;
      }
      .city {
        color: #f48905;
      }
    }
    &:nth-child(3) {
      .order {
        color: #0575f4;
      }
      .city {
        color: #0575f4;
      }
    }
  }
}
</style>