lookVGoodsDView.m 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. //
  2. // lookVGoodsDView.m
  3. // YBVideo
  4. //
  5. // Created by IOS1 on 2019/7/8.
  6. // Copyright © 2019 cat. All rights reserved.
  7. //
  8. #import "lookVGoodsDView.h"
  9. #import "YBGoodsInfoVC.h"
  10. #import "CommodityDetailVC.h"
  11. #import "OutsideGoodsDetailVC.h"
  12. @implementation lookVGoodsDView{
  13. NSDictionary *goodsDic;
  14. UIView *whiteView;
  15. }
  16. -(instancetype)initWithGoodsMsg:(NSDictionary *)dic{
  17. self = [super init];
  18. self.frame = CGRectMake(0, 0, _window_width, _window_height);
  19. goodsDic = dic;
  20. if (self) {
  21. [self creatUI];
  22. }
  23. return self;
  24. }
  25. - (void)creatUI{
  26. UIButton *btn = [UIButton buttonWithType:0];
  27. btn.frame = CGRectMake(0, 0, _window_width, _window_height-220-ShowDiff);
  28. [btn addTarget:self action:@selector(btnHide) forControlEvents:UIControlEventTouchUpInside];
  29. [self addSubview:btn];
  30. whiteView = [[UIView alloc]initWithFrame:CGRectMake(0, _window_height, _window_width, 220+ShowDiff)];
  31. whiteView.backgroundColor = [UIColor whiteColor];
  32. [self addSubview:whiteView];
  33. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:whiteView.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(10, 10)];
  34. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  35. maskLayer.frame = whiteView.bounds;
  36. maskLayer.path = maskPath.CGPath;
  37. whiteView.layer.mask = maskLayer;
  38. UIButton *coloseBtn = [UIButton buttonWithType:0];
  39. coloseBtn.frame = CGRectMake(_window_width-35, 0, 30, 30);
  40. [coloseBtn setImage:[UIImage imageNamed:@"gray_close"] forState:0];
  41. coloseBtn.imageEdgeInsets = UIEdgeInsetsMake(14, 10, 6, 10);
  42. [coloseBtn addTarget:self action:@selector(btnHide) forControlEvents:UIControlEventTouchUpInside];
  43. [whiteView addSubview:coloseBtn];
  44. UIImageView *thumbImgV = [[UIImageView alloc]initWithFrame:CGRectMake(25, 30, 90, 120)];
  45. thumbImgV.contentMode = UIViewContentModeScaleAspectFill;
  46. thumbImgV.clipsToBounds = YES;
  47. [thumbImgV sd_setImageWithURL:[NSURL URLWithString:minstr([goodsDic valueForKey:@"thumb"])]];
  48. [whiteView addSubview:thumbImgV];
  49. //UILabel *nameL = [[UILabel alloc]initWithFrame:CGRectMake(thumbImgV.right+10, 30, _window_width-(thumbImgV.right+10+10), 26)];
  50. UILabel *nameL = [[UILabel alloc]init];
  51. nameL.font = [UIFont systemFontOfSize:15];
  52. nameL.text = minstr([goodsDic valueForKey:@"name"]);
  53. nameL.numberOfLines = 2;
  54. [whiteView addSubview:nameL];
  55. [nameL mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.left.equalTo(thumbImgV.mas_right).offset(10);
  57. make.top.equalTo(thumbImgV.mas_top);
  58. make.right.equalTo(whiteView.mas_right).offset(-10);
  59. }];
  60. //UILabel *contentL = [[UILabel alloc]initWithFrame:CGRectMake(nameL.left, nameL.bottom+8, nameL.width, 45)];
  61. UILabel *contentL = [[UILabel alloc]init];
  62. contentL.textColor = RGB_COLOR(@"#646464", 1);
  63. contentL.font = [UIFont systemFontOfSize:12];
  64. contentL.numberOfLines = 3;
  65. contentL.text = minstr([goodsDic valueForKey:@"des"]);
  66. [whiteView addSubview:contentL];
  67. [contentL mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.left.equalTo(nameL);
  69. make.top.equalTo(nameL.mas_bottom).offset(8);
  70. make.right.lessThanOrEqualTo(whiteView.mas_right).offset(-10);
  71. }];
  72. UILabel *priceL = [[UILabel alloc]init];
  73. priceL.font = [UIFont boldSystemFontOfSize:17];
  74. priceL.text = [NSString stringWithFormat:@"¥%@",minstr([goodsDic valueForKey:@"price"])];
  75. priceL.textColor =Pink_Cor;// RGB_COLOR(@"#FB483A", 1);
  76. [whiteView addSubview:priceL];
  77. [priceL mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.bottom.equalTo(thumbImgV);
  79. make.left.equalTo(nameL);
  80. }];
  81. UILabel *priceL2 = [[UILabel alloc]init];
  82. priceL2.font = [UIFont systemFontOfSize:15];
  83. priceL2.text = [NSString stringWithFormat:@"¥%@",minstr([goodsDic valueForKey:@"original_price"])];
  84. priceL2.textColor = RGB_COLOR(@"#C9C9C9", 1);
  85. [whiteView addSubview:priceL2];
  86. [priceL2 mas_makeConstraints:^(MASConstraintMaker *make) {
  87. make.centerY.equalTo(priceL);
  88. make.left.equalTo(priceL.mas_right).offset(10);
  89. }];
  90. UIView *lineV = [[UIView alloc]init];
  91. lineV.backgroundColor = RGB_COLOR(@"#C9C9C9", 1);
  92. [whiteView addSubview:lineV];
  93. [lineV mas_makeConstraints:^(MASConstraintMaker *make) {
  94. make.left.right.centerY.equalTo(priceL2);
  95. make.height.mas_equalTo(1);
  96. }];
  97. if (![minstr([goodsDic valueForKey:@"type"])isEqual:@"1"]) {
  98. priceL2.hidden = YES;
  99. lineV.hidden = YES;
  100. }
  101. UIButton *buyBtn = [UIButton buttonWithType:0];
  102. buyBtn.frame = CGRectMake(25, thumbImgV.bottom+15, _window_width-50, 40);
  103. [buyBtn setBackgroundColor:RGB_COLOR(@"#EA377F", 1)];
  104. [buyBtn setTitle:YZMsg(@"去看看") forState:0];
  105. buyBtn.titleLabel.font = [UIFont systemFontOfSize:15];
  106. [buyBtn addTarget:self action:@selector(buyBtnClick) forControlEvents:UIControlEventTouchUpInside];
  107. [whiteView addSubview:buyBtn];
  108. [whiteView layoutIfNeeded];
  109. [UIView animateWithDuration:0.2 animations:^{
  110. whiteView.y = _window_height-220-ShowDiff;
  111. }];
  112. }
  113. - (void)buyBtnClick{
  114. [self removeFromSuperview];
  115. [self addShopHits];
  116. /*
  117. if ([minstr([goodsDic valueForKey:@"type"]) isEqual:@"1"]) {
  118. [PublicObj openWXMiniProgram:minstr([goodsDic valueForKey:@"href"])];
  119. }else{
  120. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:minstr([goodsDic valueForKey:@"href"])]];
  121. }
  122. */
  123. [PublicObj tokenAccess:^(BOOL isAccess) {
  124. if (!isAccess) { return; }
  125. if (![minstr([goodsDic valueForKey:@"status"]) isEqual:@"1"]) {
  126. [MBProgressHUD showError:YZMsg(@"商品不存在~")];
  127. return;
  128. }
  129. if ([minstr([goodsDic valueForKey:@"type"]) isEqual:@"1"]) {
  130. OutsideGoodsDetailVC *detail = [[OutsideGoodsDetailVC alloc]init];
  131. detail.goodsID = minstr([goodsDic valueForKey:@"id"]);
  132. if ([[Config getOwnID] isEqual:minstr([goodsDic valueForKey:@"uid"])]) {
  133. detail.fromWhere = @"seller";
  134. }
  135. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:detail animated:YES];
  136. }else{
  137. CommodityDetailVC *detail = [[CommodityDetailVC alloc]init];
  138. detail.goodsID = minstr([goodsDic valueForKey:@"id"]);
  139. if ([[Config getOwnID] isEqual:minstr([goodsDic valueForKey:@"uid"])]) {
  140. detail.fromWhere = @"seller";
  141. }
  142. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:detail animated:YES];
  143. }
  144. }];
  145. }
  146. - (void)addShopHits{
  147. NSDictionary *dic = @{
  148. @"uid":[Config getOwnID],
  149. @"token":[Config getOwnToken],
  150. //@"videoid":_videoid
  151. @"goodsid":_goodsID,
  152. };
  153. [YBNetworking postWithUrl:@"Shop.UpHits" Dic:dic Suc:^(int code, id info, NSString *msg) {
  154. } Fail:^(id fail) {
  155. }];
  156. }
  157. - (void)btnHide{
  158. [UIView animateWithDuration:0.2 animations:^{
  159. whiteView.height = _window_height;
  160. }completion:^(BOOL finished) {
  161. [self removeFromSuperview];
  162. }];
  163. }
  164. @end