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.
66 lines
1.3 KiB
66 lines
1.3 KiB
// pages/register/register.js
|
|
const app = getApp();
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
login:"",
|
|
countDownNum: 0
|
|
},
|
|
register: function({detail:{value}}){
|
|
console.log("register");
|
|
console.info(value);
|
|
app.client.register(value).then(res=>{
|
|
wx.showToast({
|
|
title: res.message,
|
|
});
|
|
wx.navigateBack({
|
|
delta: 1
|
|
})
|
|
}).catch(error=>{
|
|
wx.showToast({
|
|
title: error.toString(),
|
|
icon: "none"
|
|
})
|
|
});
|
|
},
|
|
updateLogin: function({detail:{value}}) {
|
|
this.setData({login: value});
|
|
},
|
|
send_code: function(){
|
|
if (!this.data.login) return;
|
|
this.countDown();
|
|
app.client.get_verification_code_for_register({
|
|
login: this.data.login,
|
|
success:res=>{
|
|
wx.showToast({
|
|
title: "发送成功"
|
|
})
|
|
}
|
|
}).catch(console.error);
|
|
},
|
|
countDown: function () {
|
|
let that = this;
|
|
let countDownNum = 30;
|
|
that.setData({
|
|
countDownNum: countDownNum
|
|
});
|
|
that.setData({
|
|
timer: setInterval(function () {
|
|
countDownNum--;
|
|
that.setData({
|
|
countDownNum: countDownNum
|
|
})
|
|
if (countDownNum == 0) {
|
|
clearInterval(that.data.timer);
|
|
}
|
|
}, 1000)
|
|
})
|
|
},
|
|
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
}) |