1111111
This commit is contained in:
+22
-1
@@ -1,12 +1,22 @@
|
|||||||
// app.ts
|
// app.ts
|
||||||
import { startSSE, stopSSE } from './utils/server-sent-events'
|
import { startSSE, stopSSE } from './utils/server-sent-events'
|
||||||
import { checkUpdate } from './utils/updateManager'
|
import { checkUpdate } from './utils/updateManager'
|
||||||
|
import { BASE_URL } from './env'
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const systemInfo = wx.getWindowInfo();
|
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 { };
|
export { };
|
||||||
App<IAppOption>({
|
App<IAppOption>({
|
||||||
globalData: {
|
globalData: {
|
||||||
isLogin: false, // 当前是否登录
|
isLogin: false, //
|
||||||
wasLogin: false, // 之前是否登录过,用来判断是不是 登录状态失效
|
wasLogin: false, // 之前是否登录过,用来判断是不是 登录状态失效
|
||||||
safeBottom: systemInfo.safeArea.bottom - systemInfo.safeArea.height,
|
safeBottom: systemInfo.safeArea.bottom - systemInfo.safeArea.height,
|
||||||
safeTop: systemInfo.safeArea.top * 2,
|
safeTop: systemInfo.safeArea.top * 2,
|
||||||
@@ -20,6 +30,17 @@ App<IAppOption>({
|
|||||||
isModalShowing: false, //防止有多个登录弹窗打开
|
isModalShowing: false, //防止有多个登录弹窗打开
|
||||||
},
|
},
|
||||||
async onLaunch(props: any) {
|
async onLaunch(props: any) {
|
||||||
|
// 非测试环境在 PC 端打开时提示无法使用
|
||||||
|
if (!isTestDomain() && isPCEnvironment()) {
|
||||||
|
wx.showModal({
|
||||||
|
title: "提示",
|
||||||
|
content: "该环境无法使用",
|
||||||
|
showCancel: false,
|
||||||
|
confirmText: "我知道了"
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wx.removeStorageSync("state");
|
wx.removeStorageSync("state");
|
||||||
if (props.query.state) {
|
if (props.query.state) {
|
||||||
wx.setStorageSync("state", props.query.state)
|
wx.setStorageSync("state", props.query.state)
|
||||||
|
|||||||
@@ -85,3 +85,51 @@
|
|||||||
background: linear-gradient(135deg, #4A90D9, #357ABD);
|
background: linear-gradient(135deg, #4A90D9, #357ABD);
|
||||||
color: #fff; font-size: 28rpx; font-weight: 600; border-radius: 36rpx;
|
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;
|
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({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
member: {} as FamilyMember,
|
member: {} as FamilyMember,
|
||||||
},
|
},
|
||||||
onLoad() {},
|
|
||||||
onShow() {
|
onShow() {
|
||||||
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
|
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
|
||||||
this.getTabBar().setData({ selected: 3 });
|
this.getTabBar().setData({ selected: 3 });
|
||||||
@@ -25,10 +25,13 @@ Page({
|
|||||||
this.loadMember();
|
this.loadMember();
|
||||||
},
|
},
|
||||||
loadMember() {
|
loadMember() {
|
||||||
const member = wx.getStorageSync(MEMBER_KEY) || {};
|
const member = wx.getStorageSync('family_member') || {};
|
||||||
this.setData({ member });
|
this.setData({ member });
|
||||||
},
|
},
|
||||||
goEdit() {
|
goEdit() {
|
||||||
wx.navigateTo({ url: '/pages/tab-bar/profile/edit/index' });
|
wx.navigateTo({ url: EDIT_URL });
|
||||||
|
},
|
||||||
|
goRedHistory() {
|
||||||
|
wx.navigateTo({ url: RED_HISTORY_URL });
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -7,9 +7,20 @@
|
|||||||
<view class="name">{{member.name || '点击添加家庭成员'}}</view>
|
<view class="name">{{member.name || '点击添加家庭成员'}}</view>
|
||||||
<view class="relation" wx:if="{{member.relation}}">{{member.relation}}</view>
|
<view class="relation" wx:if="{{member.relation}}">{{member.relation}}</view>
|
||||||
<view class="edit-btn" bindtap="goEdit">{{member.name ? '编辑信息' : '添加信息'}}</view>
|
<view class="edit-btn" bindtap="goEdit">{{member.name ? '编辑信息' : '添加信息'}}</view>
|
||||||
</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="content" wx:if="{{member.name}}">
|
||||||
<view class="info-card">
|
<view class="info-card">
|
||||||
<view class="info-row">
|
<view class="info-row">
|
||||||
|
|||||||
@@ -7,8 +7,17 @@ type RequestProps = {
|
|||||||
needLogin?: boolean;
|
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>(
|
export const request = <T = any>(
|
||||||
@@ -16,7 +25,7 @@ export const request = <T = any>(
|
|||||||
): Promise<T> => {
|
): Promise<T> => {
|
||||||
const app = getApp<IAppOption>();
|
const app = getApp<IAppOption>();
|
||||||
const header: any = {
|
const header: any = {
|
||||||
"X-Fingerprint": fingerprint,
|
"X-Fingerprint": generateFingerprint(),
|
||||||
};
|
};
|
||||||
if (needLogin) {
|
if (needLogin) {
|
||||||
if (!app.checkLoginState()) {
|
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,
|
userInfo?: WechatMiniprogram.UserInfo,
|
||||||
isLogin?: boolean,
|
isLogin?: boolean,
|
||||||
wasLogin?: boolean,
|
wasLogin?: boolean,
|
||||||
template: TemplateType | null,
|
template?: TemplateType | null,
|
||||||
showStock: boolean,
|
showStock?: boolean,
|
||||||
store?: any,
|
store?: any,
|
||||||
joinedArray: string[],
|
joinedArray: string[],
|
||||||
safeBottom: number,
|
safeBottom: number,
|
||||||
safeTop: number,
|
safeTop: number,
|
||||||
tabbarMap: TabbarMapType,
|
tabbarMap?: TabbarMapType,
|
||||||
tabbarItems: any[],
|
tabbarItems?: any[],
|
||||||
sseStore: any,
|
sseStore: any,
|
||||||
isModalShowing: Boolean
|
isModalShowing: Boolean
|
||||||
},
|
},
|
||||||
getPageParams: (id: number) => any,
|
getPageParams?: (id: number) => any,
|
||||||
checkLoginState: () => boolean,
|
checkLoginState: () => boolean,
|
||||||
redirectLogin: () => any,
|
redirectLogin: () => any,
|
||||||
login: (value: string) => boolean,
|
login: (value: string) => boolean,
|
||||||
getTemplate: () => Promise<any>,
|
getTemplate?: () => Promise<any>,
|
||||||
// serverSentEvents: () => void,
|
// serverSentEvents: () => void,
|
||||||
userInfoReadyCallback?: WechatMiniprogram.GetUserInfoSuccessCallback,
|
userInfoReadyCallback?: WechatMiniprogram.GetUserInfoSuccessCallback,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user