You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

259 lines
5.6 KiB

// pages/mine/pages/register/register.js
const app = getApp()
import timer from '../../../../utils/timer'
Page({
/**
* 页面的初始数据
*/
data: {
sUserName: '',
sPwd: '',
sPhone: '',
sEmail: '',
companyName: '',
brandName: '',
sVerifycode: '',
captchaLabel: '获取验证码',
captchaDisabled: false
},
//用户输入
usernameInput(e) {
this.setData({
sUserName: e.detail.value
})
},
//密码输入
passwordInput(e) {
this.setData({
sPwd: e.detail.value
})
},
//手机号输入
sPhoneInput(e) {
this.setData({
sPhone: e.detail.value
})
},
//邮箱输入
sEmailInput(e) {
this.setData({
sEmail: e.detail.value
})
},
//名称输入
companyInput(e) {
this.setData({
companyName: e.detail.value
})
},
//品牌输入
brandInput(e) {
this.setData({
brandName: e.detail.value
})
},
//验证码输入
codeInput(e) {
this.setData({
sVerifycode: e.detail.value
})
},
//获取验证码
captcha() {
let b = this.validPhone();
if (!b) return;
let obj = {
action: 'getVERCode',
sPhone: this.data.sPhone,
}
// 定时60s
timer(this)
app.globalData.request(obj).then((res) => {
if (res.Code == 1) {
wx.showModal({
title: '提示',
content: data.Msg,
})
}
}).catch(err => {
wx.showModal({
title: '提示',
content: err.Msg,
})
})
},
/**
* 生命周期函数--监听页面加载
*/
//提交审核
Submit() {
let a = this.validfrom();
if (!a) return;
let obj = {
action: 'regUser',
sUserName: this.data.sUserName,
sPwd: this.data.sPwd,
sPhone: this.data.sPhone,
sEmail: this.data.sEmail,
companyName: this.data.companyName,
brandName: this.data.brandName,
sVerifycode: this.data.sVerifycode,
}
app.globalData.request(obj).then((res) => {
wx.showModal({
title: '提示',
content: data.Msg,
})
}).catch(err => {
wx.showModal({
title: '提示',
content: err.Msg,
})
})
},
validPhone() {
let b = true;
let sPhone = this.data.sPhone;
//验证手机号
if (!this.data.sPhone) {
wx.showModal({
title: '提示',
content: "手机号不能为空",
})
b = false;
return b;
}
//验证手机格式
if (!(/^1[34578]\d{9}$/.test(sPhone))) {
wx.showModal({
title: '提示',
content: "手机格式错误",
})
b = false
return b;
}
return b;
},
validfrom() {
let a = true;
//验证用户名
if (!this.data.sUserName) {
wx.showModal({
title: '提示',
content: "用户名不能为空",
})
a = false;
return a;
}
//验证密码
if (!this.data.sPwd) {
wx.showModal({
title: '提示',
content: "密码不能为空",
})
a = false;
return a;
}
//验证手机号
if (!this.data.sPhone) {
wx.showModal({
title: '提示',
content: "手机号不能为空",
})
a = false;
return a;
}
//验证邮箱
if (!this.data.sEmail) {
wx.showModal({
title: '提示',
content: "邮箱不能为空",
})
a = false;
return a;
}
//验证公司名称
if (!this.data.companyName) {
wx.showModal({
title: '提示',
content: "公司名称不能为空",
})
a = false;
return a;
}
//验证品牌
if (!this.data.brandName) {
wx.showModal({
title: '提示',
content: "公司品牌不能为空",
})
a = false;
return a;
}
//验证验证码
if (!this.data.sVerifycode) {
wx.showModal({
title: '提示',
content: "公司品牌不能为空",
})
a = false;
return a;
}
},
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})