航海的逻辑的修改

This commit is contained in:
fengshuo
2022-08-15 15:14:38 +08:00
parent d46b04b6bf
commit d2bbdc7e65
14 changed files with 253 additions and 24 deletions

View File

@@ -760,6 +760,8 @@
E8B846D626FDE01B00A777FE /* XPMineRechargePresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = E8B846D526FDE01B00A777FE /* XPMineRechargePresenter.m */; };
E8B846D826FDE17300A777FE /* XPMineRechargeProtocol.h in Sources */ = {isa = PBXBuildFile; fileRef = E8B846D726FDE16300A777FE /* XPMineRechargeProtocol.h */; };
E8B846DC26FDE24300A777FE /* RechargeListModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8B846DB26FDE24300A777FE /* RechargeListModel.m */; };
E8BD0F8828A9E9E400DE050D /* RoomSailingPrizeModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8BD0F8728A9E9E400DE050D /* RoomSailingPrizeModel.m */; };
E8BD0F8B28A9EB0A00DE050D /* RoomSailingPrizeListModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8BD0F8A28A9EB0A00DE050D /* RoomSailingPrizeListModel.m */; };
E8C1670928067DAA00ECB15C /* XPMineGuildSuperAdminSetViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E8C1670828067DAA00ECB15C /* XPMineGuildSuperAdminSetViewController.m */; };
E8C1670C28067DED00ECB15C /* XPMineGuildChooseManagerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E8C1670B28067DED00ECB15C /* XPMineGuildChooseManagerViewController.m */; };
E8C1671228067F6C00ECB15C /* XPGuildChooseManagerRoomTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E8C1671128067F6C00ECB15C /* XPGuildChooseManagerRoomTableViewCell.m */; };
@@ -2435,6 +2437,10 @@
E8B846D726FDE16300A777FE /* XPMineRechargeProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineRechargeProtocol.h; sourceTree = "<group>"; };
E8B846DA26FDE24300A777FE /* RechargeListModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RechargeListModel.h; sourceTree = "<group>"; };
E8B846DB26FDE24300A777FE /* RechargeListModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RechargeListModel.m; sourceTree = "<group>"; };
E8BD0F8628A9E9E400DE050D /* RoomSailingPrizeModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RoomSailingPrizeModel.h; sourceTree = "<group>"; };
E8BD0F8728A9E9E400DE050D /* RoomSailingPrizeModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RoomSailingPrizeModel.m; sourceTree = "<group>"; };
E8BD0F8928A9EB0A00DE050D /* RoomSailingPrizeListModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RoomSailingPrizeListModel.h; sourceTree = "<group>"; };
E8BD0F8A28A9EB0A00DE050D /* RoomSailingPrizeListModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RoomSailingPrizeListModel.m; sourceTree = "<group>"; };
E8C1670728067DAA00ECB15C /* XPMineGuildSuperAdminSetViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineGuildSuperAdminSetViewController.h; sourceTree = "<group>"; };
E8C1670828067DAA00ECB15C /* XPMineGuildSuperAdminSetViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineGuildSuperAdminSetViewController.m; sourceTree = "<group>"; };
E8C1670A28067DED00ECB15C /* XPMineGuildChooseManagerViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineGuildChooseManagerViewController.h; sourceTree = "<group>"; };
@@ -5380,7 +5386,6 @@
E8751E5528A62A1D0056EF44 /* Api */,
E8751E5428A62A150056EF44 /* View */,
E8751E5328A62A0E0056EF44 /* Presenter */,
E8751E5228A62A010056EF44 /* Protocol */,
);
path = Sailing;
sourceTree = "<group>";
@@ -5398,6 +5403,7 @@
children = (
E8751E5D28A62A970056EF44 /* XPSailingPresenter.h */,
E8751E5E28A62A970056EF44 /* XPSailingPresenter.m */,
E8751E5228A62A010056EF44 /* Protocol */,
);
path = Presenter;
sourceTree = "<group>";
@@ -5433,6 +5439,10 @@
E8751E7028A6541B0056EF44 /* RoomSailingRankModel.m */,
E8751E7228A665BC0056EF44 /* RoomSailingInfoModel.h */,
E8751E7328A665BC0056EF44 /* RoomSailingInfoModel.m */,
E8BD0F8928A9EB0A00DE050D /* RoomSailingPrizeListModel.h */,
E8BD0F8A28A9EB0A00DE050D /* RoomSailingPrizeListModel.m */,
E8BD0F8628A9E9E400DE050D /* RoomSailingPrizeModel.h */,
E8BD0F8728A9E9E400DE050D /* RoomSailingPrizeModel.m */,
);
path = Model;
sourceTree = "<group>";
@@ -7702,6 +7712,7 @@
E8788942273A55AD00BF1D57 /* XPGiftUsersView.m in Sources */,
9B8585D3278837CE00D7D5C6 /* NobleLevelUpModel.m in Sources */,
9BD9A17927A0EC57004186FE /* XPMineVisitorPresenter.m in Sources */,
E8BD0F8828A9E9E400DE050D /* RoomSailingPrizeModel.m in Sources */,
E8659909273E800D00EE349D /* XPGiftCollectionViewFlowLayout.m in Sources */,
E8B846CB26FDD7CD00A777FE /* XPMineRechargeViewController.m in Sources */,
E86596512701A1C000846EBD /* StatisticsService.m in Sources */,
@@ -7964,6 +7975,7 @@
9B1B72BF2800422E003FACE9 /* XPAnchorPKRuleView.m in Sources */,
9BE01AE428937EDE00B50299 /* XPDressUpShopCollectionViewCell.m in Sources */,
186A534B26FC6ED900D67B2C /* TTPopupManagerService.m in Sources */,
E8BD0F8B28A9EB0A00DE050D /* RoomSailingPrizeListModel.m in Sources */,
E8834E35280009090029CCC1 /* XPMineGuildSearchMemberTableViewCell.m in Sources */,
18E7B1B226E8AF980064BC9B /* MainPresenter.m in Sources */,
E81366F626F0C0DF0076364C /* LoginFullInfoPresenter.m in Sources */,

