<template>
  <div class="join-us">
    <form action="/" method="post">
      <div class="form">
        <div class="form-group">
          <div>
            <div class="form-item">
              <div class="form-label">应聘职位：</div>
              <input type="text" class="form-control input" />
            </div>
            <div class="form-item">
              <div class="form-label">姓名：</div>
              <input type="text" class="form-control input" />
            </div>
            <div class="form-group min-width">
              <div class="form-item">
                <div class="form-label">性别：</div>
                <input type="text" class="form-control input" />
              </div>
              <div class="form-item">
                <div class="form-label">年龄：</div>
                <input type="text" class="form-control input" />
              </div>
            </div>
          </div>
          <div class="avatar">
            <div class="form-label only-mobile">性别：</div>
            <div class="avatar-choose" @click="onChooseFile">
              <span v-if="!avatar" class="icon">+</span>
              <span v-if="!avatar">照片</span>
              <img :src="avatar" v-else />
            </div>
            <input ref="file" type="file" v-show="false" accept=".png,.jpg" @change="onFileChange" />
          </div>
        </div>
        <div class="form-group">
          <div class="form-item">
            <div class="form-label">婚姻状况：</div>
            <input type="text" class="form-control input" />
          </div>
          <div class="form-item">
            <div class="form-label">出生年月：</div>
            <input type="text" class="form-control input" />
          </div>
        </div>
        <div class="form-group">
          <div class="form-item">
            <div class="form-label">毕业院校：</div>
            <input type="text" class="form-control input" />
          </div>
          <div class="form-item">
            <div class="form-label">最高学历：</div>
            <input type="text" class="form-control input" />
          </div>
        </div>
        <div class="form-group">
          <div class="form-item">
            <div class="form-label">所选专业：</div>
            <input type="text" class="form-control input" />
          </div>
          <div class="form-item">
            <div class="form-label">毕业时间：</div>
            <input type="text" class="form-control input" />
          </div>
        </div>
        <div class="form-item">
          <div class="form-label">户籍所在地：</div>
          <input type="text" class="form-control input" />
        </div>
        <div class="form-item">
          <div class="form-label">教育经历：</div>
          <textarea class="form-control textarea"></textarea>
        </div>
        <div class="form-item">
          <div class="form-label">工作经历：</div>
          <textarea class="form-control textarea"></textarea>
        </div>
        <div class="form-item">
          <div class="form-label">自我介绍：</div>
          <textarea class="form-control textarea"></textarea>
        </div>
        <div class="form-item">
          <div class="form-label">求职意向：</div>
          <textarea class="form-control textarea"></textarea>
        </div>
        <div class="form-item">
          <div class="form-label">所在区域：</div>
          <input type="text" class="form-control input" />
        </div>
        <div class="form-item">
          <div class="form-label">联系地址：</div>
          <input type="text" class="form-control input" />
        </div>
        <div class="form-group">
          <div class="form-item">
            <div class="form-label">联系电话：</div>
            <input type="text" class="form-control input" />
          </div>
          <div class="form-item">
            <div class="form-label">QQ：</div>
            <input type="text" class="form-control input" />
          </div>
        </div>
        <div class="form-group">
          <div class="form-item">
            <div class="form-label">电子邮箱：</div>
            <input type="text" class="form-control input" />
          </div>
          <div class="form-item">
            <div class="form-label">期望薪资：</div>
            <input type="text" class="form-control input" />
          </div>
        </div>
      </div>
      <button type="submit" class="submit">提交</button>
    </form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      avatar: '',
    }
  },
  methods: {
    onChooseFile() {
      console.dir(this.$refs.file)
      this.$refs.file.click()
    },
    onFileChange(e) {
      const file = e.target.files[0]
      if (!file) return
      this.avatar = URL.createObjectURL(file)
    },
  },
}
</script>

