Files
bsmall/pages/enter/enter.js
2020-09-24 11:08:03 +08:00

137 lines
3.5 KiB
JavaScript
Executable File

const api = require("../../api/api")
Page({
data:{
tle : "",
codeBtnText : "获取验证码",
codeBtnStat : false
},
// 存储手机号码
telInput(e){
this.setData({
tle: e.detail.value
})
},
// 获取短信验证码
getCode(){
setTimeout(() => {
if(this.data.tle != ''){
my.showLoading();
api.request({
url : "sms",
method: "POST",
data : {
mobile : this.data.tle,
channel : "DEFAULT"
}
}).then(res=>{
// 获取倒计时
this.setData({
codeBtnStat: true,
codeBtnText: "重新获取60s"
})
let outTimeNumber = 60
let outTime = setInterval(()=>{
if(outTimeNumber >= 1){
outTimeNumber--
this.setData({
codeBtnText: "重新获取" + outTimeNumber + 's'
})
}else{
this.setData({
codeBtnStat: false,
codeBtnText: "获取验证码"
})
clearInterval(outTime)
}
},1000)
// 提示信息
my.showToast({
content: res.data
})
my.hideLoading();
}).catch(err=>{
my.showToast({
content: "短信发送失败,请稍候重试"
})
my.hideLoading();
})
}else{
my.showToast({
content: "手机号码不能为空"
});
}
}, 100)
},
// 入驻申请
enterForm(e){
let indexValue = e.detail.value
if(indexValue.mall != '' && indexValue.user != '' && indexValue.pss != '' && indexValue.affirmpss != '' && indexValue.alipay != '' && indexValue.channel != '' && indexValue.code != ''){
my.showLoading();
api.request({
url : "users/audits",
method: "POST",
data : {
name : indexValue.mall,
mobile : indexValue.user,
password : indexValue.pss,
password_confirmation : indexValue.affirmpss,
ali_account : indexValue.alipay,
channel : "DEFAULT",
code : indexValue.code
}
}).then(res=>{
my.alert({
content : res.data,
buttonText: '知道了',
success: () => {
my.navigateBack();
}
});
my.hideLoading
}).catch(err=>{
my.showToast({
type : "fail",
content: err.data.message
})
my.hideLoading();
})
}else{
if(indexValue.mall == ''){
my.showToast({
content: "商户名不能为空"
});
}else if(indexValue.user == ''){
my.showToast({
content: "手机号码不能为空"
});
}else if(indexValue.pss == ''){
my.showToast({
content: "请设置登录密码"
});
}else if(indexValue.affirmpss == ''){
my.showToast({
content: "请确认登录密码"
});
}else if(indexValue.alipay == ''){
my.showToast({
content: "支付宝账户不能为空"
});
}else if(indexValue.channel == ''){
my.showToast({
content: "渠道码不能为空"
});
}else if(indexValue.code == ''){
my.showToast({
content: "验证码不能为空"
});
}
}
}
});