diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index 8f08c0ad..cf233f79 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -163,6 +163,7 @@ E8788950273A699900BF1D57 /* ThemeColor+SendGift.m in Sources */ = {isa = PBXBuildFile; fileRef = E878894F273A699900BF1D57 /* ThemeColor+SendGift.m */; }; E8788960273BB14200BF1D57 /* XPGiftMicroUserModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E878895F273BB14200BF1D57 /* XPGiftMicroUserModel.m */; }; E87A24F1272935920086A794 /* XPMessageRemoteExtModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E87A24F0272935920086A794 /* XPMessageRemoteExtModel.m */; }; + E884C36C2743951B00E1EBED /* GiftReceiveInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E884C36B2743951B00E1EBED /* GiftReceiveInfoModel.m */; }; E88B5CA526FB088600DA9178 /* XPMineTeenagerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E88B5CA426FB088600DA9178 /* XPMineTeenagerViewController.m */; }; E88B5CA826FB089C00DA9178 /* XPMineTeenagePwdViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E88B5CA726FB089C00DA9178 /* XPMineTeenagePwdViewController.m */; }; E88B5CAD26FB16A800DA9178 /* XPMineTeenagerDesView.m in Sources */ = {isa = PBXBuildFile; fileRef = E88B5CAC26FB16A800DA9178 /* XPMineTeenagerDesView.m */; }; @@ -563,6 +564,8 @@ E878895F273BB14200BF1D57 /* XPGiftMicroUserModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPGiftMicroUserModel.m; sourceTree = ""; }; E87A24EF272935920086A794 /* XPMessageRemoteExtModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMessageRemoteExtModel.h; sourceTree = ""; }; E87A24F0272935920086A794 /* XPMessageRemoteExtModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMessageRemoteExtModel.m; sourceTree = ""; }; + E884C36A2743951B00E1EBED /* GiftReceiveInfoModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiftReceiveInfoModel.h; sourceTree = ""; }; + E884C36B2743951B00E1EBED /* GiftReceiveInfoModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiftReceiveInfoModel.m; sourceTree = ""; }; E88B5CA326FB088600DA9178 /* XPMineTeenagerViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineTeenagerViewController.h; sourceTree = ""; }; E88B5CA426FB088600DA9178 /* XPMineTeenagerViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineTeenagerViewController.m; sourceTree = ""; }; E88B5CA626FB089C00DA9178 /* XPMineTeenagePwdViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineTeenagePwdViewController.h; sourceTree = ""; }; @@ -1517,6 +1520,8 @@ E890BC03273CF0500007C46B /* XPGiftCountModel.m */, E890BC0E273D23F00007C46B /* GiftInfoModel.h */, E890BC0F273D23F00007C46B /* GiftInfoModel.m */, + E884C36A2743951B00E1EBED /* GiftReceiveInfoModel.h */, + E884C36B2743951B00E1EBED /* GiftReceiveInfoModel.m */, ); path = Model; sourceTree = ""; @@ -2345,6 +2350,7 @@ E872308926E89BE000B90D4F /* LoginPhoneViewController.m in Sources */, 18E7B29026EA0E6B0064BC9B /* FlutterBoost+Xplan.m in Sources */, E8B846DC26FDE24300A777FE /* RechargeListModel.m in Sources */, + E884C36C2743951B00E1EBED /* GiftReceiveInfoModel.m in Sources */, 189DD75926E6003C00AB55B1 /* Api.m in Sources */, E8133916273E532D00708B66 /* XPGiftItemCollectionViewCell.m in Sources */, E8788934273A53D700BF1D57 /* XPSendGiftView.m in Sources */, diff --git a/xplan-ios/Assets.xcassets/Gift/gift_bar_recharge_arrow.imageset/gift_bar_recharge_arrow@2x.png b/xplan-ios/Assets.xcassets/Gift/gift_bar_recharge_arrow.imageset/gift_bar_recharge_arrow@2x.png index 2a813a65..5addaaa6 100644 Binary files a/xplan-ios/Assets.xcassets/Gift/gift_bar_recharge_arrow.imageset/gift_bar_recharge_arrow@2x.png and b/xplan-ios/Assets.xcassets/Gift/gift_bar_recharge_arrow.imageset/gift_bar_recharge_arrow@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Gift/gift_bar_recharge_arrow.imageset/gift_bar_recharge_arrow@3x.png b/xplan-ios/Assets.xcassets/Gift/gift_bar_recharge_arrow.imageset/gift_bar_recharge_arrow@3x.png index 538d3c86..3594fb7f 100644 Binary files a/xplan-ios/Assets.xcassets/Gift/gift_bar_recharge_arrow.imageset/gift_bar_recharge_arrow@3x.png and b/xplan-ios/Assets.xcassets/Gift/gift_bar_recharge_arrow.imageset/gift_bar_recharge_arrow@3x.png differ diff --git a/xplan-ios/Base/UI/SendGiftView/Api/Api+Gift.h b/xplan-ios/Base/UI/SendGiftView/Api/Api+Gift.h index 5206bf04..283ac35f 100644 --- a/xplan-ios/Base/UI/SendGiftView/Api/Api+Gift.h +++ b/xplan-ios/Base/UI/SendGiftView/Api/Api+Gift.h @@ -24,6 +24,28 @@ NS_ASSUME_NONNULL_BEGIN /// @param roomUid 房间的roomuid + (void)requestNormalGiftList:(HttpRequestHelperCompletion)complection roomUid:(NSString *)roomUid; + +/// 送礼物的接口 +/// @param complection 完成 +/// @param targetUids 送给谁的 +/// @param giftNum 送的个数 +/// @param sendType 送的类型 +/// @param giftId 礼物的id +/// @param giftSource 礼物的来源 +/// @param giftType 礼物的类型 +/// @param roomUid 房间的ID +/// @param msg 喊话的 +/// @param uid 用户的id ++ (void)requestSendGift:(HttpRequestHelperCompletion)complection + targetUids:(NSString *)targetUids + giftNum:(NSString *)giftNum + sendType:(NSString *)sendType + giftId:(NSString *)giftId + giftSource:(NSString *)giftSource + giftType:(NSString *)giftType + roomUid:(NSString *)roomUid + msg:(NSString *)msg + uid:(NSString *)uid; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Base/UI/SendGiftView/Api/Api+Gift.m b/xplan-ios/Base/UI/SendGiftView/Api/Api+Gift.m index 6c5c470f..75e8a04a 100644 --- a/xplan-ios/Base/UI/SendGiftView/Api/Api+Gift.m +++ b/xplan-ios/Base/UI/SendGiftView/Api/Api+Gift.m @@ -24,4 +24,30 @@ + (void)requestNormalGiftList:(HttpRequestHelperCompletion)complection roomUid:(NSString *)roomUid { [self makeRequest:@"gift/listV3" method:HttpRequestHelperMethodGET completion:complection, __FUNCTION__, roomUid, nil]; } + +/// 送礼物的接口 +/// @param complection 完成 +/// @param targetUids 送给谁的 +/// @param giftNum 送的个数 +/// @param sendType 送的类型 +/// @param giftId 礼物的id +/// @param giftSource 礼物的来源 +/// @param giftType 礼物的类型 +/// @param roomUid 房间的ID +/// @param msg 喊话的 +/// @param uid 用户的id ++ (void)requestSendGift:(HttpRequestHelperCompletion)complection + targetUids:(NSString *)targetUids + giftNum:(NSString *)giftNum + sendType:(NSString *)sendType + giftId:(NSString *)giftId + giftSource:(NSString *)giftSource + giftType:(NSString *)giftType + roomUid:(NSString *)roomUid + msg:(NSString *)msg + uid:(NSString *)uid { + NSString *method = @"gift/sendV4"; + [self makeRequest:method method:HttpRequestHelperMethodPOST completion:complection, __FUNCTION__, targetUids, giftNum, sendType, giftId, giftSource, giftType, roomUid, msg, uid, nil]; +} + @end diff --git a/xplan-ios/Base/UI/SendGiftView/Model/GiftInfoModel.h b/xplan-ios/Base/UI/SendGiftView/Model/GiftInfoModel.h index 0ea22477..7f09ae9b 100644 --- a/xplan-ios/Base/UI/SendGiftView/Model/GiftInfoModel.h +++ b/xplan-ios/Base/UI/SendGiftView/Model/GiftInfoModel.h @@ -14,6 +14,38 @@ typedef NS_ENUM(NSUInteger, GiftType) { GiftType_Lucky = 3, // 福袋礼物 }; +//礼物类型 +typedef NS_ENUM(NSUInteger, GiftSourceType) { + GiftSourceType_Normal = 1, //普通礼物 + GiftSourceType_Pack = 2, // 背包礼物 +}; + +/** + 赠送类型 1给主播直接刷礼物,2私聊送个人礼物,3房间内给坑位上的人送礼物,5.公聊大厅给人送礼物 + + - GameRoomSendType_Room: 给主播直接刷礼物 + - GameRoomSendType_Chat: 2私聊送个人礼物 + - GameRoomSendType_OnMic: 3房间内给坑位上的人送礼物 + - GameRoomSendType_PublicChat: 公聊大厅给人送礼物 + - GameRoomSendType_Team 群聊礼物 + */ +typedef NS_ENUM(NSUInteger, GiftSendType) { + GiftSendType_Room = 1,///zho + GiftSendType_Chat = 2, + GiftSendType_OnMic = 3, +}; + +/** + 送礼物的类型,1全麦,2多人非全麦,3个人送礼w + - GameRoomSendGiftType_AllMic: 全麦 + - GameRoomSendGiftType_MutableOnMic: 多人w非全麦 + - GameRoomSendGiftType_ToOne: 对个人送礼 + */ +typedef NS_ENUM(NSUInteger, RoomSendGiftType) { + RoomSendGiftType_AllMic, + RoomSendGiftType_MutableOnMic, + RoomSendGiftType_ToOne, +}; @interface GiftInfoModel : NSObject ///礼物id @@ -52,6 +84,8 @@ typedef NS_ENUM(NSUInteger, GiftType) { //isSelected 用于本地修改 @property (nonatomic,assign) BOOL isSelected;//是否被选中 +///礼物来源 +@property (nonatomic,assign) GiftSourceType sourceType; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Base/UI/SendGiftView/Model/GiftReceiveInfoModel.h b/xplan-ios/Base/UI/SendGiftView/Model/GiftReceiveInfoModel.h new file mode 100644 index 00000000..4441e766 --- /dev/null +++ b/xplan-ios/Base/UI/SendGiftView/Model/GiftReceiveInfoModel.h @@ -0,0 +1,76 @@ +// +// GiftReceiveInfoModel.h +// xplan-ios +// +// Created by 冯硕 on 2021/11/16. +// + +/* + avatar = "http://img.uat.lecheng163.com/FoNOJJrSIf9WpJ8jHC_7OGxP841o?imageslim"; + currentTime = 1637047533593; + gift = { + consumeType = 1; + giftId = 1423; + giftName = "\U795e\U79d8\U7cbd\U5b50"; + giftType = 2; + giftUrl = "http://image.uat.zhongjialx.com/FmDCm483cDGPfM1cy-KW2558HUHx?imageslim"; + goldPrice = 33; + hasEffect = 0; + hasLatest = 0; + hasTimeLimit = 0; + hasVggPic = 0; + isNobleGift = 0; + isSendMsg = 0; + isSkipRoom = 0; + isWholeServer = 0; + nobleId = 0; + nobleName = ""; + roomExclude = 0; + seqNo = 1; + vggUrl = "http://image.uat.zhongjialx.com/FmDCm483cDGPfM1cy-KW2558HUHx?imageslim"; + }; + giftId = 1423; + giftNum = 1; + nick = "\U636e\U5065\U5065\U5eb7\U5eb7****"; + targetUsers = ( + { + avatar = "http://img.uat.lecheng163.com/FnEA7WfDtE2gMLyEvGLkY0Sa9cRk?imageslim"; + nick = "IU\U7684\U79d8\U5bc6\U7537\U53cb"; + uid = 940317; + } + ); + uid = 940318;*/ + +#import +#import "GiftInfoModel.h" +NS_ASSUME_NONNULL_BEGIN + +@interface GiftReceiveUserInfoModel : NSObject +///收礼物的人 +@property(nonatomic, strong)NSString *nick; +///收礼物的人的头像 +@property(nonatomic, strong)NSString *avatar; +@end + + +@interface GiftReceiveInfoModel : NSObject +@property (nonatomic, strong) NSArray *targetUids; +///礼物信息 +@property (nonatomic,strong) GiftInfoModel *gift; +///送礼物的人uid +@property(nonatomic, assign)NSString * uid; +///礼物的id +@property (nonatomic,copy) NSString *giftId; +///送礼物的人 +@property(nonatomic, strong)NSString *nick; +///送礼物的人的头像 +@property(nonatomic, strong)NSString *avatar; +///送礼物的个数 +@property (assign, nonatomic) NSInteger giftNum; +/** 非全麦 多人送礼时 */ +@property (nonatomic, strong) NSArray *targetUsers; +///礼物来源 +@property (nonatomic,assign) GiftSourceType sourceType; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Base/UI/SendGiftView/Model/GiftReceiveInfoModel.m b/xplan-ios/Base/UI/SendGiftView/Model/GiftReceiveInfoModel.m new file mode 100644 index 00000000..2c1673ab --- /dev/null +++ b/xplan-ios/Base/UI/SendGiftView/Model/GiftReceiveInfoModel.m @@ -0,0 +1,21 @@ +// +// GiftReceiveInfoModel.m +// xplan-ios +// +// Created by 冯硕 on 2021/11/16. +// + +#import "GiftReceiveInfoModel.h" +#import "NSObject+MJExtension.h" + +@implementation GiftReceiveUserInfoModel + +@end + +@implementation GiftReceiveInfoModel + ++ (NSDictionary *)objectClassInArray { + return @{@"targetUsers":GiftReceiveUserInfoModel.class}; +} + +@end diff --git a/xplan-ios/Base/UI/SendGiftView/Presenter/XPGiftPresenter.h b/xplan-ios/Base/UI/SendGiftView/Presenter/XPGiftPresenter.h index 14b005fd..9fa46d71 100644 --- a/xplan-ios/Base/UI/SendGiftView/Presenter/XPGiftPresenter.h +++ b/xplan-ios/Base/UI/SendGiftView/Presenter/XPGiftPresenter.h @@ -6,7 +6,7 @@ // #import "BaseMvpPresenter.h" - +#import "GiftInfoModel.h" NS_ASSUME_NONNULL_BEGIN @interface XPGiftPresenter : NSObject @@ -22,6 +22,25 @@ NS_ASSUME_NONNULL_BEGIN - (void)getNormalGiftList:(NSString *)roomUid; /// 获取背包礼物 - (void)getPackGiftList; +/// 送礼物 +/// @param targetUids 送礼物的人 +/// @param giftNum 礼物的个数 +/// @param sendType 送的类型 +/// @param giftId 送礼物的id +/// @param giftSource 送礼物的来源 +/// @param giftType 礼物的类型 +/// @param roomSendType 赠送的类型 +/// @param roomUid 房主的uid +/// @param msg 喊话的内容 +- (void)sendGift:(NSString *)targetUids + giftNum:(NSString *)giftNum + sendType:(GiftSendType)sendType + giftId:(NSString *)giftId + giftSource:(GiftSourceType)giftSource + giftType:(GiftType)giftType + roomSendType:(RoomSendGiftType)roomSendType + roomUid:(NSString *)roomUid + msg:(NSString *)msg; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Base/UI/SendGiftView/Presenter/XPGiftPresenter.m b/xplan-ios/Base/UI/SendGiftView/Presenter/XPGiftPresenter.m index 8f80dc21..d5b316cc 100644 --- a/xplan-ios/Base/UI/SendGiftView/Presenter/XPGiftPresenter.m +++ b/xplan-ios/Base/UI/SendGiftView/Presenter/XPGiftPresenter.m @@ -11,7 +11,7 @@ #import "Api+Gift.h" ///Model #import "WalletInfoModel.h" -#import "GiftInfoModel.h" +#import "GiftReceiveInfoModel.h" ///P #import "XPGiftProtocol.h" @@ -62,4 +62,39 @@ } uid:uid ticket:ticket]; } + +/// 送礼物 +/// @param targetUids 送礼物的人 +/// @param giftNum 礼物的个数 +/// @param sendType 送的类型 +/// @param giftId 送礼物的id +/// @param giftSource 送礼物的来源 +/// @param giftType 礼物的类型 +/// @param roomSendType 赠送的类型 +/// @param roomUid 房主的uid +/// @param msg 喊话的内容 +- (void)sendGift:(NSString *)targetUids + giftNum:(NSString *)giftNum + sendType:(GiftSendType)sendType + giftId:(NSString *)giftId + giftSource:(GiftSourceType)giftSource + giftType:(GiftType)giftType + roomSendType:(RoomSendGiftType)roomSendType + roomUid:(NSString *)roomUid + msg:(NSString *)msg + { + NSString * uid = [AccountInfoStorage instance].getUid; + NSString * giftSourceStr = [NSString stringWithFormat:@"%ld", giftSource]; + NSString * giftTypeStr = [NSString stringWithFormat:@"%ld", giftType]; + NSString * giftSendTypeStr = [NSString stringWithFormat:@"%ld", sendType]; + if (roomUid.length <=0) { + roomUid = @""; + } + [Api requestSendGift:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + GiftReceiveInfoModel *receive = [GiftReceiveInfoModel modelWithJSON:data.data]; + receive.sourceType = giftSource; + [self.getView sendGiftSuccess:receive]; + } targetUids:targetUids giftNum:giftNum sendType:giftSendTypeStr giftId:giftId giftSource:giftSourceStr giftType:giftTypeStr roomUid:roomUid msg:msg uid:uid]; +} + @end diff --git a/xplan-ios/Base/UI/SendGiftView/Protocol/XPGiftProtocol.h b/xplan-ios/Base/UI/SendGiftView/Protocol/XPGiftProtocol.h index 1dae3651..144987a9 100644 --- a/xplan-ios/Base/UI/SendGiftView/Protocol/XPGiftProtocol.h +++ b/xplan-ios/Base/UI/SendGiftView/Protocol/XPGiftProtocol.h @@ -8,13 +8,15 @@ #import NS_ASSUME_NONNULL_BEGIN -@class WalletInfoModel, GiftInfoModel; +@class WalletInfoModel, GiftInfoModel, GiftReceiveInfoModel; @protocol XPGiftProtocol - (void)getUserWalletInfo:(WalletInfoModel *)balanceInfo; ///获取普通礼物列表 - (void)getNormalGiftListSuccess:(NSArray *)giftList; ///获取背包礼物列表 - (void)getPacketGiftListSuccess:(NSArray *)giftList; + +- (void)sendGiftSuccess:(GiftReceiveInfoModel *)receiveInfo;; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Base/UI/SendGiftView/View/Cell/XPGiftEmptyCollectionViewCell.m b/xplan-ios/Base/UI/SendGiftView/View/Cell/XPGiftEmptyCollectionViewCell.m index 56cdf08d..6f5e9618 100644 --- a/xplan-ios/Base/UI/SendGiftView/View/Cell/XPGiftEmptyCollectionViewCell.m +++ b/xplan-ios/Base/UI/SendGiftView/View/Cell/XPGiftEmptyCollectionViewCell.m @@ -6,7 +6,48 @@ // #import "XPGiftEmptyCollectionViewCell.h" +///Third +#import +///Tool +#import "ThemeColor+SendGift.h" + +@interface XPGiftEmptyCollectionViewCell () +/// +@property (nonatomic,strong) UILabel *emptyPackTip; +@end @implementation XPGiftEmptyCollectionViewCell +- (instancetype)initWithFrame:(CGRect)frame { + self = [super initWithFrame:frame]; + if (self) { + [self initSubViews]; + [self initSubViewConstraints]; + } + return self; +} + +#pragma mark - Private Method +- (void)initSubViews { + [self.contentView addSubview:self.emptyPackTip]; +} + +- (void)initSubViewConstraints { + [self.emptyPackTip mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self); + }]; +} + +#pragma mark - Getters And Setters +- (UILabel *)emptyPackTip { + if (!_emptyPackTip) { + _emptyPackTip = [[UILabel alloc] init]; + _emptyPackTip.text = @"背包暂无内容~";; + _emptyPackTip.textColor = [ThemeColor secondTextColor]; + _emptyPackTip.font = [UIFont systemFontOfSize:12]; + _emptyPackTip.textAlignment = NSTextAlignmentCenter; + } + return _emptyPackTip; +} + @end diff --git a/xplan-ios/Base/UI/SendGiftView/View/Cell/XPGiftUserCollectionViewCell.m b/xplan-ios/Base/UI/SendGiftView/View/Cell/XPGiftUserCollectionViewCell.m index cde6b371..2c0ee28a 100644 --- a/xplan-ios/Base/UI/SendGiftView/View/Cell/XPGiftUserCollectionViewCell.m +++ b/xplan-ios/Base/UI/SendGiftView/View/Cell/XPGiftUserCollectionViewCell.m @@ -77,7 +77,7 @@ make.width.mas_equalTo(23); }]; } else { - self.positionLabel.text = [NSString stringWithFormat:@"%d", microModel.microQueue.microState.position]; + self.positionLabel.text = [NSString stringWithFormat:@"%d", microModel.microQueue.microState.position + 1]; [self.positionLabel mas_updateConstraints:^(MASConstraintMaker *make) { make.width.mas_equalTo(10); }]; diff --git a/xplan-ios/Base/UI/SendGiftView/View/XPGiftBarView.h b/xplan-ios/Base/UI/SendGiftView/View/XPGiftBarView.h index 37ee3290..32b1d37d 100644 --- a/xplan-ios/Base/UI/SendGiftView/View/XPGiftBarView.h +++ b/xplan-ios/Base/UI/SendGiftView/View/XPGiftBarView.h @@ -6,13 +6,10 @@ // #import - +#import "XPGiftInfoView.h" NS_ASSUME_NONNULL_BEGIN @class XPGiftBarView, XPGiftCountModel, WalletInfoModel; @protocol XPGiftBarViewDelegate - -///点击了选择数量的 -- (void)xPGiftBarView:(XPGiftBarView *)view didClickCountButton:(UIButton *)sender; ///点击了充值的 - (void)xPGiftBarViewDidClickRecharge:(XPGiftBarView *)view;; ///点击了送礼物的的 @@ -22,6 +19,8 @@ NS_ASSUME_NONNULL_BEGIN @interface XPGiftBarView : UIView ///代理 @property (nonatomic,weak) id delegate; +///不同的tabbar +@property (nonatomic,assign) GiftSegmentType type; ///更新礼物个数 @property (nonatomic,strong) XPGiftCountModel *giftCountModel; diff --git a/xplan-ios/Base/UI/SendGiftView/View/XPGiftBarView.m b/xplan-ios/Base/UI/SendGiftView/View/XPGiftBarView.m index 0c0e9806..661e189e 100644 --- a/xplan-ios/Base/UI/SendGiftView/View/XPGiftBarView.m +++ b/xplan-ios/Base/UI/SendGiftView/View/XPGiftBarView.m @@ -9,6 +9,7 @@ ///Third #import ///Tool +#import "XPMacro.h" #import "ThemeColor+SendGift.h" #import "UIImage+Utils.h" ///Model @@ -16,13 +17,9 @@ #import "WalletInfoModel.h" ///View #import "XPGiftCountCollectionViewCell.h" -@interface XPGiftBarView () -/// -@property (nonatomic,strong) UIStackView *stackView; -///展示普通的 -@property (nonatomic,strong) UIView *infoView; -///自定义的count -@property (nonatomic,strong) UIStackView *customCountStackView; +#import "XPGiftCountView.h" +@interface XPGiftBarView () + ///余额 @property (nonatomic,strong) UILabel *balanceLabel; /// @@ -39,21 +36,31 @@ @property (nonatomic,strong) UIButton *arrowButton; ///赠送 @property (nonatomic,strong) UIButton *sendGiftButton; + ///自定义个数 +@property (nonatomic,strong) UIView *customCountView; //输入框 @property (nonatomic, strong) UITextField *editTextFiled; //发送按钮 @property (nonatomic, strong) UIButton *sureButton; +///送礼物的个数 +@property (nonatomic,strong) XPGiftCountView *giftCountView; @end @implementation XPGiftBarView +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self initSubViews]; [self initSubViewConstraints]; + [self addNotificationCenter]; + [self initEvents]; } return self; } @@ -71,23 +78,35 @@ } - (void)arrowButtonAction:(UIButton *)sender { - if (self.delegate && [self.delegate respondsToSelector:@selector(xPGiftBarView:didClickCountButton:)]) { - sender.selected = !sender.selected; - [self.delegate xPGiftBarView:self didClickCountButton:sender]; + if (![[self.superview.superview subviews] containsObject:self.giftCountView]) { + [self.superview.superview addSubview:self.giftCountView]; + + [self.giftCountView mas_makeConstraints:^(MASConstraintMaker *make) { + make.right.mas_equalTo(-15); + make.bottom.mas_equalTo(self.superview.superview.mas_bottom).offset(-45); + make.width.mas_equalTo(135); + }]; } + [self updateCountStatus]; +} + +- (void)sureButtonAction:(UIButton *)sender { + NSString *countStr = [self.editTextFiled.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + NSInteger count = [countStr integerValue]; + if (countStr.length == 0 || count == 0) { + count = 1; + } + [self.editTextFiled resignFirstResponder]; + self.editTextFiled.text = @""; + self.countLabel.text = [NSString stringWithFormat:@"%ld", count]; } #pragma mark - Private Method - (void)initSubViews { self.backgroundColor= [UIColor clearColor]; - [self addSubview:self.stackView]; - - [self.stackView addArrangedSubview:self.infoView]; - [self.stackView addArrangedSubview:self.customCountStackView]; - - [self.infoView addSubview:self.balanceLabel]; - [self.infoView addSubview:self.rechargeStackView]; - [self.infoView addSubview:self.sendOperationView]; + [self addSubview:self.balanceLabel]; + [self addSubview:self.rechargeStackView]; + [self addSubview:self.sendOperationView]; [self.rechargeStackView addArrangedSubview:self.rechargeLabel]; [self.rechargeStackView addArrangedSubview:self.rechageImageView]; @@ -96,26 +115,15 @@ [self.sendOperationView addSubview:self.arrowButton]; [self.sendOperationView addSubview:self.sendGiftButton]; - [self.customCountStackView addArrangedSubview:self.editTextFiled]; - [self.customCountStackView addArrangedSubview:self.sureButton]; + [self.customCountView addSubview:self.editTextFiled]; + [self.customCountView addSubview:self.sureButton]; } - (void)initSubViewConstraints { [self mas_makeConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(85); - }]; - - [self.stackView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.top.mas_equalTo(self); - }]; - - [self.infoView mas_makeConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(45); }]; - [self.customCountStackView mas_makeConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(40); - }]; [self.balanceLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(15); @@ -128,7 +136,7 @@ }]; [self.sendOperationView mas_makeConstraints:^(MASConstraintMaker *make) { - make.right.mas_equalTo(self.infoView).offset(-15); + make.right.mas_equalTo(self).offset(-15); make.bottom.mas_equalTo(-11); make.height.mas_equalTo(30); make.left.mas_equalTo(self.countLabel.mas_left).offset(-13); @@ -143,7 +151,7 @@ [self.arrowButton mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(30, 30)); make.centerY.mas_equalTo(self.sendGiftButton); - make.right.mas_equalTo(self.sendGiftButton.mas_left).offset(-2); + make.right.mas_equalTo(self.sendGiftButton.mas_left).offset(0); }]; [self.sendGiftButton mas_makeConstraints:^(MASConstraintMaker *make) { @@ -152,9 +160,17 @@ }]; + [self.editTextFiled mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.customCountView).offset(15); + make.right.mas_equalTo(self.sureButton.mas_left).offset(-10); + make.top.bottom.mas_equalTo(self.customCountView); + }]; + [self.sureButton mas_makeConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(30); make.width.mas_equalTo(@50); + make.centerY.mas_equalTo(self.customCountView); + make.right.mas_equalTo(self.customCountView).offset(-15); }]; } @@ -163,6 +179,59 @@ [self.rechargeStackView addGestureRecognizer:tap]; } +- (void)keyboardWillShow:(NSNotification *)notification { + CGRect keyboardRect = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue]; + CGFloat height = CGRectGetMinY(keyboardRect) - KScreenHeight; + if (height < 0) { + [UIView animateWithDuration:0.25 animations:^{ + CGRect rect = self.customCountView.superview.superview.superview.frame; + rect.origin.y = height; + self.customCountView.superview.superview.superview.frame = rect; + }]; + } +} + +//键盘隐藏 +- (void)keyboardWillHidden:(NSNotification *)notification { + [UIView animateWithDuration:0.25 animations:^{ + CGRect rect = self.customCountView.superview.superview.superview.frame; + rect.origin.y = 0; + self.customCountView.superview.superview.superview.frame = rect; + }]; + self.customCountView.hidden = YES; + self.editTextFiled.text = @""; +} + +- (void)addNotificationCenter { + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHidden:) name:UIKeyboardWillHideNotification object:nil]; +} + +- (void)updateCountStatus { + self.arrowButton.selected = !self.arrowButton.selected; + self.giftCountView.hidden = !self.arrowButton.selected; +} + +#pragma mark - XPGiftCountViewDelegate +- (void)xPGiftCountView:(XPGiftCountView *)view didClickItem:(XPGiftCountModel *)model { + self.arrowButton.selected = NO; + self.giftCountView.hidden= YES; + if (model.isCustomCount) { + if (![[self.superview.superview subviews] containsObject:self.customCountView]) { + [self.superview.superview addSubview:self.customCountView]; + + [self.customCountView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.bottom.mas_equalTo(self.superview.superview); + make.height.mas_equalTo(40); + }]; + } + self.customCountView.hidden = NO; + [self.editTextFiled becomeFirstResponder]; + } else { + self.giftCountModel = model; + } +} + #pragma mark - UITextFieldDelegate - (BOOL)textFieldShouldReturn:(UITextField *)textField { NSString *countStr = [self.editTextFiled.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; @@ -183,9 +252,15 @@ } return NO; } - - #pragma mark - Getters And Setters +- (void)setType:(GiftSegmentType)type { + if (!self.giftCountView.hidden) { + self.giftCountView.hidden = YES; + self.arrowButton.selected = NO; + } + self.giftCountView.segmentType = type; +} + - (void)setGiftCountModel:(XPGiftCountModel *)giftCountModel { _giftCountModel = giftCountModel; self.arrowButton.selected = NO; @@ -210,7 +285,6 @@ _balanceLabel = [[UILabel alloc] init]; _balanceLabel.textColor = [ThemeColor mainTextColor]; _balanceLabel.font = [UIFont systemFontOfSize:13]; - _balanceLabel.text = @"余额:10000"; } return _balanceLabel; } @@ -296,12 +370,12 @@ - (UITextField *)editTextFiled { if (!_editTextFiled) { _editTextFiled = [[UITextField alloc] init]; - NSAttributedString * attribute = [[NSAttributedString alloc] initWithString:@"请输入赠送数额" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17], NSForegroundColorAttributeName:[ThemeColor appMainColor]}]; + NSAttributedString * attribute = [[NSAttributedString alloc] initWithString:@"请输入赠送数额" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17], NSForegroundColorAttributeName:[ThemeColor secondTextColor]}]; _editTextFiled.attributedPlaceholder = attribute; _editTextFiled.borderStyle = UITextBorderStyleNone; _editTextFiled.returnKeyType = UIReturnKeyDone; _editTextFiled.delegate = self; - _editTextFiled.textColor = [ThemeColor mainTextColor]; + _editTextFiled.textColor = [ThemeColor secondTextColor]; _editTextFiled.keyboardType = UIKeyboardTypeNumberPad; } return _editTextFiled; @@ -316,29 +390,27 @@ _sureButton.backgroundColor = [ThemeColor appMainColor]; _sureButton.layer.cornerRadius = 5.0; _sureButton.layer.masksToBounds = YES; - [_sureButton addTarget:self action:@selector(sendButtonDidClick:) forControlEvents:UIControlEventTouchUpInside]; + [_sureButton addTarget:self action:@selector(sureButtonAction:) forControlEvents:UIControlEventTouchUpInside]; } return _sureButton; } -- (UIView *)infoView { - if (!_infoView) { - _infoView = [[UIView alloc] init]; - _infoView.backgroundColor = [UIColor clearColor]; + +- (UIView *)customCountView { + if (!_customCountView) { + _customCountView = [[UIView alloc] init]; + _customCountView.backgroundColor = [UIColor whiteColor]; } - return _infoView; + return _customCountView; } -- (UIStackView *)customCountStackView { - if (!_customCountStackView) { - _customCountStackView = [[UIStackView alloc] init]; - _customCountStackView.axis = UILayoutConstraintAxisHorizontal; - _customCountStackView.distribution = UIStackViewDistributionEqualSpacing; - _customCountStackView.alignment = UIStackViewAlignmentCenter; - _customCountStackView.spacing = 10; +- (XPGiftCountView *)giftCountView { + if (!_giftCountView) { + _giftCountView = [[XPGiftCountView alloc] init]; + _giftCountView.delegate = self; + _giftCountView.hidden = YES; } - return _customCountStackView; + return _giftCountView; } - @end diff --git a/xplan-ios/Base/UI/SendGiftView/View/XPGiftCountView.h b/xplan-ios/Base/UI/SendGiftView/View/XPGiftCountView.h index 3a43a66c..3f7e40f4 100644 --- a/xplan-ios/Base/UI/SendGiftView/View/XPGiftCountView.h +++ b/xplan-ios/Base/UI/SendGiftView/View/XPGiftCountView.h @@ -6,7 +6,7 @@ // #import - +#import "XPGiftInfoView.h" NS_ASSUME_NONNULL_BEGIN @class XPGiftCountView,XPGiftCountModel; @protocol XPGiftCountViewDelegate @@ -19,6 +19,8 @@ NS_ASSUME_NONNULL_BEGIN @interface XPGiftCountView : UIView ///代理 @property (nonatomic,weak) id delegate; +/// +@property (nonatomic,assign) GiftSegmentType segmentType; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Base/UI/SendGiftView/View/XPGiftCountView.m b/xplan-ios/Base/UI/SendGiftView/View/XPGiftCountView.m index 8496d2a1..d39e4391 100644 --- a/xplan-ios/Base/UI/SendGiftView/View/XPGiftCountView.m +++ b/xplan-ios/Base/UI/SendGiftView/View/XPGiftCountView.m @@ -17,6 +17,8 @@ @property (nonatomic,strong) UICollectionView *countCollectionView; ///礼物数量数据源 @property (nonatomic, strong) NSArray *giftCountArray; +/// +@property (nonatomic,strong) UIVisualEffectView *effectView; @end @implementation XPGiftCountView @@ -37,7 +39,7 @@ self.layer.masksToBounds = YES; UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect]; - effectView.frame = CGRectMake(0, 0, 135, 230); + self.effectView = effectView; [self addSubview:effectView]; self.giftCountArray = [self normalGiftCountDataArray]; [self addSubview:self.countCollectionView]; @@ -45,6 +47,14 @@ } - (void)initSubViewConstraints { + [self mas_makeConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(0); + }]; + + [self.effectView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.mas_equalTo(self); + }]; + [self.countCollectionView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.mas_equalTo(self); }]; @@ -109,6 +119,28 @@ } } +- (void)setSegmentType:(GiftSegmentType)segmentType { + _segmentType = segmentType; + if (_segmentType == GiftSegmentType_Pack) { + self.giftCountArray = [self packGiftCountDataArray]; + } else { + self.giftCountArray = [self normalGiftCountDataArray]; + } + + if (self.delegate && [self.delegate respondsToSelector:@selector(xPGiftCountView:didClickItem:)]) { + XPGiftCountModel *countItem = [self.giftCountArray objectAtIndex:0]; + [self.delegate xPGiftCountView:self didClickItem:countItem]; + } + + [self mas_updateConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(28 * self.giftCountArray.count + 10); + }]; + + + + [self.countCollectionView reloadData]; +} + #pragma mark - Getters And Setters - (UICollectionView *)countCollectionView{ diff --git a/xplan-ios/Base/UI/SendGiftView/View/XPGiftInfoView.h b/xplan-ios/Base/UI/SendGiftView/View/XPGiftInfoView.h index c0fb3c40..330ab42e 100644 --- a/xplan-ios/Base/UI/SendGiftView/View/XPGiftInfoView.h +++ b/xplan-ios/Base/UI/SendGiftView/View/XPGiftInfoView.h @@ -6,7 +6,7 @@ // #import - +#import "XPGiftInfoView.h" NS_ASSUME_NONNULL_BEGIN typedef NS_ENUM(NSInteger, GiftSegmentType) { @@ -16,13 +16,15 @@ typedef NS_ENUM(NSInteger, GiftSegmentType) { }; -@class GiftInfoModel,XPGiftInfoView; +@class GiftInfoModel,XPGiftInfoView, GiftReceiveInfoModel; @protocol XPGiftInfoViewDelegate ///点击了 规则说明 - (void)xPGiftInfoView:(XPGiftInfoView *)view didClickPlayRule:(NSString *)ruleUrl; +///点击了切换不同礼物的tabbar +- (void)xPGiftInfoView:(XPGiftInfoView *)view didClickSegment:(GiftSegmentType)type; @end @interface XPGiftInfoView : UIView @@ -31,10 +33,12 @@ typedef NS_ENUM(NSInteger, GiftSegmentType) { @property (nonatomic,strong) NSArray *normalOriginArray; ///背包礼物 @property (nonatomic,strong) NSArray *packOriginArray; - +///送背包礼物更新数据源 +- (void)updatePackSource:(GiftReceiveInfoModel *)giftReceiveInfo; ///代理 @property (nonatomic,weak) id delegate; - +///最后一次选中的礼物 +@property (nonatomic,strong,readonly) GiftInfoModel *lastSelectGift; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Base/UI/SendGiftView/View/XPGiftInfoView.m b/xplan-ios/Base/UI/SendGiftView/View/XPGiftInfoView.m index 6521ff61..26cd89d9 100644 --- a/xplan-ios/Base/UI/SendGiftView/View/XPGiftInfoView.m +++ b/xplan-ios/Base/UI/SendGiftView/View/XPGiftInfoView.m @@ -11,12 +11,14 @@ ///Tool #import "XPMacro.h" #import "ThemeColor+SendGift.h" -/// +///Model #import "GiftInfoModel.h" +#import "GiftReceiveInfoModel.h" ///View #import "XPGiftItemCollectionViewCell.h" +#import "XPGiftEmptyCollectionViewCell.h" #import "XPGiftCollectionViewFlowLayout.h" -@interface XPGiftInfoView () +@interface XPGiftInfoView () /// @property (nonatomic,strong) UIStackView *segmentStackView; ///普通礼物 @@ -38,7 +40,7 @@ ///分页控件 @property (nonatomic, strong) UIPageControl *pageController; ///展示的数据源 -@property (nonatomic,strong) NSArray *datasource; +@property (nonatomic,strong) NSMutableArray *datasource; ///普通礼物的数据源 @property (nonatomic,strong) NSArray *giftArray; /////幸运礼物的数据源 @@ -80,6 +82,16 @@ } } +#pragma mark - Public Method +- (void)updatePackSource:(GiftReceiveInfoModel *)giftReceiveInfo { + GiftInfoModel * giftInfo = [self findGiftInfoByGiftId:giftReceiveInfo.giftId.integerValue]; + giftInfo.count -= giftReceiveInfo.giftNum; + if (giftInfo.count == 0) { + [self.datasource removeObject:giftInfo]; + } + [self.giftcollectionView reloadData]; +} + #pragma mark - Private Method - (void)initSubViews { @@ -114,7 +126,7 @@ make.left.right.mas_equalTo(self); make.height.mas_equalTo(105 * 2 + 20); }]; - + [self.pageController mas_makeConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(10); }]; @@ -158,10 +170,27 @@ - (void)dealSelectGift:(GiftInfoModel *)giftInfo { self.lastSelectGift = giftInfo; + if (self.segmentType == GiftSegmentType_Pack) { + giftInfo.sourceType = GiftSourceType_Pack; + } else { + giftInfo.sourceType = GiftSourceType_Normal; + } self.playRuleButton.hidden = giftInfo.giftExplainUrl.length <= 0; giftInfo.isSelected = YES; } +// 根据礼物id查找 +- (GiftInfoModel *)findGiftInfoByGiftId:(NSInteger)giftId { + for (int i=0; i 0) { + [self resetSelectGift:self.datasource]; + GiftInfoModel * giftInfo= [self.datasource objectAtIndex:indexPath.item]; + [self dealSelectGift:giftInfo]; + [self.giftcollectionView reloadData]; + + } } #pragma mark - Getters And Setters @@ -197,6 +243,7 @@ if (segmentType == _segmentType) { return; } + [_datasource removeAllObjects]; _segmentType = segmentType; [self resetSelectGift:self.giftArray]; [self resetSelectGift:self.packOriginArray]; @@ -204,31 +251,37 @@ self.totalValueLabel.hidden = YES; switch (_segmentType) { case GiftSegmentType_Normal: - self.datasource = self.giftArray; + [self.datasource addObjectsFromArray:self.giftArray]; break; case GiftSegmentType_Lucky: - self.datasource = self.giftLuckyArray; + [self.datasource addObjectsFromArray:self.giftLuckyArray]; break; case GiftSegmentType_Pack: { - self.datasource = self.packOriginArray; + [self.datasource addObjectsFromArray:self.packOriginArray]; self.totalValueLabel.hidden = NO; self.totalValueLabel.attributedText= self.totalAttribute; } break; default: - self.datasource = self.giftArray; + [self.datasource addObjectsFromArray:self.giftArray]; break; } if (self.datasource.count > 0) { GiftInfoModel * gift = [self.datasource firstObject]; [self dealSelectGift:gift]; + } else { + self.playRuleButton.hidden = YES; } NSUInteger page = self.datasource.count / 8; self.pageController.hidden = page <= 0; [self.pageController setNumberOfPages:page]; self.pageController.currentPage = 0; [self.giftcollectionView reloadData]; + + if (self.delegate && [self.delegate respondsToSelector:@selector(xPGiftInfoView:didClickSegment:)]) { + [self.delegate xPGiftInfoView:self didClickSegment:_segmentType]; + } } - (void)setNormalOriginArray:(NSArray *)normalOriginArray { @@ -343,8 +396,6 @@ if (!_giftcollectionView) { XPGiftCollectionViewFlowLayout *layout = [[XPGiftCollectionViewFlowLayout alloc] init]; layout.scrollDirection = UICollectionViewScrollDirectionHorizontal; - CGFloat itemWidth = (CGFloat)(KScreenWidth - 10 - 5 * 3) / (CGFloat)4; - layout.itemSize = CGSizeMake(itemWidth, 105); layout.minimumLineSpacing = 5; layout.minimumInteritemSpacing = 10; layout.sectionInset = UIEdgeInsetsMake(0, 15, 0, 5); @@ -354,6 +405,7 @@ _giftcollectionView.backgroundColor = [UIColor clearColor]; _giftcollectionView.pagingEnabled = YES; [_giftcollectionView registerClass:[XPGiftItemCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPGiftItemCollectionViewCell class])]; + [_giftcollectionView registerClass:[XPGiftEmptyCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPGiftEmptyCollectionViewCell class])]; } return _giftcollectionView; } @@ -376,5 +428,12 @@ } +- (NSMutableArray *)datasource { + if (!_datasource) { + _datasource = [NSMutableArray array]; + } + return _datasource; +} + @end diff --git a/xplan-ios/Base/UI/SendGiftView/View/XPGiftUsersView.h b/xplan-ios/Base/UI/SendGiftView/View/XPGiftUsersView.h index abf101b9..5d43b208 100644 --- a/xplan-ios/Base/UI/SendGiftView/View/XPGiftUsersView.h +++ b/xplan-ios/Base/UI/SendGiftView/View/XPGiftUsersView.h @@ -14,7 +14,8 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithType:(SendGiftType)type; ///选中的人 送给谁礼物 @property (nonatomic,strong, readonly) NSMutableArray *selectUserArray; - +///是不是选择了全部麦上的人 +@property (nonatomic,assign) BOOL isSelectAll; ///麦序变化 赋值使用 - (void)microQueueUpdate:(NSArray *)queue; @end diff --git a/xplan-ios/Base/UI/SendGiftView/View/XPGiftUsersView.m b/xplan-ios/Base/UI/SendGiftView/View/XPGiftUsersView.m index f8b60793..b4ddd2a2 100644 --- a/xplan-ios/Base/UI/SendGiftView/View/XPGiftUsersView.m +++ b/xplan-ios/Base/UI/SendGiftView/View/XPGiftUsersView.m @@ -46,6 +46,7 @@ [self.userArray enumerateObjectsUsingBlock:^(XPGiftMicroUserModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { obj.isSelect = YES; }]; + self.isSelectAll = sender.selected; [self.collectionView reloadData]; } @@ -84,9 +85,13 @@ MicroQueueModel * micModel = [users objectAtIndex:i]; UserInfoModel * userInfo = micModel.userInfo; if (userInfo && userInfo.uid > 0 && userInfo.uid != uid.integerValue) { ///自己在麦上不显示在送礼物列表中 + NSString * uid = [NSString stringWithFormat:@"%ld", userInfo.uid]; XPGiftMicroUserModel * giftUserModel = [[XPGiftMicroUserModel alloc] init]; giftUserModel.microQueue = micModel; - if ([self.selectUserArray containsObject:[NSString stringWithFormat:@"%ld", userInfo.uid]]){ + if (self.allMicroButton.selected && ![self.selectUserArray containsObject:uid]) { + [self.selectUserArray addObject:uid]; + } + if ([self.selectUserArray containsObject:uid]){ giftUserModel.isSelect = YES; } [tempArray addObject:giftUserModel]; diff --git a/xplan-ios/Base/UI/SendGiftView/View/XPSendGiftView.m b/xplan-ios/Base/UI/SendGiftView/View/XPSendGiftView.m index f4c634cf..56130d24 100644 --- a/xplan-ios/Base/UI/SendGiftView/View/XPSendGiftView.m +++ b/xplan-ios/Base/UI/SendGiftView/View/XPSendGiftView.m @@ -13,18 +13,22 @@ #import "XPGiftPresenter.h" #import "TTPopup.h" #import "ThemeColor+SendGift.h" +#import "XCHUDTool.h" +///Model +#import "GiftInfoModel.h" +#import "XPGiftCountModel.h" +#import "GiftReceiveInfoModel.h" ///View #import "XPGiftUsersView.h" #import "XPGiftInfoView.h" #import "XPGiftBarView.h" -#import "XPGiftCountView.h" ///P #import "XPGiftProtocol.h" ///VC #import "XPMineRechargeViewController.h" #import "XPWebViewController.h" -@interface XPSendGiftView () +@interface XPSendGiftView ()< XPGiftBarViewDelegate, XPGiftProtocol, XPGiftInfoViewDelegate> /// @property (nonatomic,strong) UIStackView *stackView; ///送礼物的人 @@ -33,14 +37,14 @@ @property (nonatomic,strong) XPGiftInfoView *giftInfoView; ///送多少礼物 @property (nonatomic,strong) XPGiftBarView *giftBarView; -///送礼物的个数 -@property (nonatomic,strong) XPGiftCountView *giftCountView; /// @property (nonatomic,strong) XPGiftPresenter *giftPresenter; ///房主的uid @property (nonatomic,copy) NSString *roomUid; ///代理 @property (nonatomic,weak) id delegate; +///使用的地方 +@property (nonatomic,assign) SendGiftType usingplaceType; @end @@ -53,6 +57,7 @@ if (self = [super init]) { self.roomUid = uid; self.delegate = delegate; + self.usingplaceType = type; [self initSubViews]; [self initSubViewConstraints]; [self initHttpRequest]; @@ -64,7 +69,6 @@ - (void)initSubViews { self.backgroundColor = [ThemeColor giftBackGroundColor]; [self addSubview:self.stackView]; - [self addSubview:self.giftCountView]; [self.stackView addArrangedSubview:self.userView]; [self.stackView addArrangedSubview:self.giftInfoView]; [self.stackView addArrangedSubview:self.giftBarView]; @@ -79,13 +83,6 @@ [self.stackView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.top.mas_equalTo(self); }]; - - [self.giftCountView mas_makeConstraints:^(MASConstraintMaker *make) { - make.right.mas_equalTo(-15); - make.bottom.mas_equalTo(self.giftBarView.mas_top).offset(-6); - make.height.mas_equalTo(250); - make.width.mas_equalTo(135); - }]; } - (void)initHttpRequest { @@ -94,25 +91,88 @@ [self.giftPresenter getPackGiftList]; } +#pragma mark - Deal Send Gift Data +- (NSString *)dealSendGiftCount:(XPGiftCountModel *)model gift:(GiftInfoModel *)gift { + NSString * count = @"1"; + if (model.isTotal) { + count = [NSString stringWithFormat:@"%ld", gift.count]; + } else { + count = model.giftNumber; + } + return count; +} + +- (NSString *)dealSendGiftUids:(NSArray *)uids { + NSString *uidString = [[NSString alloc] init]; + for (NSString *item in uids) { + if (uidString.length > 0) { + uidString = [uidString stringByAppendingString:@","]; + } + uidString = [uidString stringByAppendingString:item]; + } + return uidString; +} + +- (RoomSendGiftType)dealRoomSendGiftType:(GiftInfoModel *)giftInfo giftCount:(XPGiftCountModel *)giftCount { + NSArray * uids = self.userView.selectUserArray; + RoomSendGiftType roomSendGiftType; + if (self.userView.isSelectAll) { + if (giftInfo.sourceType == GiftSourceType_Pack && giftCount.isTotal && giftInfo && uids.count > 1) { + [XCHUDTool showErrorWithMessage:@"只能全部赠送给一人"]; + return -1; + } + roomSendGiftType = RoomSendGiftType_AllMic; + } else if(self.userView.selectUserArray.count > 1) { + if (giftInfo.sourceType == GiftSourceType_Pack && giftCount.isTotal) { + [XCHUDTool showErrorWithMessage:@"只能全部赠送给一人"]; + return -1; + } + roomSendGiftType = RoomSendGiftType_MutableOnMic; + } else if(self.userView.selectUserArray.count == 1) { + roomSendGiftType = RoomSendGiftType_ToOne; + } else { + roomSendGiftType = -1; + } + return roomSendGiftType; +} + #pragma mark - Public Method - (void)updateMicro:(NSArray *)micros { [self.userView microQueueUpdate:micros]; } -#pragma mark - XPGiftCountViewDelegate -- (void)xPGiftCountView:(XPGiftCountView *)view didClickItem:(XPGiftCountModel *)model { - self.giftCountView.hidden = YES; - self.giftBarView.giftCountModel = model; -} #pragma mark - XPGiftBarViewDelegate - (void)xPGiftBarView:(XPGiftBarView *)view didClickSendGift:(XPGiftCountModel *)giftCount { +///总礼物 三要素 送礼物的人 送的什么礼物 送多少个礼物 + NSArray * uids = self.userView.selectUserArray; + GiftInfoModel * giftInfo = self.giftInfoView.lastSelectGift; + if (self.usingplaceType == SendGiftType_Room) { + if (uids.count > 0) { + ///送礼物的人 + NSString * uidString = [self dealSendGiftUids:uids]; + ///送礼物的个数 + NSString * giftNumber = [self dealSendGiftCount:giftCount gift:giftInfo]; + ///送的什么礼物 + NSString * giftId = [NSString stringWithFormat:@"%ld", giftInfo.giftId]; + ///给麦上的人送礼物 + GiftSendType sendType = GiftSendType_OnMic; + ///礼物来源 + GiftSourceType sourceType = giftInfo.sourceType; + ///送一个人 还是全麦 还是多人非全麦 + RoomSendGiftType roomSendType = [self dealRoomSendGiftType:giftInfo giftCount:giftCount]; + if (roomSendType == -1) { + return; + } + ///发送消息 + [self.giftPresenter sendGift:uidString giftNum:giftNumber sendType:sendType giftId:giftId giftSource:sourceType giftType:giftInfo.giftType roomSendType:roomSendType roomUid:self.roomUid msg:@""]; + } else { + [XCHUDTool showErrorWithMessage:@"请选择至少一个人"]; + return; + } + } } -///选择个数 -- (void)xPGiftBarView:(XPGiftBarView *)view didClickCountButton:(UIButton *)sender { - self.giftCountView.hidden = !sender.selected; -} ///充值 - (void)xPGiftBarViewDidClickRecharge:(XPGiftBarView *)view { @@ -129,6 +189,10 @@ [self.delegate.getCurrentNav pushViewController:webVC animated:YES]; } +- (void)xPGiftInfoView:(XPGiftInfoView *)view didClickSegment:(GiftSegmentType)type { + self.giftBarView.type = type; +} + #pragma mark - XPGiftProtocol - (void)getUserWalletInfo:(WalletInfoModel *)balanceInfo { self.giftBarView.walletInfoModel = balanceInfo; @@ -142,6 +206,16 @@ - (void)getNormalGiftListSuccess:(NSArray *)giftList { self.giftInfoView.normalOriginArray = giftList; } + +- (void)sendGiftSuccess:(GiftReceiveInfoModel *)receiveInfo { + if (receiveInfo.sourceType == GiftSourceType_Pack) { + ///更新个数 + [self.giftInfoView updatePackSource:receiveInfo]; + } else { + [self.giftPresenter getUserWallInfo]; + } +} + #pragma mark - Getters And Setters - (XPGiftUsersView *)userView { if (!_userView) { @@ -178,15 +252,6 @@ return _stackView; } -- (XPGiftCountView *)giftCountView { - if (!_giftCountView) { - _giftCountView = [[XPGiftCountView alloc] init]; - _giftCountView.delegate = self; - _giftCountView.hidden = YES; - } - return _giftCountView; -} - - (XPGiftPresenter *)giftPresenter { if (!_giftPresenter) { _giftPresenter = [[XPGiftPresenter alloc] init];