123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- // pages/register/register.js
- import { $wuxCountDown, $wuxForm } from '../../miniprogram_npm/wux-weapp/index'
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- layout: 'horizontal',
- validateMessages: {
- required: '%s 字段为必填',
- },
- registerMessage:{
- phone:'',
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 页面方法集合
- */
- //表单栏位值发生变化时
- onValuesChange(e) {
- console.log(e)
- const { changedValues, allValues } = e.detail
- // this.setValues(changedValues)
- Object.keys(changedValues).forEach((field) => {
- this.setData({
- ['loginMessage['+field+']']: changedValues[field],
- })
- })
- console.log('onValuesChange \n', changedValues, allValues)
- },
- //发送验证码
- onSendCode(){
- if (this.c2 && this.c2.interval) return !1
- this.c2 = new $wuxCountDown({
- date: +new Date() + 60000,
- onEnd() {
- this.setData({
- c2: '重新获取验证码',
- })
- },
- render(date) {
- const sec = this.leadingZeros(date.sec, 2) + ' 秒 '
- date.sec !== 0 &&
- this.setData({
- c2: sec,
- })
- },
- })
- wx.showModal({
- content: `【WuxUI】验证码:123456,有效期5分钟,请勿泄露。`,
- showCancel: !1,
- })
- },
- //手机号校验
- checkPhone(rule, value){
- if(!value){
- return Promise.reject(new Error('手机号不能为空!'))
- }
- const isTel = (value) => /^1[34578]\d{9}$/.test(value)
- if(!isTel(value)){
- return Promise.reject(new Error('手机号输入错误!'))
- }
- },
- //注册
- onSubmit(){
- const { validateFields } = $wuxForm()
- validateFields((err, values) => {
- if (!err) {
- wx.showModal({
- content: JSON.stringify(values, null, 2),
- showCancel: !1,
- })
- console.log('Received values of form: ', values);
- }
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|