EditModel.vue 9.71 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423
<template>
  <div class="editClass">
    <div class="sys-container-panel content">
      <div class="container-title">我要报名</div>
      <div class="head-line"></div>

      <div class="text-container space">
        <div class="label">选手姓名:</div>
        <div class="form-item">
          <input v-model="formData.name" placeholder="请填写参赛者姓名" />
        </div>
      </div>

      <div class="text-container space">
        <div class="label">所属地区:</div>
        <div class="inline-group inline-group-width">
          <div class="form-item inline-group inline-02" @click="selectCityHandler">
            <div class="label">{{formData.province ? formData.province : "请选择"}}</div>
            <div class="icon-draw-down"></div>
          </div>
          <div class="form-item inline-group inline-02" @click="selectCityHandler">
            <div class="label">{{formData.city ? formData.city : "请选择"}}</div>
            <div class="icon-draw-down"></div>
          </div>
        </div>
      </div>

      <div class="text-container space">
        <div class="label">个人简介:</div>
        <div class="form-item">
          <input v-model="formData.profile" placeholder="可填写参赛者获取过荣誉、特殊才艺技能等" />
        </div>
      </div>

      <div class="text-container space">
        <div class="label">竞赛宣言:</div>
        <div class="form-item">
          <input v-model="formData.slogan" placeholder="参赛口号,不超过8个字" />
        </div>
      </div>
      <div class="text-container space">
        <div class="label">家长姓名:</div>
        <div class="form-item">
          <input v-model="formData.parentName" placeholder="请填写父亲/母亲称呼" />
        </div>
      </div>
      <div class="text-container space">
        <div class="label">联系方式:</div>
        <div class="form-item">
          <input v-model="formData.parentMobile" placeholder="请填写正确手机号码" />
        </div>
      </div>
      <div class="text-container space">
        <div class="label">照片/视频:</div>
        <div class="item-group top">
          <div>
            <upload-item v-model="formData.worksList"></upload-item>
          </div>
          <div class="tips">可上传1-3张照片,首张默认为海报图</div>
        </div>
      </div>
    </div>
    <div class="sys-btn-02" @click="submitFormHandler">确认提交</div>

    <div
      class="center base-margin-top auto-register-tips"
      @click="acceptRegisterHandler"
      v-if="formData.worksCode == '' || formData.worksCode == null "
    >
      <div class="icon-register activity"></div>
      <div class="tips">自动注册为立白集团会员,立享会员权益,详见“更多福利”</div>
    </div>

    <div class="center base-margin auto-register-tips">
      <div class="icon-register" :class="{activity : privacy}"></div>
      <div class="tips">
        我已阅读并同意
        <u @click="showAgreementHandler">用户协议</u>
        <u @click="showPrivacyHandler">隐私政策</u>
      </div>
    </div>

    <van-popup position="bottom" :style="{ height: '40%' }" v-model="area.show">
      <van-area
        :area-list="areaList"
        :columns-num="2"
        title="选择城市"
        :value="formData.cityCode"
        @cancel="area.show = false"
        @confirm="confirmSelectCityHandler"
      />
    </van-popup>
  </div>
</template>

<script>
let urls = {
  area: "https://api.k.wxpai.cn/bizproxy/kdapi/area",
  submit: "/jiajiaCHApi/app/works/submit"
};

import UploadItem from "./UploadItem";
import { httpGet, httpPost } from "@/api/fetch-api";
import AreaList from "@/api/area";

import Vue from "vue";
import { Toast } from "vant";
import { Area } from "vant";
import { Popup } from "vant";

Vue.use(Popup);
Vue.use(Area);
Vue.use(Toast);

