From 7003f55dec5e8d3226874a852b207ba0faee1b53 Mon Sep 17 00:00:00 2001
From: zoujiandong <10130823232@qq.com>
Date: Fri, 11 Apr 2025 11:50:16 +0800
Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/login/login.vue | 83 +++++++++++++++++----
pages/register/register.vue | 140 +++++++++++++++++++-----------------
2 files changed, 143 insertions(+), 80 deletions(-)
diff --git a/pages/login/login.vue b/pages/login/login.vue
index 7ecf754..7cd4ced 100644
--- a/pages/login/login.vue
+++ b/pages/login/login.vue
@@ -9,7 +9,7 @@
v-if="!isPhoneLogin"
>
@@ -57,7 +57,7 @@
-->
-
+
@@ -83,6 +83,7 @@
注册
-
+
+
+
+
操作说明
@@ -145,9 +151,8 @@ import { ref, reactive } from "vue";
import { onShow } from "@dcloudio/uni-app";
import api from "@/api/api";
import auth from "@/utils/auth";
-const model = reactive({
- name: "",
-});
+const code = ref('');
+const phone = ref(null);
const isPwdPic = ref(false);
const isPhoneLogin = ref(true);
const customStyle = reactive({
@@ -165,6 +170,9 @@ const tips = ref("");
const seconds = ref(10);
const uCodeRef = ref(null);
const checked = ref(false);
+const radioChange = (e) => {
+ checked.value =!checked.value;
+};
const getPhoneNumber = (e) => {
if (e.detail.errMsg === "getPhoneNumber:ok") {
console.log(e.target.code)
@@ -185,6 +193,32 @@ const getPhoneNumber = (e) => {
});
}
};
+const phoneLogin = () => {
+ if (!isPhoneNum(phone.value)) return;
+ if (!code.value){
+ uni.showToast({
+ title: "请输入验证码",
+ icon: "none",
+ });
+ return false
+ };
+ auth().then((res) => {
+ api.mobileLogin({
+ code: code.value,
+ phone: phone.value,
+ wx_code: res,
+ })
+ .then((data) => {
+ const { envVersion } = uni.getAccountInfoSync().miniProgram;
+ if (envVersion == "release") {
+ uni.setStorageSync("AUTH_TOKEN", data.token);
+ } else {
+ uni.setStorageSync("DEV_AUTH_TOKEN", data.token);
+ }
+ });
+ });
+}
+
const isPhoneNum = (phonenum) => {
let reg = /^1[3456789]\d{9}$/;
if (!reg.test(phonenum)) {
@@ -209,22 +243,31 @@ const goRegister = () => {
});
};
const getCode = () => {
+ if (!isPhoneNum(phone.value)) return;
if (uCodeRef.value.canGetCode) {
// 模拟向后端请求验证码
uni.showLoading({
title: "正在获取验证码",
});
- setTimeout(() => {
- uni.hideLoading();
- // 这里此提示会被start()方法中的提示覆盖
- uni.$u.toast("验证码已发送");
- // 通知验证码组件内部开始倒计时
- uCodeRef.value.start();
- }, 2000);
+ getSms();
+ // setTimeout(() => {
+ // uni.hideLoading();
+ // // 这里此提示会被start()方法中的提示覆盖
+ // uni.$u.toast("验证码已发送");
+ // // 通知验证码组件内部开始倒计时
+ // uCodeRef.value.start();
+ // }, 2000);
} else {
uni.$u.toast("倒计时结束后再发送");
}
};
+const getSms=()=>{
+ api.getCode({phone: phone.value}).then(res=>{
+ uni.hideLoading();
+ uni.$u.toast("验证码已发送");
+ uCodeRef.value.start();
+ })
+}
const end = () => {
customCode.opacity = 1;
};
@@ -235,6 +278,18 @@ const start = () => {
\ No newline at end of file