123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- //
- // ASPointsHomeViewController.m
- // Asteria
- //
- // Created by iOS on 2023/6/19.
- //
- #import "ASPointsHomeViewController.h"
- #import "ASPointHeadView.h"
- #import "ASPointEranCell.h"
- #import "ASPointDetailViewController.h"
- #import "ASPointsViewModel.h"
- @interface ASPointsHomeViewController ()<UITableViewDelegate,UITableViewDataSource>
- @property (nonatomic, strong) ASPointsViewModel *vm;
- @property (nonatomic, strong) ASPointHeadView *headV;
- @property (nonatomic, strong) UITableView *tableV;
- @end
- @implementation ASPointsHomeViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.vm = [[ASPointsViewModel alloc] init];
- [self loadSubVs];
- [self configSubV];
-
-
-
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- __weak typeof(self) weakSelf = self;
- [self.vm getExtraList:^(BOOL hasNext, NSString * _Nonnull msg) {
- [weakSelf.tableV reloadData];
- }];
- }
- - (void)configSubV {
- [self setTitleStr:@"Points"];
- [self setNavRightSearch:^{
- // TODO: - to Search VC
- }];
- NSString *points = ASUserInfoManager.shared.userPoints;
- [self.headV setData:points];
- __weak typeof(self) weakSelf = self;
- [self.headV setRuleCallBack:^{
- UIViewController *vc = [CTMediator.sharedInstance getWebViewVc:@{
- @"title":@"Points Rules",
- @"url":PointRuleWebUrl,
- }];
- [weakSelf.navigationController pushViewController:vc animated:true];
-
- }];
- [self.headV setDetailCallBack:^{
- ASPointDetailViewController *vc = [ASPointDetailViewController new];
- [weakSelf.navigationController pushViewController:vc animated:true];
- }];
-
-
- self.customNavBar.backgroundColor = _F0FFFA;
- }
- - (void)loadSubVs {
- [self.view addSubview:self.tableV];
- [self.tableV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.customNavBar.mas_bottom);
- make.leading.trailing.bottom.equalTo(self.view);
- }];
- }
- // MARK: - subVs
- - (ASPointHeadView *)headV {
- if (!_headV) {
- ASPointHeadView *v = [[ASPointHeadView alloc] initWithFrame:CGRectZero];
- _headV = v;
- }
- return _headV;
- }
- - (UITableView *)tableV {
- if (!_tableV) {
- UITableView *v = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
- [v registerClass:[ASPointEranCell class] forCellReuseIdentifier:@"ASPointEranCell"];
- v.delegate = self;
- v.dataSource = self;
- [v baseSet];
- v.tableHeaderView = self.headV;
- _tableV = v;
- }
- return _tableV;
- }
- // MARK: - UITableViewDelegate,UITableViewDataSource
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return self.vm.extraPathList.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- ASPointEranCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ASPointEranCell" forIndexPath:indexPath];
- if (indexPath.row >= self.vm.extraPathList.count) {
- return cell;
- }
- ASExtraPointsModel *m = self.vm.extraPathList[indexPath.row];
- [cell setData:m.name des:m.point status:!m.is_obtain];
-
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- if (indexPath.row >= self.vm.extraPathList.count) {
- return;
- }
- ASExtraPointsModel *m = self.vm.extraPathList[indexPath.row];
- if (!m.is_obtain) {
- return;
- }
- switch (m.type.intValue) {
- case -1:{
- [self toHomeVc];
- }
- break;
- case 0: {
- // TODO: 去订单列表
-
- }
- break;
-
- default: {
- if (m.categoryId != nil && m.categoryId.length > 0) {
- UIViewController *vc = [CTMediator.sharedInstance getProductListVc:@{
- @"type":m.categoryId, //String
- @"title":m.name,//String
- @"secondTime": [NSNumber numberWithInteger:15],// NSNumber,
- @"pointGetType":[NSNumber numberWithInteger:m.type.integerValue],//NSNumber
- }];
- [self.navigationController pushViewController:vc animated:true];
- }
- }
- break;
- }
- }
- @end
|