Commit 4d52ddc85b7cd812ec09c64a7918a57efe03e84b
1 parent
70c942db
发礼物走聊天室
Showing
15 changed files
with
148 additions
and
129 deletions
LiveVideoCloud.xcodeproj/project.pbxproj
| ... | ... | @@ -211,7 +211,6 @@ |
| 211 | 211 | D255300C1E793F8200DF38A5 /* NHFighterView+animDelegagte.m in Sources */ = {isa = PBXBuildFile; fileRef = D255300B1E793F8200DF38A5 /* NHFighterView+animDelegagte.m */; }; |
| 212 | 212 | D2575C461E76857100E3A8FC /* LVCAnimationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D2575C451E76857100E3A8FC /* LVCAnimationManager.m */; }; |
| 213 | 213 | D2575C4A1E7685DE00E3A8FC /* UIView+Bubbling.m in Sources */ = {isa = PBXBuildFile; fileRef = D2575C481E7685DE00E3A8FC /* UIView+Bubbling.m */; }; |
| 214 | - D2575C671E76A25400E3A8FC /* LVCInteractionController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2575C661E76A25400E3A8FC /* LVCInteractionController.m */; }; | |
| 215 | 214 | D2575C7A1E76A4F300E3A8FC /* NHCarViews.m in Sources */ = {isa = PBXBuildFile; fileRef = D2575C6F1E76A4F300E3A8FC /* NHCarViews.m */; }; |
| 216 | 215 | D2575C7B1E76A4F300E3A8FC /* NHCarViews.xib in Resources */ = {isa = PBXBuildFile; fileRef = D2575C701E76A4F300E3A8FC /* NHCarViews.xib */; }; |
| 217 | 216 | D2575C7C1E76A4F300E3A8FC /* NHFighterView.nib in Resources */ = {isa = PBXBuildFile; fileRef = D2575C721E76A4F300E3A8FC /* NHFighterView.nib */; }; |
| ... | ... | @@ -726,8 +725,6 @@ |
| 726 | 725 | D2575C451E76857100E3A8FC /* LVCAnimationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = LVCAnimationManager.m; path = ../LVCAnimationManager.m; sourceTree = "<group>"; }; |
| 727 | 726 | D2575C481E7685DE00E3A8FC /* UIView+Bubbling.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+Bubbling.m"; sourceTree = "<group>"; }; |
| 728 | 727 | D2575C491E7685DE00E3A8FC /* UIView+Bubbling.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+Bubbling.h"; sourceTree = "<group>"; }; |
| 729 | - D2575C651E76A25400E3A8FC /* LVCInteractionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCInteractionController.h; sourceTree = "<group>"; }; | |
| 730 | - D2575C661E76A25400E3A8FC /* LVCInteractionController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCInteractionController.m; sourceTree = "<group>"; }; | |
| 731 | 728 | D2575C6D1E76A4F300E3A8FC /* NHCarView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NHCarView.h; sourceTree = "<group>"; }; |
| 732 | 729 | D2575C6E1E76A4F300E3A8FC /* NHCarViews.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NHCarViews.h; sourceTree = "<group>"; }; |
| 733 | 730 | D2575C6F1E76A4F300E3A8FC /* NHCarViews.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NHCarViews.m; sourceTree = "<group>"; }; |
| ... | ... | @@ -1843,8 +1840,6 @@ |
| 1843 | 1840 | D207BEA01E84C1EC006A0CE8 /* AnimationBaseView.m */, |
| 1844 | 1841 | D22830EF1E778C0F00627701 /* LiveBaseView.h */, |
| 1845 | 1842 | D22830F01E778C0F00627701 /* LiveBaseView.m */, |
| 1846 | - D2575C651E76A25400E3A8FC /* LVCInteractionController.h */, | |
| 1847 | - D2575C661E76A25400E3A8FC /* LVCInteractionController.m */, | |
| 1848 | 1843 | D2575C681E76A42B00E3A8FC /* Gift */, |
| 1849 | 1844 | D2575C471E7685C500E3A8FC /* heartAnimation */, |
| 1850 | 1845 | ); |
| ... | ... | @@ -2373,7 +2368,6 @@ |
| 2373 | 2368 | 810B64FE1E779B1F00133E15 /* MASCompositeConstraint.m in Sources */, |
| 2374 | 2369 | D2029C981E6EADE10027CD92 /* MJExtensionConst.m in Sources */, |
| 2375 | 2370 | 8178D4571F0204D600AA78A4 /* LVCTelevisioController.m in Sources */, |
| 2376 | - D2575C671E76A25400E3A8FC /* LVCInteractionController.m in Sources */, | |
| 2377 | 2371 | D2029CAE1E6EADE10027CD92 /* MJRefreshNormalHeader.m in Sources */, |
| 2378 | 2372 | D23696921E7FC83800E4BF71 /* chatMsgModel.m in Sources */, |
| 2379 | 2373 | 4BD856071EBACD530082061D /* UIImageView+AFNetworking.m in Sources */, | ... | ... |
LiveVideoCloud/AppDelegate/AppDelegate.m
| ... | ... | @@ -49,7 +49,7 @@ |
| 49 | 49 | // 20170327 20170328 |
| 50 | 50 | |
| 51 | 51 | |
| 52 | - CNLiveChatUserInfo *userInfo = [[CNLiveChatUserInfo alloc] initWithUserId:@"20170328ll" name:@"20170328" portrait:@""]; | |
| 52 | + CNLiveChatUserInfo *userInfo = [[CNLiveChatUserInfo alloc] initWithUserId:@"20170328ll" name:@"20170328" portrait:@"http://b.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=f0c5c08030d3d539c16807c70fb7c566/8ad4b31c8701a18bbef9f231982f07082838feba.jpg"]; | |
| 53 | 53 | |
| 54 | 54 | [[CNLiveChatManager sharedCNLiveChatManager] loginServer:userInfo success:^(NSString *userId) { |
| 55 | 55 | NSLog(@"连接服务器-----success"); | ... | ... |
LiveVideoCloud/Classes/Sections/InteractionSections/Chat/ChatMsgModel/chatMsgModel.h
| ... | ... | @@ -13,6 +13,7 @@ |
| 13 | 13 | @property (nonatomic ,copy ) NSString * _Nullable icon;//头像 |
| 14 | 14 | @property (nonatomic ,copy ) NSString * _Nullable name;//姓名 |
| 15 | 15 | @property (nonatomic ,copy ) NSString * _Nullable content;//内容 |
| 16 | +@property (nonatomic ,copy ) NSString * _Nullable uId; | |
| 16 | 17 | |
| 17 | 18 | @property (nonatomic ,assign) CGFloat level;//等级 |
| 18 | 19 | @property (nonatomic ,assign) CGFloat cellWidth;//内容宽度 | ... | ... |
LiveVideoCloud/Classes/Sections/InteractionSections/Chat/ChatViews/chatListCell.m
| ... | ... | @@ -35,7 +35,7 @@ |
| 35 | 35 | |
| 36 | 36 | [self bindView];//更新cell高度后再初始化UI |
| 37 | 37 | [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:model.icon] placeholderImage:nil]; |
| 38 | - self.iconImageView.backgroundColor = ZXRandomColor; | |
| 38 | + self.iconImageView.backgroundColor = [UIColor clearColor]; | |
| 39 | 39 | self.contentLabel.text = [NSString stringWithFormat:@"%@:%@",model.name,model.content]; |
| 40 | 40 | CGSize contentLabelSize = [self.contentLabel labelSizeWithWidth:self.width - self.iconImageView.right - 4]; |
| 41 | 41 | self.contentLabel.frame = CGRectMake(20, 0, contentLabelSize.width, contentLabelSize.height); | ... | ... |
LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftModel/GiftModel.h
| ... | ... | @@ -16,12 +16,17 @@ typedef NS_ENUM(NSInteger, GiftStyle) {//礼物类型 |
| 16 | 16 | }; |
| 17 | 17 | |
| 18 | 18 | @interface GiftModel : BaseModel <PresentModelAble> |
| 19 | -@property (copy, nonatomic) NSString *_Nullable sender;//送礼人 | |
| 19 | +@property (copy, nonatomic) NSString *_Nullable sender;//送礼人 *** | |
| 20 | 20 | @property (copy, nonatomic) NSString *_Nullable giftName;//礼物名称 *** |
| 21 | + | |
| 21 | 22 | @property (copy, nonatomic) NSString *_Nullable icon;//送礼头像 |
| 22 | 23 | @property (copy, nonatomic) NSString *_Nullable giftImageName;//礼物图片名字 |
| 23 | 24 | @property (assign, nonatomic) NSInteger giftNumber;//礼物数量 *** |
| 24 | 25 | |
| 26 | +//@property (nonatomic ,copy) NSString *_Nullable senderId;//送礼人Id | |
| 27 | +//@property (nonatomic ,copy) NSString *_Nullable giftRecName;//收礼物人名字 | |
| 28 | +@property (nonatomic ,copy) NSString *_Nullable giftRecId;//收礼物人Id | |
| 29 | + | |
| 25 | 30 | //可本地处理 |
| 26 | 31 | @property (nonatomic ,copy ) NSString * _Nullable price; // *** |
| 27 | 32 | @property (nonatomic ) GiftStyle giftStyle;//动画类型 |
| ... | ... | @@ -37,6 +42,6 @@ typedef NS_ENUM(NSInteger, GiftStyle) {//礼物类型 |
| 37 | 42 | |
| 38 | 43 | //@property (nonatomic, strong) NSString *_Nullable pushId;//跳转id |
| 39 | 44 | |
| 40 | -+ (instancetype _Nonnull)modelWithSender:(NSString *_Nonnull)sender giftName:(NSString *_Nonnull)giftName icon:(NSString *_Nonnull)icon giftImageName:(NSString *_Nonnull)giftImageName; | |
| 45 | ++ (instancetype _Nonnull)modelWithGiftName:(NSString *_Nonnull)giftName icon:(NSString *_Nullable)icon giftImageName:(NSString *_Nonnull)giftImageName; | |
| 41 | 46 | |
| 42 | 47 | @end | ... | ... |
LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftModel/GiftModel.m
| ... | ... | @@ -9,10 +9,10 @@ |
| 9 | 9 | #import "GiftModel.h" |
| 10 | 10 | |
| 11 | 11 | @implementation GiftModel |
| 12 | -+ (instancetype)modelWithSender:(NSString *)sender giftName:(NSString *)giftName icon:(NSString *)icon giftImageName:(NSString *)giftImageName | |
| 12 | ++ (instancetype _Nonnull)modelWithGiftName:(NSString *_Nonnull)giftName icon:(NSString *_Nullable)icon giftImageName:(NSString *_Nonnull)giftImageName | |
| 13 | 13 | { |
| 14 | 14 | GiftModel *model = [[GiftModel alloc] init]; |
| 15 | - model.sender = sender; | |
| 15 | +// model.sender = sender; | |
| 16 | 16 | model.giftName = giftName; |
| 17 | 17 | model.icon = icon; |
| 18 | 18 | model.giftImageName = giftImageName; | ... | ... |
LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftViews/GiftListView.h
| ... | ... | @@ -8,8 +8,19 @@ |
| 8 | 8 | |
| 9 | 9 | #import "BaseView.h" |
| 10 | 10 | @class LiveBaseView; |
| 11 | +@class GiftModel; | |
| 12 | + | |
| 13 | +@protocol GiftSelectDelegate <NSObject> | |
| 14 | + | |
| 15 | +- (void)giftSelectedModel:(GiftModel *_Nonnull)model; | |
| 16 | + | |
| 17 | +@end | |
| 11 | 18 | |
| 12 | 19 | @interface GiftListView : BaseView |
| 13 | 20 | |
| 14 | 21 | - (instancetype _Nonnull)initWithFrame:(CGRect)frame liveBaseView:(LiveBaseView *_Nullable)liveBaseView; |
| 22 | + | |
| 23 | +@property (nonatomic,weak) id <GiftSelectDelegate> delegate; | |
| 24 | + | |
| 25 | +- (void)addGiftAnimationWithModel:(GiftModel *_Nonnull)model; | |
| 15 | 26 | @end | ... | ... |
LiveVideoCloud/Classes/Sections/InteractionSections/Gift/GiftViews/GiftListView.m
| ... | ... | @@ -27,6 +27,8 @@ |
| 27 | 27 | @property (nonatomic ,weak ) LiveBaseView * _Nullable liveBaseView; |
| 28 | 28 | @property (nonatomic, strong) AnimQueueManager * animQueueManager; |
| 29 | 29 | @property (nonatomic ,strong) GiftModel * _Nullable model; |
| 30 | +@property (nonatomic ,assign) BOOL isSelectedGift; | |
| 31 | +@property (nonatomic ,assign) NSInteger curruntSelectIdx; | |
| 30 | 32 | |
| 31 | 33 | @end |
| 32 | 34 | |
| ... | ... | @@ -36,6 +38,7 @@ |
| 36 | 38 | { |
| 37 | 39 | if (self = [super initWithFrame:frame]) { |
| 38 | 40 | |
| 41 | + _isSelectedGift = NO; | |
| 39 | 42 | _images = [NSArray arrayWithObjects:@"porsch_small80",@"fighter_small80",@"plane_small80",@"love_gift",@"beer",@"chicken",@"cucumber",@"flower",@"hug",@"mouth",@"ring",@"rose",@"sticks",nil]; |
| 40 | 43 | _giftNames = [NSArray arrayWithObjects:@"跑车",@"歼灭机",@"飞机",@"大大的爱心",@"啤酒",@"小鸡",@"小黄瓜",@"鲜花",@"抱抱",@"亲吻",@"戒指",@"玫瑰花",@"荧光棒",nil]; |
| 41 | 44 | _prices = [NSArray arrayWithObjects:@"300000000",@"300000000",@"300000",@"30",@"30",@"3",@"3",@"1",@"3",@"1",@"3",@"30",@"300", nil]; |
| ... | ... | @@ -45,7 +48,7 @@ |
| 45 | 48 | self.animQueueManager = [AnimQueueManager sharedAnimQueueManager]; |
| 46 | 49 | |
| 47 | 50 | UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.width, self.height - GiftPayViewHeight)]; |
| 48 | - scrollView.contentSize = CGSizeMake(self.width *(self.giftArray.count/(MAX_ROW_COUNT*MAX_LINE_COUNT) + 1), self.height - GiftPayViewHeight); | |
| 51 | + scrollView.contentSize = CGSizeMake(self.width *(self.giftNames.count/(MAX_ROW_COUNT*MAX_LINE_COUNT) + 1), self.height - GiftPayViewHeight); | |
| 49 | 52 | scrollView.pagingEnabled = YES; |
| 50 | 53 | scrollView.bounces = NO; |
| 51 | 54 | scrollView.showsVerticalScrollIndicator = NO; |
| ... | ... | @@ -57,7 +60,7 @@ |
| 57 | 60 | CGFloat giftX = 0; |
| 58 | 61 | CGFloat giftY = 0; |
| 59 | 62 | int page = 0; |
| 60 | - for (int i = 0; i < self.giftArray.count; i ++) { | |
| 63 | + for (int i = 0; i < self.giftNames.count; i ++) { | |
| 61 | 64 | |
| 62 | 65 | if (i % MAX_LINE_COUNT == 0 && i > 0) { |
| 63 | 66 | line ++; |
| ... | ... | @@ -110,8 +113,12 @@ |
| 110 | 113 | |
| 111 | 114 | - (void)sendClick |
| 112 | 115 | { |
| 113 | - NSLog(@"sendClick"); | |
| 114 | - [Tools showNaviViewWithMessage:@"请先充值钻石哦"]; | |
| 116 | + if (_isSelectedGift) {//当前选择了礼物 | |
| 117 | + if ([self.delegate respondsToSelector:@selector(giftSelectedModel:)]) { | |
| 118 | + [self.delegate giftSelectedModel:_model]; | |
| 119 | + } | |
| 120 | + } | |
| 121 | +// [Tools showNaviViewWithMessage:@"请先充值钻石哦"]; | |
| 115 | 122 | } |
| 116 | 123 | |
| 117 | 124 | - (void)payClick |
| ... | ... | @@ -150,17 +157,40 @@ |
| 150 | 157 | #pragma mark - 选择礼物点击 |
| 151 | 158 | - (void)gestureClick:(UITapGestureRecognizer *)gesture |
| 152 | 159 | { |
| 160 | + _isSelectedGift = YES; | |
| 153 | 161 | NSInteger tag = gesture.view.tag - 10; |
| 154 | 162 | NSLog(@"%zd",tag); |
| 163 | + | |
| 164 | +// if (_curruntSelectIdx == tag && _isSelectedGift) { | |
| 165 | +// _isSelectedGift = NO; | |
| 166 | +// _curruntSelectIdx = -1; | |
| 167 | +// } | |
| 168 | +// _curruntSelectIdx = tag; | |
| 169 | + | |
| 155 | 170 | //右上角添加✔️,再次点击去掉✔️ |
| 171 | + | |
| 156 | 172 | GiftModel *model = self.giftArray[tag]; |
| 157 | - if (model.giftStyle == GiftStyleCombo) { | |
| 173 | + model.sender = [CNLiveChatManager sharedCNLiveChatManager].currentUserInfo.name; | |
| 174 | + model.icon = [CNLiveChatManager sharedCNLiveChatManager].currentUserInfo.portraitUri; | |
| 175 | +#warning 测试时 price 用假值 model.giftNumber赋值会导致不能本地连击以后再说 | |
| 176 | + model.price = @"0"; | |
| 177 | +// model.giftNumber = 3; | |
| 178 | + model.index = tag; | |
| 179 | + _model = model; | |
| 180 | +} | |
| 158 | 181 | |
| 159 | - [self.animQueueManager addAnimationWithModel:self.giftArray[tag] animContentView:(UIView *)self.liveBaseView.presentView]; | |
| 160 | - }else | |
| 161 | - { | |
| 162 | - [self.animQueueManager addAnimationWithModel:self.giftArray[tag] animContentView:self.liveBaseView]; | |
| 163 | - } | |
| 182 | +//应该加验证发送礼物消息成功后 再展示动画 | |
| 183 | +- (void)addGiftAnimationWithModel:(GiftModel *_Nonnull)model | |
| 184 | +{ | |
| 185 | + dispatch_async(dispatch_get_main_queue(), ^{ | |
| 186 | + if (model.giftStyle == GiftStyleCombo) { | |
| 187 | + | |
| 188 | + [self.animQueueManager addAnimationWithModel:self.giftArray[model.index] animContentView:(UIView *)self.liveBaseView.presentView]; | |
| 189 | + }else | |
| 190 | + { | |
| 191 | + [self.animQueueManager addAnimationWithModel:self.giftArray[model.index] animContentView:self.liveBaseView]; | |
| 192 | + } | |
| 193 | + }); | |
| 164 | 194 | } |
| 165 | 195 | |
| 166 | 196 | - (NSString *)giftNameWithImageName:(NSString *)imageName |
| ... | ... | @@ -181,21 +211,20 @@ |
| 181 | 211 | { |
| 182 | 212 | if (!_giftArray) |
| 183 | 213 | { |
| 184 | - NSArray *senders = [NSArray arrayWithObjects:@"张三",@"龙的传人",@"李四",@"王五",@"宋刘",@"老七",@"老八",@"老九",@"老十",@"老师",@"小十七",@"小十八",@"小十九", nil]; | |
| 185 | 214 | NSMutableArray *tempArr = [NSMutableArray array]; |
| 186 | 215 | for (int i = 0; i < _images.count; i ++) { |
| 187 | 216 | |
| 188 | 217 | NSString *type = _types[i]; |
| 189 | 218 | if ([type isEqualToString:@"1"]) { |
| 190 | 219 | //combo |
| 191 | - GiftModel *model1 = [GiftModel modelWithSender:senders[i] giftName:[self giftNameWithImageName:_images[i]] icon:@"love" giftImageName:_images[i]]; | |
| 220 | + GiftModel *model1 = [GiftModel modelWithGiftName:[self giftNameWithImageName:_images[i]] icon:@"" giftImageName:_images[i]]; | |
| 192 | 221 | model1.giftStyle = GiftStyleCombo; |
| 193 | 222 | model1.price = _prices[i]; |
| 194 | 223 | [tempArr addObject:model1]; |
| 195 | 224 | |
| 196 | 225 | }else |
| 197 | 226 | {//expen |
| 198 | - GiftModel *model = [GiftModel modelWithSender:senders[i] giftName:[self giftNameWithImageName:_images[i]] icon:@"love" giftImageName:@""]; | |
| 227 | + GiftModel *model = [GiftModel modelWithGiftName:[self giftNameWithImageName:_images[i]] icon:@"" giftImageName:@""]; | |
| 199 | 228 | |
| 200 | 229 | if ([type isEqualToString:@"2"]) { |
| 201 | 230 | model.giftStyle = GiftStylePorsch; | ... | ... |
LiveVideoCloud/Classes/Sections/InteractionSections/Gift/Present/ComboCell.m
| ... | ... | @@ -37,7 +37,7 @@ |
| 37 | 37 | - (void)setModel:(GiftModel *)model |
| 38 | 38 | { |
| 39 | 39 | _model = model; |
| 40 | - self.icon.image = [UIImage imageNamed:model.icon]; | |
| 40 | + [self.icon sd_setImageWithURL:[NSURL URLWithString:model.icon] placeholderImage:nil];//[UIImage zx_circleImageNamed:model.icon]; | |
| 41 | 41 | self.senderNameLbl.text = model.sender; |
| 42 | 42 | self.giftNameLbl.text = [NSString stringWithFormat:@"送一个%@",model.giftName]; |
| 43 | 43 | self.senderNameLbl.size = [self.senderNameLbl labelSize]; | ... | ... |
LiveVideoCloud/Classes/Sections/InteractionSections/LVCInteractionController.h deleted
100644 → 0
LiveVideoCloud/Classes/Sections/InteractionSections/LVCInteractionController.m deleted
100644 → 0
| 1 | -// | |
| 2 | -// LVCInteractionController.m | |
| 3 | -// LiveVideoCloud | |
| 4 | -// | |
| 5 | -// Created by 张旭 on 2017/3/13. | |
| 6 | -// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | -// | |
| 8 | - | |
| 9 | -#import "LVCInteractionController.h" | |
| 10 | -#import "LiveBaseView.h" | |
| 11 | - | |
| 12 | -@interface LVCInteractionController () | |
| 13 | - | |
| 14 | -@property (nonatomic ,strong) LiveBaseView * _Nullable liveBaseView; | |
| 15 | - | |
| 16 | -@end | |
| 17 | - | |
| 18 | -@implementation LVCInteractionController | |
| 19 | - | |
| 20 | -- (void)viewDidLoad { | |
| 21 | - [super viewDidLoad]; | |
| 22 | - // Do any additional setup after loading the view. | |
| 23 | - self.automaticallyAdjustsScrollViewInsets = NO; | |
| 24 | -} | |
| 25 | - | |
| 26 | -- (void)bindView | |
| 27 | -{ | |
| 28 | - [self.view addSubview:self.liveBaseView]; | |
| 29 | -} | |
| 30 | - | |
| 31 | -- (LiveBaseView *)liveBaseView | |
| 32 | -{ | |
| 33 | - if (!_liveBaseView) | |
| 34 | - { | |
| 35 | - _liveBaseView = [LiveBaseView liveBaseView]; | |
| 36 | - _liveBaseView.viewController = self; | |
| 37 | - _liveBaseView.backgroundColor = [UIColor clearColor]; | |
| 38 | - } | |
| 39 | - return _liveBaseView; | |
| 40 | -} | |
| 41 | - | |
| 42 | -- (void)didReceiveMemoryWarning { | |
| 43 | - [super didReceiveMemoryWarning]; | |
| 44 | - // Dispose of any resources that can be recreated. | |
| 45 | -} | |
| 46 | - | |
| 47 | -/* | |
| 48 | -#pragma mark - Navigation | |
| 49 | - | |
| 50 | -// In a storyboard-based application, you will often want to do a little preparation before navigation | |
| 51 | -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | |
| 52 | - // Get the new view controller using [segue destinationViewController]. | |
| 53 | - // Pass the selected object to the new view controller. | |
| 54 | -} | |
| 55 | -*/ | |
| 56 | - | |
| 57 | -@end |
LiveVideoCloud/Classes/Sections/InteractionSections/LiveBaseView.m
| ... | ... | @@ -24,8 +24,16 @@ |
| 24 | 24 | |
| 25 | 25 | #define BottomToolHeight 60 |
| 26 | 26 | |
| 27 | -static NSString *message_barrage = @"message_barrage"; | |
| 28 | -static NSString *message_content = @"message_content"; | |
| 27 | +static NSString *chatType = @"type"; | |
| 28 | +static NSString *chatMessage = @"message"; | |
| 29 | +static NSString *msgGiftPrice = @"giftPrice"; | |
| 30 | +static NSString *msgGiftName = @"giftName"; | |
| 31 | +static NSString *msgGiftNumber = @"giftNumber"; | |
| 32 | +static NSString *msgBarrage = @"messageBarrage"; | |
| 33 | +static NSString *msgContent = @"content"; | |
| 34 | +static NSString *giftType = @"giftType"; | |
| 35 | +static NSString *chatRoomType = @"chatRoom"; | |
| 36 | +static NSString *joinType = @"joinType"; | |
| 29 | 37 | |
| 30 | 38 | typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 31 | 39 | PopTypeGift = 1,//礼物弹窗 |
| ... | ... | @@ -33,7 +41,7 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 33 | 41 | PopTypePriMessage //私信弹窗 |
| 34 | 42 | }; |
| 35 | 43 | |
| 36 | -@interface LiveBaseView ()<bottomBtnDeledate,PresentViewDelegate,UIScrollViewDelegate,UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate,userClickDelegate,CNLiveChatManagerDelegate,PopViewDelegate> | |
| 44 | +@interface LiveBaseView ()<bottomBtnDeledate,PresentViewDelegate,UIScrollViewDelegate,UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate,userClickDelegate,CNLiveChatManagerDelegate,PopViewDelegate,GiftSelectDelegate> | |
| 37 | 45 | |
| 38 | 46 | @property (nonatomic ,strong ) UIScrollView * _Nullable scrollView; |
| 39 | 47 | //@property (nonatomic ,strong ,readwrite) AnimationBaseView * _Nullable animationBaseView;//展示层View |
| ... | ... | @@ -82,7 +90,6 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 82 | 90 | [[LVCAnimationManager shareManager] bubblingWithCenterPoint:CGPointMake(SCREEN_WIDTH - 50, SCREEN_HEIGHT - 50) toView:self.animationBaseView speed:1]; |
| 83 | 91 | |
| 84 | 92 | [self.animationBaseView addSubview:self.chatTableView]; |
| 85 | - | |
| 86 | 93 | [self.animationBaseView addSubview:self.topToolsView]; |
| 87 | 94 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; |
| 88 | 95 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHidden:) name:UIKeyboardWillHideNotification object:nil]; |
| ... | ... | @@ -95,12 +102,10 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 95 | 102 | _roomId = roomId; |
| 96 | 103 | [CNLiveChatManager sharedCNLiveChatManager].delegate = self; |
| 97 | 104 | [[CNLiveChatManager sharedCNLiveChatManager] joinChatRoom:roomId messageCount:10 success:^(NSString *targetId) { |
| 98 | - NSLog(@"success"); | |
| 105 | + NSLog(@"连接聊天室成功success %@",targetId); | |
| 99 | 106 | } error:^(CNLiveChatErrorCode errors, NSString *targetId) { |
| 100 | 107 | NSLog(@"error"); |
| 101 | 108 | }]; |
| 102 | - | |
| 103 | - [CNLiveChatManager sharedCNLiveChatManager].currentUserInfo.portraitUri = @"http://b.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=f0c5c08030d3d539c16807c70fb7c566/8ad4b31c8701a18bbef9f231982f07082838feba.jpg"; | |
| 104 | 109 | } |
| 105 | 110 | |
| 106 | 111 | - (void)dealloc |
| ... | ... | @@ -185,25 +190,26 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 185 | 190 | NSDictionary *dic; |
| 186 | 191 | if(self.barrageSwitch.isOn){ |
| 187 | 192 | //开启横屏弹幕 |
| 188 | - dic = @{message_barrage:@"1",message_content:textField.text}; | |
| 193 | + dic = @{chatType:chatRoomType, chatMessage:@{msgBarrage:@"1",msgContent:textField.text}}; | |
| 189 | 194 | }else |
| 190 | 195 | { |
| 191 | - dic = @{message_barrage:@"0",message_content:textField.text}; | |
| 196 | + dic = @{chatType:chatRoomType, chatMessage:@{msgBarrage:@"0",msgContent:textField.text}}; | |
| 192 | 197 | } |
| 193 | 198 | weakself |
| 194 | 199 | NSString *message = [Tools dictionaryToJson:dic]; |
| 195 | - [[CNLiveChatManager sharedCNLiveChatManager] sendMessage:message type:CNLive_ConversationType_CHATROOM targetId:@"1234" success:^(CNLiveChatMessage *message) { | |
| 200 | + [[CNLiveChatManager sharedCNLiveChatManager] sendMessage:message type:CNLive_ConversationType_CHATROOM targetId:_roomId success:^(CNLiveChatMessage *message) { | |
| 196 | 201 | strongself |
| 197 | 202 | NSDictionary *JSONDic = [Tools dictionaryWithJsonString:message.messageContent]; |
| 198 | - NSString *content = [JSONDic objectForKey:message_content]; | |
| 203 | + NSDictionary *msg = [JSONDic objectForKey:chatMessage]; | |
| 199 | 204 | |
| 200 | 205 | //将消息显示到列表中 |
| 201 | 206 | chatMsgModel *model = [[chatMsgModel alloc] init]; |
| 202 | 207 | model.name = message.userInfo.name; |
| 203 | - model.content = content; | |
| 208 | + model.content = [msg objectForKey:msgContent]; | |
| 204 | 209 | model.ID = message.targetId; |
| 205 | 210 | model.icon = message.userInfo.portraitUri; |
| 206 | 211 | model.cellWidth = self.chatTableView.width - 20; |
| 212 | + model.uId = message.userInfo.userId; | |
| 207 | 213 | [self.chatMsgArray addObject:model]; |
| 208 | 214 | [self.chatTableView reloadData]; |
| 209 | 215 | NSInteger section = [self.chatTableView numberOfSections]; |
| ... | ... | @@ -214,13 +220,13 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 214 | 220 | [self.chatTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES]; |
| 215 | 221 | [self.chatTableView reloadData]; |
| 216 | 222 | |
| 217 | - NSInteger isBarrage = [[JSONDic objectForKey:message_barrage] integerValue]; | |
| 223 | + NSInteger isBarrage = [[[JSONDic objectForKey:chatMessage] objectForKey:msgBarrage] integerValue]; | |
| 218 | 224 | |
| 219 | 225 | if (isBarrage) {//此条消息飘弹幕 |
| 220 | 226 | |
| 221 | 227 | chatMsgModel *barrageModel = [[chatMsgModel alloc] init]; |
| 222 | 228 | barrageModel.name = message.userInfo.name; |
| 223 | - barrageModel.content = content; | |
| 229 | + barrageModel.content = [msg objectForKey:msgContent]; | |
| 224 | 230 | barrageModel.icon = message.userInfo.portraitUri; |
| 225 | 231 | |
| 226 | 232 | [self.chatManager addAnimationWithModel:barrageModel animContentView:self.animationBaseView]; |
| ... | ... | @@ -365,6 +371,12 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 365 | 371 | } |
| 366 | 372 | } |
| 367 | 373 | |
| 374 | +- (NSString *)giftModelToJSON:(GiftModel *)model | |
| 375 | +{ | |
| 376 | + NSDictionary *dic = @{chatType:giftType,chatMessage:@{msgGiftName:model.giftName,msgGiftNumber:[NSString stringWithFormat:@"%zd",model.giftNumber],msgGiftPrice:model.price}}; | |
| 377 | + return [Tools dictionaryToJson:dic]; | |
| 378 | +} | |
| 379 | + | |
| 368 | 380 | #pragma mark - buttonClick触摸屏幕关闭方法 |
| 369 | 381 | - (void)tapGestureClick:(UITapGestureRecognizer *)gesture |
| 370 | 382 | { |
| ... | ... | @@ -427,6 +439,48 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 427 | 439 | [self clearCurrentPopView]; |
| 428 | 440 | } |
| 429 | 441 | |
| 442 | +#pragma mark - GiftSelectedDelegate | |
| 443 | +- (void)giftSelectedModel:(GiftModel *_Nonnull)model | |
| 444 | +{ | |
| 445 | + if (![model.sender isEqualToString:@""]) { | |
| 446 | + if ([[CNLiveChatManager sharedCNLiveChatManager] getConnectionStatus] == CNLive_ConnectionStatus_Connected) { | |
| 447 | + | |
| 448 | + weakself | |
| 449 | + [[CNLiveChatManager sharedCNLiveChatManager] sendMessage:[self giftModelToJSON:model] type:CNLive_ConversationType_CHATROOM targetId:_roomId success:^(CNLiveChatMessage *message) { | |
| 450 | + | |
| 451 | + NSLog(@"send Msg success: %@",message.messageContent); | |
| 452 | + strongself | |
| 453 | + NSDictionary *JSONDic = [Tools dictionaryWithJsonString:message.messageContent]; | |
| 454 | + NSDictionary *msgDic = [JSONDic objectForKey:chatMessage]; | |
| 455 | + | |
| 456 | + [self.giftListView addGiftAnimationWithModel:model]; | |
| 457 | + | |
| 458 | + CNLiveChatUserInfo *userInfo = message.userInfo; | |
| 459 | + //将消息显示到列表中 | |
| 460 | + chatMsgModel *model1 = [[chatMsgModel alloc] init]; | |
| 461 | + model1.name = message.userInfo.name; | |
| 462 | + model1.content = [NSString stringWithFormat:@" 送了一个 %@",msgDic[@"giftName"]]; | |
| 463 | + model1.ID = message.targetId; | |
| 464 | + model1.icon = userInfo.portraitUri; | |
| 465 | + model1.cellWidth = self.chatTableView.width - 20; | |
| 466 | + model1.uId = userInfo.userId; | |
| 467 | + [self.chatMsgArray addObject:model1]; | |
| 468 | + [self.chatTableView reloadData]; | |
| 469 | + NSInteger section = [self.chatTableView numberOfSections]; | |
| 470 | + if (section < 1) return; | |
| 471 | + NSInteger row = [self.chatTableView numberOfRowsInSection:section - 1]; | |
| 472 | + if (row < 1) return; | |
| 473 | + NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row - 1 inSection:section - 1]; | |
| 474 | + [self.chatTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES]; | |
| 475 | + [self.chatTableView reloadData]; | |
| 476 | + | |
| 477 | + } error:^(CNLiveChatErrorCode errors, NSString *messageId, NSString *targetId) { | |
| 478 | + NSLog(@"error"); | |
| 479 | + }]; | |
| 480 | + } | |
| 481 | + } | |
| 482 | +} | |
| 483 | + | |
| 430 | 484 | #pragma mark - CNLiveChatManagerDelegate |
| 431 | 485 | /** |
| 432 | 486 | 连接状态的的监听器 |
| ... | ... | @@ -473,15 +527,16 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 473 | 527 | case CNLive_ConversationType_CHATROOM: |
| 474 | 528 | { |
| 475 | 529 | NSDictionary *JSONDic = [Tools dictionaryWithJsonString:message.messageContent]; |
| 476 | - NSString *content = [JSONDic objectForKey:message_content]; | |
| 530 | + NSDictionary *msg = [JSONDic objectForKey:chatMessage]; | |
| 477 | 531 | |
| 478 | 532 | //将消息显示到列表中 |
| 479 | 533 | chatMsgModel *model = [[chatMsgModel alloc] init]; |
| 480 | 534 | model.name = message.userInfo.name; |
| 481 | - model.content = content; | |
| 535 | + model.content = [msg objectForKey:msgContent]; | |
| 482 | 536 | model.ID = message.targetId; |
| 483 | 537 | model.icon = message.userInfo.portraitUri; |
| 484 | 538 | model.cellWidth = self.chatTableView.width - 20; |
| 539 | + model.uId = message.userInfo.userId; | |
| 485 | 540 | [self.chatMsgArray addObject:model]; |
| 486 | 541 | [self.chatTableView reloadData]; |
| 487 | 542 | |
| ... | ... | @@ -493,13 +548,13 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 493 | 548 | [self.chatTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES]; |
| 494 | 549 | [self.chatTableView reloadData]; |
| 495 | 550 | |
| 496 | - NSInteger isBarrage = [[JSONDic objectForKey:message_barrage] integerValue]; | |
| 551 | + NSInteger isBarrage = [[[JSONDic objectForKey:chatMessage] objectForKey:msgBarrage] integerValue]; | |
| 497 | 552 | |
| 498 | 553 | if (isBarrage) {//此条消息飘弹幕 |
| 499 | 554 | |
| 500 | 555 | chatMsgModel *barrageModel = [[chatMsgModel alloc] init]; |
| 501 | 556 | barrageModel.name = message.userInfo.name; |
| 502 | - barrageModel.content = content; | |
| 557 | + barrageModel.content = [msg objectForKey:msgContent]; | |
| 503 | 558 | barrageModel.icon = message.userInfo.portraitUri; |
| 504 | 559 | [self.chatManager addAnimationWithModel:barrageModel animContentView:self.animationBaseView]; |
| 505 | 560 | } |
| ... | ... | @@ -508,14 +563,14 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 508 | 563 | case CNLive_ConversationType_PRIVATE: |
| 509 | 564 | { |
| 510 | 565 | NSDictionary *JSONDic = [Tools dictionaryWithJsonString:message.messageContent]; |
| 511 | - NSString *content = [JSONDic objectForKey:message_content]; | |
| 566 | + NSDictionary *msg = [JSONDic objectForKey:chatMessage]; | |
| 512 | 567 | PrivateView *privateView = [PrivateView privateView]; |
| 513 | 568 | |
| 514 | 569 | //将消息显示到列表中 |
| 515 | 570 | chatMsgModel *model = [[chatMsgModel alloc] init]; |
| 516 | 571 | model.name = message.userInfo.name; |
| 517 | 572 | model.isMine = NO; |
| 518 | - model.content = content; | |
| 573 | + model.content = [msg objectForKey:msgContent]; | |
| 519 | 574 | model.ID = message.targetId; |
| 520 | 575 | model.icon = message.userInfo.portraitUri; |
| 521 | 576 | model.priCellWidth = privateView.tableView.width * 0.5 - 30; |
| ... | ... | @@ -702,15 +757,6 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 702 | 757 | if (!_chatMsgArray) { |
| 703 | 758 | |
| 704 | 759 | _chatMsgArray = [NSMutableArray array]; |
| 705 | -// NSArray *names = [NSArray arrayWithObjects:@"张旭",@"老大",@"老六",@"什么人",@"金光",@"银光",@"阳光", nil]; | |
| 706 | -// NSArray *contents = [NSArray arrayWithObjects:@"阿萨德请问发群里发",@"阿萨德请问发群里发发染发我if顽皮的发球局平均分配WiF",@"阿萨德请问发群里发发染发我if顽皮的发球局平均分配WiFi我if为打破我姐夫我批发价为破房间我批发价我批发价为 爱神的箭怕我的哦期",@"里发发染发我if顽",@"金光神的箭怕我的哦期间",@"银光",@"阳光神的箭怕我的哦期间", nil]; | |
| 707 | -// for (int i = 0 ; i < names.count; i ++) { | |
| 708 | -// chatMsgModel *model = [[chatMsgModel alloc] init]; | |
| 709 | -// model.name = names[i]; | |
| 710 | -// model.content = contents[i]; | |
| 711 | -// model.cellWidth = self.chatTableView.width - 20; | |
| 712 | -// [self.chatMsgArray addObject:model]; | |
| 713 | -// } | |
| 714 | 760 | } |
| 715 | 761 | return _chatMsgArray; |
| 716 | 762 | } |
| ... | ... | @@ -733,6 +779,7 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 733 | 779 | if (!_giftListView) |
| 734 | 780 | { |
| 735 | 781 | _giftListView = [[GiftListView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT - 250, SCREEN_WIDTH, 250) liveBaseView:self]; |
| 782 | + _giftListView.delegate = self; | |
| 736 | 783 | |
| 737 | 784 | UIImageView *giftBg = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, _giftListView.width, _giftListView.height)]; |
| 738 | 785 | giftBg.image = [UIImage imageNamed:@"背景400x300"]; |
| ... | ... | @@ -752,6 +799,7 @@ typedef NS_ENUM(NSInteger, PopType) {//弹窗类型 |
| 752 | 799 | } |
| 753 | 800 | return _chatManager; |
| 754 | 801 | } |
| 802 | + | |
| 755 | 803 | /* |
| 756 | 804 | // Only override drawRect: if you perform custom drawing. |
| 757 | 805 | // An empty implementation adversely affects performance during animation. | ... | ... |
LiveVideoCloud/Classes/Sections/LiveSections/Controller/LVCVerifyViewController.m
| ... | ... | @@ -41,10 +41,11 @@ |
| 41 | 41 | }]; |
| 42 | 42 | webView.UIDelegate = self; |
| 43 | 43 | webView.navigationDelegate = self; |
| 44 | - self.webUrl = [NSString stringWithFormat:@"%@?sid=%@&plat=i&appId=%@",@"https://mobile.cnlive.com/CnliveMobile/web/review/review.jsp",[UserInformationModel manager].uid,UserAppId]; | |
| 44 | + self.webUrl = [NSString stringWithFormat:@"%@?sid=%@&plat=i&appId=%@&type=0",@"https://mobile.cnlive.com/CnliveMobile/web/review/review.jsp",[UserInformationModel manager].uid,UserAppId]; | |
| 45 | 45 | NSString *sign = [self.webUrl containsString:@"?"] ? @"&" : @"?"; |
| 46 | 46 | self.webUrl = [self.webUrl stringByAppendingFormat:@"%@appid=%@", sign, UserAppId]; |
| 47 | - | |
| 47 | +#warning 测试环境type=0,正式环境不传type | |
| 48 | + | |
| 48 | 49 | [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.webUrl]]]; |
| 49 | 50 | } |
| 50 | 51 | ... | ... |
LiveVideoCloud/animation.xcassets/Interaction/defaultUserIcon.imageset/Contents.json
LiveVideoCloud/animation.xcassets/player/Is closed.imageset/Contents.json