diff --git a/packageA/pages/profile/profile.js b/packageA/pages/profile/profile.js index e52581b..f332d06 100644 --- a/packageA/pages/profile/profile.js +++ b/packageA/pages/profile/profile.js @@ -77,7 +77,7 @@ Page({ lat: null, //维度 lon: null, //经度 loading: 0, - + oldBirtthDayLength:0, //生日日期个数 }, //通过路径跳转到其他页面 goto: function (e) { @@ -1126,20 +1126,81 @@ Page({ let address = this.getInput(e); this.data.address = address; }, - + //获取生日 + getbind(e) { + console.log("获取生日222222222"); + console.log(e); + let b = this.getInput(e); + let length = b.length; + let oldBirtthDayLength=this.data.oldBirtthDayLength + if (length > oldBirtthDayLength) { + if (b.length==4) { + b+='-' + } + if (b.length==7) { + b+='-' + } + // if (b.length==6 && b[5] >1) { + // console.log(b[5]); + + // } + } + this.setData({ + datet: b, + oldBirtthDayLength:length, + }); + }, //获取生日 bindChange: function (e) { + console.log("获取生日11111111"); + console.log(e); let strBirthday = e.detail.value; let age = this.verifyBirthday(strBirthday); if (age <= 10) { app.my_warnning("会员年龄不能小于10岁(含10岁)", 0, this); + this.setData({ + datet: '', + }); } else if (age >= 70) { app.my_warnning("会员年龄不能超过70岁(含70岁)", 0, this); - } else { this.setData({ - datet: e.detail.value, - }); + datet: '', + }); + } else { + let value = e.detail.value + + if (value.length==8) { + value+='01' + } + if (value.length==7) { + value+='-01' + } + if (value.length==9) { + let ov=value[value.length-1] + let nv=value.slice(0,-1) + if (ov==0) { + nv+='01' + }else{ + nv+='0'+ov + } + value=nv + } + // let reg= /^(\d{4})-(\d{2})-(\d{2})$/; + let reg= /^[1-9]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/ + console.log('日期验证'); + console.log(value); + console.log(reg.test(value)); + if (reg.test(value)) { + this.setData({ + datet: value, + }); + }else{ + app.my_warnning("出生日期格式不对", 0, this); + this.setData({ + datet: '', + }); + } } }, diff --git a/packageA/pages/profile/profile.wxml b/packageA/pages/profile/profile.wxml index 97a3374..b243c54 100644 --- a/packageA/pages/profile/profile.wxml +++ b/packageA/pages/profile/profile.wxml @@ -90,14 +90,16 @@ 出生日期: - + + + + + + - - {{datet?datet:"请选择时间"}} -