| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- //
- // MOMyBackpackListVC.m
- // MiMoLive
- //
- // Created by SuperC on 2023/12/21.
- //
- #import "MOMyBackpackListVC.h"
- #import "MOMyBackpackTableView.h"
- #import "MOShopBuyView.h"
- @interface MOMyBackpackListVC ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate,UIGestureRecognizerDelegate>
- @property (nonatomic, strong) JXCategoryTitleView *titleCategoryView;
- @property (nonatomic, strong) JXCategoryListContainerView *listContainerView;
- @property (nonatomic, strong) UIView *titleBgView;
- @property (nonatomic, strong) MOShopList *selectModel;
- @property (strong, nonatomic) UIImageView *bgImgView;
- @property (nonatomic, assign) NSInteger selectIndex;
- @end
- @implementation MOMyBackpackListVC
- - (void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- [self.navigationController setNavigationBarHidden:NO animated:animated];
-
- [self mo_setNavLeftItemWithImage:[UIImage imageNamed:@"icon_new_left_gray"] andBackgroundImg:[UIImage imageNamed:@"icon_mine_base_bg"]];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
-
- self.navigationItem.title = NSLocalString(@"mimo_Backpack_Package");
- // [self setNavLeftItemWithImage:[UIImage imageNamed:@"icon_nav_back"]];
-
- [self setupUI];
-
- self.navigationController.interactivePopGestureRecognizer.delegate = self;
- self.navigationController.interactivePopGestureRecognizer.enabled = YES;
- }
- - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
- return YES;
- }
- - (void)setupUI{
-
- self.selectIndex = 0;
-
- self.view.backgroundColor = [MOTools colorWithHexString:@"#FFFFFF" alpha:1.0];
-
- [self.view addSubview:self.bgImgView];
- [self.bgImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self.view);
- }];
- NSArray *colorArr = @[[MOTools colorWithHexString:@"#EEF2FD" alpha:1.0],[MOTools colorWithHexString:@"#FAFAFC" alpha:1.0]];
- UIImage *image = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, SCREENWIDTH, (SCREENHEIGHT - NAV_BAR_HEIGHT)) Colors:colorArr GradientType:1];
- [self.bgImgView setImage:image];
-
- [self.view addSubview:self.titleBgView];
- [self.titleBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.view).offset(12.0);
- make.left.equalTo(self.view).offset(12.0);
- make.right.equalTo(self.view).offset(-12.0);
- make.height.equalTo(@32.0);
- }];
- self.titleBgView.layer.cornerRadius = 32.0 / 2.0;
-
- [self.view addSubview:self.titleCategoryView];
- [self.titleCategoryView mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop);
- make.left.equalTo(self.view).offset(0.0);
- make.right.equalTo(self.view).offset(0.0);
- make.height.equalTo(@70.0);
- make.centerY.equalTo(self.titleBgView.mas_centerY);
- }];
-
-
- self.titleCategoryView.titles = @[NSLocalString(@"mimo_Backpack_Cars"),NSLocalString(@"mimo_Backpack_Headwear"),NSLocalString(@"mimo_Backpack_Bubble"),NSLocalString(@"mimo_Backpack_Package")];
- CGFloat totalItemWidth = SCREENWIDTH - 12.0 * 2.0;
- CGFloat cellWidth = totalItemWidth / self.titleCategoryView.titles.count;
- self.titleCategoryView.cellSpacing = 0;
- self.titleCategoryView.cellWidth = cellWidth;
- self.titleCategoryView.titleColor = [MOTools colorWithHexString:@"#737373" alpha:1.0];
- self.titleCategoryView.titleSelectedColor = kBaseBtnBgColor;
- self.titleCategoryView.titleLabelMaskEnabled = YES;
- self.titleCategoryView.titleFont = [MOTextTools getTheFontWithSize:15.0 AndFontName:kNormalContentFontStr];
- self.titleCategoryView.backgroundColor = [UIColor clearColor];
-
-
- JXCategoryIndicatorBackgroundView *backgroundView = [[JXCategoryIndicatorBackgroundView alloc] init];
- backgroundView.indicatorHeight = 70.0;
- backgroundView.indicatorWidth = cellWidth + 20.0;
- backgroundView.indicatorWidthIncrement = 0;
- backgroundView.indicatorColor = [UIColor clearColor];
- backgroundView.verticalMargin = 4.0;
-
- UIImageView *imgBgView = [[UIImageView alloc] init];
- imgBgView.contentMode = UIViewContentModeScaleToFill;
- [imgBgView setImage:[UIImage imageNamed:@"icon_rank_btn_bg_apple"]];
- [backgroundView addSubview:imgBgView];
- [imgBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(backgroundView);
- }];
-
- self.titleCategoryView.indicators = @[backgroundView];
-
- [self.view addSubview:self.listContainerView];
- [self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.titleCategoryView.mas_bottom).offset(-5.0);
- make.bottom.equalTo(self.view);
- make.left.equalTo(self.view).offset(0.0);
- make.right.equalTo(self.view).offset(0.0);
- }];
- self.titleCategoryView.listContainer = self.listContainerView;
- }
- // 点击选中或者滚动选中都会调用该方法。适用于只关心选中事件,不关心具体是点击还是滚动选中的。
- - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index{
- MOLogV(@"变换了");
- self.selectIndex = index;
- }
- #pragma mark - JXCategoryListContainerViewDelegate
- - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView{
- return self.titleCategoryView.titles.count;
- }
- - (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{
- WEAKSELF
- MOMyBackpackTableView *view = [[MOMyBackpackTableView alloc] init];
- view.category = index + 1;
- view.buyShopView = ^(MOShopList * _Nonnull cellModel) {
- [weakSelf toShowAlertWith:cellModel];
- };
-
- return view;
- }
- - (void)toShowAlertWith:(MOShopList *)propModel{
- WEAKSELF
- if(propModel.propInfo.pricesInfo.count > 0){
- MOTitleNormalAlertView *alertView = [[MOTitleNormalAlertView alloc] init];
- alertView.titleLabel.text = NSLocalString(@"mimo_alert_normal_tip");
- alertView.subTitleLabel.text = NSLocalString(@"mimo_prop_renew_confirm_tip1");
- [alertView.cancelBtn setTitle:NSLocalString(@"mimo_Cancel") forState:UIControlStateNormal];
- [alertView.confirmBtn setTitle:NSLocalString(@"mimo_prop_renew") forState:UIControlStateNormal];
- alertView.confirmBlock = ^{
- [weakSelf toShowBuyPropWith:propModel];
- };
- [alertView show];
- }
- else{
- MOTitleNormalAlertView *alertView = [[MOTitleNormalAlertView alloc] init];
- alertView.titleLabel.text = NSLocalString(@"mimo_alert_normal_tip");
- alertView.subTitleLabel.text = NSLocalString(@"mimo_prop_renew_confirm_tip2");
- alertView.isSingleBtn = YES;
- [alertView.confirmBtn setTitle:NSLocalString(@"mimo_TipPleaseConfirm") forState:UIControlStateNormal];
- [alertView show];
- }
- }
- - (void)toShowBuyPropWith:(MOShopList *)propModel{
-
- MOShopList *copyModel = [propModel copy];
- copyModel.id = propModel.propInfo.id;
- copyModel.cornerMark = propModel.propInfo.cornerMark;
- copyModel.storeInfo = [propModel.propInfo.storeInfo copy];
- copyModel.pricesInfo = [propModel.propInfo.pricesInfo copy];
-
- self.selectModel = copyModel;
-
- WEAKSELF
- MOShopBuyView *view = [MOShopBuyView moShopBuyView];
- view.viewModel = copyModel;
- [view showShopBuyView];
- view.buyActionBlock = ^(MOPricesInfo * _Nonnull pricesModel) {
- [weakSelf toShowSecondAlertViewWith:pricesModel];
- };
- }
- - (void)toShowSecondAlertViewWith:(MOPricesInfo *)model{
-
- WEAKSELF
- MOTitleNormalAlertView *view = [[MOTitleNormalAlertView alloc] init];
- NSString *contentStr = [NSString stringWithFormat:NSLocalString(@"mimo_prop_buy_confirm_tip"),model.diamond,self.selectModel.storeInfo.name,model.days];
- view.subTitleLabel.text = contentStr;
- view.subTitleLabel.textColor = [MOTools colorWithHexString:@"#282828" alpha:1.0];
-
- view.bgImgView.hidden = YES;
- view.containerView.backgroundColor = [MOTools colorWithHexString:@"#FFFFFF" alpha:1.0];
-
- [view.cancelBtn setBackgroundColor:[MOTools colorWithHexString:@"#B0B0B0" alpha:1.0]];
- [view.cancelBtn setTitle:NSLocalString(@"mimo_common_cancel") forState:UIControlStateNormal];
- [view.cancelBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- view.cancelBtn.layer.borderWidth = 0.0;
-
- NSArray *colorArr = @[kBaseBtnBgColor,kBaseBtnBgColor];
- UIImage *image = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, view.twoBtnWidth, 48.0) Colors:colorArr GradientType:0];
- [view.confirmBtn setBackgroundImage:image forState:UIControlStateNormal];
- [view.confirmBtn setTitle:NSLocalString(@"mimo_common_buy") forState:UIControlStateNormal];
- [view.confirmBtn setTitleColor:[MOTools colorWithHexString:@"#FFFFFF" alpha:1.0] forState:UIControlStateNormal];
-
- view.confirmBlock = ^{
-
- NSString *idStr = weakSelf.selectModel.id;
- if(idStr.length == 0){
- return;
- }
-
- NSDictionary *dict = @{@"id":idStr,
- @"key":@(model.key)};
- [kHttpManager toBuyPropWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if(kCode_Success){
- MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
- [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_common_success")];
-
- [weakSelf toRefreshTheView];
- }
- else{
- kShowNetError(data)
- }
- }];
- };
-
- [view show];
- }
- - (void)toRefreshTheView{
- WEAKSELF
- [self.listContainerView.validListDict enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull key, id<JXCategoryListContentViewDelegate> _Nonnull obj, BOOL * _Nonnull stop) {
-
- if([key integerValue] == weakSelf.selectIndex){
- MOMyBackpackTableView *listView = (MOMyBackpackTableView *)obj;
- [listView toGetFirstHttpData];
- }
- }];
- }
- #pragma mark - Lazy
- - (JXCategoryTitleView *)titleCategoryView{
- if(!_titleCategoryView){
- _titleCategoryView = [[JXCategoryTitleView alloc] init];
- _titleCategoryView.delegate = self;
- _titleCategoryView.backgroundColor = [UIColor whiteColor];
- }
- return _titleCategoryView;
- }
- - (JXCategoryListContainerView *)listContainerView{
- if(!_listContainerView){
- _listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
- }
- return _listContainerView;
- }
- - (UIView *)titleBgView{
- if(!_titleBgView){
- _titleBgView = [[UIView alloc] init];
- _titleBgView.backgroundColor = [MOTools colorWithHexString:@"#000000" alpha:0.05];
- }
- return _titleBgView;
- }
- - (UIImageView *)bgImgView{
- if(!_bgImgView){
- _bgImgView = [[UIImageView alloc] init];
- _bgImgView.contentMode = UIViewContentModeScaleToFill;
- }
- return _bgImgView;
- }
- @end
|