View File

@@ -21,6 +21,14 @@ NS_ASSUME_NONNULL_BEGIN
/// @param completion 完成
/// @param uid 用户的uid
+ (void)getSailingInfo:(HttpRequestHelperCompletion)completion uid:(NSString *)uid;
/// 开始航海
/// @param completion 完成
/// @param uid 用户的uid
/// @param keyNum 燃料数
/// @param sendMessage 是否发消息
/// @param roomUid 房间的uid
+ (void)openSailing:(HttpRequestHelperCompletion)completion uid:(NSString *)uid keyNum:(NSString *)keyNum sendMessage:(NSString *)sendMessage roomUid:(NSString *)roomUid;
@end
NS_ASSUME_NONNULL_END

View File

@@ -27,4 +27,15 @@
[self makeRequest:@"linearlyPool/userkey" method:HttpRequestHelperMethodGET completion:completion, uid, nil];
}
///
/// @param completion
/// @param uid uid
/// @param keyNum
/// @param sendMessage
/// @param roomUid uid
+ (void)openSailing:(HttpRequestHelperCompletion)completion uid:(NSString *)uid keyNum:(NSString *)keyNum sendMessage:(NSString *)sendMessage roomUid:(NSString *)roomUid {
[self makeRequest:@"" method:HttpRequestHelperMethodPOST completion:completion,__FUNCTION__, uid, keyNum, sendMessage, roomUid, nil];
}
@end

View File

@@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface RoomSailingInfoModel : NSObject
///燃料的个数
@property (nonatomic, assign) int keyNum;
@property (nonatomic, assign) NSInteger keyNum;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,19 @@
//
// RoomSailingPrizeListModel.h
// xplan-ios
//
// Created by 冯硕 on 2022/8/15.
//
#import <Foundation/Foundation.h>
#import "RoomSailingPrizeModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface RoomSailingPrizeListModel : NSObject
///奖品的数组
@property (nonatomic,strong) NSArray<RoomSailingPrizeModel *> *prizeItemList;
///剩余钥匙数
@property (nonatomic,assign) NSInteger remainKeyNum;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,15 @@
//
// RoomSailingPrizeListModel.m
// xplan-ios
//
// Created by on 2022/8/15.
//
#import "RoomSailingPrizeListModel.h"
@implementation RoomSailingPrizeListModel
+ (NSDictionary *)objectClassInArray {
return @{@"prizeItemList": RoomSailingPrizeModel.class};
}
@end

View File

