Leon 2 年 前
コミット
9965993e51

+ 0 - 138
ios/hola.xcodeproj/project.pbxproj

@@ -8,12 +8,10 @@
 
 /* Begin PBXBuildFile section */
 		00E356F31AD99517003FC87E /* holaTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* holaTests.m */; };
-		0C80B921A6F3F58F76C31292 /* libPods-hola.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5DCACB8F33CDC322A6C60F78 /* libPods-hola.a */; };
 		13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.mm */; };
 		13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
 		13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
 		579F4B7496BF069C27C20BC7 /* ExpoModulesProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 064FE7D59874E5A1126C807C /* ExpoModulesProvider.swift */; };
-		7699B88040F8A987B510C191 /* libPods-hola-holaTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 19F6CBCC0A4E27FBF8BF4A61 /* libPods-hola-holaTests.a */; };
 		81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
 		D840888E11B75659D34CCA71 /* ExpoModulesProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = ED392737ABFDE2508D91B66F /* ExpoModulesProvider.swift */; };
 /* End PBXBuildFile section */
@@ -39,13 +37,7 @@
 		13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = hola/Images.xcassets; sourceTree = "<group>"; };
 		13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = hola/Info.plist; sourceTree = "<group>"; };
 		13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = hola/main.m; sourceTree = "<group>"; };
-		19F6CBCC0A4E27FBF8BF4A61 /* libPods-hola-holaTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-hola-holaTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
-		3B4392A12AC88292D35C810B /* Pods-hola.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-hola.debug.xcconfig"; path = "Target Support Files/Pods-hola/Pods-hola.debug.xcconfig"; sourceTree = "<group>"; };
-		5709B34CF0A7D63546082F79 /* Pods-hola.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-hola.release.xcconfig"; path = "Target Support Files/Pods-hola/Pods-hola.release.xcconfig"; sourceTree = "<group>"; };
-		5B7EB9410499542E8C5724F5 /* Pods-hola-holaTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-hola-holaTests.debug.xcconfig"; path = "Target Support Files/Pods-hola-holaTests/Pods-hola-holaTests.debug.xcconfig"; sourceTree = "<group>"; };
-		5DCACB8F33CDC322A6C60F78 /* libPods-hola.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-hola.a"; sourceTree = BUILT_PRODUCTS_DIR; };
 		81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = hola/LaunchScreen.storyboard; sourceTree = "<group>"; };
-		89C6BE57DB24E9ADA2F236DE /* Pods-hola-holaTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-hola-holaTests.release.xcconfig"; path = "Target Support Files/Pods-hola-holaTests/Pods-hola-holaTests.release.xcconfig"; sourceTree = "<group>"; };
 		ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
 		ED392737ABFDE2508D91B66F /* ExpoModulesProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = ExpoModulesProvider.swift; path = "Pods/Target Support Files/Pods-hola/ExpoModulesProvider.swift"; sourceTree = "<group>"; };
 /* End PBXFileReference section */
@@ -55,7 +47,6 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				7699B88040F8A987B510C191 /* libPods-hola-holaTests.a in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -63,7 +54,6 @@
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
-				0C80B921A6F3F58F76C31292 /* libPods-hola.a in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -104,8 +94,6 @@
 			isa = PBXGroup;
 			children = (
 				ED297162215061F000B7C4FE /* JavaScriptCore.framework */,
-				5DCACB8F33CDC322A6C60F78 /* libPods-hola.a */,
-				19F6CBCC0A4E27FBF8BF4A61 /* libPods-hola-holaTests.a */,
 			);
 			name = Frameworks;
 			sourceTree = "<group>";
@@ -162,10 +150,6 @@
 		BBD78D7AC51CEA395F1C20DB /* Pods */ = {
 			isa = PBXGroup;
 			children = (
-				3B4392A12AC88292D35C810B /* Pods-hola.debug.xcconfig */,
-				5709B34CF0A7D63546082F79 /* Pods-hola.release.xcconfig */,
-				5B7EB9410499542E8C5724F5 /* Pods-hola-holaTests.debug.xcconfig */,
-				89C6BE57DB24E9ADA2F236DE /* Pods-hola-holaTests.release.xcconfig */,
 			);
 			path = Pods;
 			sourceTree = "<group>";
@@ -185,12 +169,9 @@
 			isa = PBXNativeTarget;
 			buildConfigurationList = 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "holaTests" */;
 			buildPhases = (
-				A55EABD7B0C7F3A422A6CC61 /* [CP] Check Pods Manifest.lock */,
 				00E356EA1AD99517003FC87E /* Sources */,
 				00E356EB1AD99517003FC87E /* Frameworks */,
 				00E356EC1AD99517003FC87E /* Resources */,
-				C59DA0FBD6956966B86A3779 /* [CP] Embed Pods Frameworks */,
-				F6A41C54EA430FDDC6A6ED99 /* [CP] Copy Pods Resources */,
 			);
 			buildRules = (
 			);
@@ -206,14 +187,11 @@
 			isa = PBXNativeTarget;
 			buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "hola" */;
 			buildPhases = (
-				C38B50BA6285516D6DCD4F65 /* [CP] Check Pods Manifest.lock */,
 				FD10A7F022414F080027D42C /* Start Packager */,
 				13B07F871A680F5B00A75B9A /* Sources */,
 				13B07F8C1A680F5B00A75B9A /* Frameworks */,
 				13B07F8E1A680F5B00A75B9A /* Resources */,
 				00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
-				00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */,
-				E235C05ADACE081382539298 /* [CP] Copy Pods Resources */,
 			);
 			buildRules = (
 			);
@@ -296,118 +274,6 @@
 			shellPath = /bin/sh;
 			shellScript = "set -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n";
 		};
