123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- //
- // YOUPAILZBackPackVipVC.m
- // VQU
- //
- // Created by 肖浩然的mac on 2021/9/1.
- // Copyright © 2021 MS. All rights reserved.
- //
- #import "YOUPAILZBackPackVipVC.h"
- #import "YOUPAILZBackpackModel.h"
- #import "LZAlertWindow.h"
- #import "UIViewController+TFPresent.h"
- @interface YOUPAILZBackPackVipVC ()<UITableViewDelegate,UITableViewDataSource>
- /* tableView */
- @property (strong, nonatomic) UITableView *youpaiptableView;
- /* 数据源 */
- @property (strong, nonatomic) NSArray *youpaipdataArr;
- @end
- @implementation YOUPAILZBackPackVipVC
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self youpaifinitUI];
- [self youpaifinitData];
- }
- #pragma mark-UITableViewDelegate
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- YOUPAILZBackpackModel *model = self.youpaipdataArr[indexPath.row];
- @weakify(self);
- LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:@"取消" handler:^(LZAlertAction *action) {
-
- }];
- cancelAction.cornerRadius = 24.0f;
- cancelAction.color = LZ273145Color;
- cancelAction.bgColor = LZF5F4F7Color;
- LZAlertAction *confimAction = [LZAlertAction actionWithTitle:@"确定" handler:^(LZAlertAction *action) {
- @strongify(self);
- [self youpaifdidUseCard:[NSString stringWithFormat:@"%ld",model.youpaipid]];
- }];
- confimAction.cornerRadius = 24.0f;
- confimAction.color = [UIColor whiteColor];
- confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:GradientLeftToRight]];
- LZAlertWindow *alert = [LZAlertWindow alertWithTitle:@"提示" content:@"是否使用优惠券" action:@[cancelAction,confimAction]];
- alert.contentTextAlignment = NSTextAlignmentCenter;
- [self TFPresentVC:alert completion:^{}];
-
-
-
-
- }
- //点击使用优惠券
- -(void)youpaifdidUseCard:(NSString*)ID{
-
- @weakify(self);
- [LCHttpHelper requestWithURLString:UseNobleCard parameters:@{@"p_id":ID} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
- @strongify(self);
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
- [self youpaifinitData];
-
- }else{
- [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
- }
- - (void)youpaifinitUI{
- self.youpaiptableView = [[UITableView alloc] initWithFrame:CGRectZero style:(UITableViewStylePlain)];
- self.youpaiptableView.delegate = self;
- self.youpaiptableView.dataSource = self;
- [self.youpaiptableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"LZBackpackCell"];
- self.youpaiptableView.backgroundColor = [UIColor whiteColor];
- [self.youpaiptableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
- self.youpaiptableView.tableFooterView = [UIView new];
- [self.view addSubview:self.youpaiptableView];
- self.youpaiptableView.backgroundColor = [UIColor whiteColor];
- if (@available(iOS 15.0, *)) {
- self.youpaiptableView.sectionHeaderTopPadding = 0;
- }
- [self.youpaiptableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.offset(0);
- make.left.offset(0);
- make.right.offset(0);
- make.bottom.offset(0);
- }];
- }
- #pragma mark-UITableViewDataSource
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return 99;
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
-
- return self.youpaipdataArr.count;
- }
- -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LZBackpackCell"];
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"LZBackpackCell"];
-
- YOUPAILZBackpackModel *model = self.youpaipdataArr[indexPath.row];
- cell.backgroundColor = [UIColor whiteColor];
- //image
- UIImageView *bgImageView1 = [UIImageView new];
- [cell.contentView addSubview:bgImageView1];
- [bgImageView1 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(14);
- make.width.mas_equalTo(KScreenWidth-28);
- make.top.mas_equalTo(0);
- make.height.mas_equalTo(80);
- }];
- // bgImageView.image = [UIImage imageNamed:@"vqu_images_P_test_backpack"];;
- [bgImageView1 sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaipbg_img] placeholderImage:nil];
- bgImageView1.contentMode = UIViewContentModeScaleAspectFill;
- bgImageView1.clipsToBounds = YES;
- bgImageView1.layer.cornerRadius = 10.0f;
-
- UIImageView *bgImageView2 = [UIImageView new];
- [bgImageView1 addSubview:bgImageView2];
- [bgImageView2 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.width.mas_equalTo(ScaleSize(119));
- make.top.mas_equalTo(0);
- make.height.mas_equalTo(80);
- }];
- [bgImageView2 sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaipimg] placeholderImage:nil];
- bgImageView2.contentMode = UIViewContentModeScaleAspectFill;
- bgImageView2.clipsToBounds = YES;
- //title
- UILabel *titleLabel = [UILabel new];
- [bgImageView1 addSubview:titleLabel];
- [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(bgImageView2.mas_right).offset(16);
- make.top.mas_equalTo(15);
- make.height.mas_equalTo(14);
-
- }];
- titleLabel.text = model.youpaipname;
- titleLabel.font = LCBoldFont(14);
- titleLabel.textColor = [UIColor whiteColor];
- //详情
- UILabel *detailLabel = [UILabel new];
- [bgImageView1 addSubview:detailLabel];
- [detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(titleLabel);
- make.top.mas_equalTo(titleLabel.mas_bottom).offset(6);
- make.height.mas_equalTo(10);
- }];
- detailLabel.text = [NSString stringWithFormat:@"%@",model.youpaipdiscount];
- detailLabel.font = [UIFont systemFontOfSize:10];
- detailLabel.textColor = [UIColor whiteColor];
- //时间
- UILabel *timeLabel = [UILabel new];
- [bgImageView1 addSubview:timeLabel];
- [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(detailLabel);
- make.top.mas_equalTo(detailLabel.mas_bottom).offset(11);
- }];
- timeLabel.text = model.youpaipexpire;
- timeLabel.textColor = [UIColor whiteColor];
- timeLabel.font = [UIFont systemFontOfSize:9];
- [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
- return cell;
- }
- -(void)youpaifinitData{
-
- @weakify(self);
- [LCHttpHelper requestWithURLString:SetMineGetPackage parameters:@{@"type":self.youpaiptype} needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
- @strongify(self);
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- self.youpaipdataArr = [YOUPAILZBackpackModel mj_objectArrayWithKeyValuesArray:[dict objectForKey:@"data"]];
- [self.youpaiptableView reloadData];
- if (self.youpaipdataArr.count != 0) {
- [self.youpaiptableView lz_hideEmptyView];
- }else{
- [self.youpaiptableView lz_showEmptyViewWithImage:[UIImage imageNamed:@"vqu_images_not_home_data"] content:@"暂无体验卡"];
- }
- }else{
- [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
- }
- #pragma mark - JXCategoryListContainerView
- - (UIView *)listView{
- return self.view;
- }
- @end
|