From 5a27caee6d7b6bd0b3839c789a85e3e734705cda Mon Sep 17 00:00:00 2001 From: cao123 Date: Thu, 13 Aug 2026 14:28:23 +0800 Subject: [PATCH] 1111111 --- miniprogram/app.ts | 23 +++++++++- miniprogram/pages/tab-bar/profile/index.scss | 48 ++++++++++++++++++++ miniprogram/pages/tab-bar/profile/index.ts | 13 ++++-- miniprogram/pages/tab-bar/profile/index.wxml | 15 +++++- miniprogram/utils/request.ts | 15 ++++-- tsconfig.json | 33 ++++++++++++++ typings/index.d.ts | 12 ++--- 7 files changed, 142 insertions(+), 17 deletions(-) create mode 100644 tsconfig.json diff --git a/miniprogram/app.ts b/miniprogram/app.ts index 26b2e5a..5ffdd8c 100644 --- a/miniprogram/app.ts +++ b/miniprogram/app.ts @@ -1,12 +1,22 @@ // app.ts import { startSSE, stopSSE } from './utils/server-sent-events' import { checkUpdate } from './utils/updateManager' +import { BASE_URL } from './env' // @ts-ignore const systemInfo = wx.getWindowInfo(); + +// 域名包含 .test. 则为测试环境,不拦截登录 +const isTestDomain = (): boolean => BASE_URL.includes('.test.'); + +// 判断是否在 PC/Windows 环境运行 +const isPCEnvironment = (): boolean => { + const sysInfo = wx.getSystemInfoSync(); + return ['windows', 'mac'].includes(sysInfo.platform); +}; export { }; App({ globalData: { - isLogin: false, // 当前是否登录 + isLogin: false, // wasLogin: false, // 之前是否登录过,用来判断是不是 登录状态失效 safeBottom: systemInfo.safeArea.bottom - systemInfo.safeArea.height, safeTop: systemInfo.safeArea.top * 2, @@ -20,6 +30,17 @@ App({ isModalShowing: false, //防止有多个登录弹窗打开 }, async onLaunch(props: any) { + // 非测试环境在 PC 端打开时提示无法使用 + if (!isTestDomain() && isPCEnvironment()) { + wx.showModal({ + title: "提示", + content: "该环境无法使用", + showCancel: false, + confirmText: "我知道了" + }); + return; + } + wx.removeStorageSync("state"); if (props.query.state) { wx.setStorageSync("state", props.query.state) diff --git a/miniprogram/pages/tab-bar/profile/index.scss b/miniprogram/pages/tab-bar/profile/index.scss index 94b69a3..2ac914c 100644 --- a/miniprogram/pages/tab-bar/profile/index.scss +++ b/miniprogram/pages/tab-bar/profile/index.scss @@ -85,3 +85,51 @@ background: linear-gradient(135deg, #4A90D9, #357ABD); color: #fff; font-size: 28rpx; font-weight: 600; border-radius: 36rpx; } + +/* 红包记录入口 */ +.red-packet-card { + display: flex; + align-items: center; + justify-content: space-between; + margin: 24rpx 30rpx 0; + padding: 24rpx 28rpx; + background: #fff; + border-radius: 16rpx; + box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04); +} + +.red-packet-card:active { + background: #f8f8f8; +} + +.red-packet-left { + display: flex; + align-items: center; +} + +.red-packet-icon { + width: 64rpx; + height: 64rpx; + display: flex; + align-items: center; + justify-content: center; + background: #FFF0F0; + border-radius: 12rpx; + margin-right: 20rpx; +} + +.icon-text { + font-size: 34rpx; + line-height: 1; +} + +.red-packet-title { + font-size: 28rpx; + font-weight: 500; + color: #333; +} + +.red-packet-arrow { + font-size: 36rpx; + color: #ccc; +} diff --git a/miniprogram/pages/tab-bar/profile/index.ts b/miniprogram/pages/tab-bar/profile/index.ts index 82a9daa..ed0cbbb 100644 --- a/miniprogram/pages/tab-bar/profile/index.ts +++ b/miniprogram/pages/tab-bar/profile/index.ts @@ -11,13 +11,13 @@ interface FamilyMember { notes: string; } -const MEMBER_KEY = 'family_member'; +const EDIT_URL = '/pages/tab-bar/profile/edit/index'; +const RED_HISTORY_URL = '/pages/live/red-history/red-history'; Page({ data: { member: {} as FamilyMember, }, - onLoad() {}, onShow() { if (typeof this.getTabBar === 'function' && this.getTabBar()) { this.getTabBar().setData({ selected: 3 }); @@ -25,10 +25,13 @@ Page({ this.loadMember(); }, loadMember() { - const member = wx.getStorageSync(MEMBER_KEY) || {}; + const member = wx.getStorageSync('family_member') || {}; this.setData({ member }); }, goEdit() { - wx.navigateTo({ url: '/pages/tab-bar/profile/edit/index' }); + wx.navigateTo({ url: EDIT_URL }); }, -}); + goRedHistory() { + wx.navigateTo({ url: RED_HISTORY_URL }); + }, +}); \ No newline at end of file diff --git a/miniprogram/pages/tab-bar/profile/index.wxml b/miniprogram/pages/tab-bar/profile/index.wxml index 66280f4..0ae74bf 100644 --- a/miniprogram/pages/tab-bar/profile/index.wxml +++ b/miniprogram/pages/tab-bar/profile/index.wxml @@ -7,9 +7,20 @@ {{member.name || '点击添加家庭成员'}} {{member.relation}} {{member.name ? '编辑信息' : '添加信息'}} - + - + + + + + 🧧 + + 红包记录 + + + + + diff --git a/miniprogram/utils/request.ts b/miniprogram/utils/request.ts index 63dcb84..3df67d1 100644 --- a/miniprogram/utils/request.ts +++ b/miniprogram/utils/request.ts @@ -7,8 +7,17 @@ type RequestProps = { needLogin?: boolean; }; -// 每次请求动态生成 header,确保使用最新的 openId -const fingerprint = wx.getSystemInfoSync(); +// 生成设备指纹字符串 +const generateFingerprint = (): string => { + const info = wx.getSystemInfoSync(); + return [ + String(info.system), + String(info.platform), + String(info.SDKVersion), + String(info.screenWidth), + String(info.screenHeight), + ].join("&"); +}; export const request = ( @@ -16,7 +25,7 @@ export const request = ( ): Promise => { const app = getApp(); const header: any = { - "X-Fingerprint": fingerprint, + "X-Fingerprint": generateFingerprint(), }; if (needLogin) { if (!app.checkLoginState()) { diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..16c8541 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,33 @@ +{ + "compilerOptions": { + "strictNullChecks": true, + "noImplicitAny": true, + "module": "CommonJS", + "target": "ES2020", + "allowJs": true, + "isolatedModules": true, + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "experimentalDecorators": true, + "noImplicitThis": true, + "noImplicitReturns": true, + "alwaysStrict": true, + "noFallthroughCasesInSwitch": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "strict": true, + "strictPropertyInitialization": true, + "ignoreDeprecations": "6.0", + "baseUrl": ".", + "types": ["miniprogram-api-typings"], + "paths": { + "@vant/weapp/*": ["path/to/node_modules/@vant/weapp/dist/*"] + }, + "lib": ["ES2020"], + "typeRoots": ["./typings"], + "rootDir": "./miniprogram", + "outDir": "./dist" + }, + "include": ["./**/*.ts"], + "exclude": ["node_modules", "dist"] +} diff --git a/typings/index.d.ts b/typings/index.d.ts index 47ea751..a201e36 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -28,22 +28,22 @@ interface IAppOption { userInfo?: WechatMiniprogram.UserInfo, isLogin?: boolean, wasLogin?: boolean, - template: TemplateType | null, - showStock: boolean, + template?: TemplateType | null, + showStock?: boolean, store?: any, joinedArray: string[], safeBottom: number, safeTop: number, - tabbarMap: TabbarMapType, - tabbarItems: any[], + tabbarMap?: TabbarMapType, + tabbarItems?: any[], sseStore: any, isModalShowing: Boolean }, - getPageParams: (id: number) => any, + getPageParams?: (id: number) => any, checkLoginState: () => boolean, redirectLogin: () => any, login: (value: string) => boolean, - getTemplate: () => Promise, + getTemplate?: () => Promise, // serverSentEvents: () => void, userInfoReadyCallback?: WechatMiniprogram.GetUserInfoSuccessCallback, }