123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- const app = getApp();
- Page({
-
- data: {
- user:'',
- password: '',
- codeid: '',
- code: '',
- text: '获取验证码',
- currentTime: 5,
- phone: '',
- disabled: false,
- color: '',
- },
-
- onLoad: function (options) {
- },
-
- Telephone: function (e) {
- var user = e.detail.value;
- console.log(user);
- this.setData({
- user: user
- });
- },
-
- password: function (e) {
- var password = e.detail.value;
- console.log(password);
- this.setData({
- password: password
- });
- },
-
- getCode: function (e) {
- var code = e.detail.value;
- console.log(code);
- this.setData({
- code: code
- });
- },
-
- getVerificationCode(res) {
- var that = this
- that.setData({
- disabled: true,
- color: '#ccc',
- })
- var phone = that.data.user;
- var currentTime = that.data.currentTime
- var warn = null;
- if (phone == '') {
- warn = "号码不能为空";
- } else if (phone.trim().length != 11 || ! /^1[23456789]\d{9}$/.test(phone)) {
- warn = "手机号格式不正确";
- } else {
-
- let code_url = 'public/verificationcode';
- let code_data = {
- mobile:this.data.user,
- type:2,
- source:1,
- };
- app.postRequest(code_url, code_data, function (res) {
- if (res.code == 201) {
-
- that.setData({
- codeid: res.data.id
- })
-
- wx.showToast({
- title: '短信验证码已发送',
- icon: 'none',
- duration: 2000
- });
- return;
- }
- var _qrcode = res.msg
- getApp().Tips(_qrcode);
- })
-
- var interval = setInterval(function () {
- currentTime--;
- that.setData({
- text: "重新发送(" + currentTime + 's)',
- })
-
- if (currentTime <= 0) {
- clearInterval(interval)
- that.setData({
- text: '重新发送',
- currentTime: 5,
- disabled: false,
- color: '#FF9BCA'
- })
- }
- }, 1000);
- };
-
- if (warn != null) {
- wx.showModal({
- title: '填写手机号码',
- content: warn,
- showCancel: false,
- })
- that.setData({
- disabled: false,
- color: '#FF9BCA'
- })
- return;
- };
- },
-
- complete: function (e) {
- console.log(this)
- let user = this.data.user;
- let password = this.data.password;
- let code = this.data.code;
- var complete = null;
- if (user == '') {
- complete = '请输入手机号码';
- } else if (user.trim().length != 11 || ! /^1[23456789]\d{9}$/.test(user)) {
- complete = '手机号码格式不对';
- } else if (password == '') {
- complete = '请设置密码';
- }
- else if (code == '') {
- complete = '请输入验证码';
- } else if (code.trim().length != 4 || ! /^[0-9]\d{3}$/.test(code)) {
- complete = '验证码4位数';
- } else {
- var _this = this
- console.log(this.data.nickname)
- let income_url = 'public/getback';
- let income_data = {
- user: this.data.user,
- password: this.data.password,
- code: this.data.code,
- id: this.data.codeid,
- };
- app.postRequest(income_url, income_data, function (res) {
-
- if (res.code == 201) {
- console.log(res.msg);
- wx.showModal({
- title: '提示',
- content: res.msg,
- showCancel: false,
- })
- wx.navigateTo({
- url: 'pages/Landpage/Land/Land'
- })
- } else if (res.code == 301){
- wx.showToast({
- title: res.msg,
- icon: 'none',
- duration: 1500,
- })
- }
- })
- }
-
- if (complete != null) {
- wx.showToast({
- title: complete,
- icon: 'none',
- duration: 1500
- })
- return;
- };
- },
- })
|