1111111
This commit is contained in:
+22
-1
@@ -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<IAppOption>({
|
||||
globalData: {
|
||||
isLogin: false, // 当前是否登录
|
||||
isLogin: false, //
|
||||
wasLogin: false, // 之前是否登录过,用来判断是不是 登录状态失效
|
||||
safeBottom: systemInfo.safeArea.bottom - systemInfo.safeArea.height,
|
||||
safeTop: systemInfo.safeArea.top * 2,
|
||||
@@ -20,6 +30,17 @@ App<IAppOption>({
|
||||
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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 });
|
||||
},
|
||||
});
|
||||
@@ -9,6 +9,17 @@
|
||||
<view class="edit-btn" bindtap="goEdit">{{member.name ? '编辑信息' : '添加信息'}}</view>
|
||||
</view>
|
||||
|
||||
<!-- 红包记录入口 -->
|
||||
<view class="red-packet-card" bindtap="goRedHistory">
|
||||
<view class="red-packet-left">
|
||||
<view class="red-packet-icon">
|
||||
<text class="icon-text">🧧</text>
|
||||
</view>
|
||||
<view class="red-packet-title">红包记录</view>
|
||||
</view>
|
||||
<view class="red-packet-arrow">›</view>
|
||||
</view>
|
||||
|
||||
<!-- 成员详细信息 -->
|
||||
<view class="content" wx:if="{{member.name}}">
|
||||
<view class="info-card">
|
||||
|
||||
@@ -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 = <T = any>(
|
||||
@@ -16,7 +25,7 @@ export const request = <T = any>(
|
||||
): Promise<T> => {
|
||||
const app = getApp<IAppOption>();
|
||||
const header: any = {
|
||||
"X-Fingerprint": fingerprint,
|
||||
"X-Fingerprint": generateFingerprint(),
|
||||
};
|
||||
if (needLogin) {
|
||||
if (!app.checkLoginState()) {
|
||||
|
||||
@@ -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"]
|
||||
}
|
||||
Vendored
+6
-6
@@ -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<any>,
|
||||
getTemplate?: () => Promise<any>,
|
||||
// serverSentEvents: () => void,
|
||||
userInfoReadyCallback?: WechatMiniprogram.GetUserInfoSuccessCallback,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user