// pages/register/index.js const request = require('../../utils/request.js'); const app = getApp() Page({ /** * 页面的初始数据 */ data: { nvabarData: { showCapsule: 0, //是否显示左上角图标,消息中心 1表示显示 0表示不显示 showBack: 1, //返回 title: '找回密码', //导航栏 中间的标题 // 此页面 页面内容距最顶部的距离 height: app.globalData.height * 2 + 20, }, instructionBook: '已阅读并同意使用', radioCheck: false, phone: '', disabled: false, code: '获取验证码', }, radioClick: function (event) { var radioCheck = this.data.radioCheck; this.setData({ "radioCheck": !radioCheck }); }, agreementBtn: function () { wx.navigateTo({ url: '/pages/agreement/index' }) }, talks: function (e) { this.setData({ phone: e.detail.value }) }, //校验手机号 async isPoneAvailable(str) { var myreg = /^[1][3,4,5,7,8][0-9]{9}$/; if (!myreg.test(str)) { wx.showToast({ title: '请输入正确手机号', image: '/pages/images/jinggao.png', duration: 2000 }) return false; } else { var that = this; var time = 60; that.setData({ code: '60秒后重发', disabled: true }) let list = await request.query({ url: 'api/financial/phoneMessage/sendMessage', data: { phone: this.data.phone }, method: 'post' }); if (list && list.data.data.Message && list.data.data.Message == 'OK' && list.data.data.Code && list.data.data.Code == 'OK') { if (list.data.data.number) { wx.setStorage({ key: 'code', data: list.data.data.number, }) } var Interval = setInterval(function () { time--; if (time > 0) { that.setData({ code: time + '秒后重发' }) } else { clearInterval(Interval); that.setData({ code: '获取验证码', disabled: false }) } }, 1000) } else { wx.showToast({ title: '获取验证码失败', icon: 'none', duration: 2000 }) } } }, getCode() { // console.log(this.data.phone) if (this.data.phone) { this.isPoneAvailable(this.data.phone); // var that = this; // var time = 60; // that.setData({ // code: '60秒后重发', // disabled: true // }) // let list = await request.query({ // url: 'api/financial/phoneMessage/sendMessage', // data: {phone:this.data.phone}, // method: 'post' // }); // if (list && list.data.data.Message && list.data.data.Message == 'OK' && list.data.data.Code && list.data.data.Code== 'OK') { // if (list.data.data.number) { // wx.setStorage({ // key: 'code', // data: list.data.data.number, // }) // } // var Interval = setInterval(function() { // time--; // if (time>0){ // that.setData({ // code: time + '秒后重发' // }) // }else{ // clearInterval(Interval); // that.setData({ // code: '获取验证码', // disabled: false // }) // } // },1000) // } else{ // wx.showToast({ // title: '获取验证码失败', // icon: 'none', // duration: 2000 // }) // } } else { wx.showToast({ title: '请输入手机号', icon: 'none', duration: 2000 }) } }, // 找回密码 formSubmit: function (e) { // console.log(e.detail.value) if (e.detail.value.phone == "" || e.detail.value.yanzhengma == "" || e.detail.value.password == "" || e.detail.value.againpassword == "") { wx.showToast({ title: '缺少部分信息项', icon: 'none', duration: 1500 }) return false } // console.log(this.data.radioCheck); // console.log('form发生了submit事件,携带数据为:', e.detail.value) let code = wx.getStorageSync('code') let user = wx.getStorageSync('user') // console.log('code', code) if (code == e.detail.value.yanzhengma) { if (e.detail.value.password == e.detail.value.againpassword) { let pwdRegex = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z])'); if (!pwdRegex.test(e.detail.value.password) || e.detail.value.password.length < 8 || e.detail.value.password.length >20) { wx.showModal({ title: '提示', content: '密码格式错误', confirmText: '确定', success(res) { if (res.confirm) { // console.log('用户点击取消') } else if (res.cancel) { // console.log('用户点击取消') } } }) } else { wx.request({ method: "POST", url: app.globalData.publicUrl + 'api/financial/companyuser/unpasswd2', data: { phone: e.detail.value.phone, newpasswd: e.detail.value.password, }, success: (e) => { // console.log('data',e.data) if (e.data.data == '该手机号码未注册') { wx.showModal({ title: '', content: '去注册', success(res) { if (res.confirm) { wx.navigateTo({ url: '/pages/register/index' }) } else if (res.cancel) { // console.log('用户点击取消') } } }) } else { wx.showModal({ title: '密码已修改', content: '快去登陆吧', success(res) { if (res.confirm) { wx.navigateTo({ url: '/pages/login/index' }) } else if (res.cancel) { // console.log('用户点击取消') } } }) } } }) } } else { wx.showToast({ title: '两次密码输入不一致', icon: 'none', duration: 1500 }) } // if (this.data.radioCheck == true) { // wx.request({ // method: "POST", // url: app.globalData.publicUrl + 'api/financial/companyuser', // data: { // phone: e.detail.value.phone, // passwd: e.detail.value.password, // person: e.detail.value.person // }, // success: (e) => { // console.log('success', e); // if (e.data.errcode == 0) { // wx.navigateTo({ // url: '/pages/login/index' // }) // } else { // if (e.data.details === "phone无效") { // wx.showToast({ // title: '请重新输入手机号', // icon: 'none', // duration: 1500 // }) // } else if (e.data.errmsg === "数据已存在") { // wx.showToast({ // title: '该手机号已被注册', // icon: 'none', // duration: 1500 // }) // } else { // wx.showToast({ // title: e.data.details ? e.data.details : e.data.errmsg, // icon: 'none', // duration: 1500 // }) // } // } // } // }) // } else { // wx.showToast({ // title: '请勾选企业授权协议', // icon: 'none', // duration: 1500 // }) // } } else { wx.showToast({ title: '验证码错误', icon: 'none', duration: 1500 }) } }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ radioCheck: options.radioCheck }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })