登录:
<template>
<div class="user">
<h1>用户登录</h1>
<div class="red">{ {title}}</div>
<input type="username" v-model='username' placeholder="用户名" class="username"/>
<input type="password" v-model='password' placeholder="密码" class="password"/>
<div class="phone">
<input type="tex" class="texts" placeholder="请输入验证码" name='phone' v-model="pone"/>
<div class="btn" v-show="codeData" @click='addData()'>获取验证码</div>
<div class="btn" v-show='!codeData'>{ {second}}s后重新获取</div>
</div>
<button @click='login'>登录</button>
<p>
<router-link to='/reset'>还没有账号,现在去注册</router-link>
</p>
<div>
<div class="oPic">
<input type="file" class="oInput"/>
<div class="oPicture">拍照</div>
</div>
<input type="file" accept="image/*" mutiple="mutiple"/>
<input type="file" accept="image/*" mutiple="mutiple" capture="camera" />
<!-- @change="changePic($event)" -->
<input type="file" accept="image/*">
</div>
</div>
<!-- 接口的名字:页面绑定的名字 -->
</template>
<script>
export default {
name:'my-login',
data () {
return{
username:"",
password:"",
title:"",
codeData:true,
second:6,
pone:"",
msg:''
}
},
methods:{
addData(){
var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
if(this.username=='') {
this.title='手机号不能为空'
}else if(myreg.test(this.username)){
this.title='手机号正确'
this.codeData=false
let timer=setInterval(()=>{
this.second--
if(this.second==0){
clearInterval(timer)
this.second=6
this.codeData=!this.codeData
}
},1000)
this.$axios.post('apis/phone',{pone:this.pone}).then(res=>{
console.log(res.data.msg)
this.msg=res.data.msg
})
}else{
this.title='手机号不正确'
}
},
login () {
this.$axios.post('/apis/login',{
user