9/18
parent
a7de1cd841
commit
f14194deca
@ -0,0 +1,29 @@
|
||||
<template>
|
||||
<div id="apply">
|
||||
<div class="textbox">
|
||||
</div><el-form:model="ruleForm":rules="rules"ref="ruleForm"class="demo-ruleForm"hide-required-asterisk:trueinline-message:true><el-form-item prop="comp"><el-input v-model="ruleForm.comp" placeholder="公司名称"></el-input></el-form-item><el-form-item prop="name"><el-input v-model="ruleForm.name" placeholder="姓名"></el-input></el-form-item><!-- 验证码 -->
|
||||
<el-form-item prop="phone">
|
||||
<el-input v-model="ruleForm.phone" placeholder="手机号"></el-input>
|
||||
</el-form-item><el-form-item prop="verify"><div class="bind_code">
|
||||
<el-input class="bind_code_input code" v-model="ruleForm.verify" type="text"placeholder="手机验证码"/>
|
||||
<el-button @click.native.prevent="bindforgetSendCode" class="codebtn" :disabled="disabled">{{ btnText }}</el-button>
|
||||
</div>
|
||||
</el-form-item><!-- 验证码完毕 -->
|
||||
<el-form-item>
|
||||
<el-inputv-model="ruleForm.textarea"class="msg"type="textarea"maxlength="200"resize="none"show-word-limitplaceholder="请您对需求进行简述"></el-input></el-form-item><el-form-item><el-buttonclass="applybtn"type="primary"@click="submitForm('ruleForm')">立即申请</el-button></el-form-item></el-form></div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {captchaSms,application} from "@/api/getapi";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
ruleForm: {name: "",comp: "",phone: "",verify: "",textarea: "",delivery: false,},
|
||||
rules: {comp: [{ required: true, message: " ", trigger: "blur" },{min: 3,max: 10,message: " ",trigger: "blur",},],name: [{ required: true, message: " ", trigger: "blur" },{ min: 2, max: 20, message: " ", trigger: "blur" },],phone: [{ required: true, message: " ", trigger: "blur" },{ min: 11, max: 11, message: " ", trigger: "blur" },],verify: [{ required: true, message: " ", trigger: "blur" },{ min: 4, max: 4, message: " ", trigger: "blur" },],},
|
||||
// 验证码按钮
|
||||
type: "",btnText: "获取验证码",disabled: false,};},methods: {
|
||||
// 发送验证码
|
||||
bindforgetSendCode() {this.$refs["ruleForm"].validateField("phone", (errorMessage) => {if (!errorMessage) {captchaSms({phonenumber: this.ruleForm.phone}).then(res => {console.log(res);})this.disabled = true;this.btnText = "请稍候...";setTimeout(() => {this.doLoop(60);}, 500);} else {return false;}});},
|
||||
// 手机验证码的倒计时
|
||||
doLoop: function (seconds) {seconds = seconds ? seconds : 60;this.btnText = seconds + "s后获取";let countdown = setInterval(() => {if (seconds > 0) {this.btnText = seconds + "s后获取";--seconds;} else {this.btnText = "获取验证码";this.disabled = false;clearInterval(countdown);}}, 1000);},submitForm(ruleForm) {this.$refs[ruleForm].validate((valid) => {if (valid) {let data = JSON.parse(JSON.stringify(this.ruleForm));delete data.deliveryapplication(data).then(res => {console.log(res);alert("提交成功!");} else {console.log("提交失败!!");return false;}});},},
|
||||
};
|
Loading…
Reference in New Issue