From c39e90b3bcf00f4baa154e74e42555a1b806693e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=8A=8A=E9=87=8C?= <1227971437@qq.com>
Date: Mon, 12 Apr 2021 16:00:15 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8A=BD=E7=A6=BB=E7=9F=AD=E4=BF=A1=E5=8F=91?=
=?UTF-8?q?=E9=80=81=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../login-short-code/login-short-code.vue | 72 +++++++++++++++----
.../uni-login-page/pages/index/phone-code.vue | 45 +-----------
.../pages/index/pwd-retrieve.vue | 44 +-----------
3 files changed, 61 insertions(+), 100 deletions(-)
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 b345f4f..93567c3 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 cf05513..5288f3d 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 d268bd2..0d1c6e7 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",
--
GitLab