123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268 |
- //
- // AS_GoodsReviewsListC.m
- // Asteria
- //
- // Created by 王猛 on 2024/1/4.
- //
- #import "AS_GoodsReviewsListC.h"
- #import "ASGoodsDetailsVM.h"
- #import "RadioButton.h"
- #import "GoodsReviewsListTableV.h"
- #import "GoodsReviewsWriteC.h"
- #import "ReviewsTableHearV.h"
- @interface AS_GoodsReviewsListC ()<RY_baseVMprotocol,TT_BaseTableVDelegate>
- @property (nonatomic, strong) ASGoodsDetailsVM *VM;
- @property (nonatomic, strong) UIView *topBgV;
- @property (nonatomic, strong) UIImageView *topImgV;
- @property (nonatomic, strong) UILabel *goodsTitleLab;
- @property (nonatomic, strong) QMUILabel *priceLab;
- @property (nonatomic, strong) QMUILabel *soldLab;
- @property (nonatomic, strong) NSMutableArray *radioBtnAry;
- @property (nonatomic, strong) ReviewsTableHearV *tableHeadV;
- @property (nonatomic, strong) QMUILabel *reviewsLab;
- @property (nonatomic, strong) GoodsReviewsListTableV *TableV;
- @property (nonatomic, strong) NSMutableArray *sortreTypeAry;
- @property (nonatomic, strong) NSString *sortreType;
- @end
- @implementation AS_GoodsReviewsListC
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.title = [NSString stringWithFormat:@"Reviews (%@)",self.goodsM.review_nums];
- self.TableV.Page = 1;
- self.sortreType = [self.sortreTypeAry firstObject];
- [MBProgressHUD showHUDAddedTo:self.view animated:YES];
- [self reqNet_Goods_productGetProductsReview:self.sortreType];
- [self ucm_subVeiwsTapBlock];
- }
- - (void)initSubviews {
- [super initSubviews];
- [self.view addSubview:self.topBgV];
- self.sortreTypeAry = [NSMutableArray arrayWithArray:@[@"All",@"Newest",@"Pictures"]];
- self.sortreType = [self.sortreTypeAry firstObject];
- for (int i=0; i<self.sortreTypeAry.count; i++) {
- RadioButton *radBtn= [[RadioButton alloc]init];
- radBtn.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
- radBtn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:14];
- radBtn.layer.cornerRadius = 4;
- radBtn.clipsToBounds = YES;
- radBtn.tag = i;
- [radBtn setTitle:self.sortreTypeAry[i] forState:UIControlStateNormal];
- [radBtn setTitleColor:[UIColor colorWithHexString:@"#000000"] forState:UIControlStateNormal];
- [radBtn setTitleColor:[UIColor colorWithHexString:@"#FFFFFF"] forState:UIControlStateSelected];
- [radBtn addTarget:self action:@selector(handle_onRadioButtonValueChanged:) forControlEvents:UIControlEventValueChanged];
- [self.view addSubview:radBtn];
- CGFloat btnWidth = (KScreenWidth-40)/3;
- radBtn.frame = CGRectMake(10 + i*(btnWidth+10), CGRectGetMaxY(self.topBgV.frame)+10,btnWidth, 40);
- [self.radioBtnAry addObject:radBtn];
- }
- RadioButton *firstBtn = self.radioBtnAry[0];
- [firstBtn setGroupButtons:self.radioBtnAry];
- [firstBtn setSelected:YES];
- firstBtn.backgroundColor = [UIColor colorWithHexString:@"#113632"];
-
- [self setupTableV:[GoodsReviewsListTableV class] Frame:CGRectMake(0, CGRectGetMaxY(firstBtn.frame)+10, KScreenWidth, KScreenHeight- CGRectGetMaxY(firstBtn.frame)-10)];
- self.TableV.backgroundColor = [UIColor clearColor];
- self.TableV.tableHeaderView = self.tableHeadV;
- self.TableV.Page = 1;
- self.TableV.is_refreshHeader = YES;
- self.TableV.is_refreshfoot = YES;
-
- }
- - (void)ucm_subVeiwsTapBlock{
- @weakify(self)
- self.tableHeadV.ViewtapClose = ^(NSInteger num, id _Nonnull data) {
- @strongify(self)
- if(num == 0){
- GoodsReviewsWriteC *vc = [[GoodsReviewsWriteC alloc]init];
- vc.goodsM = self.goodsM;
- vc.topBgV = self.topBgV;
- vc.nav_title = [NSString stringWithFormat:@"REVIEWS (%@)",self.goodsM.review_nums];
- [self.navigationController pushViewController:vc animated:YES];
- }
- };
- }
- - (void)ucm_changedefault{
- [self.topImgV sd_setImageWithURL:[NSURL URLWithString:self.goodsM.add_gooodsImgUrl] placeholderImage:UIImageDefaultImg_SD];
- self.goodsTitleLab.text = self.goodsM.name;
- self.priceLab.attributedText = self.goodsM.priceAtr;
- self.soldLab.text = [NSString stringWithFormat:@"SOLD: %@",self.goodsM.sold];
- [self.tableHeadV tt_confignewdata:self.goodsM];
- }
- - (void)ucm_bindvmmodel{
- self.VM = [[ASGoodsDetailsVM alloc]initDelegate:self];
- }
- #pragma mark - **************** TT_BaseTableVDelegate ****************
- - (void)refreshDataType:(NSInteger)type{
- [self reqNet_Goods_productGetProductsReview:self.sortreType];
- }
- #pragma mark - **************** reqNet ****************
- -(void)reqNet_Goods_productGetProductsReview:(NSString *)sortreType{
- NSMutableDictionary *params = [[NSMutableDictionary alloc]init];
- [params setObject:self.goodsM.Id forKey:@"pid"];
- [params setObject:@1 forKey:@"img"];
- [params setObject:sortreType forKey:@"sortreview"];
- [params setObject:@(self.TableV.Page) forKey:@"p"];
- [params setObject:@10 forKey:@"limit"];
- [self.VM ry_requestGetApi:Goods_productGetProductsReview param:params];
- }
- -(void)ry_respnsData:(nullable id)data
- parseAry:(nullable NSMutableArray *)arry
- sucess:(BOOL)sucessOrFail
- mark:(NSString *)mark
- reqNetType:(ReqNetType)reqNetType{
- [MBProgressHUD hideHUDForView:self.view animated:YES];
- if(sucessOrFail){ ///如何加载相关的评论页面
- if([mark isEqualToString:Goods_productGetProductsReview]){
- [self.TableV configDataNew:arry has_more:arry.count==10 ? YES : NO];
- }
- }
-
- }
- #pragma mark - **************** handle ****************
- -(void)handle_onRadioButtonValueChanged:(RadioButton *)btn{
- if (btn.selected) {
- btn.backgroundColor = [UIColor colorWithHexString:@"#113632"];
- self.TableV.Page = 1;
- self.sortreType = self.sortreTypeAry[btn.tag];
- [MBProgressHUD showHUDAddedTo:self.view animated:YES];
- [self reqNet_Goods_productGetProductsReview:self.sortreType];
- [self.TableV setContentOffset:CGPointMake(0, 0) animated:YES];
- }else{
- btn.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
- }
- }
- #pragma mark - **************** lazy ****************
- - (UIView *)topBgV {
- if (!_topBgV) {
- IPhoneXHeigh
- UIView *v= [[UIView alloc] initWithFrame:CGRectMake(0, securitytop_Y, KScreenWidth, 60)];
- v.backgroundColor = [UIColor colorWithHexString:@"#E0FFF5"];
-
- [v addSubview:self.topImgV];
- [v addSubview:self.goodsTitleLab];
- [v addSubview:self.priceLab];
- [v addSubview:self.soldLab];
- [self.topImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(20);
- make.top.mas_equalTo(10);
- make.height.mas_equalTo(40);
- make.width.mas_equalTo(40);
- }];
- [self.soldLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(-10);
- make.centerY.mas_equalTo(0);
- make.height.mas_equalTo(40);
- }];
- [self.goodsTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.topImgV.mas_right).offset(10);
- make.right.equalTo(self.soldLab.mas_left).offset(-10);
- make.top.mas_equalTo(10);
- make.height.mas_equalTo(20);
- }];
- [self.priceLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.topImgV.mas_right).offset(10);
- make.right.equalTo(self.soldLab.mas_left).offset(-10);
- make.top.equalTo(self.goodsTitleLab.mas_bottom);
- make.height.mas_equalTo(20);
- }];
- _topBgV = v;
- }
- return _topBgV;
- }
- - (UIImageView *)topImgV {
- if (!_topImgV) {
- _topImgV = [[UIImageView alloc] initWithImage:nil];
- _topImgV.contentMode = UIViewContentModeScaleAspectFill;
- _topImgV.clipsToBounds = YES;
- }
- return _topImgV;
- }
- - (UILabel *)goodsTitleLab {
- if (!_goodsTitleLab) {
- _goodsTitleLab = [[UILabel alloc] initWithFrame:CGRectZero];
- _goodsTitleLab.textColor = [UIColor colorWithHexString:@"#B2B2B2"];
- _goodsTitleLab.font = [UIFont fontWithName:Rob_Regular size:12];
- }
- return _goodsTitleLab;
- }
- - (QMUILabel *)priceLab {
- if (!_priceLab) {
- _priceLab = [[QMUILabel alloc] initWithFrame:CGRectZero];
- }
- return _priceLab;
- }
- - (QMUILabel *)soldLab {
- if (!_soldLab) {
- _soldLab = [[QMUILabel alloc] initWithFrame:CGRectZero];
- _soldLab.textAlignment = NSTextAlignmentRight;
- _soldLab.textColor = [UIColor colorWithHexString:@"#000000"];
- _soldLab.font = [UIFont fontWithName:Rob_Regular size:12];
- }
- return _soldLab;
- }
- - (NSMutableArray *)radioBtnAry {
- if (!_radioBtnAry) {
- _radioBtnAry = [[NSMutableArray alloc] init];
- }
- return _radioBtnAry;
- }
- - (ReviewsTableHearV *)tableHeadV {
- if (!_tableHeadV) {
- _tableHeadV = [[ReviewsTableHearV alloc] initWithFrame:CGRectFlatMake(0, 0, KScreenHeight, [ReviewsTableHearV xxx_viewHeight])];
- _tableHeadV.backgroundColor = [UIColor colorWithHexString:@"#FFFFFF"];
- }
- return _tableHeadV;
- }
- - (QMUILabel *)reviewsLab {
- if (!_reviewsLab) {
- _reviewsLab = [[QMUILabel alloc] initWithFrame:CGRectZero];
- _reviewsLab.textAlignment = NSTextAlignmentLeft;
- _reviewsLab.textColor = [UIColor blackColor];
- _reviewsLab.font = [UIFont systemFontOfSize:18];
- _reviewsLab.text = @"test";
- }
- return _reviewsLab;
- }
- - (NSMutableArray *)sortreTypeAry {
- if (!_sortreTypeAry) {
- _sortreTypeAry = [[NSMutableArray alloc] init];
- }
- return _sortreTypeAry;
- }
- @end
|