微信小程序注册

来源:互联网 发布:吉田のしる知る 番号 编辑:程序博客网 时间:2024/05/17 09:10
微笑就给一个View,其他的自己体会。。。。。。。。。。。。。。其他获取值一样大笑
.xml中
  <view class="input-pnone">手机号<input class="phoneInput" name='phoneInput' placeholder=" 请输入手机号" type="text" bindinput='photoClick' value="{{phoneInput}}" /></view>
.js中
 
data: {    phoneInput: '',    passWInput: '',    TpassWInput: '',    secretInput: '',    answerInput: ''  },
// 获取手机号  photoClick: function (e) {    this.setData({      phoneInput: e.detail.value    })  },  // 首次输入密码  passWClick: function (e) {    this.setData({      passWInput: e.detail.value    })  },  // 再次确定密码  TpassWClick: function (e) {    this.setData({      TpassWInput: e.detail.value    })  },  //设置密保问题  secretClick: function (e) {    this.setData({      secretInput: e.detail.value    })  },  //设置密保答案  answerClick: function (e) {    this.setData({      answerInput: e.detail.value    })  },  reginzeClick: function () {    //判断手机号    var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/;    //判断字母加数字    var reg = /^[\u4E00-\u9FA5]{2,4}$/;    // 判断输入的内容不能为空    if (this.data.phoneInput.length == 0 || this.data.passWInput.length == 0 || this.data.TpassWInput.length == 0 || this.data.secretInput.length == 0 || this.data.answerInput.length == 0) {      wx.showToast({        title: '内容不能为空!',        icon: 'success',        duration: 1500      })      return false;    } else if (this.data.phoneInput.length < 11) {      wx.showToast({        title: '手机号长度有误!',        icon: 'success',        duration: 1500      })      return false;    } else if (!myreg.test(this.data.phoneInput)) {      wx.showToast({        title: '手机号有误!',        icon: 'success',        duration: 1500      })      return false;    } else if (reg.test(this.data.passWInput) || this.data.TpassWInput.length < 6) {      wx.showToast({        title: '密码仅限数字+字母且密码不能小于六位',        icon: 'success',        duration: 1500      })      return false;    } else if (reg.test(this.data.TpassWInput) || this.data.TpassWInput.length < 6) {      wx.showToast({        title: '密码仅限数字+字母',        icon: 'success',        duration: 1500      })      return false;    } else if (this.data.passWInput != this.data.TpassWInput) {      wx.showToast({        title: '两次输入的密码不同!',        icon: 'success',        duration: 1500      })      return false;    } else {      wx.setStorageSync('phoneInput', this.data.phoneInput);      wx.request({        url: '公司提供的接口',        data: {          username: this.data.phoneInput,          password: this.data.passWInput,          pwdQuestion: this.data.secretInput,          pwdAnswer: this.data.answerInput        },        method: 'GET',        success: function (res) {          console.log('注册成功!!!!!!!!!!!!!!!')          console.log(res);          //注册成功          if (res.data.code == 119) {            wx.redirectTo({          //---------------------------------------跳到成功页面              url: '../zcSuccess/zcSuccess',            })          //执行失败            } else if (res.data.code == 106) {            wx.showToast({              title: res.data.message,              icon: 'success',              duration: 1500            })            return false;          // 注册用户名已存在,请直接登录            } else if (res.data.code == 117) {            wx.showToast({              title: res.data.message,              icon: 'success',              duration: 1500            })            return false;          //  昵称已存在           } else if (res.data.code == 118) {            wx.showToast({              title: res.data.message,              icon: 'success',              duration: 1500            })            return false;          //  已经执行过此操作           } else if (res.data.code == 113) {            wx.showToast({              title: res.data.message,              icon: 'success',              duration: 1500            })            return false;          }        },        fail: function (res) {        },        complete: function (res) {        }      })    }  },



 
原创粉丝点击