YBCenterTopView.m 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199
  1. //
  2. // YBCenterTopView.m
  3. // YBVideo
  4. //
  5. // Created by YB007 on 2022/5/30.
  6. // Copyright © 2022 cat. All rights reserved.
  7. //
  8. #import "YBCenterTopView.h"
  9. #import "UIImage+RKImgCategory.h"
  10. #import "ShopHomeVC.h"
  11. #import "shopDetailVC.h"
  12. #import "YBGoodsLikeVC.h"
  13. #import "EditVC.h"
  14. #import "fansViewController.h"
  15. #import "attrViewController.h"
  16. #import "Loginbonus.h"
  17. #import "JCHATConversationViewController.h"
  18. #import "JCHATAlertViewWait.h"
  19. #import "YBVipVC.h"
  20. #import "BusinessCardVC.h"
  21. #import "HeaderBackImgView.h"
  22. #import "TZImagePickerController.h"
  23. #import "YBStorageObj.h"
  24. #import "YBCheckLiveObj.h"
  25. #import "YBOtherCenterMore.h"
  26. #import "YBCenterMoreView.h"
  27. @interface YBCenterTopView()<TZImagePickerControllerDelegate,UINavigationControllerDelegate,UIImagePickerControllerDelegate,FirstLogDelegate>{
  28. CGFloat _btnHeight;
  29. Loginbonus *firstLV;
  30. NSString *bonus_switch;
  31. NSString *bonus_day;
  32. NSArray *bonus_list;
  33. NSString *dayCount;
  34. NSString *is_bonus;//是否签到
  35. MessageListModel *_userModel;
  36. UIImage *headBgimg;
  37. NSString *headBgStr;
  38. }
  39. // 背景
  40. @property(nonatomic,strong)HeaderBackImgView *headImgView;
  41. @property(nonatomic,strong)UIImageView *bigBgIV;
  42. @property(nonatomic,strong)YBButton *returnBtn; // 返回
  43. @property(nonatomic,strong)YBButton *youngBtn; // 青少年
  44. @property(nonatomic,strong)YBButton *moreBtn; // 更多
  45. @property(nonatomic,strong)YBButton *iconBtn;
  46. @property(nonatomic,strong)UIView *liveingV;
  47. @property(nonatomic,strong)UILabel *liveingL;
  48. @property(nonatomic,strong)UILabel *nameL;
  49. @property(nonatomic,strong)UILabel *idL;
  50. @property(nonatomic,strong)UIButton *qrcodeBtn;
  51. @property(nonatomic,strong)UIButton *nameBtn;
  52. // 赞、关注、粉丝等父视图
  53. @property(nonatomic,strong)UIView *itemView1;
  54. @property(nonatomic,strong)UIView *item1Content;
  55. @property(nonatomic,strong)UILabel *zanNumL;
  56. @property(nonatomic,strong)UILabel *fansNumL;
  57. @property(nonatomic,strong)UILabel *followNumL;
  58. @property(nonatomic,strong)YBButton *editBtn; // 自己-编辑
  59. @property(nonatomic,strong)YBButton *signDayBtn; // 自己-签到
  60. @property(nonatomic,strong)YBButton *followBtn; // 他人-关注
  61. @property(nonatomic,strong)YBButton *chatBtn; // 他人-聊天
  62. // 签名、个人资料等父视图
  63. @property(nonatomic,strong)UIView *itemView2;
  64. @property(nonatomic,strong)UIView *item2Content;
  65. @property(nonatomic,strong)UILabel *signatureL;
  66. @property(nonatomic,strong)UIButton *sexBtn;
  67. @property(nonatomic,strong)UIButton *ageBtn;
  68. @property(nonatomic,strong)UIButton *cityBtn;
  69. @property(nonatomic,strong)UIView *vipBgView;
  70. @property(nonatomic,strong)UIImageView *vipRightBgIV;
  71. @property(nonatomic,strong)UILabel *vipTitleL;
  72. @property(nonatomic,strong)UILabel *vipTimeL;
  73. // 直播小店、我的收藏、直播动态等父视图
  74. @property(nonatomic,strong)UIView *itemView3;
  75. @property(nonatomic,strong)MASConstraint *item2ContentMas;
  76. @property(nonatomic,strong)MASConstraint *vipBgMas;
  77. @end
  78. @implementation YBCenterTopView
  79. - (instancetype)initWithFrame:(CGRect)frame{
  80. self = [super initWithFrame:frame];
  81. if (self) {
  82. [self createUI];
  83. }
  84. return self;
  85. }
  86. -(void)createUI {
  87. _userModel = [[MessageListModel alloc]init];
  88. CGFloat bigIVHeight = _window_width * 200.0/375+20+statusbarHeight;
  89. _bigBgIV = [[UIImageView alloc]init];
  90. _bigBgIV.contentMode = UIViewContentModeScaleAspectFill;
  91. _bigBgIV.userInteractionEnabled = YES;
  92. _bigBgIV.clipsToBounds = YES;
  93. [self addSubview:_bigBgIV];
  94. [_bigBgIV mas_makeConstraints:^(MASConstraintMaker *make) {
  95. make.width.centerX.top.equalTo(self);
  96. make.height.mas_equalTo(bigIVHeight);
  97. }];
  98. UITapGestureRecognizer *headTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(headerImgTap)];
  99. [_bigBgIV addGestureRecognizer:headTap];
  100. UIImageView *iconShadow = [[UIImageView alloc]init];
  101. iconShadow.image = [UIImage imageNamed:@"个中头部-遮罩"];
  102. iconShadow.contentMode = UIViewContentModeScaleAspectFill;
  103. [_bigBgIV addSubview:iconShadow];
  104. [iconShadow mas_makeConstraints:^(MASConstraintMaker *make) {
  105. make.width.bottom.centerX.equalTo(_bigBgIV);
  106. make.top.equalTo(_bigBgIV.mas_centerY).multipliedBy(0.2);
  107. }];
  108. _returnBtn = [self createBtnStatus:BtnFun_CenterReturn corner:0 havebg:NO];
  109. [_returnBtn setImage:[UIImage imageNamed:@"个中头部-返回"] forState:0];
  110. [self addSubview:_returnBtn];
  111. [_returnBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  112. make.left.equalTo(self.mas_left).offset(10);
  113. make.top.equalTo(self.mas_top).offset(statusbarHeight+20);
  114. make.width.height.mas_equalTo(50);
  115. }];
  116. // _youngBtn = [self createBtnStatus:BtnFun_CenterYoung corner:14 havebg:NO];
  117. // [_youngBtn setImage:[UIImage imageNamed:@"个中头部-青年"] forState:0];
  118. // [_youngBtn setTitle:YZMsg(@"青少年模式") forState:0];
  119. // _youngBtn.contentEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 6);
  120. // _youngBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -5, 0, 0);
  121. // _youngBtn.backgroundColor = RGB_COLOR(@"#272727", 0.5);
  122. // [self addSubview:_youngBtn];
  123. // [_youngBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  124. // make.left.equalTo(_returnBtn.mas_right);
  125. // make.centerY.equalTo(_returnBtn);
  126. // make.height.mas_equalTo(28);
  127. // }];
  128. _moreBtn = [self createBtnStatus:BtnFun_CenterMore corner:0 havebg:NO];
  129. [_moreBtn setImage:[UIImage imageNamed:@"个中头部-更多"] forState:0];
  130. [self addSubview:_moreBtn];
  131. [_moreBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  132. make.right.equalTo(self.mas_right).offset(-15);
  133. make.width.height.centerY.equalTo(_returnBtn);
  134. }];
  135. _returnBtn.hidden = _youngBtn.hidden = YES;
  136. //
  137. [self addSubview:self.iconBtn];
  138. [_iconBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  139. make.width.height.mas_equalTo(90);
  140. make.left.equalTo(self.mas_left).offset(15);
  141. make.bottom.equalTo(_bigBgIV.mas_bottom).offset(-30);
  142. }];
  143. [self addSubview:self.liveingV];
  144. [_liveingV mas_makeConstraints:^(MASConstraintMaker *make) {
  145. make.width.height.centerX.centerY.equalTo(_iconBtn);
  146. }];
  147. _liveingL.hidden = _liveingV.hidden = YES;;
  148. // 昵称
  149. [self addSubview:self.nameL];
  150. [_nameL mas_makeConstraints:^(MASConstraintMaker *make) {
  151. make.left.equalTo(_iconBtn.mas_right).offset(10);
  152. make.bottom.equalTo(_iconBtn.mas_centerY).offset(-2);
  153. make.right.lessThanOrEqualTo(self.mas_right).offset(-15);
  154. }];
  155. [self addSubview:self.nameBtn];
  156. [_nameBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  157. make.left.right.top.bottom.equalTo(_nameL);
  158. }];
  159. // id
  160. [self addSubview:self.idL];
  161. [_idL mas_makeConstraints:^(MASConstraintMaker *make) {
  162. make.left.equalTo(_nameL.mas_left);
  163. make.top.equalTo(_iconBtn.mas_centerY).offset(2);
  164. }];
  165. _qrcodeBtn = [self createBtnStatus:BtnFun_CenterQrcode corner:0 havebg:NO];
  166. [_qrcodeBtn setImage:[UIImage imageNamed:@"center_card"] forState:0];
  167. [self addSubview:_qrcodeBtn];
  168. _qrcodeBtn.hidden = YES;
  169. _qrcodeBtn.jk_touchAreaInsets = UIEdgeInsetsMake(10, 10, 10, 10);
  170. [_qrcodeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  171. make.width.height.mas_equalTo(16);
  172. make.left.equalTo(_idL.mas_right).offset(5);
  173. make.centerY.equalTo(_idL);
  174. }];
  175. [self addSubview:self.itemView1];
  176. [_itemView1 mas_makeConstraints:^(MASConstraintMaker *make) {
  177. make.width.centerX.equalTo(self);
  178. make.top.equalTo(_bigBgIV.mas_bottom).offset(-15);
  179. make.height.mas_equalTo(70);
  180. }];
  181. [self addSubview:self.itemView2];
  182. [_itemView2 mas_makeConstraints:^(MASConstraintMaker *make) {
  183. make.width.centerX.equalTo(self);
  184. make.top.equalTo(_itemView1.mas_bottom).offset(0);
  185. }];
  186. [self addSubview:self.itemView3];
  187. [_itemView3 mas_makeConstraints:^(MASConstraintMaker *make) {
  188. make.width.centerX.equalTo(self);
  189. make.top.equalTo(_itemView2.mas_bottom).offset(0);
  190. make.height.mas_equalTo(70);
  191. }];
  192. }
  193. - (void)setIsTabbar:(BOOL)isTabbar {
  194. _isTabbar = isTabbar;
  195. _returnBtn.hidden = isTabbar;
  196. }
  197. - (void)setOtherUid:(NSString *)otherUid{
  198. _otherUid = otherUid;
  199. if ([_otherUid isEqual:@"0"]) {
  200. _moreBtn.hidden = YES;
  201. _followBtn.hidden = _chatBtn.hidden = YES;
  202. }else if ([_otherUid isEqual:[Config getOwnID]]) {
  203. _editBtn.hidden = _signDayBtn.hidden = NO;
  204. _youngBtn.hidden = NO;
  205. _qrcodeBtn.hidden = NO;
  206. }else{
  207. _followBtn.hidden = _chatBtn.hidden = NO;
  208. _youngBtn.hidden = YES;
  209. _qrcodeBtn.hidden = YES;
  210. }
  211. }
  212. - (void)setDataDic:(NSDictionary *)dataDic{
  213. _dataDic = dataDic;
  214. [self addLivingAnimation];
  215. NSURL *bg_url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",[_dataDic valueForKey:@"bg_img"]]];
  216. [_bigBgIV sd_setImageWithURL:bg_url];
  217. NSString *userId = minstr([_dataDic valueForKey:@"id"]);
  218. NSString *userName = minstr([_dataDic valueForKey:@"user_nickname"]);
  219. NSString *userIcon = [_dataDic valueForKey:@"avatar"];
  220. NSString *isAtt = minstr([_dataDic valueForKey:@"isattention"]);
  221. NSURL *iconUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@",userIcon]];
  222. [_iconBtn sd_setImageWithURL:iconUrl forState:0];
  223. _nameL.text = userName;
  224. _idL.text = [NSString stringWithFormat:@"ID:%@",userId];
  225. _userModel.uidStr = userId;
  226. _userModel.unameStr = userName;
  227. _userModel.iconStr = userIcon;
  228. _userModel.isAtt = isAtt;
  229. int bonus_switch = [minstr([dataDic valueForKey:@"bonus_switch"]) intValue];
  230. int young_switch = [minstr([dataDic valueForKey:@"teenagers_switch"]) intValue];//[YBYoungManager shareInstance].youngSwitch;
  231. BOOL showSign = NO;
  232. if (bonus_switch == 1 && young_switch == 0 && ![PublicObj isUp]) {
  233. showSign = YES;
  234. }
  235. [self resetSignDayBtn:showSign];
  236. int isattention = [minstr([dataDic valueForKey:@"isattention"]) intValue];
  237. _followBtn.selected = isattention;
  238. _zanNumL.text = minstr([dataDic valueForKey:@"praise"]);
  239. _fansNumL.text = minstr([dataDic valueForKey:@"fans"]);
  240. _followNumL.text = minstr([dataDic valueForKey:@"follows"]);
  241. // 签名
  242. _signatureL.text = minstr([_dataDic valueForKey:@"signature"]);
  243. int sex = [minstr([_dataDic valueForKey:@"sex"])intValue];
  244. if (sex == 1) {
  245. [_sexBtn setImage:[UIImage imageNamed:@"个中头部-男"] forState:0];
  246. [_sexBtn setTitle:YZMsg(@"男") forState:0];
  247. }else{
  248. [_sexBtn setImage:[UIImage imageNamed:@"个中头部-女"] forState:0];
  249. [_sexBtn setTitle:YZMsg(@"女") forState:0];
  250. }
  251. [_ageBtn setTitle:minstr([_dataDic valueForKey:@"age"]) forState:0];
  252. [_cityBtn setTitle:minstr([_dataDic valueForKey:@"city"]) forState:0];
  253. //会员
  254. if ([[_dataDic valueForKey:@"vipinfo"] isKindOfClass:[NSDictionary class]]) {
  255. NSDictionary *vipInfo = [_dataDic valueForKey:@"vipinfo"];
  256. NSString *isVip = minstr([vipInfo valueForKey:@"isvip"]);
  257. NSString *vipSitch = minstr([vipInfo valueForKey:@"vip_switch"]);
  258. _vipBgView.hidden = YES;
  259. if ([vipSitch isEqual:@"1"] &&
  260. [[Config getOwnID] intValue] > 0 &&
  261. [_otherUid isEqual:[Config getOwnID]] &&
  262. ![PublicObj isUp] &&
  263. young_switch == 0) {
  264. _vipBgView.hidden = NO;
  265. }
  266. [self layoutVipView];
  267. NSString *vipEndTime = minstr([vipInfo valueForKey:@"vip_endtime"]);
  268. if ([isVip isEqual:@"1"]) {
  269. _vipTitleL.text = YZMsg(@"尊贵会员");
  270. _vipTimeL.text = vipEndTime;
  271. }else {
  272. _vipTitleL.text = YZMsg(@"成为会员");
  273. _vipTimeL.text = YZMsg(@"尊享会员特权");
  274. }
  275. [_vipBgView layoutIfNeeded];
  276. [_vipRightBgIV setBackgroundImage:[UIImage rk_gradientColorImageFromColors:@[RGB_COLOR(@"#FBD5AF", 1),RGB_COLOR(@"#F8E7D4", 1)] gradientType:RKGradientTypeLeftToRight imgSize:_vipRightBgIV.size]];
  277. }
  278. // 直播小店、直播历史、收藏
  279. [self botSubsItemSet:young_switch];
  280. // 回调整体高度
  281. [self layoutIfNeeded];
  282. [_itemView1 jk_setRoundedCorners:UIRectCornerTopLeft|UIRectCornerTopRight radius:10];
  283. CGFloat getmaxh = CGRectGetMaxY(_itemView3.frame);
  284. if (self.topEvent) {
  285. self.topEvent(TopCtrType_Layout, @{@"top_height":@(getmaxh)});
  286. }
  287. }
  288. -(void)layoutVipView {
  289. [_item2ContentMas uninstall];
  290. [_vipBgMas uninstall];
  291. if (_vipBgView.hidden == YES) {
  292. [_item2ContentMas install];
  293. }else{
  294. [_vipBgMas install];
  295. }
  296. }
  297. -(void)addLivingAnimation {
  298. //直播中动画
  299. NSDictionary *liveInfo = [_dataDic valueForKey:@"liveinfo"];
  300. if ([minstr([liveInfo valueForKey:@"islive"]) isEqual:@"1"] && ![minstr([liveInfo valueForKey:@"uid"]) isEqual:[Config getOwnID]]) {
  301. _liveingV.hidden = _liveingL.hidden = NO;
  302. [_iconBtn.imageView.layer addAnimation:[PublicObj avatarScaleAnimation] forKey:@"avatar_scale"];
  303. [_liveingV.layer addAnimation:[PublicObj bottomScaleAnimation] forKey:@"bottom_scale"];
  304. _iconBtn.layer.borderColor = Pink_Cor.CGColor;
  305. }else {
  306. _liveingV.hidden = _liveingL.hidden = YES;
  307. _iconBtn.layer.borderColor = UIColor.clearColor.CGColor;
  308. }
  309. }
  310. -(void)removeLivingAnimation {
  311. [_iconBtn.imageView.layer removeAllAnimations];
  312. [_liveingV.layer removeAllAnimations];
  313. _liveingV.hidden = _liveingL.hidden = YES;
  314. _iconBtn.layer.borderColor = UIColor.clearColor.CGColor;
  315. }
  316. - (YBButton *)iconBtn{
  317. if (!_iconBtn) {
  318. _iconBtn = [YBButton buttonWithType:UIButtonTypeCustom];
  319. _iconBtn.layer.borderWidth = 1;
  320. _iconBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
  321. _iconBtn.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;
  322. _iconBtn.imageView.contentMode = UIViewContentModeScaleAspectFill;
  323. _iconBtn.imageView.clipsToBounds = YES;
  324. _iconBtn.imageView.layer.masksToBounds = YES;
  325. _iconBtn.imageView.layer.cornerRadius = 45;
  326. _iconBtn.layer.masksToBounds = YES;
  327. _iconBtn.layer.cornerRadius = 45;
  328. [_iconBtn addTarget:self action:@selector(clickIconBtn) forControlEvents:UIControlEventTouchUpInside];
  329. }
  330. return _iconBtn;
  331. }
  332. -(void)clickIconBtn {
  333. NSDictionary *liveInfo = [_dataDic valueForKey:@"liveinfo"];
  334. if ([minstr([liveInfo valueForKey:@"islive"]) isEqual:@"1"] && ![minstr([liveInfo valueForKey:@"uid"]) isEqual:[Config getOwnID]]) {
  335. [YBCheckLiveObj checkLiveManeger].liveUid = minstr([liveInfo valueForKey:@"uid"]);
  336. [YBCheckLiveObj checkLiveManeger].liveStream = minstr([liveInfo valueForKey:@"stream"]);
  337. [YBCheckLiveObj checkLiveManeger].currentIndex = 0;
  338. [YBCheckLiveObj checkLiveManeger].listArray = nil;
  339. [[YBCheckLiveObj checkLiveManeger] checkLiving];
  340. }else if([minstr([liveInfo valueForKey:@"uid"]) isEqual:[Config getOwnID]]){
  341. //进入编辑
  342. EditVC *eVC = [[EditVC alloc]init];
  343. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:eVC animated:YES];
  344. }
  345. }
  346. -(void)nameBtnClick{
  347. NSDictionary *liveInfo = [_dataDic valueForKey:@"liveinfo"];
  348. if([minstr([liveInfo valueForKey:@"uid"]) isEqual:[Config getOwnID]]){
  349. //进入编辑
  350. EditVC *eVC = [[EditVC alloc]init];
  351. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:eVC animated:YES];
  352. }
  353. }
  354. - (UIView *)liveingV{
  355. if (!_liveingV) {
  356. //直播中动画外边缘
  357. _liveingV = [[UIView alloc]init];
  358. _liveingV.layer.borderColor = RGB_COLOR(@"#EA377F", 0.5).CGColor;
  359. _liveingV.layer.borderWidth = 0.8;
  360. _liveingV.cornerRadius = 45;
  361. _liveingV.userInteractionEnabled = NO;
  362. _liveingL = [[UILabel alloc]init];
  363. _liveingL.text = YZMsg(@"直播");
  364. _liveingL.textAlignment = NSTextAlignmentCenter;
  365. _liveingL.textColor = UIColor.whiteColor;
  366. _liveingL.backgroundColor = Pink_Cor;
  367. _liveingL.font = SYS_Font(10);
  368. _liveingL.layer.cornerRadius = 35;
  369. _liveingL.layer.masksToBounds = YES;
  370. _liveingL.userInteractionEnabled = YES;
  371. [_iconBtn.imageView addSubview:_liveingL];
  372. [_liveingL mas_makeConstraints:^(MASConstraintMaker *make) {
  373. make.centerX.top.equalTo(_iconBtn.imageView);
  374. make.width.equalTo(_iconBtn.imageView.mas_width).multipliedBy(0.85);
  375. make.height.mas_equalTo(20);
  376. }];
  377. }
  378. return _liveingV;
  379. }
  380. - (UILabel *)nameL{
  381. if (!_nameL) {
  382. _nameL = [[UILabel alloc]init];
  383. _nameL.textColor = UIColor.whiteColor;
  384. _nameL.font = [UIFont boldSystemFontOfSize:18];
  385. }
  386. return _nameL;
  387. }
  388. - (UIButton *)nameBtn{
  389. if (!_nameBtn) {
  390. _nameBtn = [UIButton buttonWithType:0];
  391. [_nameBtn addTarget:self action:@selector(nameBtnClick) forControlEvents:UIControlEventTouchUpInside];
  392. }
  393. return _nameBtn;
  394. }
  395. - (UILabel *)idL{
  396. if (!_idL) {
  397. _idL = [[UILabel alloc]init];
  398. _idL.textColor = UIColor.whiteColor;
  399. _idL.font = SYS_Font(16);
  400. }
  401. return _idL;
  402. }
  403. - (UIView *)itemView1{
  404. if (!_itemView1) {
  405. _itemView1 = [[UIView alloc]init];
  406. _itemView1.backgroundColor = UIColor.whiteColor;
  407. _item1Content = [[UIView alloc]init];
  408. [_itemView1 addSubview:_item1Content];
  409. [_item1Content mas_makeConstraints:^(MASConstraintMaker *make) {
  410. make.width.equalTo(_itemView1.mas_width).offset(-10);
  411. make.centerX.height.centerY.equalTo(_itemView1);
  412. }];
  413. NSArray *titleA = @[@"获赞",@"粉丝",@"关注"];
  414. NSArray *funA = @[@(BtnFun_CenterZanList),@(Btnfun_CenterFanList),@(Btnfun_CenterFollowList)];
  415. MASViewAttribute *mas_left = _item1Content.mas_left;
  416. for (int i = 0; i<titleA.count; i++) {
  417. UIView *itemV = [[UIView alloc]init];
  418. itemV.backgroundColor = UIColor.clearColor;
  419. [_item1Content addSubview:itemV];
  420. [itemV mas_makeConstraints:^(MASConstraintMaker *make) {
  421. make.left.equalTo(mas_left).offset(2);
  422. make.height.centerY.equalTo(_itemView1);
  423. }];
  424. mas_left = itemV.mas_right;
  425. UILabel *numsL = [[UILabel alloc]init];
  426. numsL.textColor = UIColor.blackColor;
  427. numsL.font = [UIFont boldSystemFontOfSize:16];
  428. numsL.textAlignment = NSTextAlignmentCenter;
  429. numsL.text = @"0";
  430. [itemV addSubview:numsL];
  431. [numsL mas_makeConstraints:^(MASConstraintMaker *make) {
  432. make.bottom.equalTo(itemV.mas_centerY).offset(-2);
  433. make.centerX.equalTo(itemV);
  434. }];
  435. UILabel *titleL = [[UILabel alloc]init];
  436. titleL.textColor = UIColor.grayColor;
  437. titleL.font = SYS_Font(15);
  438. titleL.text = YZMsg(titleA[i]);
  439. titleL.textAlignment = NSTextAlignmentCenter;
  440. [itemV addSubview:titleL];
  441. [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
  442. make.width.centerX.equalTo(numsL);
  443. make.top.equalTo(itemV.mas_centerY).offset(2);
  444. make.left.equalTo(itemV.mas_left).offset(15);
  445. make.right.equalTo(itemV.mas_right).offset(-15);
  446. }];
  447. YBButton *shadowBtn = [self createBtnStatus:[funA[i] integerValue] corner:0 havebg:NO];
  448. [itemV addSubview:shadowBtn];
  449. [shadowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  450. make.width.height.centerX.centerY.equalTo(itemV);
  451. }];
  452. if (shadowBtn.btnFunStatus == BtnFun_CenterZanList) {
  453. _zanNumL = numsL;
  454. }else if (shadowBtn.btnFunStatus == Btnfun_CenterFanList){
  455. _fansNumL = numsL;
  456. }else if (shadowBtn.btnFunStatus == Btnfun_CenterFollowList){
  457. _followNumL = numsL;
  458. }
  459. }
  460. _btnHeight = 30;
  461. /// 自己
  462. // 签到
  463. _signDayBtn = [self createBtnStatus:BtnFun_CenterDaySign corner:5 havebg:YES];
  464. [_signDayBtn setImage:[UIImage imageNamed:@"个中头部-签到"] forState:0];
  465. [_item1Content addSubview:_signDayBtn];
  466. [_signDayBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  467. make.right.equalTo(_item1Content.mas_right).offset(-10);
  468. make.width.height.mas_equalTo(_btnHeight);
  469. make.centerY.equalTo(_itemView1);
  470. }];
  471. // 编辑
  472. _editBtn = [self createBtnStatus:BtnFun_CenterEdit corner:5 havebg:YES];
  473. [_editBtn setTitle:YZMsg(@"编辑资料") forState:0];
  474. _editBtn.contentEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 10);
  475. [_item1Content addSubview:_editBtn];
  476. [_editBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  477. make.centerY.equalTo(_signDayBtn);
  478. make.right.equalTo(_signDayBtn.mas_left).offset(-10);
  479. make.height.mas_equalTo(_btnHeight);
  480. }];
  481. /// 他人
  482. // 私信
  483. _chatBtn = [self createBtnStatus:BtnFun_CenterImMsg corner:5 havebg:YES];
  484. [_chatBtn setImage:[UIImage imageNamed:@"个中头部-私信"] forState:0];
  485. [_item1Content addSubview:_chatBtn];
  486. [_chatBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  487. make.right.equalTo(_item1Content.mas_right).offset(-10);
  488. make.width.height.mas_equalTo(_btnHeight);
  489. make.centerY.equalTo(_itemView1);
  490. }];
  491. // 关注
  492. _followBtn = [self createBtnStatus:BtnFun_CenterFollow corner:5 havebg:NO];
  493. _followBtn.contentEdgeInsets = UIEdgeInsetsMake(0, 18, 0, 18);
  494. [_followBtn setTitle:[NSString stringWithFormat:@"+ %@",YZMsg(@"关注")] forState:0];
  495. [_followBtn setTitle:YZMsg(@"已关注") forState:UIControlStateSelected];
  496. [_followBtn jk_setBackgroundColor:RGB_COLOR(@"#FC4369", 1) forState:0];
  497. [_followBtn jk_setBackgroundColor:RGB_COLOR(@"#F7F7F7", 1) forState:UIControlStateSelected];
  498. [_followBtn setTitleColor:UIColor.grayColor forState:UIControlStateSelected];
  499. [_item1Content addSubview:_followBtn];
  500. [_followBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  501. make.centerY.equalTo(_chatBtn);
  502. make.right.equalTo(_chatBtn.mas_left).offset(-10);
  503. make.height.mas_equalTo(_btnHeight);
  504. }];
  505. _signDayBtn.hidden = _editBtn.hidden = _chatBtn.hidden = _followBtn.hidden = YES;
  506. }
  507. return _itemView1;
  508. }
  509. -(void)resetSignDayBtn:(BOOL)show {
  510. if (![_otherUid isEqual:[Config getOwnID]]) {
  511. return;
  512. }
  513. _signDayBtn.hidden = !show;
  514. [_signDayBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
  515. if (show) {
  516. make.right.equalTo(_item1Content.mas_right).offset(-10);
  517. make.width.mas_equalTo(_btnHeight);
  518. }else{
  519. make.right.equalTo(_item1Content.mas_right).offset(0);
  520. make.width.mas_equalTo(0);
  521. }
  522. make.height.mas_equalTo(_btnHeight);
  523. make.centerY.equalTo(_itemView1);
  524. }];
  525. }
  526. /// 创建简单按钮【多处公用,加个别专用属性请在外部单独处理】
  527. -(YBButton *)createBtnStatus:(BtnFunStatus)status corner:(CGFloat)corner havebg:(BOOL)havebg{
  528. YBButton *ybBtn = [YBButton buttonWithType:UIButtonTypeCustom];
  529. ybBtn.titleLabel.font = SYS_Font(13);
  530. if(status == BtnFun_CenterFollow){
  531. [ybBtn setTitleColor:UIColor.whiteColor forState:0];
  532. }else{
  533. [ybBtn setTitleColor:UIColor.blackColor forState:0];
  534. }
  535. ybBtn.btnFunStatus = status;
  536. ybBtn.layer.masksToBounds = YES;
  537. ybBtn.layer.cornerRadius = corner;
  538. if (havebg) {
  539. ybBtn.backgroundColor = RGB_COLOR(@"#F7F7F7", 1);
  540. }
  541. [ybBtn addTarget:self action:@selector(clickShadowBtn:) forControlEvents:UIControlEventTouchUpInside];
  542. return ybBtn;
  543. }
  544. -(YBButton *)createSexAgeCity{
  545. YBButton *ybBtn = [YBButton buttonWithType:UIButtonTypeCustom];
  546. ybBtn.titleLabel.font = SYS_Font(14);
  547. [ybBtn setTitleColor:UIColor.grayColor forState:0];
  548. ybBtn.layer.masksToBounds = YES;
  549. ybBtn.layer.cornerRadius = 5;
  550. ybBtn.backgroundColor = RGB_COLOR(@"#F7F7F7", 1);
  551. return ybBtn;
  552. }
  553. #pragma mark - 点击事件
  554. -(void)clickShadowBtn:(YBButton *)sender {
  555. NSLog(@"====click:%ld",(long)sender.btnFunStatus);
  556. if ([[Config getOwnID] intValue]<=0 && sender.btnFunStatus != BtnFun_CenterReturn) {
  557. [PublicObj warnLogin];
  558. return;
  559. }
  560. // if([_otherUid isEqual:@"-9999"]){
  561. // _otherUid = [Config getOwnID];
  562. // }
  563. if (sender.btnFunStatus == Btnfun_CenterFanList){
  564. /// 粉丝列表
  565. fansViewController *fans = [[fansViewController alloc]init];
  566. fans.fensiUid = _otherUid;
  567. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:fans animated:YES];
  568. }else if (sender.btnFunStatus == Btnfun_CenterFollowList){
  569. /// 关注列表
  570. attrViewController *attention = [[attrViewController alloc]init];
  571. attention.guanzhuUID = _otherUid;
  572. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:attention animated:YES];
  573. }else if (sender.btnFunStatus == BtnFun_CenterDaySign){
  574. /// 签到
  575. [self getSignDayReq];
  576. }else if (sender.btnFunStatus == BtnFun_CenterShop) {
  577. /// 小店
  578. if ([_otherUid isEqual:[Config getOwnID]]) {
  579. ShopHomeVC *shop = [[ShopHomeVC alloc]init];
  580. shop.shop_name = YZMsg(@"我的小店");
  581. shop.shop_switch = minstr([_dataDic valueForKey:@"isshop"]);
  582. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:shop animated:YES];
  583. }else{
  584. shopDetailVC *vc = [[shopDetailVC alloc]init];
  585. vc.toUserID = _otherUid;
  586. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:vc animated:YES];
  587. }
  588. }else if (sender.btnFunStatus == BtnFun_CenterLiveRecord){
  589. /// 直播动态
  590. PubH5 *h5vc = [[PubH5 alloc]init];
  591. h5vc.url =[h5url stringByAppendingString:[NSString stringWithFormat:@"/appapi/lrecording/record?uid=%@&token=%@&touid=%@",[Config getOwnID],[Config getOwnToken],_otherUid]];
  592. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:h5vc animated:YES];
  593. }else if (sender.btnFunStatus == BtnFun_CenterCollection){
  594. /// 我的收藏
  595. YBGoodsLikeVC *liveVC = [[YBGoodsLikeVC alloc]init];
  596. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:liveVC animated:YES];
  597. }else if (sender.btnFunStatus == BtnFun_CenterEdit){
  598. /// 编辑
  599. EditVC *eVC = [[EditVC alloc]init];
  600. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:eVC animated:YES];
  601. }else if (sender.btnFunStatus == BtnFun_CenterFollow){
  602. /// 关注-取关
  603. [self doAttentUser];
  604. }else if (sender.btnFunStatus == BtnFun_CenterImMsg){
  605. /// 私信
  606. [self goToChat];
  607. }else if (sender.btnFunStatus == BtnFun_CenterVip){
  608. /// vip
  609. YBVipVC *vipVC = [[YBVipVC alloc]init];
  610. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:vipVC animated:YES];
  611. }else if (sender.btnFunStatus == BtnFun_CenterQrcode){
  612. /// 名片
  613. BusinessCardVC *cardVC = [[BusinessCardVC alloc]init];
  614. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:cardVC animated:YES];
  615. }else if (sender.btnFunStatus == BtnFun_CenterMore){
  616. /// 更多
  617. if ([_otherUid isEqual:[Config getOwnID]]) {
  618. [self showSelfMore];
  619. }else{
  620. [self showOtherMore];
  621. }
  622. }else if (sender.btnFunStatus == BtnFun_CenterYoung){
  623. /// 青少年
  624. [[YBYoungManager shareInstance] checkYoungStatus:YoungFrom_Center];
  625. }else if (sender.btnFunStatus == BtnFun_CenterReturn){
  626. [[YBBaseAppDelegate sharedAppDelegate]popViewController:YES];
  627. }
  628. }
  629. - (UIView *)itemView2{
  630. if (!_itemView2) {
  631. _itemView2 = [[UIView alloc]init];
  632. _itemView2.backgroundColor = UIColor.whiteColor;
  633. _item2Content = [[UIView alloc]init];
  634. _item2Content.backgroundColor = UIColor.clearColor;
  635. [_itemView2 addSubview:_item2Content];
  636. [_item2Content mas_remakeConstraints:^(MASConstraintMaker *make) {
  637. make.left.equalTo(_itemView2.mas_left).offset(15);
  638. make.top.equalTo(_itemView2.mas_top).offset(10);
  639. make.bottom.equalTo(_itemView2.mas_bottom).offset(-10);
  640. _item2ContentMas = make.right.equalTo(_itemView2.mas_right).offset(-15);
  641. }];
  642. // vip
  643. _vipBgView = [[UIView alloc]init];
  644. _vipBgView.hidden = YES;
  645. _vipBgView.backgroundColor = UIColor.clearColor;
  646. [_itemView2 addSubview:_vipBgView];
  647. [_vipBgView mas_remakeConstraints:^(MASConstraintMaker *make) {
  648. _vipBgMas = make.right.equalTo(_itemView2);
  649. make.left.equalTo(_item2Content.mas_right);
  650. make.centerY.equalTo(_itemView2).offset(-10);
  651. make.height.mas_equalTo(36);
  652. }];
  653. [self layoutVipView];
  654. UIImageView *vipLeftIV = [[UIImageView alloc]init];
  655. vipLeftIV.image = [UIImage imageNamed:@"会员背景-圆"];
  656. [_vipBgView addSubview:vipLeftIV];
  657. [vipLeftIV mas_makeConstraints:^(MASConstraintMaker *make) {
  658. make.left.height.centerY.equalTo(_vipBgView);
  659. make.width.equalTo(vipLeftIV.mas_height);
  660. }];
  661. UIImageView *vipRightIV = [[UIImageView alloc]init];
  662. [_vipBgView addSubview:vipRightIV];
  663. [_vipBgView bringSubviewToFront:vipLeftIV];
  664. _vipRightBgIV = vipRightIV;
  665. [vipRightIV mas_makeConstraints:^(MASConstraintMaker *make) {
  666. make.left.equalTo(vipLeftIV.mas_centerX);
  667. make.height.centerY.right.equalTo(_vipBgView);
  668. }];
  669. UILabel *vipTitleL = [[UILabel alloc]init];
  670. vipTitleL.font = [UIFont boldSystemFontOfSize:11];
  671. vipTitleL.textColor = RGB_COLOR(@"#AC561F", 1);
  672. [_vipBgView addSubview:vipTitleL];
  673. _vipTitleL = vipTitleL;
  674. [vipTitleL mas_makeConstraints:^(MASConstraintMaker *make) {
  675. make.left.equalTo(vipLeftIV.mas_right).offset(5);
  676. make.right.equalTo(_vipBgView.mas_right).offset(-5);
  677. make.bottom.equalTo(_vipBgView.mas_centerY).offset(-1);
  678. }];
  679. UILabel *vipTimeL = [[UILabel alloc]init];
  680. vipTimeL.font = SYS_Font(10);
  681. vipTimeL.textColor = RGB_COLOR(@"#AC561F", 1);
  682. [_vipBgView addSubview:vipTimeL];
  683. _vipTimeL = vipTimeL;
  684. [vipTimeL mas_makeConstraints:^(MASConstraintMaker *make) {
  685. make.left.right.equalTo(vipTitleL);
  686. make.top.equalTo(_vipBgView.mas_centerY).offset(1);
  687. }];
  688. YBButton *vipShadowBtn = [self createBtnStatus:BtnFun_CenterVip corner:0 havebg:NO];
  689. [_vipBgView addSubview:vipShadowBtn];
  690. [vipShadowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  691. make.width.centerX.height.centerY.equalTo(_vipBgView);
  692. }];
  693. _signatureL = [[UILabel alloc]init];
  694. _signatureL.font = [UIFont systemFontOfSize:14];
  695. _signatureL.textColor =UIColor.blackColor;
  696. _signatureL.numberOfLines = 3;
  697. [_item2Content addSubview:_signatureL];
  698. [_signatureL mas_makeConstraints:^(MASConstraintMaker *make) {
  699. make.top.left.equalTo(_item2Content);
  700. make.right.equalTo(_item2Content.mas_right);
  701. }];
  702. CGFloat item2BtnHeight = 20;
  703. _sexBtn = [self createSexAgeCity];
  704. _sexBtn.contentEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 8);
  705. _sexBtn.imageEdgeInsets = UIEdgeInsetsMake(0, -6, 0, 0);
  706. [_item2Content addSubview:_sexBtn];
  707. [_sexBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  708. make.height.mas_equalTo(item2BtnHeight);
  709. make.left.equalTo(_item2Content.mas_left);
  710. make.top.equalTo(_signatureL.mas_bottom).offset(10);
  711. make.bottom.equalTo(_item2Content.mas_bottom);
  712. }];
  713. _ageBtn = [self createSexAgeCity];
  714. _ageBtn.contentEdgeInsets = UIEdgeInsetsMake(0, 8, 0, 8);
  715. [_item2Content addSubview:_ageBtn];
  716. [_ageBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  717. make.height.centerY.equalTo(_sexBtn);
  718. make.left.equalTo(_sexBtn.mas_right).offset(8);
  719. }];
  720. _cityBtn = [self createSexAgeCity];
  721. _cityBtn.contentEdgeInsets = UIEdgeInsetsMake(0, 8, 0, 8);
  722. [_item2Content addSubview:_cityBtn];
  723. [_cityBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  724. make.height.centerY.equalTo(_sexBtn);
  725. make.left.equalTo(_ageBtn.mas_right).offset(8);
  726. make.right.lessThanOrEqualTo(_item2Content.mas_right);
  727. }];
  728. [_signatureL setContentCompressionResistancePriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
  729. [_sexBtn setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
  730. [_ageBtn setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
  731. [_cityBtn setContentCompressionResistancePriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
  732. [_vipTitleL setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
  733. [_vipTimeL setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisHorizontal];
  734. }
  735. return _itemView2;
  736. }
  737. - (UIView *)itemView3{
  738. if (!_itemView3) {
  739. _itemView3 = [[UIView alloc]init];
  740. _itemView3.backgroundColor = UIColor.whiteColor;
  741. }
  742. return _itemView3;
  743. }
  744. #pragma mark - 底部样式
  745. -(void)botSubsItemSet:(int)youngSwitch {
  746. _itemView3.hidden = youngSwitch;
  747. [_itemView3 mas_remakeConstraints:^(MASConstraintMaker *make) {
  748. make.width.centerX.equalTo(self);
  749. make.top.equalTo(_itemView2.mas_bottom).offset(0);
  750. if (youngSwitch == 1) {
  751. make.height.mas_equalTo(0);
  752. }else{
  753. make.height.mas_equalTo(70);
  754. }
  755. }];
  756. /**
  757. * 己方展示:
  758. * 直播小店 我的收藏
  759. *
  760. * 他人展示:
  761. * 直播小店 直播动态
  762. */
  763. [_itemView3 removeAllSubViews];
  764. NSArray *itemsContent = @[];
  765. if ([_otherUid isEqual:[Config getOwnID]]) {
  766. itemsContent = @[
  767. @{@"name":@"直播小店",
  768. @"des":@"这里什么都有",
  769. @"img":@"个中头部-小店",
  770. @"action":@(BtnFun_CenterShop),
  771. },
  772. @{@"name":@"我的收藏",
  773. @"des":@"收藏好物",
  774. @"img":@"个中头部-收藏",
  775. @"action":@(BtnFun_CenterCollection),
  776. }
  777. ];
  778. }else{
  779. int isshop = [minstr([_dataDic valueForKey:@"isshop"]) intValue];
  780. itemsContent = @[
  781. @{@"name":@"直播动态",
  782. @"des":@"查看历史记录",
  783. @"img":@"个中头部-直记",
  784. @"action":@(BtnFun_CenterLiveRecord),
  785. }
  786. ];
  787. if (isshop == 1) {
  788. itemsContent = @[
  789. @{@"name":@"直播小店",
  790. @"des":@"这里什么都有",
  791. @"img":@"个中头部-小店",
  792. @"action":@(BtnFun_CenterShop),
  793. },
  794. @{@"name":@"直播动态",
  795. @"des":@"查看历史记录",
  796. @"img":@"个中头部-直记",
  797. @"action":@(BtnFun_CenterLiveRecord),
  798. }
  799. ];
  800. }
  801. }
  802. [self layoutItem3ViewWithArray:itemsContent];
  803. }
  804. -(void)layoutItem3ViewWithArray:(NSArray *)itemsContent {
  805. CGFloat itemSpace = 5;
  806. CGFloat leftSpace = 15;
  807. CGFloat itemW = (_window_width-leftSpace*2-itemSpace)/2;
  808. MASViewAttribute *mas_first_left = _itemView3.mas_left;
  809. for (int i = 0; i<itemsContent.count; i++) {
  810. UIView *itemV = [[UIView alloc]init];
  811. itemV.backgroundColor = UIColor.clearColor;
  812. [_itemView3 addSubview:itemV];
  813. [itemV mas_makeConstraints:^(MASConstraintMaker *make) {
  814. make.left.equalTo(mas_first_left).offset(leftSpace);
  815. make.width.mas_equalTo(itemW);
  816. make.height.mas_equalTo(40);
  817. make.centerY.equalTo(_itemView3);
  818. }];
  819. leftSpace = itemSpace;
  820. mas_first_left = itemV.mas_right;
  821. NSDictionary *subDic = itemsContent[i];
  822. UIView *leftV = [[UIView alloc]init];
  823. leftV.layer.cornerRadius = 5;
  824. leftV.layer.masksToBounds = YES;
  825. leftV.backgroundColor =RGB(235, 235, 235);// RGB_COLOR(@"#2c2840", 1);
  826. [itemV addSubview:leftV];
  827. [leftV mas_makeConstraints:^(MASConstraintMaker *make) {
  828. make.left.height.centerY.equalTo(itemV);
  829. make.width.equalTo(leftV.mas_height);
  830. }];
  831. UIImageView *lftIV = [[UIImageView alloc]init];
  832. lftIV.image = [UIImage imageNamed:[subDic valueForKey:@"img"]];
  833. [leftV addSubview:lftIV];
  834. [lftIV mas_makeConstraints:^(MASConstraintMaker *make) {
  835. make.width.height.mas_equalTo(22);
  836. make.centerX.centerY.equalTo(leftV);
  837. }];
  838. UILabel *rightTopL = [[UILabel alloc]init];
  839. rightTopL.text = YZMsg([subDic valueForKey:@"name"]);
  840. rightTopL.textColor = UIColor.blackColor;
  841. rightTopL.font = SYS_Font(15);
  842. [itemV addSubview:rightTopL];
  843. [rightTopL mas_makeConstraints:^(MASConstraintMaker *make) {
  844. make.left.equalTo(leftV.mas_right).offset(10);
  845. make.bottom.equalTo(leftV.mas_centerY).offset(-1);
  846. make.right.lessThanOrEqualTo(itemV.mas_right);
  847. }];
  848. UILabel *rightBotL = [[UILabel alloc]init];
  849. rightBotL.text = YZMsg([subDic valueForKey:@"des"]);
  850. rightBotL.textColor = RGB_COLOR(@"#969696", 1);
  851. rightBotL.font = SYS_Font(13);
  852. [itemV addSubview:rightBotL];
  853. [rightBotL mas_makeConstraints:^(MASConstraintMaker *make) {
  854. make.left.equalTo(rightTopL);
  855. make.top.equalTo(leftV.mas_centerY).offset(1);
  856. make.right.lessThanOrEqualTo(itemV.mas_right);
  857. }];
  858. YBButton *shadowBtn = [YBButton buttonWithType:UIButtonTypeCustom];
  859. shadowBtn.btnFunStatus = [[subDic valueForKey:@"action"] integerValue];
  860. [shadowBtn addTarget:self action:@selector(clickShadowBtn:) forControlEvents:UIControlEventTouchUpInside];
  861. [itemV addSubview:shadowBtn];
  862. [shadowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  863. make.width.height.centerX.centerY.equalTo(itemV);
  864. }];
  865. }
  866. }
  867. #pragma mark - 顶部背景
  868. -(void)headerImgTap {
  869. YBWeakSelf;
  870. if (!_headImgView) {
  871. _headImgView = [[HeaderBackImgView alloc]initWithFrame:CGRectMake(0, 0, _window_width, _window_height) andHeadUrl:minstr([_dataDic valueForKey:@"bg_img"]) andUerid:_otherUid];
  872. _headImgView.tapEvent = ^(NSString *types) {
  873. if ([types isEqual:@"hide"]) {
  874. }else if ([types isEqual:@"拍照"]){
  875. [weakSelf clickTake];
  876. }else if ([types isEqual:@"相册"]){
  877. [weakSelf clickSel];
  878. }
  879. [weakSelf.headImgView removeFromSuperview];
  880. weakSelf.headImgView = nil;
  881. };
  882. [[UIApplication sharedApplication].keyWindow addSubview:_headImgView];
  883. }
  884. }
  885. -(void)clickTake{
  886. UIImagePickerController *imagePickerController = [UIImagePickerController new];
  887. imagePickerController.allowsEditing = YES;
  888. imagePickerController.delegate = self;
  889. imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
  890. imagePickerController.allowsEditing = YES;
  891. imagePickerController.showsCameraControls = YES;
  892. imagePickerController.cameraDevice = UIImagePickerControllerCameraDeviceRear;
  893. //imagePickerController.mediaTypes = @[(NSString *)kUTTypeImage];
  894. imagePickerController.modalPresentationStyle = 0;
  895. [[[YBBaseAppDelegate sharedAppDelegate]topViewController] presentViewController:imagePickerController animated:YES completion:nil];
  896. }
  897. -(void)clickSel {
  898. TZImagePickerController *imagePC = [[TZImagePickerController alloc]initWithMaxImagesCount:1 delegate:self];
  899. imagePC.preferredLanguage = [lagType isEqual:ZH_CN] ? @"zh-Hans":@"en";
  900. imagePC.modalPresentationStyle = 0;
  901. imagePC.showSelectBtn = YES;
  902. imagePC.allowCrop = NO;
  903. imagePC.allowPickingOriginalPhoto = NO;
  904. imagePC.oKButtonTitleColorNormal = Pink_Cor;
  905. imagePC.allowTakePicture = YES;
  906. imagePC.allowTakeVideo = NO;
  907. imagePC.allowPickingVideo = NO;
  908. imagePC.allowPickingMultipleVideo = NO;
  909. [[[YBBaseAppDelegate sharedAppDelegate] topViewController]presentViewController:imagePC animated:YES completion:nil];
  910. }
  911. - (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto{
  912. NSLog(@"------多选择图片--:%@",photos);
  913. UIImage *img = photos[0];
  914. headBgimg = img;
  915. [self updateBgImg];
  916. }
  917. -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{
  918. if (@available(iOS 11, *)) {
  919. UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  920. }
  921. NSString *type = [info objectForKey:UIImagePickerControllerMediaType];
  922. if ([type isEqualToString:@"public.image"]) {
  923. //先把图片转成NSData
  924. UIImage* image = [info objectForKey:@"UIImagePickerControllerEditedImage"];
  925. headBgimg = image;
  926. [self updateBgImg];
  927. [picker dismissViewControllerAnimated:YES completion:^{
  928. [UIApplication sharedApplication].statusBarHidden=NO;
  929. }];
  930. }
  931. }
  932. -(void)updateBgImg {
  933. [MBProgressHUD showMessage:@""];
  934. YBWeakSelf;
  935. [[YBStorageObj storageManeger]getCOSType:^(int code) {
  936. dispatch_async(dispatch_get_main_queue(), ^{
  937. if (code == 0) {
  938. [weakSelf uploadHeadBgImg];
  939. }
  940. });
  941. }];
  942. }
  943. -(void)uploadHeadBgImg{
  944. dispatch_group_t group = dispatch_group_create();
  945. dispatch_queue_t queue = dispatch_get_global_queue(0, 0);
  946. dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
  947. if (headBgimg) {
  948. dispatch_group_async(group, queue, ^{
  949. NSString *imageName = [PublicObj getNameBaseCurrentTime:@"_centerHeaderBg.png"];
  950. [[YBStorageObj storageManeger]yb_storageImg:headBgimg andName:imageName progress:^(CGFloat percent) {
  951. }complete:^(int code, NSString *key) {
  952. //图片成功
  953. headBgStr = key;
  954. dispatch_semaphore_signal(semaphore);
  955. }];
  956. dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
  957. });
  958. }
  959. dispatch_group_notify(group, queue, ^{
  960. dispatch_async(dispatch_get_main_queue(), ^{
  961. [self setBgService];
  962. });
  963. NSLog(@"任务完成执行");
  964. });
  965. }
  966. -(void)setBgService{
  967. //YBWeakSelf;
  968. NSDictionary *parDic = @{@"uid":[Config getOwnID],@"token":[Config getOwnToken],@"img":headBgStr};
  969. [YBNetworking postWithUrl:@"User.updateBgImg" Dic:parDic Suc:^(int code, id info, NSString *msg) {
  970. [MBProgressHUD hideHUD];
  971. if (code == 0) {
  972. NSDictionary*infos = [info firstObject];
  973. NSString *newUrl = minstr([infos valueForKey:@"bg_img"]);
  974. NSMutableDictionary *m_dic = [NSMutableDictionary dictionaryWithDictionary:_dataDic];
  975. [m_dic setObject:newUrl forKey:@"bg_img"];
  976. _dataDic = [NSDictionary dictionaryWithDictionary:m_dic];
  977. [_bigBgIV sd_setImageWithURL:[NSURL URLWithString:newUrl]];
  978. // [weakSelf pullData];
  979. }
  980. } Fail:^(id fail) {
  981. [MBProgressHUD hideHUD];
  982. }];
  983. }
  984. #pragma mark - 签到
  985. -(void)getSignDayReq {
  986. [YBNetworking postWithUrl:@"User.Bonus" Dic:nil Suc:^(int code, id info, NSString *msg) {
  987. if (code == 0) {
  988. NSArray *infos = info;
  989. bonus_switch = [NSString stringWithFormat:@"%@",[[infos lastObject] valueForKey:@"bonus_switch"]];
  990. bonus_day = [[infos lastObject] valueForKey:@"bonus_day"];
  991. bonus_list = [[infos lastObject] valueForKey:@"bonus_list"];
  992. //int day = [bonus_day intValue];
  993. dayCount = minstr([[infos lastObject] valueForKey:@"count_day"]);
  994. is_bonus = minstr([[infos lastObject] valueForKey:@"is_bonus"]);
  995. if ([bonus_switch isEqual:@"1"]) {
  996. [self firstLog];
  997. }
  998. }
  999. } Fail:^(id fail) {
  1000. }];
  1001. }
  1002. -(void)firstLog{
  1003. firstLV = [[Loginbonus alloc]initWithFrame:CGRectMake(0, 0, _window_width, _window_height)AndNSArray:bonus_list AndDay:bonus_day andDayCount:dayCount andIsBonus:is_bonus];
  1004. firstLV.delegate = self;
  1005. [[UIApplication sharedApplication].keyWindow addSubview:firstLV];
  1006. }
  1007. -(void)removeView:(NSDictionary*)dic{
  1008. [firstLV removeFromSuperview];
  1009. firstLV = nil;
  1010. }
  1011. #pragma mark - 私信
  1012. -(void)goToChat{
  1013. if (_isChatPage) {
  1014. [[YBBaseAppDelegate sharedAppDelegate]popViewController:YES];
  1015. return;
  1016. }
  1017. NSDictionary *userDic = @{
  1018. @"id":_userModel.uidStr,
  1019. @"user_nickname":_userModel.unameStr,
  1020. @"avatar":_userModel.iconStr,
  1021. };
  1022. [[YBMessageManager shareManager] chatWithUser:userDic];
  1023. }
  1024. #pragma mark - 关注-取关
  1025. -(void)doAttentUser{
  1026. YBWeakSelf;
  1027. NSDictionary *subdic = @{
  1028. @"uid":[Config getOwnID],
  1029. @"touid":[NSString stringWithFormat:@"%@",[_dataDic valueForKey:@"id"]],
  1030. @"token":[Config getOwnToken],
  1031. };
  1032. [YBNetworking postWithUrl:@"User.setAttent" Dic:subdic Suc:^(int code, id info, NSString *msg) {
  1033. if(code == 0) {
  1034. NSDictionary *infoDic = [info firstObject];
  1035. NSString *isattent = [NSString stringWithFormat:@"%@",[infoDic valueForKey:@"isattent"]];
  1036. if (weakSelf.topEvent) {
  1037. weakSelf.topEvent(TopCtrType_Attent, @{@"isattent":isattent});
  1038. }
  1039. _userModel.isAtt = isattent;
  1040. if ([isattent isEqual:@"1"]) {
  1041. [MBProgressHUD showError:YZMsg(@"已关注")];
  1042. }else{
  1043. [MBProgressHUD showError:YZMsg(@"已取消关注")];
  1044. }
  1045. [weakSelf changeFollowState:[isattent intValue]];
  1046. }else if (code == 700) {
  1047. [PublicObj tokenExpired:msg];
  1048. }else{
  1049. [MBProgressHUD showError:msg];
  1050. }
  1051. } Fail:^(id fail) {
  1052. }];
  1053. }
  1054. -(void)changeFollowState:(int)isAttent {
  1055. _followBtn.selected = isAttent;
  1056. }
  1057. #pragma mark - 他人主页更多
  1058. -(void)showOtherMore{
  1059. if ([[Config getOwnID] intValue]<=0) {
  1060. [PublicObj warnLogin];
  1061. return;
  1062. }
  1063. NSString *url = [NSString stringWithFormat:@"User.checkBlack&uid=%@&token=%@&touid=%@",[Config getOwnID],[Config getOwnToken],_otherUid];
  1064. YBWeakSelf;
  1065. [YBNetworking postWithUrl:url Dic:nil Suc:^(int code, id info, NSString *msg) {
  1066. if (code == 0) {
  1067. NSDictionary *infoDic = [info firstObject];
  1068. NSString *u2t = [NSString stringWithFormat:@"%@",[infoDic valueForKey:@"u2t"]];
  1069. //u2t 0-未拉黑 1-已拉黑
  1070. NSString *blackTitle = YZMsg(@"拉黑");
  1071. if ([u2t isEqual:@"1"]) {
  1072. blackTitle = YZMsg(@"解除拉黑");
  1073. }
  1074. [weakSelf showSheetWithAttTitle:@"" andBlackTitle:blackTitle];
  1075. }else {
  1076. [MBProgressHUD showPop:msg];
  1077. }
  1078. } Fail:^(id fail) {
  1079. }];
  1080. }
  1081. -(void)showSheetWithAttTitle:(NSString *)attStr andBlackTitle:(NSString *)blackStr{
  1082. YBWeakSelf;
  1083. //name_str、id_str、black_str
  1084. NSDictionary *infoDic = @{
  1085. @"name_str":minstr([_dataDic valueForKey:@"user_nickname"]),
  1086. @"id_str":[NSString stringWithFormat:@"ID:%@",[_dataDic valueForKey:@"id"]],
  1087. @"black_str":blackStr,
  1088. };
  1089. [YBOtherCenterMore showOtherMoreWithBtns:infoDic complete:^(BtnFunStatus clickType) {
  1090. dispatch_async(dispatch_get_main_queue(), ^{
  1091. if (clickType == BtnFun_CenterImMsg) {
  1092. [weakSelf goToChat];
  1093. }else if(clickType == BtnFun_CenterReport){
  1094. [weakSelf doReportUser];
  1095. }else if (clickType == BtnFun_CenterBlack){
  1096. [weakSelf setBlack];
  1097. }
  1098. });
  1099. }];
  1100. }
  1101. #pragma mark - 举报
  1102. -(void)doReportUser{
  1103. PubH5 *h5vc = [[PubH5 alloc]init];
  1104. h5vc.url =[h5url stringByAppendingString:[NSString stringWithFormat:@"/appapi/userreport/index?uid=%@&token=%@&touid=%@",[Config getOwnID],[Config getOwnToken],_otherUid]];
  1105. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:h5vc animated:YES];
  1106. }
  1107. #pragma mark - 拉黑
  1108. -(void)setBlack {
  1109. NSString *url = [NSString stringWithFormat:@"User.setBlack&uid=%@&token=%@&touid=%@",[Config getOwnID],[Config getOwnToken],_otherUid];
  1110. YBWeakSelf;
  1111. [YBNetworking postWithUrl:url Dic:nil Suc:^(int code, id info, NSString *msg) {
  1112. if (code == 0) {
  1113. NSString *infoDic = [info firstObject];
  1114. NSString *isBlakc = [NSString stringWithFormat:@"%@",[infoDic valueForKey:@"isblack"]];
  1115. if ([isBlakc isEqual:@"1"]) {
  1116. [MBProgressHUD showPop:YZMsg(@"拉黑成功")];
  1117. if ([_userModel.isAtt isEqual:@"1"]) {
  1118. _userModel.isAtt = @"0";
  1119. [weakSelf changeFollowState:0];
  1120. if (weakSelf.topEvent) {
  1121. weakSelf.topEvent(TopCtrType_Attent, @{@"isattent":@"0"});
  1122. }
  1123. }
  1124. }else {
  1125. [MBProgressHUD showPop:YZMsg(@"解除拉黑成功")];
  1126. }
  1127. }else {
  1128. [MBProgressHUD showPop:msg];
  1129. }
  1130. } Fail:^(id fail) {
  1131. }];
  1132. }
  1133. #pragma mark - 自己个人主页更多
  1134. -(void)showSelfMore {
  1135. [YBCenterMoreView showMoreViewWithSeller:minstr([_dataDic valueForKey:@"isshop"])];
  1136. }
  1137. @end