@@ -0,0 +1,45 @@
//
// RoomSailingPrizeModel.h
// xplan-ios
//
// Created by 冯硕 on 2022/8/15.
//
#import <Foundation/Foundation.h>
typedef enum : NSUInteger {
SailingPrizeLevelOne=1,
SailingPrizeLevelTwo,
SailingPrizeLevelThree,
SailingPrizeLevelFour,
} SailingPrizeLevel;
//奖品类型。1-萌币2-礼物3-座驾4-头饰5-背景6-实物7-靓号8-全麦礼物
typedef NS_ENUM(NSUInteger, SailingPrizeType) {
SailingPrizeType_Gold = 1,
SailingPrizeType_Gift,
SailingPrizeType_Car,
SailingPrizeType_Headwear,
SailingPrizeType_Background,
SailingPrizeType_Matter,
SailingPrizeType_Beautif,
SailingPrizeType_WholeServer
};
NS_ASSUME_NONNULL_BEGIN
@interface RoomSailingPrizeModel : NSObject
@property (nonatomic, copy) NSString *prizeName;//奖品名称
@property (nonatomic, copy) NSString *prizeImgUrl;//奖品icon
@property (nonatomic, assign) SailingPrizeType prizeType;//奖品类型
@property (nonatomic, copy) NSString *prizeTypeDesc;//奖品类型描述
@property (nonatomic, assign) int prizeNum;//奖品数量
@property (nonatomic, assign) CGFloat platformValue;//价格
@property (nonatomic, assign) SailingPrizeLevel prizeLevel;//奖品等级
@property (nonatomic, assign) NSInteger referenceId;//相关实体id
@property (nonatomic, assign) NSInteger prizeId;//奖品id
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,12 @@
//
// RoomSailingPrizeModel.m
// xplan-ios
//
// Created by on 2022/8/15.
//
#import "RoomSailingPrizeModel.h"
@implementation RoomSailingPrizeModel
@end

View File

@@ -0,0 +1,21 @@
//
// XPSailingProtocol.h
// xplan-ios
//
// Created by 冯硕 on 2022/8/12.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class RoomSailingInfoModel, RoomSailingPrizeListModel;
@protocol XPSailingProtocol <NSObject>
///获取航海的信息成功
- (void)getSailingInfoSuccess:(RoomSailingInfoModel *)info;
///开启一个探索成功
- (void)openSailingSuccess:(RoomSailingPrizeListModel *)model;
///探索一次失败
- (void)openSailingFail:(NSString *)message;
@end
NS_ASSUME_NONNULL_END

View File

@@ -10,7 +10,11 @@
NS_ASSUME_NONNULL_BEGIN
@interface XPSailingPresenter : BaseMvpPresenter
/// 获取航海信息
- (void)getSailingInfo;
///开始探索
- (void)openSailing:(NSString *)roomUid sendMessage:(BOOL)sendMessage keyNum:(NSInteger)keyNum;
@end
NS_ASSUME_NONNULL_END

View File

@@ -6,7 +6,34 @@
//
#import "XPSailingPresenter.h"
#import "Api+Sailing.h"
#import "AccountInfoStorage.h"
#import "RoomSailingInfoModel.h"
#import "RoomSailingPrizeListModel.h"
#import "XPSailingProtocol.h"
@implementation XPSailingPresenter
///
- (void)getSailingInfo {
NSString * uid = [AccountInfoStorage instance].getUid;
[Api getSailingInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
RoomSailingInfoModel * info = [RoomSailingInfoModel modelWithDictionary:data.data];
[[self getView] getSailingInfoSuccess:info];
}] uid:uid];
}
///
- (void)openSailing:(NSString *)roomUid sendMessage:(BOOL)sendMessage keyNum:(NSInteger)keyNum {
NSString * keyNumStr = [NSString stringWithFormat:@"%ld", keyNum];
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * sendMessageStr = [NSString stringWithFormat:@"%d", sendMessage];
[Api openSailing:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
RoomSailingPrizeListModel * listModel = [RoomSailingPrizeListModel modelWithDictionary:data.data];
[[self getView] openSailingSuccess:listModel];
} fail:^(NSInteger code, NSString * _Nullable msg) {
[[self getView] openSailingFail:msg];
} showLoading:YES] uid:uid keyNum:keyNumStr sendMessage:sendMessageStr roomUid:roomUid];
}
@end

View File

@@ -1,16 +0,0 @@
//
// XPSailingProtocol.h
// xplan-ios
//
// Created by 冯硕 on 2022/8/12.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol XPSailingProtocol <NSObject>
@end
NS_ASSUME_NONNULL_END

View File

