lianxi4-wh
v1.0.0
Published
```js let tel = document.querySelector(".tel"); let telCode = document.querySelector(".telCode"); let getTelCode = document.querySelector(".getTelCode"); let symCode = document.querySelector(".symCode"); let getSymCode = document.querySelector(".getS
Downloads
2
Readme
let tel = document.querySelector(".tel");
let telCode = document.querySelector(".telCode");
let getTelCode = document.querySelector(".getTelCode");
let symCode = document.querySelector(".symCode");
let getSymCode = document.querySelector(".getSymCode");
let btn = document.querySelector(".btn");
//验证码
getSymCode.onclick = () => {
getSymCode.innerHTML = Math.random().toString(36).slice(2, 6)
}
getTelCode.onclick = () => {
axios.post("/api/getCode").then(result => {
console.log(result.data)
})
}
//判断手机号
btn.onclick = () => {
if (!/^1[3-9]\d{9}$/.test(tel.value)) {
alert("手机号不对")
return;
}
//判断非空
if (!tel.value || !telCode.value || !symCode.value) {
alert("不能为空")
return;
}
//判断验证码
if (symCode.value !== getSymCode.innerHTML) {
alert("验证码不一致")
return;
}
axios.post("/api/login", {
tel: tel.value,
telCode: telCode.value,
}).then(result => {
if (result.data.code) {
location.href = "list.html"
} else {
alert(0)
}
})
}