123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- /*
- * 发送验证码
- * 验证码时间 _self.sendCodeTime
- * 是否在发送中 _self.isSendCodeUse true 发送中
- */
- function sendCode(data,callback){
- let _self = this
- if(!checkPhone(data.phone)){
- // uni.showToast({
- // title: "手机号格式不正确",
- // duration: 1500,
- // mask: false,
- // icon: 'none',
- // })
- return
- }
- if(_self.isSendCodeUse){return}
- //设置定时器 60s 内发送
- _self.isSendCodeUse = true
- let times = setInterval(function(){
- _self.sendCodeTime--
- if(_self.sendCodeTime<0){
- _self.isSendCodeUse = false
- _self.sendCodeTime = 60
- clearInterval(times)
- }
- },1000)
- // Load.open(_self)
- _self.request({
- url:"/Send/sendSmsCode",
- data,
- success(r){
- if(r.code==200){
- showToast({title:r.msg})
- if(callback){
- callback()
- }
- }
- }
- })
- }
- /*
- * 验证手机号
- */
- function checkPhone(phone){
- let reg=/^[1][3,4,5,6,7,8,9][0-9]{9}$/
- let _self = this
- if(!phone){
- uni.showToast({
- title: "手机号不能为空",
- duration: 1500,
- mask: false,
- icon: 'none',
- })
- return false
- }
- if (!reg.test(phone)) {
- uni.showToast({
- title: "手机号格式不正确",
- duration: 1500,
- mask: false,
- icon: 'none',
- })
- return false
- } else {
- return true
- }
- }
- function checkCode(code){
- let _self = this
- if(!code){
- _self.toast("验证码不能为空")
- return false
- }else{
- return true
- }
- }
- function checkInvite(invite){
- let _self = this
- if(!invite){
- _self.toast("请填写推荐码")
- return false
- }else{
- return true
- }
- }
- function checkPwd(pwd){
- let _self = this
- if(!pwd){
- _self.toast("密码不能为空")
- return false
- }
- if(pwd.length<6||pwd.length>20){
- _self.toast("密码长度不正确")
- return false
- }else{
- return true
- }
- }
- function showToast(config){
- config.duration = config.duration || 1500;
- uni.showToast({
- title: config.title,
- duration: config.duration,
- mask: config.mask||false,
- icon: config.icon||'none',
- success(){
- setTimeout(config.success||function(){},config.duration)
- }
- })
- }
|