解决了已知问题
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
// pages/zucepage/zucepage.js
|
||||
import {url} from '../../request'
|
||||
Page({
|
||||
|
||||
/**
|
||||
@ -8,59 +8,171 @@ Page({
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
|
||||
name(e){
|
||||
this.setData({
|
||||
name:e.detail.value
|
||||
})
|
||||
console.log(e.detail.value);
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
phone(e){
|
||||
this.setData({
|
||||
phone:e.detail.value
|
||||
})
|
||||
console.log(e.detail.value);
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
code(e){
|
||||
this.setData({
|
||||
code:e.detail.value
|
||||
})
|
||||
console.log(e.detail.value);
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
yanzhengma(e){
|
||||
this.setData({
|
||||
yanzhengma:e.detail.value
|
||||
})
|
||||
console.log(e.detail.value);
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
password(e){
|
||||
this.setData({
|
||||
password:e.detail.value
|
||||
})
|
||||
console.log(e.detail.value);
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
getcode(){
|
||||
const phone = this.data.phone;
|
||||
if (!/^\d{11}$/.test(phone)) {
|
||||
wx.showToast({
|
||||
title: '请输入11位的手机号',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
wx.request({
|
||||
url: url + '/userInfo/code',
|
||||
method: 'POST',
|
||||
data: {
|
||||
templateString: this.data.phone
|
||||
},
|
||||
header: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
success(res) {
|
||||
console.log('发送成功', res);
|
||||
if(res.data.code==1){
|
||||
wx.showToast({
|
||||
title: '发送成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
}else{
|
||||
wx.showToast({
|
||||
title: res.data.message,
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
},
|
||||
fail(err) {
|
||||
console.error('请求失败', err);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
// 注册
|
||||
submit(){
|
||||
const yanzhengma = this.data.yanzhengma
|
||||
const phone = this.data.phone
|
||||
const password = this.data.password
|
||||
const code = this.data.code
|
||||
const name = this.data.name
|
||||
if (!name) {
|
||||
wx.showToast({
|
||||
title: '请输入昵称',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!/^\d{6}$/.test(yanzhengma)) {
|
||||
wx.showToast({
|
||||
title: '请输入6位验证码',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!/^\d{6,11}$/.test(phone)) {
|
||||
wx.showToast({
|
||||
title: '请输入6到11位的账号',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 密码验证(6~10位字符)
|
||||
if (!/^.{6,10}$/.test(password)) {
|
||||
wx.showToast({
|
||||
title: '请输入6到10位的密码',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!/^\d{6}$/.test(code)) {
|
||||
wx.showToast({
|
||||
title: '请输入6位的邀请码',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (this.data.isAgree!=true) {
|
||||
wx.showToast({
|
||||
title: '请先勾选协议',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
console.log("sakldhasjdhja");
|
||||
wx.request({
|
||||
url: url + '/userInfo/register',
|
||||
method: 'POST',
|
||||
data: {
|
||||
nickName: this.data.name,
|
||||
phoneNumber: this.data.phone,
|
||||
verificationCode: this.data.yanzhengma,
|
||||
invitationCode: this.data.code,
|
||||
userPassword: this.data.password
|
||||
},
|
||||
header: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
success(res) {
|
||||
console.log('注册成功', res);
|
||||
if(res.data.code==1){
|
||||
wx.showToast({
|
||||
title: '注册成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
setTimeout(() => {
|
||||
wx.navigateBack({
|
||||
delta: 1
|
||||
})
|
||||
}, 2000);
|
||||
}else{
|
||||
wx.showToast({
|
||||
title: res.data.message,
|
||||
icon: 'error',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
},
|
||||
fail(err) {
|
||||
console.error('请求失败', err);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
})
|
||||
// 勾选
|
||||
onAgreeChange(e) {
|
||||
this.setData({
|
||||
isAgree: true
|
||||
});
|
||||
console.log("gaibianler",this.data.isAgree);
|
||||
},
|
||||
})
|
||||
|
Reference in New Issue
Block a user