绚火健康
This commit is contained in:
149
pages/register/index.js
Normal file
149
pages/register/index.js
Normal file
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* 手太欠
|
||||
* 愿这世界都如故事里一样 美好而动人~
|
||||
*/
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
successHide : false, // 注册成功
|
||||
checked : false, // 勾选协议
|
||||
codename : '获取验证码',
|
||||
smsDisabled : false,// 获取验证码 禁止点击
|
||||
seeState : false, //小眼睛
|
||||
againState : false, //小眼睛-再次输入密码
|
||||
passwordState: true, //小眼睛-显示
|
||||
passwordAgain: true, //小眼睛-显示-再次输入密码
|
||||
phone : "", // 手机号
|
||||
code : "", // 验证码
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad() {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {},
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
bindInput(e) {
|
||||
this.setData({
|
||||
phone: e.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 短信验证码
|
||||
*/
|
||||
bindCode(e) {
|
||||
this.setData({
|
||||
code: e.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取短信验证码
|
||||
*/
|
||||
getPhoneCode(e) {
|
||||
let mobile = this.data.phone
|
||||
var _this = this
|
||||
if (mobile == "") {
|
||||
wx.showToast({
|
||||
title : '手机号不能为空',
|
||||
icon : 'none',
|
||||
duration : 1000
|
||||
})
|
||||
return false;
|
||||
}else{
|
||||
wx.$api.auth.getSms({
|
||||
mobileNo: mobile
|
||||
}).then(res=>{
|
||||
console.log(res)
|
||||
_this.setData({
|
||||
smsDisabled : true
|
||||
})
|
||||
|
||||
wx.showToast({
|
||||
title : '发送成功',
|
||||
icon : 'success',
|
||||
duration: 2000
|
||||
})
|
||||
var num = 60;
|
||||
var timer = setInterval(function () {
|
||||
num--;
|
||||
if (num <= 0) {
|
||||
clearInterval(timer);
|
||||
_this.setData({
|
||||
codename : '重新发送',
|
||||
smsDisabled : false
|
||||
})
|
||||
|
||||
} else {
|
||||
_this.setData({
|
||||
codename : num + "s后重新获取",
|
||||
smsDisabled : true
|
||||
})
|
||||
}
|
||||
}, 1000)
|
||||
}).catch(err=>{})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 查看密码
|
||||
*/
|
||||
seeClick() {
|
||||
this.setData({
|
||||
seeState : !this.data.seeState,
|
||||
passwordState: !this.data.passwordState
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 查看密码-再次
|
||||
*/
|
||||
seeAgain() {
|
||||
this.setData({
|
||||
againState : !this.data.againState,
|
||||
passwordAgain : !this.data.passwordAgain
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 立即注册
|
||||
*/
|
||||
registerForm(e) {
|
||||
let value = e.detail.value
|
||||
let data = {
|
||||
username : this.data.phone,
|
||||
code : value.code,
|
||||
password : value.password,
|
||||
password_confirmation : value.password_confirmation,
|
||||
parent_id : ''
|
||||
}
|
||||
wx.$api.auth.register(data).then(res => {
|
||||
// 存储登录信息
|
||||
wx.setStorage({
|
||||
key : 'token',
|
||||
data : res.data.token_type + ' ' + res.data.access_token,
|
||||
success: () =>{
|
||||
this.setData({
|
||||
successHide: true
|
||||
})
|
||||
}
|
||||
})
|
||||
}).catch(() =>{
|
||||
this.setData({
|
||||
disabled: false
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user