<template>
  <div class="container">
    <div class="header">
      <span>中德全国校区</span>
      <div class="right">
        <div class="submit-area">
          <div class="label">加盟申请</div>
          <div class="phone-num">
            <img src="http://res.training.luojigou.vip/FmUjRlN7yn8o8HkXV21yOAJt-2C0?imageView2/0/q/50|imageslim" alt="" />
            <div class="num">400-6807300</div>
          </div>
          <div class="form">
            <el-form :model="form" :rules="rules" ref="ruleForm">
              <el-form-item prop="name">
                <el-input placeholder="姓名" v-model="form.name"></el-input>
              </el-form-item>
              <el-form-item prop="phone">
                <el-input placeholder="手机号" v-model="form.phone"></el-input>
              </el-form-item>
              <el-form-item prop="email">
                <el-input placeholder="邮箱地址" v-model="form.email"></el-input>
              </el-form-item>
              <el-form-item prop="city">
                <el-input placeholder="加盟城市" v-model="form.city"></el-input>
              </el-form-item>
              <div class="submit" @click="handleSubmit('ruleForm')">提交申请</div>
            </el-form>
          </div>
        </div>
      </div>

      <!-- <div class="form channel">
        <div class="text control">加盟申请</div>
        <div class="info control">
          <img src="~assets/images/campus/phone.png" alt="">
          <div class="phone">400-6807300</div>
        </div>
        <div class="control-input">
          <input type="text" placeholder="姓名">
        </div>
        <div class="control-input">
          <input type="text" placeholder="手机号">
        </div>
        <div class="control-input">
          <input type="text" placeholder="邮箱地址">
        </div>
        <div class="control-input">
          <input type="text" placeholder="加盟城市">
        </div>
        <div class="submit">提交申请</div>
      </div> -->
    </div>

    <!-- 全国校区 -->
    <div class="campus">
      <div class="title-content">
        <div class="c-title title-zh title-content wow animate__animated animate__fadeInDown">
          <div class="title-en">NATIONWIDE</div>
          全国校区
        </div>
      </div>
      <div class="c-content w1200">
        <div class="list-warp">
          <ul class="list">
            <li class="campus-item" v-for="(item, index) in campusList" :key="index">
              <img :src="item.imgUrl" alt="">
              <div class="info">
                <div class="area">{{ item.area }}</div>
                <div class="name">{{ item.name }}</div>
                <div class="address">
                  <div class="icon"><img :src="iconAddr" :srcset="`${iconAddrSet[0]} 1x, ${iconAddrSet[1]} 2x`" alt=""></div>
                  <p>{{ item.address }}</p>
                </div>
                <div class="phone">
                  <div class="icon"><img :src="iconPhone" :srcset="`${iconPhoneSet[0]} 1x, ${iconPhoneSet[1]} 2x`" alt=""></div>
                  <p>{{ item.phone }}</p>
                </div>
                <div class="detail">
                  <!-- to="{name:'news-category',params:{category: indexFirstNewsList.articleCategoryId}} -->
                  <nuxt-link :to="{ name: 'campus-type', params: { type: item.id } }">
                    查看详情
                  </nuxt-link>
                </div>
              </div>
          </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";

if (process.browser) {
  var {WOW} = require('wowjs')
}

