Browse Source

调整注册功能

master
453530270@qq.com 2 years ago
parent
commit
c08092f8e2
  1. 10
      api/reg/index.js
  2. 27
      pages/reg/reg.vue

10
api/reg/index.js

@ -2,10 +2,16 @@ import request from '@/utils/request'
// api地址 // api地址
const api = { const api = {
smsurl:'slb/userself/v1/account/username/unique-validate/' smsurl:'slb/userself/v1/account/username/unique-validate/',
verifycode:'slb/userself/v1/verify-code'
} }
// 发送验证码(手机号+验证码) // 校验手机号是否唯一
export function sendSms(params) { export function sendSms(params) {
return request.get(api.smsurl+params) return request.get(api.smsurl+params)
} }
// 发送验证码(手机号+验证码)
export function sendVerifyCode(params){
return request.get(api.verifycode,params)
}

27
pages/reg/reg.vue

@ -46,7 +46,7 @@
<!-- 找回密码 注册 --> <!-- 找回密码 注册 -->
<view class="regtips"> <view class="regtips">
<view>已拥有账户?<a class="loginnow" @tap="gologin">登录</a></view> <view>已拥有账户?<a class="loginnow" @tap="debounce(gologin,500)">登录</a></view>
</view> </view>
<!-- 弹框 --> <!-- 弹框 -->
@ -92,6 +92,8 @@
utchk2:false, utchk2:false,
// //
murl:"", murl:"",
//
isCutdown:false,
// //
st:120, st:120,
// / // /
@ -133,14 +135,27 @@
getsmscode(){ getsmscode(){
// //
let mb = this.mobile let mb = this.mobile
if(this.validteMobile(mb)){ if(this.validteMobile(mb) && this.isCutdown!=true){
regApi.sendSms(mb).then(res=>{ regApi.sendSms(mb).then(res=>{
if(res.resultCode=="00000000"){ if(res.resultCode=="00000000"){
if(res.data ==1){ if(res.data ==1){
this.$toast("手机号已被注册") this.$toast("手机号已被注册")
this.st = 60
}else{ //
//
let pars={username:mb,purpose:1}
regApi.sendVerifyCode(pars).then(res=>{
// console.log("verify code",res)
if(res.resultCode === "00000000"){
// //
this.countDown() this.countDown()
this.$toast("发送成功")
}else{
this.$error(res.resultMsg)
}
})
} }
//
} }
console.log(res) console.log(res)
}); });
@ -152,15 +167,17 @@
let app = this let app = this
app.$refs.abtn.$el.innerText=app.st+"秒" app.$refs.abtn.$el.innerText=app.st+"秒"
let qq = app.st let qq = app.st
console.log(qq) // console.log(qq)
setTimeout(function(){ setTimeout(function(){
if(app.st>1){ if(app.st>1){
app.st-- app.st--
app.countDown(app.st) app.countDown(app.st)
//ing
app.isCutdown=true
}else{ }else{
app.st = "获取验证码" app.st=0
app.$refs.abtn.$el.innerText = "获取验证码"
} }
},1000) },1000)
}, },

Loading…
Cancel
Save