From 7bca7c62d976628325381180f559be7e13a375eb Mon Sep 17 00:00:00 2001 From: panda <1565636758@qq.com> Date: Mon, 15 Dec 2025 14:17:33 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=9B=BE?= =?UTF-8?q?=E5=BD=A2=E9=AA=8C=E8=AF=81=E7=A0=81=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=BB=91=E5=9D=97=E5=92=8C=E6=96=87=E5=AD=97?= =?UTF-8?q?=E7=82=B9=E5=87=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/api/login.ts | 105 +++-- src/http/http.ts | 26 +- src/http/types.ts | 5 +- .../auth/components/Verifition/Verify.vue | 432 ++++++++++++++++++ .../Verifition/Verify/VerifyPoints.vue | 251 ++++++++++ .../Verifition/Verify/VerifySlide.vue | 345 ++++++++++++++ .../auth/components/Verifition/utils/ase.ts | 14 + src/pages/auth/login.vue | 105 +++-- 9 files changed, 1189 insertions(+), 95 deletions(-) create mode 100644 src/pages/auth/components/Verifition/Verify.vue create mode 100644 src/pages/auth/components/Verifition/Verify/VerifyPoints.vue create mode 100644 src/pages/auth/components/Verifition/Verify/VerifySlide.vue create mode 100644 src/pages/auth/components/Verifition/utils/ase.ts diff --git a/package.json b/package.json index 2c328d8..ea7a96e 100644 --- a/package.json +++ b/package.json @@ -113,6 +113,7 @@ "@dcloudio/uni-mp-xhs": "3.0.0-4070620250821001", "@dcloudio/uni-quickapp-webview": "3.0.0-4070620250821001", "abortcontroller-polyfill": "^1.7.8", + "crypto-js": "^4.2.0", "dayjs": "1.11.10", "pinia": "2.0.36", "pinia-plugin-persistedstate": "3.2.1", diff --git a/src/api/login.ts b/src/api/login.ts index f4f086c..8cfe2f1 100644 --- a/src/api/login.ts +++ b/src/api/login.ts @@ -6,106 +6,115 @@ import type { IUpdateInfo, IUpdatePassword, IUserInfoRes, -} from "./types/login"; -import { http } from "@/http/http"; +} from './types/login' +import { http } from '@/http/http' /** * 登录表单 */ export interface ILoginForm { - type: "username" | "register" | "sms"; - username?: string; - password?: string; - nickname?: string; - captchaVerification?: string; - mobile?: string; - code?: string; + type: 'username' | 'register' | 'sms' + username?: string + password?: string + nickname?: string + captchaVerification?: string + mobile?: string + code?: string } /** 账号密码登录 Request VO */ export interface AuthLoginReqVO { - password?: string; - username?: string; - captchaVerification?: string; + password?: string + username?: string + captchaVerification?: string // 绑定社交登录时,需要传递如下参数 - socialType?: number; - socialCode?: string; - socialState?: string; + socialType?: number + socialCode?: string + socialState?: string } /** 注册 Request VO */ export interface AuthRegisterReqVO { - username: string; - password: string; - captchaVerification: string; + username: string + password: string + captchaVerification: string } /** 短信登录 Request VO */ export interface AuthSmsLoginReqVO { - mobile: string; - code: string; + mobile: string + code: string } /** 发送短信验证码 Request VO */ export interface AuthSmsSendReqVO { - mobile: string; - scene: number; + mobile: string + scene: number } /** 租户信息 */ export interface TenantVO { - id: number; - name: string; + id: number + name: string } /** 重置密码 Request VO */ export interface AuthResetPasswordReqVO { - mobile: string; - code: string; - password: string; + mobile: string + code: string + password: string } /** * 获取验证码 * @returns ICaptcha 验证码 */ -export function getCode() { - return http.get("/user/getCode"); +export function getCode(data: any) { + return http.postOriginal('/system/captcha/get', data) +} + +/** + * 校验验证码 + * @param data 验证码校验参数 + * @returns Promise 包含校验结果 + */ +export function checkCaptcha(data: any) { + return http.postOriginal('/system/captcha/check', data) } /** 使用账号密码登录 */ export function login(data: AuthLoginReqVO) { - return http.post("/system/auth/login", data); + return http.post('/system/auth/login', data) } /** 注册用户 */ export function register(data: AuthRegisterReqVO) { - return http.post("/system/auth/register", data); + return http.post('/system/auth/register', data) } /** 短信登录 */ export function smsLogin(data: AuthSmsLoginReqVO) { - return http.post("/system/auth/sms-login", data); + return http.post('/system/auth/sms-login', data) } /** 发送短信验证码 */ export function sendSmsCode(data: AuthSmsSendReqVO) { - return http.post("/system/auth/send-sms-code", data); + return http.post('/system/auth/send-sms-code', data) } /** 获取租户简单列表 */ export function getTenantSimpleList() { - return http.get("/system/tenant/simple-list"); + return http.get('/system/tenant/simple-list') } /** 根据租户域名获取租户信息 */ export function getTenantByWebsite(website: string) { - return http.get(`/system/tenant/get-by-website?website=${website}`); + return http.get(`/system/tenant/get-by-website?website=${website}`) } /** 通过短信重置密码 */ export function smsResetPassword(data: AuthResetPasswordReqVO) { - return http.post("/system/auth/reset-password", data); + return http.post('/system/auth/reset-password', data) } /** @@ -113,40 +122,40 @@ export function smsResetPassword(data: AuthResetPasswordReqVO) { * @param refreshToken 刷新token */ export function refreshToken(refreshToken: string) { - return http.post(`/system/auth/refresh-token?refreshToken=${refreshToken}`); + return http.post(`/system/auth/refresh-token?refreshToken=${refreshToken}`) } /** * 获取用户信息 */ export function getUserInfo() { - return http.get("/user/info"); + return http.get('/user/info') } /** * 获取权限信息 */ export function getAuthPermissionInfo() { - return http.get("/system/auth/get-permission-info"); + return http.get('/system/auth/get-permission-info') } /** 退出登录 */ export function logout() { - return http.post("/system/auth/logout"); + return http.post('/system/auth/logout') } /** * 修改用户信息 */ export function updateInfo(data: IUpdateInfo) { - return http.post("/user/updateInfo", data); + return http.post('/user/updateInfo', data) } /** * 修改用户密码 */ export function updateUserPassword(data: IUpdatePassword) { - return http.post("/user/updatePassword", data); + return http.post('/user/updatePassword', data) } /** @@ -156,11 +165,11 @@ export function updateUserPassword(data: IUpdatePassword) { export function getWxCode() { return new Promise((resolve, reject) => { uni.login({ - provider: "weixin", - success: (res) => resolve(res), - fail: (err) => reject(new Error(err)), - }); - }); + provider: 'weixin', + success: res => resolve(res), + fail: err => reject(new Error(err)), + }) + }) } /** @@ -169,5 +178,5 @@ export function getWxCode() { * @returns Promise 包含登录结果 */ export function wxLogin(data: { code: string }) { - return http.post("/auth/wxLogin", data); + return http.post('/auth/wxLogin', data) } diff --git a/src/http/http.ts b/src/http/http.ts index 3f4b24a..8d68064 100644 --- a/src/http/http.ts +++ b/src/http/http.ts @@ -64,8 +64,7 @@ export function http(options: CustomRequestOptions) { }) // 将任务队列的所有任务重新请求 taskQueue.forEach(task => task()) - } - catch (refreshErr) { + } catch (refreshErr) { console.error('刷新 token 失败:', refreshErr) refreshing = false // 刷新 token 失败,跳转到登录页 @@ -90,8 +89,7 @@ export function http(options: CustomRequestOptions) { } toLoginPage({ queryString }) }, 2000) - } - finally { + } finally { // 不管刷新 token 成功与否,都清空任务队列 taskQueue = [] } @@ -102,6 +100,10 @@ export function http(options: CustomRequestOptions) { // 处理其他成功状态(HTTP状态码200-299) if (res.statusCode >= 200 && res.statusCode < 300) { + // add by panda 25.12.10:如果设置了 original 为 true,则返回原始数据 + if (options.original) { + return resolve(responseData as unknown as T) + } // 处理业务逻辑错误 if (code !== ResultEnum.Success0 && code !== ResultEnum.Success200) { // add by 芋艿:后端返回的 msg 提示 @@ -198,8 +200,24 @@ export function httpDelete(url: string, query?: Record, header?: }) } +/** + * POST 请求(返回原始数据) + */ +export function httpPostOriginal(url: string, data?: Record, query?: Record, header?: Record, options?: Partial) { + return http({ + url, + data, + query, + method: 'POST', + header, + original: true, + ...options, + }) +} + // 支持与 axios 类似的API调用 http.get = httpGet http.post = httpPost http.put = httpPut http.delete = httpDelete +http.postOriginal = httpPostOriginal diff --git a/src/http/types.ts b/src/http/types.ts index 0928666..0d0e1e1 100644 --- a/src/http/types.ts +++ b/src/http/types.ts @@ -5,6 +5,8 @@ export type CustomRequestOptions = UniApp.RequestOptions & { query?: Record /** 出错时是否隐藏错误提示 */ hideErrorToast?: boolean + /** 是否返回原始数据 add by panda 25.12.10 */ + original?: boolean } & IUniUploadFileOptions // 添加uni.uploadFile参数类型 // 通用响应格式(兼容 msg + message 字段) @@ -32,6 +34,3 @@ export interface PageResult { list: T[] total: number } - -/** 加载状态枚举 - 从 wot-design-uni 重新导出 */ -export type { LoadMoreState } from 'wot-design-uni/components/wd-loadmore/types' diff --git a/src/pages/auth/components/Verifition/Verify.vue b/src/pages/auth/components/Verifition/Verify.vue new file mode 100644 index 0000000..ce8a519 --- /dev/null +++ b/src/pages/auth/components/Verifition/Verify.vue @@ -0,0 +1,432 @@ + + + + + diff --git a/src/pages/auth/components/Verifition/Verify/VerifyPoints.vue b/src/pages/auth/components/Verifition/Verify/VerifyPoints.vue new file mode 100644 index 0000000..b67af36 --- /dev/null +++ b/src/pages/auth/components/Verifition/Verify/VerifyPoints.vue @@ -0,0 +1,251 @@ + + + diff --git a/src/pages/auth/components/Verifition/Verify/VerifySlide.vue b/src/pages/auth/components/Verifition/Verify/VerifySlide.vue new file mode 100644 index 0000000..f1b11d8 --- /dev/null +++ b/src/pages/auth/components/Verifition/Verify/VerifySlide.vue @@ -0,0 +1,345 @@ + + + diff --git a/src/pages/auth/components/Verifition/utils/ase.ts b/src/pages/auth/components/Verifition/utils/ase.ts new file mode 100644 index 0000000..12e0ffd --- /dev/null +++ b/src/pages/auth/components/Verifition/utils/ase.ts @@ -0,0 +1,14 @@ +import CryptoJS from 'crypto-js' +/** + * @word 要加密的内容 + * @keyWord String 服务器随机返回的关键字 + */ +export function aesEncrypt(word, keyWord = 'XwKsGlMcdPMEhR1B') { + const key = CryptoJS.enc.Utf8.parse(keyWord) + const srcs = CryptoJS.enc.Utf8.parse(word) + const encrypted = CryptoJS.AES.encrypt(srcs, key, { + mode: CryptoJS.mode.ECB, + padding: CryptoJS.pad.Pkcs7, + }) + return encrypted.toString() +} diff --git a/src/pages/auth/login.vue b/src/pages/auth/login.vue index 8318762..0149df0 100644 --- a/src/pages/auth/login.vue +++ b/src/pages/auth/login.vue @@ -27,7 +27,12 @@ no-border /> - + + + @@ -70,107 +75,127 @@