-		00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */ = {
-			isa = PBXShellScriptBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			inputFileListPaths = (
-				"${PODS_ROOT}/Target Support Files/Pods-hola/Pods-hola-frameworks-${CONFIGURATION}-input-files.xcfilelist",
-			);
-			name = "[CP] Embed Pods Frameworks";
-			outputFileListPaths = (
-				"${PODS_ROOT}/Target Support Files/Pods-hola/Pods-hola-frameworks-${CONFIGURATION}-output-files.xcfilelist",
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-			shellPath = /bin/sh;
-			shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-hola/Pods-hola-frameworks.sh\"\n";
-			showEnvVarsInLog = 0;
-		};
-		A55EABD7B0C7F3A422A6CC61 /* [CP] Check Pods Manifest.lock */ = {
-			isa = PBXShellScriptBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			inputFileListPaths = (
-			);
-			inputPaths = (
-				"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
-				"${PODS_ROOT}/Manifest.lock",
-			);
-			name = "[CP] Check Pods Manifest.lock";
-			outputFileListPaths = (
-			);
-			outputPaths = (
-				"$(DERIVED_FILE_DIR)/Pods-hola-holaTests-checkManifestLockResult.txt",
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-			shellPath = /bin/sh;
-			shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n    # print error to STDERR\n    echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n    exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
-			showEnvVarsInLog = 0;
-		};
-		C38B50BA6285516D6DCD4F65 /* [CP] Check Pods Manifest.lock */ = {
-			isa = PBXShellScriptBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			inputFileListPaths = (
-			);
-			inputPaths = (
-				"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
-				"${PODS_ROOT}/Manifest.lock",
-			);
-			name = "[CP] Check Pods Manifest.lock";
-			outputFileListPaths = (
-			);
-			outputPaths = (
-				"$(DERIVED_FILE_DIR)/Pods-hola-checkManifestLockResult.txt",
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-			shellPath = /bin/sh;
-			shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n    # print error to STDERR\n    echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n    exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
-			showEnvVarsInLog = 0;
-		};
-		C59DA0FBD6956966B86A3779 /* [CP] Embed Pods Frameworks */ = {
-			isa = PBXShellScriptBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			inputFileListPaths = (
-				"${PODS_ROOT}/Target Support Files/Pods-hola-holaTests/Pods-hola-holaTests-frameworks-${CONFIGURATION}-input-files.xcfilelist",
-			);
-			name = "[CP] Embed Pods Frameworks";
-			outputFileListPaths = (
-				"${PODS_ROOT}/Target Support Files/Pods-hola-holaTests/Pods-hola-holaTests-frameworks-${CONFIGURATION}-output-files.xcfilelist",
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-			shellPath = /bin/sh;
-			shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-hola-holaTests/Pods-hola-holaTests-frameworks.sh\"\n";
-			showEnvVarsInLog = 0;
-		};
-		E235C05ADACE081382539298 /* [CP] Copy Pods Resources */ = {
-			isa = PBXShellScriptBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			inputFileListPaths = (
-				"${PODS_ROOT}/Target Support Files/Pods-hola/Pods-hola-resources-${CONFIGURATION}-input-files.xcfilelist",
-			);
-			name = "[CP] Copy Pods Resources";
-			outputFileListPaths = (
-				"${PODS_ROOT}/Target Support Files/Pods-hola/Pods-hola-resources-${CONFIGURATION}-output-files.xcfilelist",
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-			shellPath = /bin/sh;
-			shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-hola/Pods-hola-resources.sh\"\n";
-			showEnvVarsInLog = 0;
-		};
-		F6A41C54EA430FDDC6A6ED99 /* [CP] Copy Pods Resources */ = {
-			isa = PBXShellScriptBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-			);
-			inputFileListPaths = (
-				"${PODS_ROOT}/Target Support Files/Pods-hola-holaTests/Pods-hola-holaTests-resources-${CONFIGURATION}-input-files.xcfilelist",
-			);
-			name = "[CP] Copy Pods Resources";
-			outputFileListPaths = (
-				"${PODS_ROOT}/Target Support Files/Pods-hola-holaTests/Pods-hola-holaTests-resources-${CONFIGURATION}-output-files.xcfilelist",
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-			shellPath = /bin/sh;
-			shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-hola-holaTests/Pods-hola-holaTests-resources.sh\"\n";
-			showEnvVarsInLog = 0;
-		};
 		FD10A7F022414F080027D42C /* Start Packager */ = {
 			isa = PBXShellScriptBuildPhase;
 			buildActionMask = 2147483647;
@@ -462,7 +328,6 @@
 /* Begin XCBuildConfiguration section */
 		00E356F61AD99517003FC87E /* Debug */ = {
 			isa = XCBuildConfiguration;
-			baseConfigurationReference = 5B7EB9410499542E8C5724F5 /* Pods-hola-holaTests.debug.xcconfig */;
 			buildSettings = {
 				BUNDLE_LOADER = "$(TEST_HOST)";
 				CODE_SIGN_STYLE = Manual;
@@ -492,7 +357,6 @@
 		};
 		00E356F71AD99517003FC87E /* Release */ = {
 			isa = XCBuildConfiguration;
-			baseConfigurationReference = 89C6BE57DB24E9ADA2F236DE /* Pods-hola-holaTests.release.xcconfig */;
 			buildSettings = {
 				BUNDLE_LOADER = "$(TEST_HOST)";
 				CODE_SIGN_STYLE = Manual;
@@ -519,7 +383,6 @@
 		};
 		13B07F941A680F5B00A75B9A /* Debug */ = {
 			isa = XCBuildConfiguration;
-			baseConfigurationReference = 3B4392A12AC88292D35C810B /* Pods-hola.debug.xcconfig */;
 			buildSettings = {
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CLANG_ENABLE_MODULES = YES;
@@ -549,7 +412,6 @@
 		};
 		13B07F951A680F5B00A75B9A /* Release */ = {
 			isa = XCBuildConfiguration;
-			baseConfigurationReference = 5709B34CF0A7D63546082F79 /* Pods-hola.release.xcconfig */;
 			buildSettings = {
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				CLANG_ENABLE_MODULES = YES;

+ 72 - 2
ios/hola/AppDelegate.mm

@@ -5,7 +5,7 @@
 #import <React/RCTRootView.h>
 
 #import <React/RCTAppSetupUtils.h>
-
+//#import <RCTJPushModule.h>
 #if RCT_NEW_ARCH_ENABLED
 #import <React/CoreModulesPlugins.h>
 #import <React/RCTCxxBridgeDelegate.h>
@@ -18,7 +18,7 @@
 
 static NSString *const kRNConcurrentRoot = @"concurrentRoot";
 
-@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> {
+@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate,JPUSHRegisterDelegate> {
   RCTTurboModuleManager *_turboModuleManager;
   RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
   std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
@@ -31,6 +31,13 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
 
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 {
+  // APNS
+//    JPUSHRegisterEntity * entity = [[JPUSHRegisterEntity alloc] init];
+//    if (@available(iOS 12.0, *)) {
+//      entity.types = JPAuthorizationOptionNone; //JPAuthorizationOptionAlert|JPAuthorizationOptionBadge|JPAuthorizationOptionSou//nd|JPAuthorizationOptionProvidesAppNotificationSettings;
+//    }
+//    [JPUSHService registerForRemoteNotificationConfig:entity delegate:self];
+  
   RCTAppSetupPrepareApp(application);
 
   RCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:launchOptions];
@@ -128,4 +135,67 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
 
 #endif
 
+//************************************************JPush start************************************************
+
+////注册 APNS 成功并上报 DeviceToken
+//- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
+//  [JPUSHService registerDeviceToken:deviceToken];
+//}
+//
+////iOS 7 APNS
+//- (void)application:(UIApplication *)application didReceiveRemoteNotification:  (NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
+//  // iOS 10 以下 Required
+//  NSLog(@"iOS 7 APNS");
+//  [JPUSHService handleRemoteNotification:userInfo];
+//  [[NSNotificationCenter defaultCenter] postNotificationName:J_APNS_NOTIFICATION_ARRIVED_EVENT object:userInfo];
+//  completionHandler(UIBackgroundFetchResultNewData);
+//}
+//
+////iOS 10 前台收到消息
+//- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center  willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler {
+//  NSDictionary * userInfo = notification.request.content.userInfo;
+//  if([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
+//    // Apns
+//    NSLog(@"iOS 10 APNS 前台收到消息");
+//    [JPUSHService handleRemoteNotification:userInfo];
+//    [[NSNotificationCenter defaultCenter] postNotificationName:J_APNS_NOTIFICATION_ARRIVED_EVENT object:userInfo];
+//  }
+//  else {
+//    // 本地通知 todo
+//    NSLog(@"iOS 10 本地通知 前台收到消息");
+//    [[NSNotificationCenter defaultCenter] postNotificationName:J_LOCAL_NOTIFICATION_ARRIVED_EVENT object:userInfo];
+//  }
+//  //需要执行这个方法,选择是否提醒用户,有 Badge、Sound、Alert 三种类型可以选择设置
+//  completionHandler(UNNotificationPresentationOptionAlert);
+//}
+//
+////iOS 10 消息事件回调
+//- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler: (void (^)(void))completionHandler {
+//  NSDictionary * userInfo = response.notification.request.content.userInfo;
+//  if([response.notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
+//    // Apns
+//    NSLog(@"iOS 10 APNS 消息事件回调");
+//    [JPUSHService handleRemoteNotification:userInfo];
+//    // 保障应用被杀死状态下,用户点击推送消息,打开app后可以收到点击通知事件
+//    [[RCTJPushEventQueue sharedInstance]._notificationQueue insertObject:userInfo atIndex:0];
+//    [[NSNotificationCenter defaultCenter] postNotificationName:J_APNS_NOTIFICATION_OPENED_EVENT object:userInfo];
+//  }
+//  else {
+//    // 本地通知
+//    NSLog(@"iOS 10 本地通知 消息事件回调");
+//    // 保障应用被杀死状态下,用户点击推送消息,打开app后可以收到点击通知事件
+//    [[RCTJPushEventQueue sharedInstance]._localNotificationQueue insertObject:userInfo atIndex:0];
+//    [[NSNotificationCenter defaultCenter] postNotificationName:J_LOCAL_NOTIFICATION_OPENED_EVENT object:userInfo];
+//  }
+//  // 系统要求执行这个方法
+//  completionHandler();
+//}
+//
+////自定义消息
+//- (void)networkDidReceiveMessage:(NSNotification *)notification {
+//  NSDictionary * userInfo = [notification userInfo];
+//  [[NSNotificationCenter defaultCenter] postNotificationName:J_CUSTOM_NOTIFICATION_EVENT object:userInfo];
+//}
+
+
 @end

+ 1 - 0
package.json

@@ -84,6 +84,7 @@
     "expo-sensors": "~12.0.1",
     "i18next": "^23.5.1",
     "i18next-browser-languagedetector": "^7.1.0",
+    "jpush-react-native": "^3.0.5",
     "react": "^18.1.0",
     "react-dom": "^18.1.0",
     "react-i18next": "^13.2.2",

+ 2 - 1
src/app.scss

@@ -113,6 +113,7 @@ page {
 
 .box_title{
     display: flex;
+    background-color: red;
     height: 48px;
     font-weight: bold;
     font-size: 48px;
@@ -124,7 +125,7 @@ page {
 .box_subtitle{
     font-size: 32px;
     line-height: 32px;
-    font-weight: 400px;
+    // font-weight: 400px;
     margin-bottom: 20px;
     opacity: 0.4;
     color: #fff;

+ 1 - 6
src/components/input/Switch.tsx

@@ -1,13 +1,8 @@
 import { View, Image } from "@tarojs/components";
 import './Switch.scss'
 import { IconSwitchOff } from "../basic/Icons";
-import Taro from "@tarojs/taro";
+import { rpxToPx } from "@/utils/tools";
 export default function Component(props: { isOn: boolean, onClick: Function }) {
-
-    function rpxToPx(n: number) {
-        var rate = Taro.getSystemInfoSync().windowWidth / 750;
-        return n * rate;
-    }
     if (process.env.TARO_ENV == 'weapp') {
         return <View className="switch1" style={{ backgroundColor: global.isDebug ? 'blue' : 'transparent' }} onClick={(e) => {
             if (process.env.TARO_ENV == 'weapp') {

+ 47 - 0
src/components/layout/Box.rn.tsx

@@ -0,0 +1,47 @@
+import { View, Text } from "@tarojs/components";
+import './Box.scss'
+import { BoxType } from "@/utils/types";
+import Taro from "@tarojs/taro";
+import { ColorType } from "@/context/themes/color";
+import { useState } from "react";
+import { LayoutChangeEvent,View as HView } from "react-native";
+import { rpxToPx } from "@/utils/tools";
+
+export default function Component(props: {
+    children: React.ReactNode,
+    title?: string,
+    header?: React.ReactNode,
+    style?: any,
+    type?: BoxType,
+    onClick?: Function,
+    tranparentBg?: boolean
+}) {
+
+    const [height, setHeight] = useState<number>(1000000);
+
+    const handleLayout = (event: LayoutChangeEvent) => {
+        console.log('oppsu1111')
+        const { height } = event.nativeEvent.layout;
+        console.log(height)
+        setHeight(height);
+    };
+
+    function onClick(e) {
+        if (props.onClick) {
+            props.onClick()
+            return
+        }
+        Taro.vibrateShort({
+            type: 'medium'
+        })
+    }
+
+    return <View className="box-container" style={{ ...props.style, backgroundColor: props.tranparentBg ? 'transparent' : ColorType.box,height:height+rpxToPx(80) }} onTap={onClick}>
+        {
+            props.title && <Text className="box-title">{props.title}</Text>
+        }
+        <HView onLayout={handleLayout}>
+            {props.children}
+        </HView>
+    </View>
+}

+ 1 - 0
src/components/layout/Box.scss

@@ -13,6 +13,7 @@
     flex-direction: column;
     margin-bottom: 24px;
     flex-shrink: 0;
+
     // position: relative;
 }
 

+ 2 - 4
src/components/layout/Box.tsx → src/components/layout/Box.weapp.tsx

@@ -36,13 +36,11 @@ export default function Component(props: {
                 </View>
             </View>
     }
-    return <View>
-        {props.header ? props.header : null}
-        <View className="box-container" style={{ ...props.style,backgroundColor:props.tranparentBg?'transparent':ColorType.box }} onTap={onClick}>
+
+    return <View className="box-container" style={{ ...props.style,backgroundColor:props.tranparentBg?'transparent':ColorType.box }} onTap={onClick}>
             {
                 props.title && <Text className="box-title">{props.title}</Text>
             }
             {props.children}
         </View>
-    </View>;
 }

+ 1 - 4
src/components/layout/SectionHeader.tsx

@@ -1,6 +1,7 @@
 import { View, Text } from '@tarojs/components'
 import './SectionHeader.scss'
 import Taro from '@tarojs/taro';
+import { rpxToPx } from '@/utils/tools';
 
 export default function Component(props: {
     top: number,
@@ -8,10 +9,6 @@ export default function Component(props: {
     title: string,
     children?: React.ReactNode,
 }) {
-    function rpxToPx(n: number) {
-        var rate = Taro.getSystemInfoSync().windowWidth / 750;
-    return n * rate;
-    }
     return <View className='section_header'
         style={{
             marginTop: rpxToPx(props.top),

+ 3 - 2
src/features/auth/components/CreatePassword.tsx

@@ -44,6 +44,8 @@ export default function Component(prop: { name?: string, email?: string }) {
 
   useEffect(() => {
     if (user.isLogin) {
+      navigation.pop(3)
+      return
       Taro.navigateBack({
         delta: 2
       })
@@ -71,9 +73,8 @@ export default function Component(prop: { name?: string, email?: string }) {
       global.email,
       password
     ).then(res => {
-      console.log('oppsu2')
       dispatch(registerSuccess(res))
-      navigation.goBack(3)
+      
     }).catch(e => {
       console.log('oppsu')
     })

+ 30 - 5
src/features/auth/components/login.tsx

@@ -12,6 +12,12 @@ import { login } from "@/services/user";
 import { useDispatch, useSelector } from "react-redux";
 import Taro from "@tarojs/taro";
 import { ColorType } from "@/context/themes/color";
+import { loginSuccess } from "@/store/user";
+
+let useNavigation;
+if (process.env.TARO_ENV == 'rn') {
+    useNavigation = require("@react-navigation/native").useNavigation
+}
 
 export default function Login(props: { register: () => void }) {
     const { t } = useTranslation()
@@ -20,8 +26,19 @@ export default function Login(props: { register: () => void }) {
     const [password, setPassword] = useState('');
     const user = useSelector((state: any) => state.user);
 
+    let navigation;
+    if (useNavigation) {
+        navigation = useNavigation()
+    }
+
     useEffect(() => {
         if (user.isLogin) {
+
+            if (process.env.TARO_ENV=='rn'){
+                navigation.pop(2)
+                return
+            }
+
             if (user.scenario_select_count > 0) {
                 Taro.navigateBack({
                     delta: 2
@@ -50,9 +67,9 @@ export default function Login(props: { register: () => void }) {
 
     function loginComponent() {
         return <View>
-            <Inputs value={name} onChange={handleNameChange} onConfirm={(e)=>{}} placeholder={t('feature.auth.login.input_account_placeholder')}></Inputs>
+            <Inputs value={name} onChange={handleNameChange} onConfirm={(e) => { }} placeholder={t('feature.auth.login.input_account_placeholder')}></Inputs>
             <View style={{ height: 20 }} />
-            <Inputs value={password} isSecure={true} onChange={handlePasswordChange} onConfirm={(e)=>{}} placeholder={t('feature.auth.login.input_password_placeholder')}></Inputs>
+            <Inputs value={password} isSecure={true} onChange={handlePasswordChange} onConfirm={(e) => { }} placeholder={t('feature.auth.login.input_password_placeholder')}></Inputs>
         </View>
     }
 
@@ -60,10 +77,18 @@ export default function Login(props: { register: () => void }) {
         if (isLoginButtonDisabled) {
             return;
         }
-        dispatch(login(name, password) as any);
+        console.log('begin login')
+        login(name, password).then(res => {
+            console.log(res)
+            dispatch(loginSuccess(res))
+            // navigation.goBack(3)
+        }).catch(e => {
+            console.log('error',e)
+        })
+        // dispatch(login(name, password) as any);
     }
 
-    return <View style={{width: '100%', height: '100%'}}>
+    return <View style={{ width: '100%', height: '100%' }}>
         <Texts text={'App Name'} type={TextType.primary}></Texts>
         {
             loginComponent()
@@ -71,7 +96,7 @@ export default function Login(props: { register: () => void }) {
         <Buttons
             onClick={LoginF}
             title={t('feature.auth.create_account.btn_next')}
-            btnStyle={{ marginLeft: 23, marginRight: 23, marginTop: 20, marginBottom: 20,height:44,borderRadius:22,backgroundColor:ColorType.fast }}
+            btnStyle={{ marginLeft: 23, marginRight: 23, marginTop: 20, marginBottom: 20, height: 44, borderRadius: 22, backgroundColor: ColorType.fast }}
             disabled={isLoginButtonDisabled}></Buttons>
 
         <View className="agree_view">

+ 1 - 5
src/features/common/SpecBtns.tsx

@@ -7,11 +7,7 @@ import './SpecBtns.scss'
 import Taro from "@tarojs/taro"
 import { useTranslation } from "react-i18next"
 import { ColorType } from "@/context/themes/color"
-
-export const rpxToPx = (n: number) => {
-    var rate = Taro.getSystemInfoSync().windowWidth / 750;
-    return n * rate;
-}
+import { rpxToPx } from "@/utils/tools"
 
 export const StartFastBtn = (props: { onClick: Function, isLoading?: boolean }) => {
     const { t } = useTranslation()

+ 2 - 1
src/features/trackTimeDuration/components/TimelineStage.tsx

@@ -9,6 +9,7 @@ import Switch from '@/components/input/Switch';
 import { useSelector } from 'react-redux';
 import Taro from '@tarojs/taro';
 import { jumpPage } from '../hooks/Common';
+import { rpxToPx } from '@/utils/tools';
 
 
 export default function Component(props: { data: any, title?: string, subTitle?: string, isSchedule?: boolean }) {
@@ -44,7 +45,7 @@ export default function Component(props: { data: any, title?: string, subTitle?:
         })
     }
 
-    return <View style={{ display: 'flex', flexDirection: 'column', width: '578rpx' }}>
+    return <View style={{ display: 'flex', flexDirection: 'column', width: rpxToPx(578) }}>
         {/* <Text className='box_title'>{props.title ? props.title : 'Title'}</Text> */}
         <View className="box_header" style={{ backgroundColor: global.isDebug ? 'pink' : 'transparent' }}>
             <Text className="box_title" style={{ backgroundColor: global.isDebug ? 'red' : 'transparent' }}>{props.title ? props.title : 'Title'}</Text>

+ 8 - 3
src/features/trackTimeDuration/components/TitleView.scss

@@ -29,13 +29,18 @@
     
 }
 
-.icon {
+.iconAddBg{
+    padding-left: 32px;
+    padding-right: 32px;
+}
+
+.iconAdd {
     width: 44px;
     height: 44px;
     padding-top: 12px;
     padding-bottom: 12px;
-    padding-left: 32px;
-    padding-right: 32px;
+    flex-shrink: 0;
+    // box-sizing: border-box;
 }
 
 .subTitle{

+ 1 - 1
src/features/trackTimeDuration/components/TitleView.tsx

@@ -72,7 +72,7 @@ export default function Component(props: {
                 fontSize: props.secondPage ? 28 : 36
             }}>{props.title}</Text>
             {
-                user.isLogin && props.showAddBtn && <Image onClick={more} src={require('@/assets/images/add.png')} className='icon' />
+                user.isLogin && props.showAddBtn && <View className='iconAddBg' onClick={more}><Image src={require('@/assets/images/add.png')} className='iconAdd' /></View>
             }
         </View>
         {

+ 452 - 0
src/pages/clock/Clock.rn.tsx

@@ -0,0 +1,452 @@
+import { Component, PropsWithChildren, useEffect, useRef, useState } from 'react'
+import { View, Text, Button, Input, Picker, Swiper, SwiperItem, Icon } from '@tarojs/components'
+import '../index/index.scss'
+import './Clock.scss'
+// import './context/locales/index'
+import '@/context/locales/index'
+import Taro, { useDidShow, usePageScroll, useReady, useRouter, useShareAppMessage } from '@tarojs/taro'
+// import ComponentA from './component'
+
+
+import { useDispatch, useSelector } from 'react-redux';
+import { getInfoSuccess, logoutSuccess } from '@/store/user';
+import { wxPubFollow } from '@/services/permission';
+import { gobalConfigs, staticResources, uploadSessionKey } from '@/services/common';
+import Clocks from '@/features/trackTimeDuration/components/Clock';
+import Console from '@/features/trackTimeDuration/components/Console';
+import Schedule from '@/features/trackTimeDuration/components/Schedule';
+import { getChecks, getClocks } from '@/services/trackTimeDuration';
+import { setScenario } from '@/store/scenario';
+import trackTimeService from '@/store/trackTimeMachine';
+import { setWXFollow } from '@/store/permission';
+import Tooltip from '@/components/view/Tooltip'
+import RequestType, { thirdPartRequest } from '@/services/thirdPartRequest'
+import { setConfigs } from '@/store/common'
+import RecordFastSleep from '@/features/trackTimeDuration/components/RecordFastSleep'
+import Box from '@/components/layout/Box'
+import Layout from '@/components/layout/layout'
+import { CheckBoxType, NaviBarTitleShowType, TemplateType } from '@/utils/types'
+import { updateScenario } from '@/store/time'
+import { showModal } from '@/store/modal'
+import { ConsoleType, changeConsoleStatus } from '@/store/console'
+import TitleView from '@/features/trackTimeDuration/components/TitleView'
+import StatusIndicator from '@/features/trackTimeDuration/components/StatusIndicator'
+import { useTranslation } from 'react-i18next'
+import TableCellHeader from '@/components/layout/TableCellHeader'
+import SectionHeader from '@/components/layout/SectionHeader'
+import Header from '@/components/layout/Header'
+import { TimeFormatter } from '@/utils/time_format'
+import NoData from '@/components/view/NoData'
+import { ColorType } from '@/context/themes/color'
+import { jumpPage } from '@/features/trackTimeDuration/hooks/Common'
+import DemoA from './demoA'
+import { ScrollView } from 'react-native-gesture-handler'
+// import TabBar from '../../components/Tabbar';
+
+// import Rings from '@components/view/Rings';
+
+let useNavigation;
+if (process.env.TARO_ENV == 'rn') {
+    useNavigation = require("@react-navigation/native").useNavigation
+}
+
+
+export default function IndexPage() {
+    const dispatch = useDispatch();
+    const { t } = useTranslation()
+    const [checkData, setCheckData] = useState(null)
+    const user = useSelector((state: any) => state.user);
+    const time = useSelector((state: any) => state.time);
+    const common = useSelector((state: any) => state.common);
+    const consoleData = useSelector((state: any) => state.console);
+    const [counter, setCounter] = useState(0)
+    const [timerId, setTimerId] = useState(null)
+    const [needShowAddTip, setNeedShowAddTip] = useState(false)
+    const [showErrorPage, setErrorPage] = useState(false)
+
+    const [swiperIndex, setSwiperIndex] = useState(0)
+    const [autoPlay, setAutoPlay] = useState(false)
+
+    const [showModal, setShowModal] = useState(false)
+    const [modalDetail, setModalDetail] = useState<any>({})
+
+    const [showModal2, setShowModal2] = useState(false)
+    const [modalDetail2, setModalDetail2] = useState<any>({})
+    const [showSingleFastEnd, setShowSingleFastEnd] = useState(false)
+    const [consoleStatus, setConsoleStatus] = useState(consoleData.status)
+
+    let navigation;
+    if (useNavigation) {
+        navigation = useNavigation()
+    }
+
+    global.dispatch = dispatch;
+
+    global.checkData = () => {
+        console.log('refresh clock data')
+        getCheckData()
+    }
+
+    useEffect(() => {
+        global.consoleType = 'idle'
+        dispatch(staticResources() as any);
+    }, [])
+
+    useEffect(() => {
+        getCheckData()
+    }, [time.status])
+
+    useEffect(() => {
+        setConsoleStatus(consoleData.status)
+        switch (consoleData.status) {
+            case ConsoleType.end:
+                setTimeout(() => {
+                    dispatch(changeConsoleStatus({ status: ConsoleType.idle }))
+                }, 2000)
+
+                break
+        }
+    }, [consoleData.status])
+
+    useEffect(() => {
+        if (user.isLogin) {
+            //检查用户是否添加过小程序
+            checkAddToMini();
+            //检查session是否过期
+            checkSession()
+            getCheckData()
+        }
+    }, [user.isLogin])
+
+    function checkSession() {
+        if (process.env.TARO_ENV === 'weapp') {
+            thirdPartRequest(RequestType.RequestTypeCheckSession).then(res => {
+            }).catch(err => {
+                console.log('session_key 已经失效,需要更新登录code')
+                thirdPartRequest(RequestType.RequestTypeWXLogin).then(result => {
+                    uploadSessionKey({ type: 'WX_MP', code: (result as any).code });
+                })
+            })
+        }
+    }
+
+    function checkAddToMini() {
+        process.env.TARO_ENV == 'weapp' &&
+            wx.checkIsAddedToMyMiniProgram({
+                success: (res) => {
+                    if (!res.added) {
+                        setNeedShowAddTip(true)
+                    }
+                },
+                fail: (e) => {
+                }
+            });
+    }
+
+    useEffect(() => {
+        startTimer();
+        return () => {
+            // 在组件卸载时清除定时器
+            if (timerId) {
+                clearInterval(timerId);
+            }
+        };
+    }, [timerId]);
+
+    const startTimer = () => {
+        // 避免重复启动定时器
+        if (timerId) {
+            return;
+        }
+
+        const id = setInterval(() => {
+            setCounter((prevCounter) => prevCounter + 1);
+            //每天0点刷新一下打卡数据
+            var now = new Date()
+            if (now.getHours() == 0 && now.getMinutes() == 0) {
+                getCheckData()
+            }
+        }, 1000);
+
+        setTimerId(id as any);
+    };
+
+
+    useReady(async () => {
+        const userData = await getStorage('userData');
+        if (userData) {
+            dispatch(getInfoSuccess(JSON.parse(userData as string)) as any);
+            setTimeout(() => {
+                checkWXPubFollow()
+                getCheckData()
+
+            }, 200)
+
+        }
+    })
+
+    if (process.env.TARO_ENV == 'weapp') {
+        useShareAppMessage((e) => {
+            return {
+                title: t('share.title'),
+                path: 'pages/clock/Clock'
+            }
+        })
+    }
+
+    function clearTempScenarioCache() {
+        global.schedule_fast = null
+        global.schedule_sleep = null
+        Taro.removeStorage({
+            key: 'tempScenario',
+            success: function (res) {
+            }
+        })
+    }
+
+    usePageScroll((e) => {
+    })
+
+    useDidShow(() => {
+        if (process.env.TARO_ENV == 'weapp') {
+            global.updateTab(0)
+            if (user.isLogin) {
+                checkWXPubFollow()
+            }
+        }
+
+        clearTempScenarioCache()
+    })
+
+    global.refreshTime = () => {
+        getCheckData()
+    }
+
+    global.showSingleFastEnd = () => {
+        setShowSingleFastEnd(true)
+    }
+
+    function tapClock() {
+        if (!user.isLogin) {
+            jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
+        }
+    }
+
+    function getCheckData() {
+        getClocks().then(res => {
+            setErrorPage(false)
+            dispatch(updateScenario((res as any).current_record))
+            dispatch(setConfigs((res as any).time_input_schema));
+            dispatch(setScenario((res as any).scenario));
+
+            if ((res as any).theme_color) {
+                global.fastColor = (res as any).theme_color.fast
+                global.sleepColor = (res as any).theme_color.sleep
+            }
+
+            global.scenario = (res as any).current_record.scenario;
+            const currentState = trackTimeService.getSnapshot();
+            let json = {};
+            var key = (res as any).current_record.scenario
+            var status = (res as any).current_record.status
+            json[key] = status
+            currentState.value = json;
+            setCheckData(res as any)
+
+            if ((res as any).current_record.status != 'ONGOING1') {
+                setSwiperIndex(0)
+            }
+            else {
+                if (global.consoleType == 'going') {
+                    setShowSingleFastEnd(true)
+                    setTimeout(() => {
+                        setShowSingleFastEnd(false)
+                        setSwiperIndex(1)
+                        setAutoPlay(true)
+                        global.consoleType = 'end'
+                        dispatch(changeConsoleStatus({ status: ConsoleType.end }))
+                        setTimeout(() => {
+                            global.consoleType = 'idle'
+                        }, 2000)
+                    }, 500)
+                }
+                else {
+                }
+            }
+
+        }).catch(e => {
+            console.log('aaa')
+            if (!checkData) {
+                console.log('this is a test')
+                setErrorPage(true)
+            }
+            else {
+                console.log('sss')
+            }
+        })
+    }
+
+    function checkWXPubFollow() {
+        var params;
+        if (global.forceRefreshWXPub) {
+            params = {
+                force_refresh: true
+            }
+        }
+        global.forceRefreshWXPub = false
+        wxPubFollow(params).then(res => {
+            dispatch(setWXFollow((res as any).wx_pub_followed));
+            console.log('当前的关注状态' + (res as any).wx_pub_followed);
+
+        })
+    }
+
+    async function getStorage(key: string) {
+        try {
+            const res = await Taro.getStorage({ key });
+            return res.data;
+        } catch {
+            return '';
+        }
+    }
+
+    function schedule() {
+        if (!user.isLogin) {
+            return <View />
+        }
+        return <Schedule data={(checkData as any).current_record} />
+    }
+
+    function needSwiper() {
+        var isNeed = time.scenario == 'FAST_SLEEP' &&
+            (time.status == 'WAIT_FOR_START' ||
+                time.status == 'ONGOING1' ||
+                time.status == 'ONGOING2')
+        if (showSingleFastEnd) {
+            return false;
+        }
+        return isNeed
+    }
+
+    global.showClockModal = (isShow: boolean, detail: any) => {
+        setShowModal(isShow)
+        setModalDetail(detail)
+    }
+
+    global.showClockModal2 = (isShow: boolean, detail: any) => {
+        setShowModal2(isShow)
+        setModalDetail2(detail)
+    }
+
+    function headerView() {
+        return <TitleView title={t('page.clock.title')} showAddBtn={true}>
+            <StatusIndicator />
+        </TitleView>
+    }
+
+    function errorView() {
+        if (showErrorPage) {
+            return <NoData refresh={() => { getCheckData() }} />
+        }
+        return <View />
+    }
+
+    function consoleView() {
+        if (!checkData) {
+            return <View />
+        }
+        return <View className='console_bg'>
+            {
+                needSwiper() ? <Swiper className='swiper' indicatorColor='#333'
+                    indicatorActiveColor='#999'
+                    current={swiperIndex}
+                    autoplay={autoPlay}
+                    duration={300}
+                    interval={300}
+                    indicator-offset={[0, -30]}
+                    indicator-height={30}
+                    indicatorDots={global.consoleType == 'idle'}
+                    onChange={(e) => {
+                        setSwiperIndex(e.detail.current)
+                        if (e.detail.current == 0)
+                            setAutoPlay(false)
+                    }}
+                >
+                    <SwiperItem className='swiperItem'>
+                        <Console />
+
+                    </SwiperItem>
+
+                    <SwiperItem className='swiperItem'>
+                        <Console isNextStep={true} />
+                    </SwiperItem>
+                </Swiper> :
+                    <Console isNextStep={showSingleFastEnd} />
+
+            }
+        </View>
+    }
+
+
+    function detail() {
+        return (
+            <Layout type={TemplateType.customHeader} header={headerView()} title={t('page.clock.title')} titleShowStyle={NaviBarTitleShowType.scrollToShow}>
+                <View style={{ flex: 1, flexDirection: 'column', display: 'flex', backgroundColor: '#000', color: '#fff' }}>
+                    {
+                        needShowAddTip && <Tooltip title="添加到我的小程序" closeTip={() => { setNeedShowAddTip(false) }} />
+                    }
+
+                    <Box>
+                        <View className='clock_bg' onClick={tapClock}>
+                            <Clocks />
+                        </View>
+                    </Box>
+                    {
+                        errorView()
+                    }
+                    {
+                        user.isLogin && consoleView()
+                    }
+                    {
+                        user.isLogin && checkData && schedule()
+                    }
+
+                    {
+                        user.isLogin && <View style={{ backgroundColor: global.isDebug ? 'pink' : 'transparent' }}>
+                            {
+                                checkData && (checkData as any).latest_record &&
+                                <SectionHeader top={48} bottom={24} title={t('feature.track_time_duration.record_fast_sleep.header.latest_record')}>
+                                    <Header title='' action={() => {
+                                        jumpPage('/pages/common/RecordsHistory?type=time&title=time')
+                                    }} />
+                                </SectionHeader>
+                            }
+                        </View>
+                    }
+                    {
+                        user.isLogin && checkData && (checkData as any).latest_record &&
+                        <RecordFastSleep type='latest' data={(checkData as any).latest_record} delSuccess={getCheckData} />
+                    }
+                    <View style={{ height: 100 }} />
+                </View>
+
+                {
+                    showModal && modalDetail
+                }
+                {
+                    showModal2 && modalDetail2
+                }
+
+            </Layout>
+        )
+    }
+
+    // if (process.env.TARO_ENV == 'rn')
+    //     return <View />
+
+    return <ScrollView>
+        {
+            detail()
+        }
+    </ScrollView>
+}

+ 0 - 0
src/pages/clock/Clock.tsx → src/pages/clock/Clock.weapp.tsx


+ 25 - 0
src/pages/clock/demoA.tsx

@@ -0,0 +1,25 @@
+// import { View } from "@tarojs/components";
+import { useLayoutEffect, useRef, useState } from "react";
+import { LayoutChangeEvent, View } from "react-native";
+
+export default function DemoA(props:{ children}) {
+    const [height, setHeight] = useState<number>(1000000);
+
+    const handleLayout = (event: LayoutChangeEvent) => {
+        console.log('oppsu1111')
+        const { height } = event.nativeEvent.layout;
+        console.log(height)
+        setHeight(height);
+    };
+    //onLayout={handleLayout}
+
+    return (
+        <View style={{  backgroundColor: 'blue', height:height,width:200 }} >
+            <View onLayout={handleLayout}>
+
+            
+            {props.children}
+            </View>
+        </View>
+    );
+}

+ 8 - 3
src/services/http/request.ts

@@ -45,7 +45,7 @@ export async function request<T>(param: RequestParam): Promise<T> {
 
     let retryCount = 0;
 
-    
+
 
     function performRequest(resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) {
         const { url, method, data } = param;
@@ -79,7 +79,7 @@ export async function request<T>(param: RequestParam): Promise<T> {
                 return;
             }
             // global.postBtnUpdateStatus('idle')
-            ToastUtil.getInstance().showToast(method=='GET'?'网络连接失败,请检查网络':'操作失败,请检查网络');
+            ToastUtil.getInstance().showToast(method == 'GET' ? '网络连接失败,请检查网络' : '操作失败,请检查网络');
             // Taro.showToast({
             //     icon:'none',
             //     title: method=='GET'?'网络连接失败,请检查网络':'操作失败,请检查网络',
@@ -87,7 +87,7 @@ export async function request<T>(param: RequestParam): Promise<T> {
             reject('timeout');
         }, kTimeout);
 
-        console.log('post request',data)
+        console.log(url)
 
         requestTask = Taro.request({
             url: url,
@@ -99,6 +99,10 @@ export async function request<T>(param: RequestParam): Promise<T> {
                 clearTimeout(timer);
                 const { statusCode, data } = response;
 
+                if (statusCode != 200) {
+                    console.log(response)
+                }
+
                 if (statusCode >= 200 && statusCode < 300) {
                     //正常数据返回
                     var resp = {} as T;
@@ -124,6 +128,7 @@ export async function request<T>(param: RequestParam): Promise<T> {
                 }
             },
             fail: err => {
+                console.log('oooooooddd', err)
                 // global.postBtnUpdateStatus('idle')
                 // console.log('oppsu');
                 // clearTimeout(timer);

+ 13 - 6
src/services/user.tsx

@@ -17,11 +17,18 @@ export const checkUnique = (username?: string, email?: string) => {
 
 }
 
-export const login = (username: string, password: string) => (dispatch: any) => {
-    request({
-        url: API_LOGIN, method: 'POST', data: { username, password }
-    }).then(res => {
-        dispatch(loginSuccess(res));
+export const login = (username: string, password: string) => {
+    return new Promise((resolve, reject) => {
+        request({
+            url: API_LOGIN, method: 'POST', data: { username, password }
+        }).then(res => {
+            console.log('ssss')
+            resolve(res)
+            // dispatch(loginSuccess(res));
+        }).catch(e=>{
+            console.log('vvvvvv')
+            reject(e)
+        })
     })
 }
 
@@ -62,7 +69,7 @@ export const register = (name: string, email: string, password: string) => {
         }).then(res => {
             resolve(res);
             // dispatch(loginSuccess(res));
-        }).catch(e=>{
+        }).catch(e => {
             reject(e)
         })
     })

+ 7 - 0
src/utils/tools.ts

@@ -1,3 +1,5 @@
+import Taro from "@tarojs/taro";
+
 export function alphaToHex(alpha) {
     var alphaValue = Math.round(alpha * 255); // 将透明度乘以255并四舍五入
     var hexValue = alphaValue.toString(16); // 将整数转换为十六进制字符串
@@ -5,4 +7,9 @@ export function alphaToHex(alpha) {
         hexValue = "0" + hexValue; // 如果十六进制字符串只有一位,补零
     }
     return hexValue;
+}
+
+export function rpxToPx(n: number) {
+    var rate = Taro.getSystemInfoSync().windowWidth / 750;
+    return n * rate;
 }

+ 5 - 0
yarn.lock

@@ -10094,6 +10094,11 @@ joycon@^3.0.1:
   resolved "https://registry.npmmirror.com/joycon/-/joycon-3.1.1.tgz#bce8596d6ae808f8b68168f5fc69280996894f03"
   integrity sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==
 
+jpush-react-native@^3.0.5:
+  version "3.0.5"
+  resolved "https://registry.npmmirror.com/jpush-react-native/-/jpush-react-native-3.0.5.tgz#9b34ae457c0b8c5f75d785add3c49e05b3d101be"
+  integrity sha512-vnFKNWvF0adomxxTCcO45R7AIKpNddDJ+zXLEHlRDwb3WHA+dWrs9fdsQS8gbaB+jzSx/GDaZr10OIVs4MAEcw==
+
 js-base64@^2.1.9:
   version "2.6.4"
   resolved "https://registry.npmmirror.com/js-base64/-/js-base64-2.6.4.tgz#f4e686c5de1ea1f867dbcad3d46d969428df98c4"