export default {
  props: ["value"],
  data() {
    return {
      autoRegister: true,
      privacy: true,
      successModelVisiable: true,
      area: {
        show: false
      },
      formData: this.value,
      loading: false
    };
  },
  methods: {
    selectCityHandler() {
      if (!this.formData.cityCode) {
        this.formData.cityCode = "110100";
      }
      this.area.show = true;
    },
    confirmSelectCityHandler(res) {
      let province = res[0];
      let city = res[1];
      if (!city) {
        return;
      }
      this.formData.province = province.name;
      this.formData.provinceCode = province.code;
      this.formData.city = city.name;
      this.formData.cityCode = city.code;
      this.area.show = false;
    },
    acceptRegisterHandler() {
      // this.autoRegister = !this.autoRegister;
      // if (!this.autoRegister) {
      // }
    },
    showAgreementHandler() {
      this.$emit("agreement");
    },
    showPrivacyHandler() {
      this.$emit("privacy");
    },
    submitFormHandler() {
      if (!this.autoRegister) {
        return;
      }
      if (!this.formData.name) {
        Toast("请填写“参数者姓名”");
        return;
      }
      if (!this.formData.province) {
        Toast("请选择“所属地区”");
        return;
      }
      if (!this.formData.profile) {
        Toast("请填写“个人简介”");
        return;
      }
      if (!this.formData.slogan) {
        Toast("请填写“竞赛宣言”");
        return;
      }
      if (this.formData.slogan.length > 8) {
        Toast("“竞赛宣言”不要超过8个字");
        return;
      }
      if (!this.formData.parentName) {
        Toast("请填写“家长姓名”");
        return;
      }
      if (!this.formData.parentMobile) {
        Toast("请填写“联系方式”");
        return;
      }
      if (
        this.formData.parentMobile.indexOf("1") != 0 ||
        this.formData.parentMobile.length != 11
      ) {
        Toast("请填写正确的“联系方式”");
        return;
      }
      if (!this.formData.worksList || this.formData.worksList.length == 0) {
        Toast("请上传作品");
        return;
      }

      if (this.loading) {
        return;
      }
      this.loading = true;
      Toast.loading({
        mask: true,
        forbidClick: true,
        message: "数据提交中..."
      });
      httpPost({ url: urls.submit, data: this.formData })
        .then(res => {
          this.loading = false;
          Toast.clear();
          let isFirst = !this.formData.worksCode ? true : false;
          let data = {
            isFirst: isFirst,
            worksCode: res
          };
          this.formData.worksCode = res;
          this.$emit("submit", data);
        })
        .catch(res => {
          this.loading = false;
          Toast.clear();
          let msg = res.errMsg ? res.errMsg : "作品提交失败";
          Toast(msg);
        });
    }
  },
  computed: {
    areaList() {
      return AreaList;
    }
  },
  components: {
    UploadItem
  },
  created() {}
};
</script>

<style lang="scss" scoped>
.content {
  margin: 85px auto 60px auto;
  padding-bottom: 60px;

  .head-line {
    height: 60px;
  }

  .edit {
    width: 630px;
    text-align: right;
    u {
      font-size: 24px;
      color: #5db288;
      position: relative;
      z-index: 1000;
    }
  }

  .swipe {
    width: 630px;
    height: 320px;
    margin: auto;
    border: 2px solid #82acae;
    border-radius: 30px;
  }

  .space {
    margin-top: 20px !important;
  }
  .top {
    display: flex;
    align-items: flex-start !important;
  }

  .inline-group-width {
    width: 500px;
  }

  .inline-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .text-container {
    display: flex;
    align-items: center;
    width: 620px;
    margin: auto;

    .inline {
      width: 315px !important;
    }

    .inline-02 {
      width: 180px !important;
      padding: 0 30px;
      .label {
        font-size: 20px;
      }
    }

    .right {
      justify-content: flex-end !important;
    }

    .label {
      min-width: 128px;
      font-size: 20px;
      text-align: left;
    }
    .msg {
      color: #303531;
      font-size: 24px;
      text-align: left;
    }
    .primay {
      font-size: 32px !important;
      font-weight: 600;
      color: #ff9e30;
    }

    .form-item {
      width: 500px;
      height: 52px;
      border: 1px solid #82acae;
      background-color: #addfe1;
      border-radius: 26px;
      line-height: 52px;
      display: flex;
      align-items: center;

      input {
        margin-left: 25px;
        line-height: 52px;
        height: 52px;
        border: none;
        width: 90%;
        height: 100%;
        background-color: transparent;
        position: relative;
        z-index: 1000;
        font-size: 22px;
      }
    }
  }

  input::-webkit-input-placeholder {
    color: #4f9984;
    font-size: 18px;
  }
}

.view-btn-group {
  display: flex;
  width: 730px;
  margin: auto;
  justify-content: space-between;
  margin-bottom: 200px;

  .sys-btn-02 {
    width: 300px;
    line-height: 90px;
  }
}

.auto-register-tips {
  width: 700px;
  margin: auto;
}

.icon-draw-down {
  width: 30px;
  height: 18px;
  background: url(../../../assets/imgs/draw-down.png) no-repeat;
  background-size: 100%;
}

.base-margin-top {
  margin-top: 40px;
}

.base-margin {
  margin-top: 20px;
  margin-bottom: 80px;
}

.icon-register {
  width: 30px;
  height: 30px;
  background: url(../../../assets/imgs/checkbox-uncheck.png) no-repeat;
  background-size: 100%;
}

.icon-register.activity {
  width: 30px;
  height: 30px;
  background: url(../../../assets/imgs/checkbox-checked.png) no-repeat;
  background-size: 100%;
}

.center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.disabled {
  filter: grayscale(100%);
}

.tips {
  font-size: 20px;
  color: #064e39;
  padding-left: 10px;
  text-align: left;
}
</style>