<style scoped lang="scss">
@media screen and (min-width: 768px) {
  .join-us {
    .form {
      .form-group {
        display: flex;
        justify-content: space-between;

        & > div {
          flex: 1;
          width: 50%;
          flex-shrink: 0;
        }

        &.min-width {
          .form-control {
            width: 180px;
          }
          .form-item:nth-child(2) {
            .form-label {
              width: 120px;
            }
          }
        }
      }

      .avatar {
        position: relative;
        .avatar-choose {
          position: absolute;
          right: 0;
          bottom: 26px;
          width: 188px;
          height: 224px;
          border: 1px solid #201405;
          display: flex;
          justify-content: center;
          align-items: center;
          font-size: 25px;
          font-weight: 400;
          color: #000000;
          cursor: pointer;

          img {
            display: block;
            width: 100%;
            height: 100%;
            object-fit: contain;
          }
        }
      }

      .form-item {
        display: flex;
        align-items: center;
        margin-bottom: 26px;

        &.vertical {
          display: block;

          .form-control {
            margin-top: 24px;
          }
        }

        .form-label {
          font-size: 25px;
          font-weight: 400;
          color: #000000;
          width: 150px;
          text-align: right;
          flex-shrink: 0;
        }
        .form-control {
          flex: 1;
          &.input {
            height: 54px;
            line-height: 52px;
            border: 1px solid #000000;
            box-sizing: border-box;
            padding: 0 16px;
          }

          &.textarea {
            display: block;
            width: 100%;
            height: 180px;
            padding: 16px;
            line-height: 24px;
          }

          label {
            display: inline-block;
            font-size: 25px;
            font-weight: 400;
            color: #000000;
            margin-right: 120px;
            margin-top: 24px;

            input {
              margin-left: 16px;
              transform: scale(1.4);
            }
          }
        }
      }
    }

    .submit {
      display: block;
      width: 189px;
      height: 38px;
      background: #f3920d;
      border-radius: 19px;
      font-size: 25px;
      font-weight: 400;
      color: #000000;
      line-height: 38px;
      text-align: center;
      border: 0;
      margin: 44px auto 0;
      cursor: pointer;
    }
  }
}

@media screen and (max-width: 768px) {
  .join-us {
    width: 6.86rem;
    margin: 0 auto;
    .form {
      .fl,
      .fr {
        float: unset !important;
      }

      .avatar {
        margin-bottom: 0.26rem;
        .form-label {
          font-size: 0.28rem;
          font-weight: 400;
          color: #000000;
          margin-bottom: 0.16rem;
        }
        .avatar-choose {
          width: 2.6rem;
          height: 2.6rem;
          border: 0.01rem solid #b2b2b2;
          display: flex;
          justify-content: center;
          flex-direction: column;
          align-items: center;
          font-size: 0.28rem;
          font-weight: 400;
          color: #b2b2b2;
          cursor: pointer;

          .icon {
            font-size: 0.72rem;
            font-weight: lighter;
            margin-bottom: 0.16rem;
          }

          img {
            display: block;
            width: 100%;
            height: 100%;
            object-fit: contain;
          }
        }
      }

      .form-item {
        margin-bottom: 0.26rem;

        .form-label {
          font-size: 0.28rem;
          font-weight: 400;
          color: #000000;
          margin-bottom: 0.16rem;
        }
        .form-control {
          &.input {
            width: 100%;
            height: 0.9rem;
            line-height: 0.88rem;
            border: 0.01rem solid #b2b2b2;
            box-sizing: border-box;
            padding: 0 0.16rem;
          }

          &.textarea {
            display: block;
            width: 100%;
            height: 3.5rem;
            padding: 16px;
            line-height: 0.32rem;
            box-sizing: border-box;
            border-color: #b2b2b2;
          }

          &.checkbox-group {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;

            label {
              display: flex;
              flex-direction: row-reverse;
              justify-content: flex-end;
              font-size: 0.28rem;
              font-weight: 400;
              color: #000000;
              margin-top: 0.35rem;
              width: 50%;

              input {
                margin-right: 0.16rem;
              }
            }
          }
        }
      }
    }

    .submit {
      display: block;
      width: 3.5rem;
      height: 0.9rem;
      background: #f3920d;
      font-size: 0.28rem;
      font-weight: 400;
      color: #000000;
      line-height: 0.9rem;
      text-align: center;
      border: 0;
      margin: 0.9rem auto 0;
      cursor: pointer;
    }
  }
}
</style>
