送礼物的接口的接入
This commit is contained in:
@@ -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 = "<group>"; };
|
||||
E87A24EF272935920086A794 /* XPMessageRemoteExtModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMessageRemoteExtModel.h; sourceTree = "<group>"; };
|
||||
E87A24F0272935920086A794 /* XPMessageRemoteExtModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMessageRemoteExtModel.m; sourceTree = "<group>"; };
|
||||
E884C36A2743951B00E1EBED /* GiftReceiveInfoModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiftReceiveInfoModel.h; sourceTree = "<group>"; };
|
||||
E884C36B2743951B00E1EBED /* GiftReceiveInfoModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiftReceiveInfoModel.m; sourceTree = "<group>"; };
|
||||
E88B5CA326FB088600DA9178 /* XPMineTeenagerViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineTeenagerViewController.h; sourceTree = "<group>"; };
|
||||
E88B5CA426FB088600DA9178 /* XPMineTeenagerViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineTeenagerViewController.m; sourceTree = "<group>"; };
|
||||
E88B5CA626FB089C00DA9178 /* XPMineTeenagePwdViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineTeenagePwdViewController.h; sourceTree = "<group>"; };
|
||||
@@ -1517,6 +1520,8 @@
|
||||
E890BC03273CF0500007C46B /* XPGiftCountModel.m */,
|
||||
E890BC0E273D23F00007C46B /* GiftInfoModel.h */,
|
||||
E890BC0F273D23F00007C46B /* GiftInfoModel.m */,
|
||||
E884C36A2743951B00E1EBED /* GiftReceiveInfoModel.h */,
|
||||
E884C36B2743951B00E1EBED /* GiftReceiveInfoModel.m */,
|
||||
);
|
||||
path = Model;
|
||||
sourceTree = "<group>";
|
||||
@@ -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 */,
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 186 B After Width: | Height: | Size: 186 B |
Binary file not shown.
Before Width: | Height: | Size: 261 B After Width: | Height: | Size: 268 B |
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
76
xplan-ios/Base/UI/SendGiftView/Model/GiftReceiveInfoModel.h
Normal file
76
xplan-ios/Base/UI/SendGiftView/Model/GiftReceiveInfoModel.h
Normal file
@@ -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 <Foundation/Foundation.h>
|
||||
#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<GiftReceiveUserInfoModel *> *targetUsers;
|
||||
///礼物来源
|
||||
@property (nonatomic,assign) GiftSourceType sourceType;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
21
xplan-ios/Base/UI/SendGiftView/Model/GiftReceiveInfoModel.m
Normal file
21
xplan-ios/Base/UI/SendGiftView/Model/GiftReceiveInfoModel.m
Normal file
@@ -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
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -8,13 +8,15 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class WalletInfoModel, GiftInfoModel;
|
||||
@class WalletInfoModel, GiftInfoModel, GiftReceiveInfoModel;
|
||||
@protocol XPGiftProtocol <NSObject>
|
||||
- (void)getUserWalletInfo:(WalletInfoModel *)balanceInfo;
|
||||
///获取普通礼物列表
|
||||
- (void)getNormalGiftListSuccess:(NSArray<GiftInfoModel *> *)giftList;
|
||||
///获取背包礼物列表
|
||||
- (void)getPacketGiftListSuccess:(NSArray<GiftInfoModel *> *)giftList;
|
||||
|
||||
- (void)sendGiftSuccess:(GiftReceiveInfoModel *)receiveInfo;;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -6,7 +6,48 @@
|
||||
//
|
||||
|
||||
#import "XPGiftEmptyCollectionViewCell.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
///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
|
||||
|
@@ -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);
|
||||
}];
|
||||
|
@@ -6,13 +6,10 @@
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "XPGiftInfoView.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class XPGiftBarView, XPGiftCountModel, WalletInfoModel;
|
||||
@protocol XPGiftBarViewDelegate <NSObject>
|
||||
|
||||
///点击了选择数量的
|
||||
- (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<XPGiftBarViewDelegate> delegate;
|
||||
///不同的tabbar
|
||||
@property (nonatomic,assign) GiftSegmentType type;
|
||||
|
||||
///更新礼物个数
|
||||
@property (nonatomic,strong) XPGiftCountModel *giftCountModel;
|
||||
|
@@ -9,6 +9,7 @@
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
///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 ()<UITextFieldDelegate>
|
||||
///
|
||||
@property (nonatomic,strong) UIStackView *stackView;
|
||||
///展示普通的
|
||||
@property (nonatomic,strong) UIView *infoView;
|
||||
///自定义的count
|
||||
@property (nonatomic,strong) UIStackView *customCountStackView;
|
||||
#import "XPGiftCountView.h"
|
||||
@interface XPGiftBarView ()<UITextFieldDelegate, XPGiftCountViewDelegate>
|
||||
|
||||
///余额
|
||||
@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
|
||||
|
@@ -6,7 +6,7 @@
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "XPGiftInfoView.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class XPGiftCountView,XPGiftCountModel;
|
||||
@protocol XPGiftCountViewDelegate <NSObject>
|
||||
@@ -19,6 +19,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@interface XPGiftCountView : UIView
|
||||
///代理
|
||||
@property (nonatomic,weak) id<XPGiftCountViewDelegate> delegate;
|
||||
///
|
||||
@property (nonatomic,assign) GiftSegmentType segmentType;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -17,6 +17,8 @@
|
||||
@property (nonatomic,strong) UICollectionView *countCollectionView;
|
||||
///礼物数量数据源
|
||||
@property (nonatomic, strong) NSArray<XPGiftCountModel *> *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{
|
||||
|
@@ -6,7 +6,7 @@
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#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 <NSObject>
|
||||
|
||||
///点击了 规则说明
|
||||
- (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<XPGiftInfoViewDelegate> delegate;
|
||||
|
||||
///最后一次选中的礼物
|
||||
@property (nonatomic,strong,readonly) GiftInfoModel *lastSelectGift;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -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 ()<UICollectionViewDelegate, UICollectionViewDataSource>
|
||||
@interface XPGiftInfoView ()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
|
||||
///
|
||||
@property (nonatomic,strong) UIStackView *segmentStackView;
|
||||
///普通礼物
|
||||
@@ -38,7 +40,7 @@
|
||||
///分页控件
|
||||
@property (nonatomic, strong) UIPageControl *pageController;
|
||||
///展示的数据源
|
||||
@property (nonatomic,strong) NSArray<GiftInfoModel *> *datasource;
|
||||
@property (nonatomic,strong) NSMutableArray <GiftInfoModel *> *datasource;
|
||||
///普通礼物的数据源
|
||||
@property (nonatomic,strong) NSArray<GiftInfoModel *> *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<self.datasource.count ; i++) {
|
||||
GiftInfoModel *giftInfo = [self.datasource objectAtIndex:i];
|
||||
if (giftInfo.giftId == giftId) {
|
||||
return giftInfo;
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#pragma mark - scrollviewdelegate
|
||||
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
|
||||
@@ -171,25 +200,42 @@
|
||||
}
|
||||
|
||||
#pragma mark - UICollectionViewDelegate And UICollectionDatasource
|
||||
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (self.segmentType == GiftSegmentType_Pack && self.datasource.count == 0) {
|
||||
return CGSizeMake(KScreenWidth, 105 * 2 + 10);
|
||||
}
|
||||
CGFloat itemWidth = (CGFloat)(KScreenWidth - 10 - 5 * 3) / (CGFloat)4;
|
||||
return CGSizeMake(itemWidth, 105);
|
||||
}
|
||||
|
||||
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
|
||||
if (self.segmentType == GiftSegmentType_Pack && self.datasource.count == 0) {
|
||||
return 1;
|
||||
}
|
||||
return self.datasource.count;
|
||||
}
|
||||
|
||||
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
|
||||
XPGiftItemCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPGiftItemCollectionViewCell class]) forIndexPath:indexPath];
|
||||
GiftInfoModel * giftInfo;
|
||||
giftInfo= [self.datasource objectAtIndex:indexPath.item];
|
||||
cell.giftInfo = giftInfo;
|
||||
if (self.segmentType ==GiftSegmentType_Pack && self.datasource.count == 0) {
|
||||
XPGiftEmptyCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPGiftEmptyCollectionViewCell class]) forIndexPath:indexPath];
|
||||
return cell;
|
||||
}
|
||||
XPGiftItemCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPGiftItemCollectionViewCell class]) forIndexPath:indexPath];
|
||||
GiftInfoModel * giftInfo;
|
||||
giftInfo= [self.datasource objectAtIndex:indexPath.item];
|
||||
cell.giftInfo = giftInfo;
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
|
||||
[collectionView deselectItemAtIndexPath:indexPath animated:YES];
|
||||
[self resetSelectGift:self.datasource];
|
||||
GiftInfoModel * giftInfo= [self.datasource objectAtIndex:indexPath.item];
|
||||
[self dealSelectGift:giftInfo];
|
||||
[self.giftcollectionView reloadData];
|
||||
|
||||
if (self.datasource.count > 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<GiftInfoModel *> *)datasource {
|
||||
if (!_datasource) {
|
||||
_datasource = [NSMutableArray array];
|
||||
}
|
||||
return _datasource;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
@@ -14,7 +14,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (instancetype)initWithType:(SendGiftType)type;
|
||||
///选中的人 送给谁礼物
|
||||
@property (nonatomic,strong, readonly) NSMutableArray<NSString *> *selectUserArray;
|
||||
|
||||
///是不是选择了全部麦上的人
|
||||
@property (nonatomic,assign) BOOL isSelectAll;
|
||||
///麦序变化 赋值使用
|
||||
- (void)microQueueUpdate:(NSArray<MicroQueueModel *> *)queue;
|
||||
@end
|
||||
|
@@ -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];
|
||||
|
@@ -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 ()<XPGiftCountViewDelegate, XPGiftBarViewDelegate, XPGiftProtocol, XPGiftInfoViewDelegate>
|
||||
@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<RoomHostDelegate> 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<NSString *> *)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<MicroQueueModel *> *)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<GiftInfoModel *> *)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];
|
||||
|
Reference in New Issue
Block a user