| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 | 
							- //
 
- //  ASVipCouponsViewController.m
 
- //  Asteria
 
- //
 
- //  Created by iOS on 2023/7/1.
 
- //
 
- #import "ASVipCouponsViewController.h"
 
- #import "ASCouponListCell.h"
 
- #import "ASHomeAlertWindow.h"
 
- #import "ASVipCouponsViewModel.h"
 
- @interface ASVipCouponsViewController () <UITableViewDelegate,UITableViewDataSource>
 
- @property (nonatomic, strong) ASVipCouponsViewModel *vm;
 
- @property (nonatomic, strong) UIView *colorBgV;
 
- @property (nonatomic, strong) UITableView *tableV;
 
- @end
 
- @implementation ASVipCouponsViewController
 
- - (void)viewDidLoad {
 
-     [super viewDidLoad];
 
-     self.vm = [ASVipCouponsViewModel new];
 
-     [self loadSubVs];
 
-     [self configSubVs];
 
-     
 
-     
 
- }
 
- - (void)configSubVs {
 
-     self.titleStr = @"VIP Exclusive Coupon";
 
-     [self setNavRightSearch:^{
 
-         
 
-     }];
 
-     self.statusBgV.backgroundColor = _E0FFF5;
 
-     self.customNavBar.backgroundColor = _F0FFFA;
 
-     
 
-     __weak typeof(self) weakSelf = self;
 
-     self.tableV.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
 
-         [weakSelf getNetData];
 
-     }];
 
-     [self.tableV.mj_header beginRefreshing];
 
-     
 
- }
 
- // MARK: - net
 
- - (void)getNetData {
 
-     [MBProgressHUD showHUDAddedTo:self.view animated:true];
 
-     __weak typeof(self) weakSelf = self;
 
-     [self.vm getVipCouponList:self.level com:^(BOOL isSuccess, NSString * _Nonnull msg) {
 
-         [MBProgressHUD hideHUDForView:weakSelf.view animated:true];
 
-         [weakSelf.tableV.mj_header endRefreshing];
 
-         if (weakSelf.vm.couponArr.count == 0) {
 
-             [weakSelf showEmptyV:weakSelf.tableV];
 
-         } else {
 
-             [weakSelf hiddenEmpty];
 
-         }
 
-         [weakSelf.tableV reloadData];
 
-         if (!isSuccess) {
 
-             [weakSelf.view makeToast:msg];
 
-         }
 
-     }];
 
- }
 
- // MARK: - loadSubVs
 
- - (void)loadSubVs {
 
-     [self.view addSubview:self.colorBgV];
 
-     [self.view addSubview:self.tableV];
 
-     
 
-     [self.colorBgV mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.top.equalTo(self.customNavBar.mas_bottom);
 
-         make.leading.trailing.bottom.equalTo(self.view);
 
-     }];
 
-     
 
-     [self.tableV mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.top.equalTo(self.customNavBar.mas_bottom);
 
-         make.leading.trailing.bottom.equalTo(self.view);
 
-     }];
 
-     
 
-     dispatch_async(dispatch_get_main_queue(), ^{
 
-         [UIView viewAddHorColorBg:self.colorBgV colorArr:@[
 
-             (id)_E0FFF5.CGColor,
 
-             (id)Col_FFF.CGColor
 
-         ] startP:CGPointMake(0.5, 0.2) endP:CGPointMake(0.5, 1)];
 
-     });
 
- }
 
- // MARK: - subVs
 
- - (UIView *)colorBgV {
 
-     if (!_colorBgV) {
 
-         UIView *v = [UIView baseV];
 
-         v.backgroundColor = Col_FFF;
 
-         _colorBgV = v;
 
-     }
 
-     return _colorBgV;
 
- }
 
- - (UITableView *)tableV {
 
-     if (!_tableV) {
 
-         UITableView *v = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
 
-         [v baseSet];
 
-         v.backgroundColor = UIColor.clearColor;
 
-         v.delegate  = self;
 
-         v.dataSource = self;
 
-         [v registerClass:[ASCouponListCell class] forCellReuseIdentifier:@"ASCouponListCell"];
 
-         _tableV = v;
 
-     }
 
-     return _tableV;
 
- }
 
- // MARK: - UITableViewDelegate,UITableViewDataSource
 
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
 
-     return self.vm.couponArr.count;
 
- }
 
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
 
-     ASCouponListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASCouponListCell" forIndexPath:indexPath];
 
-     __weak typeof(self) weakSelf = self;
 
-     if (self.vm.couponArr.count <= indexPath.row) {
 
-         [cell setVipCouponStyle];
 
-         return cell;
 
-     }
 
-     ASVipCouponModel *vipM = self.vm.couponArr[indexPath.row];
 
-     [cell setCopyCallBack:^{
 
-         [weakSelf.vm postGetCoupon:vipM.Id com:^(BOOL isSuccess, NSString * _Nonnull msg) {
 
-             if (isSuccess) {
 
-                 [ASHomeAlertWindow alertMsg:@"Coupon Received Please Check In My Coupon"];
 
-             } else {
 
-                 [weakSelf.view makeToast:msg];
 
-             }
 
-             [weakSelf getNetData];
 
-         }];
 
-     }];
 
-     [cell setVipData:vipM];
 
-     [cell setVipCouponStyle];
 
-     return cell;
 
- }
 
- @end
 
 
  |