diff --git a/GIGA.xcodeproj/project.pbxproj b/GIGA.xcodeproj/project.pbxproj index c6af09b..ae7b844 100644 --- a/GIGA.xcodeproj/project.pbxproj +++ b/GIGA.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 6B67B068A469498C38CEF799 /* Pods_GIGA.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B14B65914FBF61910191D7A8 /* Pods_GIGA.framework */; }; + 8314D2112133ABE500B458BF /* WeiIXinApiManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 8314D2102133ABE500B458BF /* WeiIXinApiManager.m */; }; 83346AC0212BB50A0054D597 /* PassWordResetVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 83346ABE212BB50A0054D597 /* PassWordResetVC.m */; }; 83346AC1212BB50A0054D597 /* PassWordResetVC.xib in Resources */ = {isa = PBXBuildFile; fileRef = 83346ABF212BB50A0054D597 /* PassWordResetVC.xib */; }; 83346AC5212BBC8C0054D597 /* GiGaRegistViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83346AC3212BBC8C0054D597 /* GiGaRegistViewController.m */; }; @@ -18,6 +19,7 @@ 83346AD4212BFF6E0054D597 /* UserGuardViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 83346AD3212BFF6E0054D597 /* UserGuardViewController.m */; }; 83346AD7212C18F50054D597 /* GiGaAppGaurdVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 83346AD6212C18F50054D597 /* GiGaAppGaurdVC.m */; }; 833DA7762122A62000A5C614 /* GiGaMaskTaskViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 833DA7752122A62000A5C614 /* GiGaMaskTaskViewController.m */; }; + 8342D9FD2131150200D16B1D /* 4481.wav in Resources */ = {isa = PBXBuildFile; fileRef = 8342D9FC2131150200D16B1D /* 4481.wav */; }; 8349585C212511040064DB6C /* AppDelegate+ThirdParty.m in Sources */ = {isa = PBXBuildFile; fileRef = 8349585B212511040064DB6C /* AppDelegate+ThirdParty.m */; }; 835060A2212D1225007E6220 /* GiGaMeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 835060A1212D1225007E6220 /* GiGaMeViewController.m */; }; 835060A5212D3536007E6220 /* AppDelegate+GiGaConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 8361B40A21217B2100238FEB /* AppDelegate+GiGaConfig.m */; }; @@ -105,6 +107,8 @@ /* Begin PBXFileReference section */ 055947143A68ADCC68C3F3E1 /* Pods-GIGA.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GIGA.debug.xcconfig"; path = "Pods/Target Support Files/Pods-GIGA/Pods-GIGA.debug.xcconfig"; sourceTree = ""; }; + 8314D20F2133ABE500B458BF /* WeiIXinApiManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WeiIXinApiManager.h; sourceTree = ""; }; + 8314D2102133ABE500B458BF /* WeiIXinApiManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WeiIXinApiManager.m; sourceTree = ""; }; 83346ABD212BB50A0054D597 /* PassWordResetVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PassWordResetVC.h; sourceTree = ""; }; 83346ABE212BB50A0054D597 /* PassWordResetVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PassWordResetVC.m; sourceTree = ""; }; 83346ABF212BB50A0054D597 /* PassWordResetVC.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PassWordResetVC.xib; sourceTree = ""; }; @@ -121,6 +125,7 @@ 83346AD6212C18F50054D597 /* GiGaAppGaurdVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiGaAppGaurdVC.m; sourceTree = ""; }; 833DA7742122A62000A5C614 /* GiGaMaskTaskViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaMaskTaskViewController.h; sourceTree = ""; }; 833DA7752122A62000A5C614 /* GiGaMaskTaskViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiGaMaskTaskViewController.m; sourceTree = ""; }; + 8342D9FC2131150200D16B1D /* 4481.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = 4481.wav; sourceTree = ""; }; 8349585A212511040064DB6C /* AppDelegate+ThirdParty.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AppDelegate+ThirdParty.h"; sourceTree = ""; }; 8349585B212511040064DB6C /* AppDelegate+ThirdParty.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "AppDelegate+ThirdParty.m"; sourceTree = ""; }; 835060A0212D1225007E6220 /* GiGaMeViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaMeViewController.h; sourceTree = ""; }; @@ -293,6 +298,7 @@ 83346AC8212BD4160054D597 /* Source */ = { isa = PBXGroup; children = ( + 8342D9FC2131150200D16B1D /* 4481.wav */, 838388D92130046D00D14C53 /* emojizone.mp4 */, 838388C9212FA00200D14C53 /* MaskTime.png */, 838388C3212F934400D14C53 /* pomodoSound.m4a */, @@ -386,6 +392,8 @@ 8357ADCF2123C5F7000816F2 /* GiGaAPIRequest.m */, 8357ADD12123C7C6000816F2 /* GiGaAPIResult.h */, 8357ADD22123C7C6000816F2 /* GiGaAPIResult.m */, + 8314D20F2133ABE500B458BF /* WeiIXinApiManager.h */, + 8314D2102133ABE500B458BF /* WeiIXinApiManager.m */, ); path = GiGaNetTool; sourceTree = ""; @@ -928,6 +936,7 @@ 83835BA8212E4748001480F2 /* MAssaageCenterCell.xib in Resources */, 8361B3D3212155C300238FEB /* Assets.xcassets in Resources */, 8361B3D1212155C200238FEB /* Main.storyboard in Resources */, + 8342D9FD2131150200D16B1D /* 4481.wav in Resources */, 83835BB0212E4FCD001480F2 /* MessageListViewCell.xib in Resources */, 83346ACF212BD7830054D597 /* GiGaWebViewController.xib in Resources */, ); @@ -1025,6 +1034,7 @@ 83346AC5212BBC8C0054D597 /* GiGaRegistViewController.m in Sources */, 83346AD7212C18F50054D597 /* GiGaAppGaurdVC.m in Sources */, 8349585C212511040064DB6C /* AppDelegate+ThirdParty.m in Sources */, + 8314D2112133ABE500B458BF /* WeiIXinApiManager.m in Sources */, 83835BCA212E8045001480F2 /* GIGAQuetionView.m in Sources */, 8361B3CE212155C200238FEB /* ViewController.m in Sources */, 8361B4382121847600238FEB /* UINavigationBar+Custom.m in Sources */, diff --git a/GIGA/AppDelegate+ThirdParty.m b/GIGA/AppDelegate+ThirdParty.m index 1dac50d..7574835 100644 --- a/GIGA/AppDelegate+ThirdParty.m +++ b/GIGA/AppDelegate+ThirdParty.m @@ -8,6 +8,7 @@ #import "AppDelegate+ThirdParty.h" #define PUSH_APPKEY @"1f8122badd24c2adb8b3f231" +#import "WXApi.h" @implementation AppDelegate (ThirdParty) @@ -37,11 +38,11 @@ //微信 - + [WXApi registerApp:WXin_APPID]; } -// 微信 +#pragma mark 微信 - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options { return [WXApi handleOpenURL:url delegate:self]; @@ -57,11 +58,14 @@ if ([resp isKindOfClass:[SendAuthResp class]]) { SendAuthResp*rep = (SendAuthResp*)resp; if (resp.errCode == 0) { - [[NSNotificationCenter defaultCenter] postNotificationName: @"WXAuthSuccess" object:@{@"code":rep.code}]; - + NC_POST_NAME_OBJECT(kWeiXinAuthrization_Success, @{@"code":rep.code}) + }else{ + [[UIApplication sharedApplication].keyWindow makeToast:@"授权失败" duration:1.6 position:CSToastPositionCenter]; } } } + +#pragma mark - 远程推送 // ios 10 Support - (void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler API_AVAILABLE(ios(10.0)){ @@ -102,7 +106,6 @@ [UIApplication sharedApplication].applicationIconBadgeNumber = 0; [JPUSHService resetBadge]; - // Required, iOS 7 Support GILog(@"iOS 7 userInfo%@",userInfo); [JPUSHService handleRemoteNotification:userInfo]; diff --git a/GIGA/AppDelegate.m b/GIGA/AppDelegate.m index b2240a0..ae0253a 100644 --- a/GIGA/AppDelegate.m +++ b/GIGA/AppDelegate.m @@ -40,7 +40,6 @@ //广告页 [self creatAdView]; //[self setupTabBarController]; - return YES; } @@ -109,7 +108,7 @@ if (_isMasking) { - [[GiGaLocalNotificationManager localNotifiationCenter] sendLocalNotification:@"闹钟提醒!" fireTimeInterval:2 alertAction:@"面膜时间已添加闹钟提醒!" withIdentifier:kLOCALNotifiID_APPTERMINAL]; +// [[GiGaLocalNotificationManager localNotifiationCenter] sendLocalNotification:@"闹钟提醒!" fireTimeInterval:2 alertAction:@"面膜时间已添加闹钟提醒!" withIdentifier:kLOCALNotifiID_APPTERMINAL]; } } diff --git a/GIGA/Common/GiGaHelper.h b/GIGA/Common/GiGaHelper.h index 2e484cc..7df77f2 100644 --- a/GIGA/Common/GiGaHelper.h +++ b/GIGA/Common/GiGaHelper.h @@ -45,6 +45,8 @@ //计算文字的长度 + (CGSize)sizeWithText:(NSString *)text font:(UIFont *)font maxSize:(CGSize)maxSize; ++(CGFloat)getSpaceLabelHeight:(NSString*)str withFont:(UIFont*)font maxSize:(CGSize)maxSize; ++(void)setLabelSpace:(UILabel*)label withValue:(NSString*)str withFont:(UIFont*)font; @end diff --git a/GIGA/Common/GiGaHelper.m b/GIGA/Common/GiGaHelper.m index 7a791a0..4d56ac1 100644 --- a/GIGA/Common/GiGaHelper.m +++ b/GIGA/Common/GiGaHelper.m @@ -55,7 +55,6 @@ NSString *futrueTimeStr = [formatter stringFromDate:futrueDate]; NSDate *furtureformatDate = [formatter dateFromString:futrueTimeStr]; long futrueTimestamp= [furtureformatDate timeIntervalSince1970]; - return futrueTimestamp; } @@ -84,10 +83,65 @@ } -//计算文字的长度 +//计算文字size + (CGSize)sizeWithText:(NSString *)text font:(UIFont *)font maxSize:(CGSize)maxSize { return [text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:font} context:nil].size; } ++(CGFloat)getSpaceLabelHeight:(NSString*)str withFont:(UIFont*)font maxSize:(CGSize)maxSize { + + NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init]; + + paraStyle.lineBreakMode = NSLineBreakByCharWrapping; + + paraStyle.alignment = NSTextAlignmentLeft; + + paraStyle.lineSpacing = 6; + + paraStyle.hyphenationFactor = 1.0; + + paraStyle.firstLineHeadIndent = 0.0; + + paraStyle.paragraphSpacingBefore = 0.0; + + paraStyle.headIndent = 0; + + paraStyle.tailIndent = 0; + + NSDictionary *dic = @{NSFontAttributeName:font, NSParagraphStyleAttributeName:paraStyle, NSKernAttributeName:@1.5f + }; + CGSize size =[str boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil].size; + + return size.height; + +} + ++(void)setLabelSpace:(UILabel*)label withValue:(NSString*)str withFont:(UIFont*)font { + + NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init]; + + paraStyle.lineBreakMode = NSLineBreakByCharWrapping; + + paraStyle.alignment = NSTextAlignmentLeft; + + paraStyle.lineSpacing = 6; //设置行间距 + + paraStyle.hyphenationFactor = 1.0; + + paraStyle.firstLineHeadIndent = 0.0; + + paraStyle.paragraphSpacingBefore = 0.0; + + paraStyle.headIndent = 0; + + paraStyle.tailIndent = 0; + //设置字间距 NSKernAttributeName:@1.5f + NSDictionary *dic = @{NSFontAttributeName:font, NSParagraphStyleAttributeName:paraStyle, NSKernAttributeName:@1.5f + }; + NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:str attributes:dic]; + + label.attributedText = attributeStr; + +} @end diff --git a/GIGA/Common/GiGaLocalNotificationManager/GiGaLocalNotificationManager.m b/GIGA/Common/GiGaLocalNotificationManager/GiGaLocalNotificationManager.m index 090a6a3..54d5b44 100644 --- a/GIGA/Common/GiGaLocalNotificationManager/GiGaLocalNotificationManager.m +++ b/GIGA/Common/GiGaLocalNotificationManager/GiGaLocalNotificationManager.m @@ -28,25 +28,24 @@ UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init]; content.title = alertAction; content.body = alertBoday; - content.sound = [UNNotificationSound defaultSound]; + //content.sound = [UNNotificationSound defaultSound]; + content.sound = [UNNotificationSound soundNamed:@"4481.wav"]; //content.sound = UNNotificationSound //通知附件 音<10M p3 p4 ,视频<50M pmeg mpeg4 图片<5M NSURL *imageUrl = [[NSBundle mainBundle] URLForResource:@"MaskTime" withExtension:@"png"]; UNNotificationAttachment *attach = [UNNotificationAttachment attachmentWithIdentifier:@"photo" URL:imageUrl options:nil error:nil]; - NSURL *audioUrl = [[NSBundle mainBundle] URLForResource:@"pomodoSound" withExtension:@"m4a"]; + NSURL *audioUrl = [[NSBundle mainBundle] URLForResource:@"4481" withExtension:@"wav"]; UNNotificationAttachment *attachAudio = [UNNotificationAttachment attachmentWithIdentifier:@"audio" URL:audioUrl options:nil error:nil]; NSURL *vedioUrl = [[NSBundle mainBundle] URLForResource:@"emojizone" withExtension:@"mp4"]; UNNotificationAttachment *vedioAudio = [UNNotificationAttachment attachmentWithIdentifier:@"vedio" URL:vedioUrl options:nil error:nil]; - content.attachments = @[vedioAudio]; - + content.attachments = @[attachAudio]; //延迟通知 第一个参数是重复的时间间隔,最小60s,第二个参数是是否重复。 - UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:timeInterval repeats:NO]; + UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:60 repeats:NO]; UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:identifier content:content trigger:trigger]; - [center addNotificationRequest:request withCompletionHandler:^(NSError *_Nullable error) { GILog(@"成功添加推送"); @@ -62,6 +61,7 @@ localNotification.alertAction = alertAction; localNotification.applicationIconBadgeNumber = 1; localNotification.soundName = UILocalNotificationDefaultSoundName; + localNotification.soundName = @"4481.wav"; //localNotification.alertLaunchImage = @"MaskTime.png"; localNotification.userInfo = @{identifier:identifier}; //根据设定时间发送通知 @@ -127,6 +127,7 @@ API_AVAILABLE(ios(10.0)){ NSLog(@"iOS10 前台 收到本地通知:{\\\\nbody:%@,\\\\ntitle:%@,\\\\nsubtitle:%@,\\\\nbadge:%@,\\\\nsound:%@,\\\\nuserInfo:%@\\\\n}",body,title,subtitle,badge,sound,userInfo); [self showAlert:title message:body]; + [center removeAllPendingNotificationRequests]; } completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert); } @@ -136,7 +137,7 @@ API_AVAILABLE(ios(10.0)){ API_AVAILABLE(ios(10.0)){ GILog(@"ios10用户点击通知栏相应"); - + [center removeAllPendingNotificationRequests]; completionHandler(); } // diff --git a/GIGA/Common/GiGaNetTool/GiGaNetManager.h b/GIGA/Common/GiGaNetTool/GiGaNetManager.h index 1885ee9..c524b0d 100644 --- a/GIGA/Common/GiGaNetTool/GiGaNetManager.h +++ b/GIGA/Common/GiGaNetTool/GiGaNetManager.h @@ -12,4 +12,6 @@ +(GiGaNetManager *)shareInstance; +(void)request:(GiGaAPIRequest*)api; + + @end diff --git a/GIGA/Common/GiGaNetTool/GiGaNetManager.m b/GIGA/Common/GiGaNetTool/GiGaNetManager.m index d4ae1b2..355ee8d 100644 --- a/GIGA/Common/GiGaNetTool/GiGaNetManager.m +++ b/GIGA/Common/GiGaNetTool/GiGaNetManager.m @@ -67,4 +67,6 @@ } } + + @end diff --git a/GIGA/Common/GiGaNetTool/WeiIXinApiManager.h b/GIGA/Common/GiGaNetTool/WeiIXinApiManager.h new file mode 100644 index 0000000..d12d6f4 --- /dev/null +++ b/GIGA/Common/GiGaNetTool/WeiIXinApiManager.h @@ -0,0 +1,35 @@ +// +// WeiIXinApiManager.h +// GIGA +// +// Created by lianxiang on 2018/8/27. +// Copyright © 2018年 com.giga.ios. All rights reserved. +// + +#import + +@interface WeiIXinApiManager : NSObject + +/** + 微信授权成功后获取 access_token + + @param url get access_token + @param parameters 参数 + @param success 成功 + @param failure 失败 + */ ++(void)weixinAccessTokeRequstUrl:(NSString *)url parameters:(NSDictionary *)parameters success:(void (^)(id response))success + failure:(void (^)(NSError *err))failure; + +/** + 获取微信用户信息 + + @param parameters 参数 + @param success 成功 + @param failure 失败 + */ ++(void)getWeiXinUserInfoUrl:(NSString *)url parameters:(NSDictionary *)parameters + success:(void (^)(id response))success + failure:(void (^)(NSError *err))failure; + +@end diff --git a/GIGA/Common/GiGaNetTool/WeiIXinApiManager.m b/GIGA/Common/GiGaNetTool/WeiIXinApiManager.m new file mode 100644 index 0000000..5dfa2a9 --- /dev/null +++ b/GIGA/Common/GiGaNetTool/WeiIXinApiManager.m @@ -0,0 +1,45 @@ +// +// WeiIXinApiManager.m +// GIGA +// +// Created by lianxiang on 2018/8/27. +// Copyright © 2018年 com.giga.ios. All rights reserved. +// + +#import "WeiIXinApiManager.h" + +@implementation WeiIXinApiManager + ++(void)weixinAccessTokeRequstUrl:(NSString *)url parameters:(NSDictionary *)parameters success:(void (^)(id response))success + failure:(void (^)(NSError *err))failure +{ + [self getrequstweiAPiUrl:url params:parameters success:success failure:failure]; +} + ++ (void)getWeiXinUserInfoUrl:(NSString *)url parameters:(NSDictionary *)parameters success:(void (^)(id))success failure:(void (^)(NSError *))failure +{ + [self getrequstweiAPiUrl:url params:parameters success:success failure:failure]; + +} + ++(void)getrequstweiAPiUrl:(NSString *)url params:(NSDictionary *)parameters success:(void (^)(id response))success + failure:(void (^)(NSError *err))failure +{ + AFHTTPSessionManager*manager=[[AFHTTPSessionManager alloc] init]; + manager.responseSerializer=[AFHTTPResponseSerializer serializer]; + [manager GET:url parameters:parameters progress:^(NSProgress * _Nonnull downloadProgress) { + + } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { + if (success) { + success(responseObject); + } + } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { + if (failure) { + failure(error); + } + + }]; +} + + +@end diff --git a/GIGA/Common/GiGaUserDB/GiGaUserDefault.h b/GIGA/Common/GiGaUserDB/GiGaUserDefault.h index 1d8ce43..0489720 100644 --- a/GIGA/Common/GiGaUserDB/GiGaUserDefault.h +++ b/GIGA/Common/GiGaUserDB/GiGaUserDefault.h @@ -39,5 +39,13 @@ +(void)saveAppGaurdflag:(BOOL)showedGaurd; +(BOOL)isShowedAppGaurd; +/** + 调用微信登录 获取access_token返回信息 + + @param dic 返回信息对象 + */ ++(void)saveWeiXinaccesstokenInfoWithDic:(NSDictionary *)dic; ++(NSDictionary *)getWeiXinAccessToenDic; + @end diff --git a/GIGA/Common/GiGaUserDB/GiGaUserDefault.m b/GIGA/Common/GiGaUserDB/GiGaUserDefault.m index 15e9993..4d9261c 100644 --- a/GIGA/Common/GiGaUserDB/GiGaUserDefault.m +++ b/GIGA/Common/GiGaUserDB/GiGaUserDefault.m @@ -12,6 +12,7 @@ NSString *const kUserManagerVerision = @"GiGAUserDBVeriosn"; NSString *const GIGADEFAULTKEY_USERID = @"GiGaUserId"; NSString *const kShowUserGuard = @"ShowUserGuard"; NSString *const kShowAppGuard = @"ShowAppGuard"; +NSString *const kWeiXinSaveToken = @"WeiXinSaveToken"; @implementation GiGaUserDefault @@ -77,4 +78,14 @@ NSString *const kShowAppGuard = @"ShowAppGuard"; return showedGaurd; } ++(void)saveWeiXinaccesstokenInfoWithDic:(NSDictionary *)dic +{ + [UD_STADARDUD setObject:dic forKey:kWeiXinSaveToken]; +} + ++(NSDictionary *)getWeiXinAccessToenDic{ + + return [UD_STADARDUD objectForKey:kWeiXinSaveToken]; +} + @end diff --git a/GIGA/Common/Source/4481.wav b/GIGA/Common/Source/4481.wav new file mode 100644 index 0000000..af66b76 Binary files /dev/null and b/GIGA/Common/Source/4481.wav differ diff --git a/GIGA/Config/GIGA.h b/GIGA/Config/GIGA.h index e63655a..4a66850 100644 --- a/GIGA/Config/GIGA.h +++ b/GIGA/Config/GIGA.h @@ -39,6 +39,10 @@ UD_SYNC #define kLOCALNotifiID_MASKETIMEEND @"GIGALocalNotificationMaskTimeEnd" //app 挂起 #define kLOCALNotifiID_APPTERMINAL @"GIGALocalNotificationAppTerminal" +//微信登陆授权成功 +#define kWeiXinAuthrization_Success @"WXAuthSuccess" +#define WXin_APPID @"wx1fa33defa5cbc8dd" +#define WXin_APPSecret @"3c03917b01f74a7f2d8a9bdd64f40697" #define GIGARGB(R,G,B,A) [UIColor colorWithRed:R/255.0f green:G/255.0f blue:B/255.0f alpha:A] #define GIGAUIColorFromRGB_A(rgbValue,alphaValue) [UIColor \ diff --git a/GIGA/Info.plist b/GIGA/Info.plist index 94c9d30..d169db5 100644 --- a/GIGA/Info.plist +++ b/GIGA/Info.plist @@ -2,6 +2,10 @@ + LSApplicationQueriesSchemes + + weixin + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleDisplayName @@ -18,6 +22,19 @@ APPL CFBundleShortVersionString 1.0 + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLName + weixin + CFBundleURLSchemes + + wx1fa33defa5cbc8dd + + + CFBundleVersion 1 LSRequiresIPhoneOS diff --git a/GIGA/Modules/LogIn/Controller/GiGaUserLoginVC.m b/GIGA/Modules/LogIn/Controller/GiGaUserLoginVC.m index d3439c5..1f4e766 100644 --- a/GIGA/Modules/LogIn/Controller/GiGaUserLoginVC.m +++ b/GIGA/Modules/LogIn/Controller/GiGaUserLoginVC.m @@ -11,6 +11,10 @@ #import "PassWordResetVC.h" #import "GiGaRegistViewController.h" #import "GiGaUserDefault.h" +#import "WXApi.h" +#import "GiGaNetManager.h" +#import "WeiIXinApiManager.h" + @interface GiGaUserLoginVC () @property (weak, nonatomic) IBOutlet UIImageView *userImagView; @property (weak, nonatomic) IBOutlet UITextField *acountTextField; @@ -33,9 +37,19 @@ [self textFieldUI]; [self.registBtn addTarget:self action:@selector(registBtnAction) forControlEvents:UIControlEventTouchUpInside]; [self.loginBtn addTarget:self action:@selector(loginBtnAction:) forControlEvents:UIControlEventTouchUpInside]; + [self.weiXinLoginBtn addTarget:self + action:@selector(weiXinLoginAction) forControlEvents:UIControlEventTouchUpInside]; + NC_ADD_TARGET_NAME_OBJECT(self, @selector(WeiXinLongIn:), kWeiXinAuthrization_Success, nil) + if (![WXApi isWXAppInstalled]) { + self.weiXinLoginBtn.hidden = YES; + } +} + +-(void)dealloc{ + NC_REMOVE_NAME(self, kWeiXinAuthrization_Success,nil); } -(void)setUpX{ @@ -49,8 +63,7 @@ } -(void)textFieldUI{ - - + //self.acountTextField.attributedPlaceholder = @""; UIView *acountView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)]; acountView.backgroundColor = [UIColor redColor]; @@ -60,7 +73,8 @@ self.acountTextField.leftView = acountView; self.acountTextField.leftViewMode = UITextFieldViewModeAlways; - [self.passwordTextField setValue:[UIColor colorWithRed:153/255.0f green:153/255.0f blue:153/255.0f alpha:1] forKey:@"_placeholderLabel.textColor"]; +// NSAttributedString *passholderText = [[NSAttributedString alloc] initWithString:@"密码" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:[UIColor redColor]}]; +// self.passwordTextField.attributedPlaceholder = passholderText; UIView *passView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)]; passView.backgroundColor = [UIColor redColor]; UIImageView *passViewIcon = [[UIImageView alloc] initWithFrame:CGRectMake(15, 5, 16, 18)]; @@ -68,7 +82,6 @@ [passView addSubview:passViewIcon]; self.passwordTextField.leftView = passView; self.passwordTextField.leftViewMode = UITextFieldViewModeAlways; - self.loginBtn.layer.masksToBounds = YES; self.loginBtn.layer.cornerRadius = self.loginBtn.frame.size.height / 2; @@ -116,4 +129,58 @@ [self dismissViewControllerAnimated:YES completion:nil]; } +#pragma mark - 微信登录 +// 授权 +-(void)weiXinLoginAction{ + + if ([WXApi isWXAppInstalled]) { + SendAuthReq * req = [[SendAuthReq alloc] init] ; + req.scope = @"snsapi_userinfo"; + req.state = @"wx_oauth2_authorization_state"; + [WXApi sendReq:req]; + + } +} + +//授权成功获取access_token +-(void)WeiXinLongIn:(NSNotification *)notification{ + + NSDictionary *param = @{ + @"appid":WXin_APPID, + @"secret":WXin_APPSecret, + @"code":notification.object[@"code"], + @"grant_type":@"authorization_code" + }; + [WeiIXinApiManager weixinAccessTokeRequstUrl:@"https://api.weixin.qq.com/sns/oauth2/access_token" parameters:param success:^(id response) { + NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingAllowFragments error:nil]; + GILog(@"access_token back -->%@",dict); + [GiGaUserDefault saveWeiXinaccesstokenInfoWithDic:dict]; + [self requstWeiXinUserinfo]; + + } failure:^(NSError *err) { + GILog(@"access_token err-->%@",err.localizedDescription); + + }]; + +} + +//获取微信用户信息 +-(void)requstWeiXinUserinfo{ + + NSDictionary *tokenDic = [GiGaUserDefault getWeiXinAccessToenDic]; + NSDictionary *param = @{ + @"openid":tokenDic[@"openid"], + @"access_token":tokenDic[@"access_token"], + }; + + [WeiIXinApiManager getWeiXinUserInfoUrl:@"https://api.weixin.qq.com/sns/userinfo" parameters:param success:^(id response) { + NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingAllowFragments error:nil]; + GILog(@"weixinUser info back -->%@",dict); + + } failure:^(NSError *err) { + + GILog(@"weixin_userinfoApi err-->%@",err.localizedDescription); + }]; +} + @end diff --git a/GIGA/Modules/Mask/Controller/GiGaMaskTaskViewController.m b/GIGA/Modules/Mask/Controller/GiGaMaskTaskViewController.m index 1043132..b830378 100644 --- a/GIGA/Modules/Mask/Controller/GiGaMaskTaskViewController.m +++ b/GIGA/Modules/Mask/Controller/GiGaMaskTaskViewController.m @@ -22,6 +22,7 @@ #import "LXCountTimer.h" #import "GiGaHelper.h" #import +#import "GiGaMeViewController.h" @interface GiGaMaskTaskViewController () { @@ -56,7 +57,7 @@ -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; - [self startMaskTime]; + } - (void)viewDidLoad { @@ -139,14 +140,15 @@ -(void)startMaskTime{ AppDelegate *delegate =(AppDelegate *) [[UIApplication sharedApplication] delegate]; + if (delegate.isMasking) { + return; + } delegate.isMasking = YES; [_musicPalyer play]; - [self setBackGroundPlayingInfo];//锁屏音频信息 //总时间隔 s NSTimeInterval timeInterVal = 58; - NSString *timeformat = [GiGaHelper stringWithNSTimerinterval:timeInterVal]; NSArray *timesArr = [timeformat componentsSeparatedByString:@":"]; NSString *hour = timesArr[0]; @@ -161,8 +163,7 @@ } -#pragma mark 设置后台锁屏样式 无效?? - +#pragma mark 设置后台锁屏音频信息 -(void)setBackGroundPlayingInfo{ MPMediaItemArtwork *arwork = [[MPMediaItemArtwork alloc] initWithImage:[UIImage imageNamed:@"MaskTime.png"]]; @@ -181,6 +182,7 @@ [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; } + - (void) remoteControlReceivedWithEvent: (UIEvent *) receivedEvent { if (receivedEvent.type == UIEventTypeRemoteControl) { @@ -216,15 +218,12 @@ #pragma mark 开始测试 -(void)testBtnAcion:(UIButton *)btn{ - AppDelegate *delegate =(AppDelegate *) [[UIApplication sharedApplication] delegate]; - if (delegate.isMasking) { - return; - } + [self startMaskTime]; - return ; - + BOOL isUserLogin = [GiGaUserDefault isUserLogin]; + if (isUserLogin) { //GIGA_ShowToast(@"userLogin!"); @@ -260,7 +259,6 @@ GiGaAdDetailViewController *detailVC=[[GiGaAdDetailViewController alloc] init]; [self.navigationController pushViewController:detailVC animated:YES]; - } #pragma mark 新手引导消失 @@ -298,11 +296,13 @@ userGuardVC.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5]; [self presentViewController:userGuardVC animated:NO completion:nil]; } + #pragma mark App引导页 -(void)showAPPappGaurdView{ GiGaAppGaurdVC *gaurdVC = [[GiGaAppGaurdVC alloc] init]; [self presentViewController:gaurdVC animated:YES completion:nil]; } + #pragma mark - setUpNav -(void)setUpNav{ @@ -320,11 +320,11 @@ [rightBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal]; [rightBtn addTarget:self action:@selector(rightBtnAction) forControlEvents:UIControlEventTouchUpInside]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightBtn]; - } -#pragma mark 消息 action +#pragma mark 消息 action -(void)leftBtnAction{ + BOOL isUserLogin = [GiGaUserDefault isUserLogin]; if (isUserLogin) { @@ -342,6 +342,9 @@ #pragma mark 个人中心 action -(void)rightBtnAction{ + GiGaMeViewController *meVC= [[GiGaMeViewController alloc] init]; + [self.navigationController pushViewController:meVC animated:YES]; + } #pragma mark -bottomView diff --git a/GIGA/Modules/Mask/Exercises/Controller/GiGaQuestionVC.m b/GIGA/Modules/Mask/Exercises/Controller/GiGaQuestionVC.m index 9973ae4..c9d9d01 100644 --- a/GIGA/Modules/Mask/Exercises/Controller/GiGaQuestionVC.m +++ b/GIGA/Modules/Mask/Exercises/Controller/GiGaQuestionVC.m @@ -44,7 +44,7 @@ -(void)setquestionArray{ NSArray *array = @[ - @{@"questionid" : @"1", @"totalCount" : @"5", @"question" : @"如果昨天是明天的话就好了,这样今天就周五了。真实的今天可能是星期几?", @"questiontype" : @"1", @"questiontype_text" : @"单选题", @"questionselectnumber" : @"3", @"questiondescribe" : @"星期三:理想今天是星期五,昨天是星期四,真实明天是理想的昨天是星期四,真实的今天是星期三。\n星期日:理想今天是星期五,明天是星期六,真实昨天是理想的明天是星期六,真实的今天是星期日。", @"trueanswer" : @"A", @"userAnswer" : @[], @"tkselect" : @[@"A:星期三", @"B:星期四", @"C:星期五"]}, + @{@"questionid" : @"1", @"totalCount" : @"5", @"question" : @"如果昨天是明天的话就好了,这样今天就周五了。真实的今天可能是星期几?", @"questiontype" : @"1", @"questiontype_text" : @"单选题", @"questionselectnumber" : @"3", @"questiondescribe" : @"星期三:理想今天是星期五,昨天是星期四,真实明天是理想的昨天是星期四,真实的今天是星期三。\n星期日:理想今天是星期五,明天是星期六,真实昨天是理想的明天是星期六,真实的今天是星期日。", @"trueanswer" : @"A", @"userAnswer" : @[], @"tkselect" : @[@"A:星期三星期三星期三星期三星期三星期三星期三", @"B:星期四", @"C:星期五星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三星期三"]}, @{@"questionid" : @"2", @"totalCount" : @"5", @"question" : @"这里是问题,这道题的答案是AC。这里是问题,这道题的答案是AC。这里是问题,这道题的答案是AC。", @"questiontype" : @"1", @"questiontype_text" : @"多选题", @"questionselectnumber" : @"5", @"questiondescribe" : @"这里是答案解析,这里可以很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长很长的。", @"trueanswer" : @"AC", @"userAnswer" : @[], @"tkselect" : @[@"A:这个选项是正确的。这个选项是正确的。这个选项是正确的。", @"B:这个选项是错误的。这个选项是错误的。这个选项是错误的。", @"C:这个选项是正确的。这个选项是正确的。这个选项是正确的。", @"D:这个选项是错误的。这个选项是错误的。这个选项是错误的。", @"E:这个选项是错误的。这个选项是错误的。这个选项是错误的。"]}, @{@"questionid" : @"3", @"totalCount" : @"5", @"question" : @"以下哪个牌子不是化妆品?", @"questiontype" : @"1", @"questiontype_text" : @"单选题", @"questionselectnumber" : @"3", @"questiondescribe" : @"化妆品,化妆品化妆品化妆品化妆品化妆品化妆品化妆品。", @"trueanswer" : @"A", @"userAnswer" : @[], @"tkselect" : @[@"A:化妆品", @"B:化妆品", @"C:星期五"]}, @{@"questionid" : @"4", @"totalCount" : @"5", @"question" : @"如果昨天是明天的话就好了,这样今天就周五了。真实的今天可能是星期几?", @"questiontype" : @"1", @"questiontype_text" : @"单选题", @"questionselectnumber" : @"3", @"questiondescribe" : @"真实昨天是理想的明天是星期六,真实的今天是星期日?", @"trueanswer" : @"A", @"userAnswer" : @[], @"tkselect" : @[@"A:星三", @"B:星", @"C:期"]}, @@ -80,9 +80,8 @@ [self.view layoutIfNeeded];//必加 //刷新答案相关数据 - [_questionView reloadViewWithFrame:CGRectMake(0, CGRectGetMaxY(_questionlabel.frame) + 15, KMainW, 0) style:[_currentModel.questiontype intValue] - 1 answerArray:_currentModel.tkselect userAnswers:_currentModel.userAnswer]; - - + [_questionView reloadViewWithFrame:CGRectMake(30, CGRectGetMaxY(_questionlabel.frame) + 15, KMainW - 30*2, 0) style:[_currentModel.questiontype intValue] - 1 answerArray:_currentModel.tkselect userAnswers:_currentModel.userAnswer]; + } #pragma mark 创建控件 diff --git a/GIGA/Modules/Mask/Exercises/View/GIGAQuetionView.m b/GIGA/Modules/Mask/Exercises/View/GIGAQuetionView.m index f2122c9..275765e 100644 --- a/GIGA/Modules/Mask/Exercises/View/GIGAQuetionView.m +++ b/GIGA/Modules/Mask/Exercises/View/GIGAQuetionView.m @@ -25,7 +25,7 @@ { if (!_view) { UIView *view = [[UIView alloc] init]; - //view.backgroundColor = [UIColor blueColor]; + view.backgroundColor = [UIColor blueColor]; [self addSubview:view]; _view = view; } @@ -77,13 +77,15 @@ NSString *labelText = _answerArr[i]; labelText = [labelText stringByReplacingOccurrencesOfString:@"\r" withString:@""]; labelText = [labelText stringByReplacingOccurrencesOfString:@"\n" withString:@""]; + //内容高度 - CGFloat labelH = [GiGaHelper sizeWithText:labelText font:font maxSize:CGSizeMake(KMainW - 50, MAXFLOAT)].height; + //CGFloat labelH = [GiGaHelper sizeWithText:labelText font:font maxSize:CGSizeMake(frame.size.width - btnH - 5, MAXFLOAT)].height; + CGFloat labelH = [GiGaHelper getSpaceLabelHeight:labelText withFont:font maxSize:CGSizeMake(frame.size.width - btnH - 5, MAXFLOAT)]; //选项标签 - UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(btnH + 5, labelY + 4, KMainW - 50, labelH)]; - label.text = labelText; + UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(btnH + 5, labelY + 4,frame.size.width - btnH - 5, labelH)]; + [GiGaHelper setLabelSpace:label withValue:labelText withFont:font] ; label.font = font; label.numberOfLines = 0; label.textColor = GIGAUIColorFromRGBA(0x616161); @@ -112,18 +114,17 @@ } } - self.view.frame = CGRectMake(10, 0, KMainW - 20, labelY - padding); + self.view.frame = CGRectMake(0,0,frame.size.width, labelY - padding); frame.size.height = labelY - padding; self.frame = frame; - [self setNeedsUpdateConstraints]; - [self mas_updateConstraints:^(MASConstraintMaker *make) { - make.top.mas_equalTo(self.superview.mas_top).offset(frame.origin.y + 10); - make.left.mas_equalTo(self.superview.mas_left).offset(30); - make.height.mas_equalTo(frame.size.height); - make.width.mas_equalTo(frame.size.width - 30*2); - }]; - +// [self setNeedsUpdateConstraints]; +// [self mas_updateConstraints:^(MASConstraintMaker *make) { +// make.top.mas_equalTo(self.superview.mas_top).offset(frame.origin.y + 10); +// make.left.mas_equalTo(self.superview.mas_left).offset(30); +// make.height.mas_equalTo(frame.size.height); +// make.width.mas_equalTo(frame.size.width - 30*2); +// }]; } - (void)btnOnClick:(UIButton *)btn diff --git a/GIGA/Modules/Me/Controller/GiGaMeViewController.m b/GIGA/Modules/Me/Controller/GiGaMeViewController.m index d811e88..24eab68 100644 --- a/GIGA/Modules/Me/Controller/GiGaMeViewController.m +++ b/GIGA/Modules/Me/Controller/GiGaMeViewController.m @@ -7,6 +7,7 @@ // #import "GiGaMeViewController.h" +#import "GiGaUserViewController.h" @interface GiGaMeViewController () @@ -16,6 +17,7 @@ - (void)viewDidLoad { [super viewDidLoad]; + self.title = @"我的"; // Do any additional setup after loading the view. } @@ -24,14 +26,12 @@ // Dispose of any resources that can be recreated. } -/* -#pragma mark - Navigation +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event +{ + GiGaUserViewController *userVC= [[GiGaUserViewController alloc] init]; + [self.navigationController pushViewController:userVC animated:YES]; -// In a storyboard-based application, you will often want to do a little preparation before navigation -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { - // Get the new view controller using [segue destinationViewController]. - // Pass the selected object to the new view controller. } -*/ + @end diff --git a/GIGA/Modules/Me/Controller/GiGaUserViewController.m b/GIGA/Modules/Me/Controller/GiGaUserViewController.m index c25b6c0..8eb792e 100644 --- a/GIGA/Modules/Me/Controller/GiGaUserViewController.m +++ b/GIGA/Modules/Me/Controller/GiGaUserViewController.m @@ -15,8 +15,11 @@ @implementation GiGaUserViewController - (void)viewDidLoad { + [super viewDidLoad]; // Do any additional setup after loading the view. + self.title = @"个人中心"; + } - (void)didReceiveMemoryWarning { @@ -24,6 +27,7 @@ // Dispose of any resources that can be recreated. } + /* #pragma mark - Navigation