*/
data: {
phone:‘’, //手机号
password:‘’//用户密码
},
/**
- 生命周期函数–监听页面加载
*/
onLoad: function (options) {
},
//表单项内容发生改变的回调
handleInput(event){
// let type = event.currentTarget.id; //id传值
// console.log(type, event.detail.value);
let type = event.currentTarget.dataset.type; //data-type=value
this.setData({
})
},
//登录的回调
async login(){
//1、收集表单数据
let{phone,password} = this.data;
//2、前端验证
/*
1、内容为空
2、手机号格式不正确
3、手机号格式正确,验证通过
*/
if(!phone){
//提示用户
wx.showToast({
title:“手机号不能为空”,
icon:‘none’
})
return;
}
//定义正则表达式
let phoneReg =/^1(3|4|5|6|7|8|9)\d{9}$/;
if(!phoneReg.test(phone)){
wx.show