123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293 |
- //
- // SPSBMineTableViewController.m
- // 我的社保
- //
- // Created by shanp on 2021/5/12.
- //
- #import "SPSBMineTableViewController.h"
- #import "SPSBUIGeneralHeader.h"
- #import "SPSBBusinessManager.h"
- #import "SPSBRedDotModel.h"
- #import "SPSBMineGuideViewController.h"
- #import "SPSBAboutViewController.h"
- #import "SPSBMailAddressListViewController.h"
- #import "SPSBPurchasersListViewController.h"
- #import "SPSBMineMessageTableViewController.h"
- #import "SPSBAccountSettingTableViewController.h"
- #import "SPSBActionSheetViewController.h"
- #import "SPSBCustomerServiceManager.h"
- #import "SPSBMakePhoneCallManager.h"
- #import "SPSBDisplayDiscountCouponViewController.h"
- typedef NS_ENUM(NSUInteger, SPSBMineTableViewRowType) {
- SPSBMineTableViewRowTypePurchasers = 0,
- SPSBMineTableViewRowTypeMessage,
- SPSBMineTableViewRowTypeDiscountCoupon,
- SPSBMineTableViewRowTypeMail,
- SPSBMineTableViewRowTypeGuide,
- SPSBMineTableViewRowTypeAccountSetting,
- SPSBMineTableViewRowTypeHelpAndCustomerService,
- SPSBMineTableViewRowTypeAbout,
- };
- @interface SPSBMineTableViewController () {
- NSArray *_titleArray;
- NSArray *_imageArray;
- SPSBMakePhoneCallManager *_makePhoneCallManager;
- }
- @end
- @implementation SPSBMineTableViewController
- - (instancetype)init {
- self = [super initWithStyle:UITableViewStyleGrouped backgroundColor:SPSBTableViewBackgroundColorGray];
- if (!self) return nil;
- _titleArray = @[@"购买人员", @"我的消息", @"优惠券", @"邮寄信息", @"新手指南", @"账户设置", @"帮助与客服", @"关于我们", @""];
- _imageArray = @[@"info", @"message", @"money", @"location", @"guide", @"safe", @"my_phone", @"about", @""];
- _makePhoneCallManager = [[SPSBMakePhoneCallManager alloc] initWithController:self];
- return self;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self setupTableView];
- }
- #pragma mark - Action
- - (void)toPurchasers {
- @weakify(self)
- spsb_needLogin(^{
- @strongify(self)
- self->_spsb_needRefreshRedDot = true;
- SPSBPurchasersListViewController *vc = SPSBPurchasersListViewController.new;
- vc.spsb_type = SPSBPurchasersListTypeManage;
- [self.navigationController pushViewController:vc animated:true];
- });
- }
- - (void)toMessage {
- @weakify(self)
- spsb_needLogin(^{
- @strongify(self)
- self->_spsb_needRefreshRedDot = true;
- [self.navigationController pushViewController:SPSBMineMessageTableViewController.new animated:true];
- });
- }
- - (void)toDiscountCoupon {
- spsb_needLogin(^{
- [self.navigationController pushViewController:SPSBDisplayDiscountCouponViewController.new animated:true];
- });
- }
- - (void)toMail {
- @weakify(self)
- spsb_needLogin(^{
- @strongify(self)
- [self.navigationController pushViewController:SPSBMailAddressListViewController.new animated:true];
- });
- }
- - (void)toGuide {
- [self.navigationController pushViewController:SPSBMineGuideViewController.new animated:true];
- }
- - (void)toAccountSetting {
- spsb_needLogin(^{
- [self.navigationController pushViewController:SPSBAccountSettingTableViewController.new animated:true];
- });
- }
- - (void)toHelpAndCustomerService {
- SPSBActionSheetViewController *vc = SPSBActionSheetViewController.new;
- @weakify(self)
- [vc addActionWithTitle:@"客服电话" action:^{
- @strongify(self)
- [self makePhoneCall];
- }];
- [vc addActionWithTitle:@"在线客服" action:^{
- @strongify(self)
- [self onlineService];
- }];
- [self presentViewController:vc animated:false completion:nil];
- }
- - (void)makePhoneCall {
- [_makePhoneCallManager showHandleContactMenu];
- }
- - (void)onlineService {
- [spsb_customerServiceManager() toOnlineContactWithBaseController:self];
- }
- - (void)toAbout {
- [self.navigationController pushViewController:SPSBAboutViewController.new animated:true];
- }
- #pragma mark - Network Action
- #pragma mark - Delegate & DataSource
- static NSString * const reuseIdentifier = @"SPSBMineTableViewCell";
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
- if (!cell) {
- cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
- UIImageView *imageView = UIImageView.new;
- imageView.tag = 3000;
- [cell.contentView addSubview:imageView];
- [imageView makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.equalTo(17);
- make.centerY.equalTo(cell.contentView);
- }];
-
- UILabel *titleLabel = [UILabel convenienceWithFont:spsb_font(16) text:nil textColor:spsb_333333_color()];
- titleLabel.tag = 3001;
- [cell.contentView addSubview:titleLabel];
- [titleLabel makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.equalTo(55);
- make.centerY.equalTo(cell.contentView);
- }];
-
- UIImageView *arrow = [[UIImageView alloc] initWithImage:jxh_getImage(list_arrow)];
- [cell.contentView addSubview:arrow];
- [arrow makeConstraints:^(JXHConstraintMaker *make) {
- make.trailing.equalTo(-15);
- make.centerY.equalTo(cell.contentView);
- }];
-
- if (indexPath.section == 0 && indexPath.row == 1) {
- UIView *tipsView = [[UIView alloc] init];
- tipsView.tag = 3002;
- [cell.contentView addSubview:tipsView];
- [tipsView makeConstraints:^(JXHConstraintMaker *make) {
- make.top.and.bottom.equalTo(0);
- make.trailing.equalTo(-33);
- }];
-
- UILabel *label = [UILabel convenienceWithFont:spsb_font(15) text:nil textColor:spsb_999999_color() textAlignment:NSTextAlignmentRight];
- label.tag = 3003;
- [tipsView addSubview:label];
- [label makeConstraints:^(JXHConstraintMaker *make) {
- make.trailing.equalTo(0);
- make.centerY.equalTo(tipsView);
- }];
-
- UIView *dian = UIView.new;
- dian.backgroundColor = spsb_FF5E5E_color();
- [dian setLayerCornerRadius:4 clipToBounds:false];
- [tipsView addSubview:dian];
- [dian makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.equalTo(0);
- make.trailing.equalTo(label.leading).offset(-5);
- make.centerY.equalTo(tipsView);
- make.size.equalTo(CGSizeMake(8, 8));
- }];
- }
- }
-
- UIImageView *icon = [cell.contentView viewWithTag:3000];
- UILabel *title = [cell.contentView viewWithTag:3001];
- SPSBMineTableViewRowType type = indexPath.section * 3 + indexPath.row;
- icon.image = [UIImage imageNamed:_imageArray[type]];
- title.text = _titleArray[type];
- UIView *tipsView = [cell.contentView viewWithTag:3002];
- if (type == SPSBMineTableViewRowTypeMessage) {
- if (spsb_redDotModel().spsb_msg.integerValue <= 0) {
- tipsView.hidden = true;
- return cell;
- }
- tipsView.hidden = false;
- UILabel *tips = [tipsView viewWithTag:3003];
- NSInteger msg = spsb_redDotModel().spsb_msg.integerValue;
- if (msg > 100) {
- tips.text = @"99+新消息";
- } else {
- tips.text = [NSString stringWithFormat:@"%ld新消息", (long)msg];
- }
- } else {
- tipsView.hidden = true;
- }
- return cell;
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return 3;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- if (section == 2) return 2;
- return 3;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- [tableView deselectRowAtIndexPath:indexPath animated:false];
- SPSBMineTableViewRowType type = indexPath.section * 3 + indexPath.row;
- switch (type) {
- case SPSBMineTableViewRowTypePurchasers:
- [self toPurchasers];
- break;
- case SPSBMineTableViewRowTypeMessage:
- [self toMessage];
- break;
- case SPSBMineTableViewRowTypeDiscountCoupon:
- [self toDiscountCoupon];
- break;
- case SPSBMineTableViewRowTypeMail:
- [self toMail];
- break;
- case SPSBMineTableViewRowTypeGuide:
- [self toGuide];
- break;
- case SPSBMineTableViewRowTypeAccountSetting:
- [self toAccountSetting];
- break;
- case SPSBMineTableViewRowTypeHelpAndCustomerService:
- [self toHelpAndCustomerService];
- break;
- case SPSBMineTableViewRowTypeAbout:
- [self toAbout];
- break;
-
- default:
- break;
- }
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
- return jxh_onePixe();
- }
- - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
- return UIView.new;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
- return 12;
- }
- - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
- UIView *footerView = [[UIView alloc] init];
- footerView.backgroundColor = spsb_F5F5F5_color();
- return footerView;
- }
- - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
- if (scrollView.contentOffset.y < 0) {
- scrollView.contentOffset = CGPointMake(0, 0);
- return;
- }
- if (_spsb_scrollAction) {
- _spsb_scrollAction(scrollView.contentOffset.y);
- }
- }
- #pragma mark - UI
- - (void)setupTableView {
- self.tableView.rowHeight = 50.f;
- }
- @end
|