@@ -5,12 +5,11 @@
// Created by 冯硕 on 2022/8/12.
//
#import "BaseViewController.h"
#import "MvpViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface XPSailingViewController : BaseViewController
@interface XPSailingViewController : MvpViewController
- (instancetype)initWithRoomUid:(NSString *)roomUid;
@end
NS_ASSUME_NONNULL_END

View File

@@ -8,17 +8,24 @@
#import "XPSailingViewController.h"
///Third
#import <Masonry/Masonry.h>
#import <NIMSDK/NIMSDK.h>
///Tool
#import "ThemeColor.h"
#import "XPMacro.h"
#import "TTPopup.h"
#import "XPHtmlUrl.h"
///Model
#import "RoomSailingInfoModel.h"
#import "RoomSailingPrizeListModel.h"
#import "AttachmentModel.h"
///View
#import "XPSailingRankView.h"
#import "XPRoomHalfWebView.h"
///P
#import "XPSailingPresenter.h"
#import "XPSailingProtocol.h"
@interface XPSailingViewController ()
@interface XPSailingViewController ()<XPSailingProtocol, NIMSystemNotificationManagerDelegate>
///View
@property (nonatomic,strong) UIView * topView;
///
@@ -48,10 +55,30 @@
///
@property (nonatomic,strong) UILabel *consumLabel;
@property (nonatomic,assign) NSInteger exploreCount;
///
@property (nonatomic,strong) RoomSailingInfoModel *sailingInfo;
///uid
@property (nonatomic,strong) NSString *roomUid;
@end
@implementation XPSailingViewController
- (void)dealloc {
[[NIMSDK sharedSDK].systemNotificationManager removeDelegate:self];
}
- (instancetype)initWithRoomUid:(NSString *)roomUid {
if (self = [super init]) {
self.roomUid = roomUid;
[[NIMSDK sharedSDK].systemNotificationManager addDelegate:self];
}
return self;
}
- (__kindof id)createPresenter {
return [[XPSailingPresenter alloc] init];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self initSubViews];
@@ -158,6 +185,24 @@
}];
}
#pragma mark - XPSailingProtocol
- (void)getSailingInfoSuccess:(RoomSailingInfoModel *)info {
self.sailingInfo = info;
NSString * fuleStr = [NSString stringWithFormat:@"%ld", info.keyNum];
[self.fuleButton setTitle:fuleStr forState:UIControlStateNormal];
}
- (void)openSailingSuccess:(RoomSailingPrizeListModel *)model {
self.sailingInfo.keyNum = model.remainKeyNum;
NSString * fuleStr = [NSString stringWithFormat:@"%ld", self.sailingInfo.keyNum];
[self.fuleButton setTitle:fuleStr forState:UIControlStateNormal];
self.exploreButton.userInteractionEnabled = YES;
}
- (void)openSailingFail:(NSString *)message {
self.exploreButton.userInteractionEnabled = YES;
}
#pragma mark - Event Response
- (void)dismissView {
[self dismissViewControllerAnimated:YES completion:nil];
@@ -197,7 +242,22 @@
}
- (void)exploreButtonAction:(UIButton *)sender {
if (self.exploreCount > self.sailingInfo.keyNum) {
TTAlertConfig * config = [[TTAlertConfig alloc] init];
config.title = @"";
config.message = @"参与活动获得燃料";
config.confirmButtonConfig.title = @"去参与";
config.cancelButtonConfig.title = @"取消";
[TTPopup alertWithConfig:config confirmHandler:^{
[self getFuleButtonAction:self.getFuleButton];
} cancelHandler:^{
}];
} else {
NSString * roomUid = [NSString stringWithFormat:@""];
[self.presenter openSailing:roomUid sendMessage:YES keyNum:self.exploreCount];
self.exploreButton.userInteractionEnabled = NO;
}
}
- (void)textFiledDidChange:(UITextField *)textFiled {
@@ -214,6 +274,18 @@
self.exploreCount = textFiled.text.integerValue;
}
#pragma mark - NIMSystemNotificationManagerDelegate
- (void)onReceiveCustomSystemNotification:(NIMCustomSystemNotification *)notification {
if (notification.receiverType == NIMSessionTypeP2P) {
AttachmentModel *attachment = [AttachmentModel modelWithJSON:notification.content];
if (attachment.first == CustomMessageType_Account && attachment.second == Custom_Message_Sub_Account_Changed){
if (attachment.second == Custom_Message_Sub_Account_Changed) {
[self.presenter getSailingInfo];
}
}
}
}
#pragma mark - Getters And Setters
- (void)setExploreCount:(NSInteger)exploreCount {
_exploreCount = exploreCount;