export default {
  data() {
    return {
      form: {},
      iconAddr: require('~/assets/images/campus/icon_address.png'),
      iconAddrSet: [require('~/assets/images/campus/icon_address.png'), require('~/assets/images/campus/icon_adderss@2x.png')],
      iconPhone: require('~/assets/images/campus/icon_phone.png'),
      iconPhoneSet: [require('~/assets/images/campus/icon_phone.png'), require('~/assets/images/campus/icon_phone@2x.png')],
      campusList: [
        {
          id: 1,
          // imgUrl: 'http://zaojiao.net/public/static/index/images/xq/xq1-1.jpg',
          imgUrl: require('~/assets/images/campus/xq1-1.jpg'),
          address: '盈港东路8300弄佳乐苑社区商铺',
          phone: '4007288000',
          name: '襄阳校区',
          area: '上海市·上海市市辖区·青浦区'
        },
        {
          id: 2,
          imgUrl: require('~/assets/images/campus/xq2-1.jpg'),
          address: '盈港东路8300弄佳乐苑社区商铺',
          phone: '4007288000',
          name: '武汉校区',
          area: '上海市·上海市市辖区·青浦区'
        },
        {
          id: 3,
          imgUrl: require('~/assets/images/campus/xq3-1.jpg'),
          address: '盈港东路8300弄佳乐苑社区商铺',
          phone: '4007288000',
          name: '唐山校区',
          area: '上海市·上海市市辖区·青浦区'
        },
        {
          id: 4,
          imgUrl: require('~/assets/images/campus/xq4-1.jpg'),
          address: '盈港东路8300弄佳乐苑社区商铺',
          phone: '4007288000',
          name: '莆田校区',
          area: '上海市·上海市市辖区·青浦区'
        }
      ],
      rules: {
        name: [{ required: true, message: "请输入姓名", trigger: "blur" }],
        phone: [
          { required: true, message: "请输入手机号", trigger: "blur" },
          {
            pattern: /^1[34578]\d{9}$/,
            message: "请输入正确手机号",
            trigger: "blur",
          },
        ],
        email: [
          { required: true, message: "请输入邮箱地址", trigger: "blur" },
          {
            type: "email",
            message: "请输入正确的邮箱地址",
            trigger: ["blur", "change"],
          },
        ],
        city: [{ required: true, message: "请输入加盟城市", trigger: "blur" }],
      },
    }
  },
  head() {
    return {
      title: "逻辑狗官网-中德智慧教育",
      meta: [
        {
          name: "keywords",
          hid: "keywords",
          content: `逻辑狗官网、逻辑狗教材、 幼儿园教材、逻辑狗课程、逻辑狗思维训练课程、儿童思维教育、0-12岁儿童`,
        },
        {
          name: "description",
          hid: "description",
          content: `逻辑狗官方网站，专为0-12岁儿童设计的思维训练课程，中德智慧教育，全球优质教育内容输出平台`,
        },
      ],
    };
  },
  created() {

  },
  mounted() {
    if (process.browser) { 
      new WOW({
          offset: 0,   
          live: true
      }).init()
    }
  },
  methods: {
    async handleSubmit(formName) {
      this.$refs[formName].validate(async (valid) => {
        if (valid) {
          const { data } = await axios.post(`${this.$store.state.wordpressAPI}/official-api/joinIn`,{
            ...this.form
          });
          if(data.status == 200 ) {
            this.$notify({
              title: '成功',
              message: '提交成功',
              type: 'success'
            });
            this.$refs[formName].resetFields();
          } else {
              this.$notify({
                title: '失败',
                message: '提交失败',
                type: 'info'
              });
          }
          // this.$message.success('提交成功');
        } else {
          console.log('err');
          return false;
        }
      });
    }
  }
}
</script>

<style lang="scss">

@import "~static/common/style.sass";

.title-content {
  position: relative;
  text-align: center;
}
.title-en {
  position: absolute;
  font-size: 56px;
  font-family: PingFangSC-Semibold, sans-serif;
  font-weight: 600;
  color:rgba(35,106,250,1);
  opacity: 0.16;
}

.title-zh {
  position: relative;
  display: inline-block;
  font-size: 46px;
  font-family: PingFangSC-Semibold, sans-serif;
  font-weight: 600;
  color:#333333;
  text-align: center;
}

