diff --git a/uni_modules/uni-login-page/components/login-short-code/login-short-code.vue b/uni_modules/uni-login-page/components/login-short-code/login-short-code.vue index b345f4fe6906e02843f7ba54f55c1a57976db93b..93567c31886eb4683a6fe451b71b4a073f12bf5a 100644 --- a/uni_modules/uni-login-page/components/login-short-code/login-short-code.vue +++ b/uni_modules/uni-login-page/components/login-short-code/login-short-code.vue @@ -28,6 +28,13 @@ count: { type: [String, Number], default: 60 + }, + /** + * 手机号码 + */ + phone: { + type: [String, Number], + default: '' } }, data() { @@ -49,10 +56,43 @@ initClick() { this.start = debounce(() => { if (this.reverseNumber != 0) return; - this.$emit('getCode', () => { - this.reverseNumber = Number(this.count); + this.sendMsg(); + }) + }, + sendMsg() { + let reg_phone = /^1\d{10}$/; + if(!reg_phone.test(this.phone))return uni.showToast({ + title: '手机号格式错误', + icon: 'none' + }); + uniCloud.callFunction({ + "name": "user-center", + "data": { + "action": "sendSmsCode", + "params": { + "mobile": this.phone, + "type": "login" + } + }, + success: (e) => { + uni.showToast({ + title: "短信验证码发送成功", + icon: 'none' + }); + this.reverseNumber = Number(this.count); this.getCode(); - }); + this.$emit('getCode'); + }, + fail: (err) => { + console.log(err); + uni.showToast({ + title: '短信验证码发送失败', + icon: 'none' + }); + }, + complete: () => { + uni.hideLoading() + } }) }, getCode() { @@ -73,17 +113,19 @@ diff --git a/uni_modules/uni-login-page/pages/index/phone-code.vue b/uni_modules/uni-login-page/pages/index/phone-code.vue index cf05513aadb76abb08b39ee34bb9b9481a5488ac..5288f3d5618d0c00ab1b57f01474fe3784a757c4 100644 --- a/uni_modules/uni-login-page/pages/index/phone-code.vue +++ b/uni_modules/uni-login-page/pages/index/phone-code.vue @@ -11,7 +11,7 @@ @@ -70,48 +70,7 @@ onReady() { this.$refs.shortCode.start(); }, - methods: { - /** - * 获取验证码倒计时 - * 倒计时期间不会触发该方法 - */ - getCode(done) { - if (this.phoneNumber == '') return uni.showToast({ - title: '请填写手机号', - icon: 'none' - }); - uniCloud.callFunction({ - "name": "user-center", - "data": { - "action": "sendSmsCode", - "params": { - "mobile": this.phoneNumber, - "type": "login" - } - }, - success: (e) => { - console.log(e); - uni.showToast({ - title: "短信验证码发送成功", - icon: 'none' - }); - - // uni.showModal({ - // content: JSON.stringify(e.result), - // showCancel: false, - // confirmText: '知道了' - // }); - // 发送成功后开启倒计时 - done(); - }, - fail: (err) => { - console.log(err); - }, - complete: () => { - uni.hideLoading() - } - }) - }, + methods: { /** * 完成并提交 */ diff --git a/uni_modules/uni-login-page/pages/index/pwd-retrieve.vue b/uni_modules/uni-login-page/pages/index/pwd-retrieve.vue index d268bd21eb5c016d75ef5721b00b1b8ce69cc4e1..0d1c6e7dd37c4a830d639dfa7a8c942425da3937 100644 --- a/uni_modules/uni-login-page/pages/index/pwd-retrieve.vue +++ b/uni_modules/uni-login-page/pages/index/pwd-retrieve.vue @@ -13,7 +13,7 @@ { - console.log(e); - uni.showToast({ - title: "短信验证码发送成功", - icon: 'none' - }); - // uni.showModal({ - // content: JSON.stringify(e.result), - // showCancel: false, - // confirmText: '知道了' - // }); - // 发送成功后开启倒计时 - done(); - }, - fail: (err) => { - console.log(err); - }, - complete: () => { - uni.hideLoading() - } - }) - }, + methods: { checkCode(callback){ uniCloud.callFunction({//联网验证登陆 "name": "user-center",