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.
104 lines
2.3 KiB
104 lines
2.3 KiB
var api = require("../../utils/api.js")
|
|
Page({
|
|
data: {
|
|
mobile: "",
|
|
smsCode: "",
|
|
submitEvent: false,
|
|
wait: 60
|
|
},
|
|
adInputMobile: function (e) {
|
|
this.setData({
|
|
mobile: e.detail.value.trim('')
|
|
})
|
|
},
|
|
adInputSmsCode: function (e) {
|
|
this.setData({
|
|
smsCode: e.detail.value.trim('')
|
|
})
|
|
},
|
|
outtime () {
|
|
let that = this
|
|
if (that.data.wait === 0) {
|
|
that.setData({
|
|
wait: 60,
|
|
btntxt: "获取验证码"
|
|
})
|
|
} else {
|
|
that.setData({
|
|
wait: that.data.wait - 1
|
|
})
|
|
setTimeout(() => {
|
|
that.outtime()
|
|
}, 1000)
|
|
}
|
|
},
|
|
toRegister: function () {
|
|
if (this.data.mobile === "") {
|
|
wx.showToast({
|
|
title: "请先输入手机号",
|
|
icon: "none",
|
|
duration: 3000
|
|
})
|
|
return false
|
|
}
|
|
if (this.data.smsCode === "") {
|
|
wx.showToast({
|
|
title: "请先输入验证码",
|
|
icon: "none",
|
|
duration: 3000
|
|
})
|
|
return false
|
|
}
|
|
if (this.data.submitEvent === true) {
|
|
wx.showToast({
|
|
title: "正在登录,请稍候...",
|
|
icon: "none",
|
|
duration: 3000
|
|
})
|
|
return false
|
|
}
|
|
wx.showLoading({
|
|
title: "正在注册..."
|
|
})
|
|
let that = this
|
|
wx.login({
|
|
success: function (response) {
|
|
let mobile = that.data.mobile
|
|
let smsCode = that.data.smsCode
|
|
let wxCode = response.code
|
|
api.gridLeaderRegister(mobile, smsCode, wxCode).then(function (res) {
|
|
console.log(res)
|
|
wx.hideLoading()
|
|
wx.setStorageSync("isFirst", "noFirst")
|
|
wx.reLaunch({
|
|
url: "/pages/indexNew/indexNew"
|
|
})
|
|
})
|
|
}
|
|
})
|
|
},
|
|
getSmsCode () {
|
|
console.log(this.data.mobile)
|
|
if (this.data.mobile === "") {
|
|
wx.showToast({
|
|
title: "请先输入手机号",
|
|
icon: "none",
|
|
duration: 3000
|
|
})
|
|
return false
|
|
}
|
|
if (this.data.wait < 60) {
|
|
wx.showToast({
|
|
title: "请" + this.data.wait + "秒后再试",
|
|
duration: 2000,
|
|
icon: "none"
|
|
})
|
|
return
|
|
}
|
|
this.outtime()
|
|
api.sendSms(this.data.mobile).then(function (res) {
|
|
console.log("已经成功发送验证码")
|
|
console.log(res)
|
|
})
|
|
}
|
|
})
|
|
|