feat(mini-app): 重构微信小程序前台,完善详情页模块并优化登录流程

- 新增详情页全套UI组件,重构详情页面的代码结构与业务逻辑
- 删除单独的登录页面与对应路由,将登录逻辑集成至个人中心页面
- 统一多页面组件的UI圆角样式,优化部分组件的布局与交互
- 调整玩法页面的跳转逻辑,点击路线卡片直接跳转至详情页
- 优化管家页面的tabBar显示隐藏与页面滚动锁定逻辑
- 更新首页团建项目的文案内容,简化描述文本
- 更新README文档,删除冗余的测试文件与废弃的路由配置
- 修复联系弹窗的事件触发逻辑,新增opened事件支持
This commit is contained in:
duanshuwen
2026-08-13 21:56:23 +08:00
parent 988f7c3f4c
commit d5a4f7549b
22 changed files with 527 additions and 332 deletions

View File

@@ -1,62 +0,0 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import {
clearAuthSession,
getAuthSession,
isLoggedIn,
maskPhone,
requireLogin,
saveAuthSession,
} from "@/lib/auth";
function installUniStorageMock() {
const storage = new Map<string, unknown>();
const navigateTo = vi.fn();
(globalThis as unknown as { uni: unknown }).uni = {
getStorageSync: (key: string) => storage.get(key),
setStorageSync: (key: string, value: unknown) => storage.set(key, value),
removeStorageSync: (key: string) => storage.delete(key),
navigateTo,
};
return { navigateTo, storage };
}
describe("miniapp auth helpers", () => {
beforeEach(() => {
vi.restoreAllMocks();
});
it("stores and clears the customer auth session", () => {
installUniStorageMock();
saveAuthSession({
token: "customer-token",
customer: { id: "customer-test", phoneMasked: "100****0000" },
});
expect(isLoggedIn()).toBe(true);
expect(getAuthSession()).toEqual({
token: "customer-token",
customer: { id: "customer-test", phoneMasked: "100****0000" },
});
clearAuthSession();
expect(isLoggedIn()).toBe(false);
expect(getAuthSession()).toBeNull();
});
it("redirects anonymous users to login with an encoded target", () => {
const { navigateTo } = installUniStorageMock();
const allowed = requireLogin("/pages/mine/index");
expect(allowed).toBe(false);
expect(navigateTo).toHaveBeenCalledWith({
url: "/pages/login/index?redirect=%2Fpages%2Fmine%2Findex",
});
});
it("masks phone numbers before rendering them on the client", () => {
expect(maskPhone("10000000000")).toBe("100****0000");
});
});