.header {
  position: relative;
  background-image: url('~assets/images/campus/header.png');
  background-repeat: no-repeat;
  background-size: cover;
  // height: 882px;
  height: 595px;
  // padding: 446px 0 0 302px;
  padding: 230px 0 0 15%;
  span {
    font-size: 66px;
    font-family: PingFangSC-Semibold, sans-serif;
    font-weight: 600;
    color:#ffffff;
    line-height: 112px;
  }
  .right {
    font-size: 16px;
    position: absolute;
    right: 13.8%;
    top: 50%;
    transform: translateY(-50%);
    // bottom: 124px;
    width: 327px;
    height: 450px;
    background-color: #fff;
    padding: 34px 38px 12px 39px;
    border-radius: 3px;
    .submit-area {
      .label {
        font-size: 14px;
        font-family: PingFangSC-Regular, sans-serif;
        font-weight: 400;
        color: rgba(91, 95, 93, 1);
        margin-bottom: 7px;
      }
      .phone-num {
        display: flex;
        align-items: center;
        img {
          width: 22px;
          height: 22px;
          display: block;
          margin-right: 15px;
        }
        .num {
          font-size: 26px;
          font-family: PingFangSC-Medium, sans-serif;
          font-weight: bold;
          color: rgba(0, 0, 0, 1);
        }
      }
      .form {
        margin-top: 20px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: center;
        .el-input {
          width: 250px;
          height: 44px;
        }
        .el-form-item__error {
          color: #cd2026;
          // left: 124px;
        }
        .el-form-item {
          &.is-error {
            .el-input__inner {
              border-color: #dcdfe6;
            }
          }
        }
        .submit {
          cursor: pointer;
          margin: 0 auto;
          text-align: center;
          font-size: 14px;
          width: 148px;
          height: 27px;
          line-height: 27px;
          background: linear-gradient(
            180deg,
            rgba(88, 144, 251, 1) 0%,
            rgba(51, 117, 252, 1) 100%
          );
          box-shadow: 0px 7px 14px 0px rgba(136, 176, 254, 0.79);
          border-radius: 3px;
          color: #ffffff;
        }
        img {
          width: 176px;
          height: 55px;
        }
      }
    }
  }
  // .form {
  //   font-size: 16px;
  //   position: absolute;
  //   right: 13.8%;
  //   bottom: 124px;
  //   width: 327px;
  //   height: 450px;
  //   background:#FFFFFF;
  //   border-radius: 3px;
  //   padding: 34px 0 12px;
  //   div.text {
  //     font-size:14px;
  //     line-height:20px;
  //     font-family:PingFangSC-Regular, sans-serif;
  //     font-weight:400;
  //     color: #5B5F5D;
  //     margin-bottom: 7px;
  //   }
  //   div.info {
  //     display: flex;
  //     align-items: center;
  //     margin-bottom: 20px;
  //     .phone {
  //       font-size: 26px;
  //       font-family: PingFangSC-Medium, sans-serif;
  //       font-weight: 500;
  //       margin-left: 15px;
  //     }
  //   }
  //   .control {
  //     width:250px;
  //     margin: 0 auto;
  //   }
  //   .control-input {
  //     margin: 0 auto;
  //     width:250px;
  //     border-radius: 3px;
  //     border: 1px solid rgba(151,151,151,1);
  //     margin-bottom: 23px;
  //     input {
  //       width: 100%;
  //       height:44px;
  //       line-height: 44px;
  //       padding: 0 13px ;
  //       background: none;
  //       outline: none;  
  //       border: 0px;
  //       &::-webkit-input-placeholder {
  //         color: #A4A6A5;
  //       }
  //     }
  //   }
  //   .submit {
  //     margin: 0 auto;
  //     text-align: center;
  //     font-size:14px;
  //     width: 148px;
  //     height: 27px;
  //     line-height: 27px;
  //     background: linear-gradient(180deg,rgba(88,144,251,1) 0%,rgba(51,117,252,1) 100%);
  //     box-shadow: 0px 7px 14px 0px rgba(136,176,254,0.79);
  //     border-radius: 3px;
  //     color: #ffffff;
  //   }
  // }
}

.campus {
  padding: 192px 0 206px;
  .title-en {
    top: -40px;
    left: 50%;
    transform: translate(-50%);
  }
  .c-content {
    margin-top: 130px;
    ul {
      li.campus-item {
        display: inline-block;
        width: 374px;
        background:#FFFFFF;
        box-shadow: 0px 9px 13px 0px rgba(123,166,252,0.13);
        border-radius: 10px;
        margin: 0 38px 42px 0;
        transition: transform .3s ease-in-out;
        &:nth-child(3n) {
          margin-right: 0;
        }
        &:hover {
          transform: translate3d(0,-8px,0);
        }
        img {
          width: 100%;
          border-radius: 18px 18px 0 0;
        }
        .info {
          height: 175px;
          color: #898A8C;
          padding: 15px 20px 15px;
          .icon {
            margin-right: 8px;
            img {
              width: 10px;
              height: 12px;
            }
          }
        }
        .area {
          font-size:14px;
          font-family: PingFangSC-Regular, sans-serif;
          font-weight: 400;
          color:#898A8C;
          line-height: 20px;
        }
        .name {
          font-size:22px;
          font-family: PingFangSC-Medium, sans-serif;
          font-weight:500;
          color:#1F241E;
          line-height:30px;
          margin-top: 5px;
        }
        .address {
          display: flex;
          align-items: center;
          margin-top: 9px;
          p {
            font-size: 12px;
            font-family: PingFangSC-Regular, sans-serif;
            font-weight: 400;
            color:#898A8C;
          }
        }
        .phone {
          display: flex;
          align-items: center;
          margin-top: 2px;
          p {
            color:#898A8C;
            font-size: 12px;
            font-family: PingFangSC-Regular, sans-serif;
            font-weight: 400;
          }
        }
        .detail {
          width: 85px;
          line-height: 26px;
          border-radius: 4px;
          font-size: 10px;
          text-align: center;
          margin: 17px auto 0;
          background: linear-gradient(180deg, #5890FB 0%, #3375FC 100%);
          box-shadow: 0px 7px 14px 0px rgba(136, 176, 254, 0.79);
          border-radius: 4px;
          a {
            color: #ffffff;
          }
        }
      }
    }
  }
}

</style>
