Commit 59d665b2 authored by Sandy's avatar Sandy

bug fix

parent 5572cc93
......@@ -81,6 +81,9 @@
8F973C271F21FD54003D3ADB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8F973BF01F21F6DD003D3ADB /* Main.storyboard */; };
8F973C321F21FE32003D3ADB /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8F973C2F1F21FE32003D3ADB /* AppDelegate.m */; };
8F973C341F21FE32003D3ADB /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8F973C301F21FE32003D3ADB /* main.m */; };
8FC2BE8F1F39AC270023FA6B /* SaleInputListViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8FC2BE8E1F39AC270023FA6B /* SaleInputListViewModel.m */; };
8FC2BE941F39AC430023FA6B /* ico_make.png in Resources */ = {isa = PBXBuildFile; fileRef = 8FC2BE911F39AC430023FA6B /* ico_make.png */; };
8FC2BE951F39AC430023FA6B /* JSDropDownMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = 8FC2BE931F39AC430023FA6B /* JSDropDownMenu.m */; };
8FED0FB41F38602F004916CC /* AboutTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8FED0FB31F38602F004916CC /* AboutTableViewController.m */; };
8FEF5E641F285E56001496E3 /* CALayer+Addtions.m in Sources */ = {isa = PBXBuildFile; fileRef = 8FEF5E481F285E56001496E3 /* CALayer+Addtions.m */; };
8FEF5E661F285E56001496E3 /* ChineseLogHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 8FEF5E4A1F285E56001496E3 /* ChineseLogHelper.m */; };
......@@ -267,6 +270,11 @@
8F973C2E1F21FE32003D3ADB /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
8F973C2F1F21FE32003D3ADB /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
8F973C301F21FE32003D3ADB /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
8FC2BE8D1F39AC270023FA6B /* SaleInputListViewModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SaleInputListViewModel.h; sourceTree = "<group>"; };
8FC2BE8E1F39AC270023FA6B /* SaleInputListViewModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SaleInputListViewModel.m; sourceTree = "<group>"; };
8FC2BE911F39AC430023FA6B /* ico_make.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = ico_make.png; sourceTree = "<group>"; };
8FC2BE921F39AC430023FA6B /* JSDropDownMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDropDownMenu.h; sourceTree = "<group>"; };
8FC2BE931F39AC430023FA6B /* JSDropDownMenu.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSDropDownMenu.m; sourceTree = "<group>"; };
8FED0FB21F38602F004916CC /* AboutTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AboutTableViewController.h; sourceTree = "<group>"; };
8FED0FB31F38602F004916CC /* AboutTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AboutTableViewController.m; sourceTree = "<group>"; };
8FEF5E471F285E56001496E3 /* CALayer+Addtions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CALayer+Addtions.h"; sourceTree = "<group>"; };
......@@ -680,6 +688,8 @@
8F4BFCE71F2F07C1003EA16B /* SaleInputViewModel.m */,
8FF9F6E11F347517006B0EC0 /* SaleInputState.h */,
8FF9F6E21F347517006B0EC0 /* SaleInputState.m */,
8FC2BE8D1F39AC270023FA6B /* SaleInputListViewModel.h */,
8FC2BE8E1F39AC270023FA6B /* SaleInputListViewModel.m */,
);
path = ViewModels;
sourceTree = "<group>";
......@@ -788,6 +798,7 @@
8F973C041F21FB67003D3ADB /* Tools */ = {
isa = PBXGroup;
children = (
8FC2BE901F39AC430023FA6B /* JSDropDownMenu */,
8FF9F6E71F37FF6C006B0EC0 /* CustomMMSpreadSheetView */,
8F4BFCF51F2F3238003EA16B /* PictureTableViewCell */,
8F6C923F1F2AE4AD0060E983 /* LocationHelper */,
......@@ -965,6 +976,16 @@
path = ..;
sourceTree = "<group>";
};
8FC2BE901F39AC430023FA6B /* JSDropDownMenu */ = {
isa = PBXGroup;
children = (
8FC2BE911F39AC430023FA6B /* ico_make.png */,
8FC2BE921F39AC430023FA6B /* JSDropDownMenu.h */,
8FC2BE931F39AC430023FA6B /* JSDropDownMenu.m */,
);
path = JSDropDownMenu;
sourceTree = "<group>";
};
8FEF5E461F285E56001496E3 /* Category */ = {
isa = PBXGroup;
children = (
......@@ -1132,6 +1153,7 @@
buildActionMask = 2147483647;
files = (
8F973C251F21FD54003D3ADB /* LaunchScreen.storyboard in Resources */,
8FC2BE941F39AC430023FA6B /* ico_make.png in Resources */,
8F250D2F1F297DA80031B4BC /* restrictedshine.tiff in Resources */,
8F250D2D1F297DA80031B4BC /* mask.jpg in Resources */,
8F4BFCC71F2EDCD8003EA16B /* BusinessItems.plist in Resources */,
......@@ -1211,6 +1233,7 @@
8F6C92381F2ADF4F0060E983 /* HomeWeatherBoard.m in Sources */,
8F250D961F29D86E0031B4BC /* ZJPermissionManager.m in Sources */,
8F4BFD061F2F3314003EA16B /* GalleryCollectionViewCell.m in Sources */,
8FC2BE8F1F39AC270023FA6B /* SaleInputListViewModel.m in Sources */,
8F250D921F29D4B40031B4BC /* UserInfo.m in Sources */,
8F1040B91F25C8A000B4C16E /* MineTableViewController.m in Sources */,
8F6C923B1F2ADFEC0060E983 /* WeatherModel.m in Sources */,
......@@ -1272,6 +1295,7 @@
8FF9F7021F37FF6C006B0EC0 /* MMTopRowCell.m in Sources */,
8F250D271F297DA80031B4BC /* XWInteractiveTransition.m in Sources */,
8F250D391F297DA80031B4BC /* XWCoolAnimator+XWMiddlePageFlip.m in Sources */,
8FC2BE951F39AC430023FA6B /* JSDropDownMenu.m in Sources */,
8FF9F7031F37FF6C006B0EC0 /* MMViewController.m in Sources */,
8F250D531F297DA80031B4BC /* XWFilterAnimator+XWRipple.m in Sources */,
8F4BFCD61F2EF56A003EA16B /* SaleInputListTableViewCell.m in Sources */,
......
......@@ -22,7 +22,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="159" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="AOL-sy-21t">
<rect key="frame" x="0.0" y="20" width="375" height="647"/>
<rect key="frame" x="0.0" y="64" width="375" height="603"/>
<color key="backgroundColor" red="0.90188914539999998" green="0.89984929560000004" blue="0.93195199969999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<inset key="separatorInset" minX="15" minY="0.0" maxX="0.0" maxY="0.0"/>
<prototypes>
......@@ -196,7 +196,7 @@
<constraints>
<constraint firstAttribute="trailing" secondItem="aQG-ol-2ju" secondAttribute="trailing" constant="30" id="3C9-JN-WBq"/>
<constraint firstAttribute="trailing" secondItem="AOL-sy-21t" secondAttribute="trailing" id="Kdx-SC-TsM"/>
<constraint firstItem="AOL-sy-21t" firstAttribute="top" secondItem="fKx-QB-8T3" secondAttribute="bottom" id="QOO-8v-8hV"/>
<constraint firstItem="AOL-sy-21t" firstAttribute="top" secondItem="fKx-QB-8T3" secondAttribute="bottom" constant="44" id="QOO-8v-8hV"/>
<constraint firstItem="AOL-sy-21t" firstAttribute="leading" secondItem="j2C-xo-rlz" secondAttribute="leading" id="iu7-Rm-0Jn"/>
<constraint firstAttribute="bottom" secondItem="aQG-ol-2ju" secondAttribute="bottom" constant="30" id="mt7-Yx-faA"/>
<constraint firstItem="dCI-SM-A4p" firstAttribute="top" secondItem="AOL-sy-21t" secondAttribute="bottom" id="wkx-IT-CW7"/>
......@@ -1346,7 +1346,7 @@
<color key="textColor" red="1" green="0.9999405146" blue="0.99998033050000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="商铺" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tk7-yh-1u7">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="合同" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tk7-yh-1u7">
<rect key="frame" x="32" y="31" width="37" height="22"/>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<color key="textColor" red="1" green="0.9999405146" blue="0.99998033050000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
......
......@@ -24,4 +24,5 @@
- (void)httpPayments;
- (void)allInputMoney;
- (IBAction)actionSubmit:(id)sender;
@end
......@@ -18,9 +18,10 @@
[super viewDidLoad];
self.title = @"新建销售录入";
self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 84, 0);
UIBarButtonItem *rightBtn = [[UIBarButtonItem alloc] initWithTitle:@"历史查询" style:UIBarButtonItemStylePlain target:self action:@selector(actionGoHistory)];
UIBarButtonItem *rightBtn = [[UIBarButtonItem alloc] initWithTitle:@"历史" style:UIBarButtonItemStylePlain target:self action:@selector(actionGoHistory)];
self.navigationItem.rightBarButtonItem = rightBtn;
[self httpPayments];
}
......@@ -104,13 +105,16 @@
- (IBAction)actionSubmit:(id)sender {
self.viewModel.request.saleCount = @(self.totalView.textFieldBillCount.text.integerValue);
self.viewModel.request.contract = self.topView.contract;
self.viewModel.request.saleDate = self.topView.textFieldDate.text;
WS(weakSelf);
//赋值
kCanNotBeNil(self.viewModel.request.contract, @"请选择合同");
kCanNotBeNil(self.viewModel.request.contract, @"请选择合同!");
[self alertTitle:@"温馨提示" msg:@"确认提交?" okAction:^(UIAlertAction * _Nullable action) {
NSString *msg = [NSString stringWithFormat:@"销售日期:%@\n总金额: %@\n\n确认提交?",self.topView.textFieldDate.text, self.totalView.labelTotal.text];
[self alertTitle:@"温馨提示" msg:msg okAction:^(UIAlertAction * _Nullable action) {
[weakSelf.viewModel httpSubmit:^(BOOL isSuccess) {
if (isSuccess) {
weakSelf.commplete();
[weakSelf.navigationController popViewControllerAnimated:YES];
}
}];
......
......@@ -23,7 +23,7 @@
self.topView.right2.hidden = YES;
self.topView.userInteractionEnabled = NO;
self.totalView.textFieldBillCount.userInteractionEnabled = NO;
self.btnBottom.hidden = YES;
[self.btnBottom setTitle:@"返回" forState:UIControlStateNormal];
self.title = @"销售录入详情";
WS(weakSelf);
[self.viewModel httpDetailWithUuid:self.listModel.billNumber callBack:^(BOOL isSuccess) {
......@@ -46,6 +46,10 @@
CLog(@"空实现父类httpPayments方法");
}
- (IBAction)actionSubmit:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
......
......@@ -12,8 +12,11 @@
#import "HMSaleInputDetail.h"
#import "SaleInputDetailViewController.h"
#import "HMSaleInputQuery.h"
#import "JSDropDownMenu.h"
#import "SaleInputListViewModel.h"
@interface SaleInputListViewController ()
@property (strong, nonatomic) HMSaleInputQuery *query;
@property (strong, nonatomic) SaleInputListViewModel *viewModel;
@end
......@@ -26,6 +29,23 @@
[self refresh];
self.tableView.rowHeight = 159;
self.btnAdd.hidden = !AppGlobal.permission.saleinput.newField;
[self configDropMenu];
}
- (void)configDropMenu {
JSDropDownMenu *menu = [[JSDropDownMenu alloc] initWithOrigin:CGPointMake(0, 0) andHeight:45];
menu.indicatorColor = [UIColor colorWithRed:175.0f / 255.0f green:175.0f / 255.0f blue:175.0f / 255.0f alpha:1.0];
menu.separatorColor = [UIColor colorWithRed:210.0f / 255.0f green:210.0f / 255.0f blue:210.0f / 255.0f alpha:1.0];
menu.textColor = [UIColor colorWithRed:83.f / 255.0f green:83.f / 255.0f blue:83.f / 255.0f alpha:1.0f];
menu.dataSource = self.viewModel;
menu.delegate = self.viewModel;
[self.view addSubview:menu];
WS(weakSelf);
self.viewModel.blockRequest = ^{
weakSelf.page = 1;
[weakSelf httpRequest];
};
}
- (void)viewWillAppear:(BOOL)animated {
......@@ -34,16 +54,14 @@
}
- (void)httpRequest {
self.query.contracts = [AppGlobal getUserContractUuids];
self.query.page = @(self.page);
self.query.pageSize = @(self.pageSize);
self.query.dateRange = [HMSaleInputQuery_dateRange new];
self.query.dateRange.beginDate = @"2016-07-12";
self.query.dateRange.endDate = [NSDate date].yearMonthDayString;
self.viewModel.query.page = @(self.page);
self.viewModel.query.pageSize = @(self.pageSize);
WS(weakSelf);
[ZJHttpManager POST:@"hdmall/salesinput/query" parameters:self.query.toDictionary complete:^(id responseObject, NSError *error) {
[MBProgressHUD j_loading];
[ZJHttpManager POST:@"hdmall/salesinput/query" parameters:self.viewModel.query.toDictionary complete:^(id responseObject, NSError *error) {
[MBProgressHUD j_hideLoadingView];
if (kIsResponse) {
if (weakSelf.page == 0) {
if (weakSelf.page == 1) {
[weakSelf.arrData removeAllObjects];
}
......@@ -75,25 +93,14 @@
- (void)actionAdd:(UIButton *)sender {
SaleInputAddViewController *addVC = [SaleInputAddViewController viewControllerWithStoryBoardType:STORYBOARD_TYPE_SALEINPUT];
WS(weakSelf);
addVC.commplete = ^{
weakSelf.page = 1;
[weakSelf httpRequest];
};
[self listPushCustomAnimate:addVC];
}
ZJLazy(HMSaleInputQuery, query);
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
ZJLazy(SaleInputListViewModel, viewModel);
@end
//
// SaleInputListViewModel.h
// HDMall
//
// Created by Javen on 2017/8/8.
// Copyright © 2017年 上海勾芒信息科技. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "JSDropDownMenu.h"
#import "HMSaleInputQuery.h"
#import "SaleInputState.h"
@interface SaleInputListViewModel : NSObject<JSDropDownMenuDataSource, JSDropDownMenuDelegate>
@property (strong, nonatomic) NSArray *arrDropMenu;
@property (strong, nonatomic) NSArray *arrDateTitles;
@property (strong, nonatomic) NSArray *arrStateTitles;
@property (assign, nonatomic) NSInteger dateTag;
@property (assign, nonatomic) NSInteger stateTag;
@property (strong, nonatomic) HMSaleInputQuery *query;
@property (copy, nonatomic) void (^blockRequest)(void);
@end
//
// SaleInputListViewModel.m
// HDMall
//
// Created by Javen on 2017/8/8.
// Copyright © 2017年 上海勾芒信息科技. All rights reserved.
//
#import "SaleInputListViewModel.h"
#import "NSDate+Additions.h"
#define KDateRangeTypeWeek @"最近一周"
#define KDateRangeTypeOneMonth @"最近一月"
#define KDateRangeTypeThreeMonth @"最近三月"
@implementation SaleInputListViewModel
- (instancetype)init {
self = [super init];
if (self) {
self.arrDateTitles = @[KDateRangeTypeWeek, KDateRangeTypeOneMonth, KDateRangeTypeThreeMonth];
self.arrStateTitles = @[@"全部",@"未生效", @"已生效"];
self.arrDropMenu = @[self.arrDateTitles, self.arrStateTitles];
//第一次请求,默认是最近一周
NSDate *end = [NSDate date];
NSDate *begin = [NSDate dateWithTimeInterval:-7 * 24 * 60 * 60 sinceDate:end];
self.query.contracts = [AppGlobal getUserContractUuids];
self.query.dateRange = [HMSaleInputQuery_dateRange new];
self.query.dateRange.beginDate = begin.yearMonthDayString;
self.query.dateRange.endDate = end.yearMonthDayString;
}
return self;
}
- (NSInteger)numberOfColumnsInMenu:(JSDropDownMenu *)menu {
return 2;
}
- (NSInteger)menu:(JSDropDownMenu *)menu numberOfRowsInColumn:(NSInteger)column leftOrRight:(NSInteger)leftOrRight leftRow:(NSInteger)leftRow {
return [self.arrDropMenu[column] count];
}
- (NSString *)menu:(JSDropDownMenu *)menu titleForColumn:(NSInteger)column {
return [self.arrDropMenu[column] firstObject];
}
- (NSString *)menu:(JSDropDownMenu *)menu titleForRowAtIndexPath:(JSIndexPath *)indexPath {
return [self.arrDropMenu[indexPath.column] objectAtIndex:indexPath.row];
}
- (BOOL)haveRightTableViewInColumn:(NSInteger)column {
return NO;
}
- (CGFloat)widthRatioOfLeftColumn:(NSInteger)column {
return 1;
}
- (NSInteger)currentLeftSelectedRow:(NSInteger)column {
if (column == 0) {
return self.dateTag;
} else {
return self.stateTag;
}
}
- (void)menu:(JSDropDownMenu *)menu didSelectRowAtIndexPath:(JSIndexPath *)indexPath {
NSString *title = [self.arrDropMenu[indexPath.column] objectAtIndex:indexPath.row];
if (indexPath.column == 0) {
self.dateTag = indexPath.row;
NSDate *end = [NSDate date];
NSDate *begin = nil;
if ([title isEqualToString:KDateRangeTypeWeek]) {
begin = [NSDate dateWithTimeInterval:-7 * 24 * 60 * 60 sinceDate:end];
}else if ([title isEqualToString:KDateRangeTypeOneMonth]){
begin = [NSDate dateWithTimeInterval:-30 * 24 * 60 * 60 sinceDate:end];
}else if ([title isEqualToString:KDateRangeTypeThreeMonth]){
begin = [NSDate dateWithTimeInterval:-90 * 24 * 60 * 60 sinceDate:end];
}
self.query.dateRange.beginDate = begin.yearMonthDayString;
self.query.dateRange.endDate = end.yearMonthDayString;
} else {
self.stateTag = indexPath.row;
if (indexPath.row == 0) {
self.query.state = nil;
}else{
self.query.state = [SaleInputState stateWithText:title].code;
}
}
self.blockRequest();
}
ZJLazy(HMSaleInputQuery, query);
@end
......@@ -20,5 +20,7 @@
*/
@property (strong, nonatomic) NSDictionary *dicData;
//+ (SaleInputState *)stateWithText:(NSString *)text;
+ (SaleInputState *)stateWithText:(NSString *)text;
+ (NSArray *)allStateCodes;
@end
......@@ -26,4 +26,21 @@
self.text = [[self.dicData objectForKey:code] objectForKey:@"text"];
self.img = [[self.dicData objectForKey:code] objectForKey:@"img"];
}
+ (SaleInputState *)stateWithText:(NSString *)text {
SaleInputState *state = [SaleInputState new];
for (NSString *key in state.dicData.allKeys) {
NSDictionary *dic = [state.dicData objectForKey:key];
if ([[dic objectForKey:@"text"] isEqualToString:text]) {
state.code = key;
break;
}
}
return state;
}
+ (NSArray *)allStateCodes {
SaleInputState *state = [SaleInputState new];
return state.dicData.allKeys;
}
@end
......@@ -41,7 +41,7 @@
self.request.store = [HMSaleInputDetail_store modelWithDic:AppGlobal.user.store.toDictionary];
self.request.receiver = @"contract";
self.request.balance = false;
self.request.saleDate = [[NSDate date] yearMonthDayString];
// self.request.saleDate = [[NSDate date] yearMonthDayString];
self.request.payments = (id)[NSMutableArray array];
for (HMSaleInputDetail_payments *payments in self.arrPayments) {
HMSaleInputDetail_payments *paymentsCopy = [HMSaleInputDetail_payments modelWithDic:payments.toDictionary];
......
......@@ -14,24 +14,43 @@
- (void)awakeFromNib {
[super awakeFromNib];
self.textFieldDate.type = DateTextFieldYearMonthDay;
self.textFieldDate.rangeType = DateTextFieldRangeBefore;
WS(weakSelf);
self.textFieldDate.blockEndEdit = ^{
kCanNotBeNil(weakSelf.contract.uuid, @"请先选择合同!");
[weakSelf httpToDayData];
};
if (!AppGlobal.isMall) {
self.btnStore.userInteractionEnabled = NO;
self.right1.hidden = YES;
UserInfo_contracts *contract = AppGlobal.user.contracts[0];
self.contract = [HMSaleInputDetail_contract modelWithDic:contract.toDictionary];
[self.btnStore setTitle:contract.name forState:UIControlStateNormal];
[self actionContract:nil];
}
//如果是每天早晨11点之前进入销售录入页面,则显示日期为昨天
NSDate *dateNow = [NSDate date];
//时间点字符串
NSString *point = [dateNow.yearMonthDayString stringByAppendingString:@" 11:00:00"];
NSDateFormatter *f = [NSDateFormatter new];
[f setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDate *datePoint = [f dateFromString:point];
NSComparisonResult result = [dateNow compare:datePoint];
if (result == NSOrderedAscending) {//小于
NSDate *yesterDay = [NSDate dateWithTimeInterval:- 24 * 60 * 60 sinceDate:dateNow];
self.textFieldDate.text = yesterDay.yearMonthDayString;
}else{
self.textFieldDate.text = [dateNow yearMonthDayString];
}
self.textFieldDate.type = DateTextFieldYearMonthDay;
self.textFieldDate.rangeType = DateTextFieldRangeBefore;
WS(weakSelf);
self.textFieldDate.blockEndEdit = ^{
[weakSelf httpToDayData];
};
}
- (IBAction)actionContract:(id)sender {
if (AppGlobal.user.contracts.count == 1) {
UserInfo_contracts *contract = AppGlobal.user.contracts[0];
if (!AppGlobal.isMall) {
UserInfo_contracts *contract = [AppGlobal getTenantContract];
self.contract = [HMSaleInputDetail_contract modelWithDic:contract.toDictionary];
[self.btnStore setTitle:contract.name forState:UIControlStateNormal];
[self httpToDayData];
......@@ -39,7 +58,8 @@
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"选择合同" message:nil preferredStyle:(UIAlertControllerStyleAlert)];
for (UserInfo_contracts *contract in AppGlobal.user.contracts) {
UIAlertAction *action = [UIAlertAction actionWithTitle:contract.name style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSString *title = [NSString stringWithFormat:@"%@【%@】", contract.name, contract.code];
UIAlertAction *action = [UIAlertAction actionWithTitle:title style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
self.contract = [HMSaleInputDetail_contract modelWithDic:contract.toDictionary];
[self.btnStore setTitle:contract.name forState:UIControlStateNormal];
[self httpToDayData];
......@@ -58,7 +78,9 @@
* 获取今日的销售录入数据
*/
- (void)httpToDayData {
kCanNotBeNil(self.contract.uuid, @"请选择合同!");
if (self.contract == nil) {
return;
}
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:self.contract.uuid, @"contract", [NSDictionary dictionaryWithObjectsAndKeys:[self.textFieldDate.text stringByAppendingString:@" 00:00:00"], @"beginDate", [self.textFieldDate.text stringByAppendingString:@" 23:59:59"], @"endDate", nil], @"dateRange", nil];
[MBProgressHUD j_loading];
WS(weakSelf);
......
......@@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.0.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
......
......@@ -145,7 +145,7 @@
}
- (void)listTableViewReloadData {
[MBProgressHUD j_hideLoadingView];
// [MBProgressHUD j_hideLoadingView];
self.tableView.emptyDataSetSource = self;
self.tableView.emptyDataSetDelegate = self;
[self.tableView reloadData];
......
......@@ -114,4 +114,5 @@ typedef NS_ENUM(NSInteger, STORYBOARD_TYPE_) {
*/
- (void)hasPermission:(BOOL)permission yes:(void (^__nonnull)(void))yes no:(void (^__nonnull)(void))no;
+ (UIViewController *_Nullable)getCurrentVC;
@end
......@@ -151,4 +151,43 @@
return [numberPre evaluateWithObject:futureString];
}
//获取当前屏幕显示的viewcontroller
+ (UIViewController *)getCurrentVC
{
UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
UIViewController *currentVC = [self getCurrentVCFrom:rootViewController];
return currentVC;
}
+ (UIViewController *)getCurrentVCFrom:(UIViewController *)rootVC
{
UIViewController *currentVC;
if ([rootVC presentedViewController]) {
// 视图是被presented出来的
rootVC = [rootVC presentedViewController];
}
if ([rootVC isKindOfClass:[UITabBarController class]]) {
// 根视图为UITabBarController
currentVC = [self getCurrentVCFrom:[(UITabBarController *)rootVC selectedViewController]];
} else if ([rootVC isKindOfClass:[UINavigationController class]]){
// 根视图为UINavigationController
currentVC = [self getCurrentVCFrom:[(UINavigationController *)rootVC visibleViewController]];
} else {
// 根视图为非导航类
currentVC = rootVC;
}
return currentVC;
}
@end
//
// JSDropDownMenu.h
// JSDropDownMenu
//
// Created by Jsfu on 15-1-12.
// Copyright (c) 2015年 jsfu. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <UIKit/UIKit.h>
@interface JSIndexPath : NSObject
@property (nonatomic, assign) NSInteger column;
// 0 左边 1 右边
@property (nonatomic, assign) NSInteger leftOrRight;
// 左边行
@property (nonatomic, assign) NSInteger leftRow;
// 右边行
@property (nonatomic, assign) NSInteger row;
- (instancetype)initWithColumn:(NSInteger)column leftOrRight:(NSInteger)leftOrRight leftRow:(NSInteger)leftRow row:(NSInteger)row;
+ (instancetype)indexPathWithCol:(NSInteger)col leftOrRight:(NSInteger)leftOrRight leftRow:(NSInteger)leftRow row:(NSInteger)row;
@end
#pragma mark - data source protocol
@class JSDropDownMenu;
@protocol JSDropDownMenuDataSource <NSObject>
@required
- (NSInteger)menu:(JSDropDownMenu *)menu numberOfRowsInColumn:(NSInteger)column leftOrRight:(NSInteger)leftOrRight leftRow:(NSInteger)leftRow;
- (NSString *)menu:(JSDropDownMenu *)menu titleForRowAtIndexPath:(JSIndexPath *)indexPath;
- (NSString *)menu:(JSDropDownMenu *)menu titleForColumn:(NSInteger)column;
/**
* 表视图显示时,左边表显示比例
*/
- (CGFloat)widthRatioOfLeftColumn:(NSInteger)column;
/**
* 表视图显示时,是否需要两个表显示
*/
- (BOOL)haveRightTableViewInColumn:(NSInteger)column;
/**
* 返回当前菜单左边表选中行
*/
- (NSInteger)currentLeftSelectedRow:(NSInteger)column;
@optional
//default value is 1
- (NSInteger)numberOfColumnsInMenu:(JSDropDownMenu *)menu;
/**
* 是否需要显示为UICollectionView 默认为否
*/
- (BOOL)displayByCollectionViewInColumn:(NSInteger)column;
@end
#pragma mark - delegate
@protocol JSDropDownMenuDelegate <NSObject>
@optional
- (void)menu:(JSDropDownMenu *)menu didSelectRowAtIndexPath:(JSIndexPath *)indexPath;
- (void)menu:(JSDropDownMenu *)menu didTapMenuAtIndex:(NSInteger)index;
@end
#pragma mark - interface
@interface JSDropDownMenu : UIView <UITableViewDataSource, UITableViewDelegate, UICollectionViewDataSource, UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
@property (nonatomic, weak) id <JSDropDownMenuDataSource> dataSource;
@property (nonatomic, weak) id <JSDropDownMenuDelegate> delegate;
@property (nonatomic, strong) UIColor *indicatorColor;
@property (nonatomic, strong) UIColor *textColor;
@property (nonatomic, strong) UIColor *separatorColor;
@property (nonatomic, copy) void (^blockTapMenu)(NSInteger index);
/**
* the width of menu will be set to screen width defaultly
*
* @param origin the origin of this view's frame
* @param height menu's height
*
* @return menu
*/
- (instancetype)initWithOrigin:(CGPoint)origin andHeight:(CGFloat)height;
- (NSString *)titleForRowAtIndexPath:(JSIndexPath *)indexPath;
- (void)updateMenuTitle:(NSString *)string;
- (void)backgroundTapped:(UITapGestureRecognizer *)paramSender;
@end
//
// JSDropDownMenu.m
// JSDropDownMenu
//
// Created by Jsfu on 15-1-12.
// Copyright (c) 2015年 jsfu. All rights reserved.
//
#import "JSDropDownMenu.h"
#define BackColor [UIColor colorWithRed:244.0f/255.0f green:244.0f/255.0f blue:244.0f/255.0f alpha:1.0]
// 选中颜色加深
#define SelectColor [UIColor colorWithRed:238.0f/255.0f green:238.0f/255.0f blue:238.0f/255.0f alpha:1.0]
@interface NSString (Size)
- (CGSize)textSizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(NSLineBreakMode)lineBreakMode;
@end
@implementation NSString (Size)
- (CGSize)textSizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(NSLineBreakMode)lineBreakMode
{
CGSize textSize;
if (CGSizeEqualToSize(size, CGSizeZero))
{
NSDictionary *attributes = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
textSize = [self sizeWithAttributes:attributes];
}
else
{
NSStringDrawingOptions option = NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading;
//NSStringDrawingTruncatesLastVisibleLine如果文本内容超出指定的矩形限制,文本将被截去并在最后一个字符后加上省略号。 如果指定了NSStringDrawingUsesLineFragmentOrigin选项,则该选项被忽略 NSStringDrawingUsesFontLeading计算行高时使用行间距。(字体大小+行间距=行高)
NSDictionary *attributes = [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
CGRect rect = [self boundingRectWithSize:size
options:option
attributes:attributes
context:nil];
textSize = rect.size;
}
return textSize;
}
@end
@interface JSCollectionViewCell:UICollectionViewCell
@property(nonatomic,strong) UILabel *textLabel;
@property(nonatomic,strong) UIImageView *accessoryView;
-(void)removeAccessoryView;
@end
@implementation JSCollectionViewCell
-(instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
_textLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
_textLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:_textLabel];
}
return self;
}
-(void)setAccessoryView:(UIImageView *)accessoryView{
[self removeAccessoryView];
_accessoryView = accessoryView;
_accessoryView.frame = CGRectMake(self.frame.size.width-10-16, (self.frame.size.height-12)/2, 16, 12);
[self addSubview:_accessoryView];
}
-(void)removeAccessoryView{
if(_accessoryView){
[_accessoryView removeFromSuperview];
}
}
@end
@interface JSTableViewCell : UITableViewCell
@property(nonatomic,readonly) UILabel *cellTextLabel;
@property(nonatomic,strong) UIImageView *cellAccessoryView;
-(void)setCellText:(NSString *)text align:(NSString*)align;
@end
@implementation JSTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
_cellTextLabel = [[UILabel alloc] init];
_cellTextLabel.textAlignment = NSTextAlignmentCenter;
_cellTextLabel.font = [UIFont systemFontOfSize:14.0f];
[self addSubview:_cellTextLabel];
}
return self;
}
-(void)setCellText:(NSString *)text align:(NSString*)align{
_cellTextLabel.text = text;
// 只取宽度
CGSize textSize = [text textSizeWithFont:[UIFont systemFontOfSize:14.0f] constrainedToSize:CGSizeMake(MAXFLOAT, 14) lineBreakMode:NSLineBreakByWordWrapping];
// CGSize textSize = [text sizeWithFont:[UIFont systemFontOfSize:14.0f] constrainedToSize:CGSizeMake(MAXFLOAT, 14)];
CGFloat marginX = 20;
if (![@"left" isEqualToString:align]) {
marginX = (self.frame.size.width-textSize.width)/2;
}
_cellTextLabel.frame = CGRectMake(marginX, 0, textSize.width, self.frame.size.height);
if(_cellAccessoryView){
_cellAccessoryView.frame = CGRectMake(_cellTextLabel.frame.origin.x+_cellTextLabel.frame.size.width+10, (self.frame.size.height-12)/2, 16, 12);
}
}
-(void)setCellAccessoryView:(UIImageView *)accessoryView{
if (_cellAccessoryView) {
[_cellAccessoryView removeFromSuperview];
}
_cellAccessoryView = accessoryView;
_cellAccessoryView.frame = CGRectMake(_cellTextLabel.frame.origin.x+_cellTextLabel.frame.size.width+10, (self.frame.size.height-12)/2, 16, 12);
[self addSubview:_cellAccessoryView];
}
@end
@implementation JSIndexPath
- (instancetype)initWithColumn:(NSInteger)column leftOrRight:(NSInteger)leftOrRight leftRow:(NSInteger)leftRow row:(NSInteger)row {
self = [super init];
if (self) {
_column = column;
_leftOrRight = leftOrRight;
_leftRow = leftRow;
_row = row;
}
return self;
}
+ (instancetype)indexPathWithCol:(NSInteger)col leftOrRight:(NSInteger)leftOrRight leftRow:(NSInteger)leftRow row:(NSInteger)row {
JSIndexPath *indexPath = [[self alloc] initWithColumn:col leftOrRight:leftOrRight leftRow:leftRow row:row];
return indexPath;
}
@end
#pragma mark - menu implementation
@interface JSDropDownMenu ()
@property (nonatomic, assign) NSInteger currentSelectedMenudIndex;
@property (nonatomic, assign) BOOL show;
@property (nonatomic, assign) NSInteger numOfMenu;
@property (nonatomic, assign) CGPoint origin;
@property (nonatomic, strong) UIView *backGroundView;
@property (nonatomic, strong) UIView *bottomShadow;
@property (nonatomic, strong) UITableView *leftTableView;
@property (nonatomic, strong) UITableView *rightTableView;
@property (nonatomic, strong) UICollectionView *collectionView;
//data source
@property (nonatomic, copy) NSArray *array;
//layers array
@property (nonatomic, copy) NSArray *titles;
@property (nonatomic, copy) NSArray *indicators;
@property (nonatomic, copy) NSArray *bgLayers;
@property (nonatomic, assign) NSInteger leftSelectedRow;
@property (nonatomic, assign) BOOL hadSelected;
@end
@implementation JSDropDownMenu
- (void)removeFromSuperview
{
[super removeFromSuperview];
[self.backGroundView removeFromSuperview];
[self.bottomShadow removeFromSuperview];
[self.leftTableView removeFromSuperview];
[self.rightTableView removeFromSuperview];
[self.collectionView removeFromSuperview];
}
#pragma mark - getter
- (UIColor *)indicatorColor {
if (!_indicatorColor) {
_indicatorColor = [UIColor blackColor];
}
return _indicatorColor;
}
- (UIColor *)textColor {
if (!_textColor) {
_textColor = [UIColor blackColor];
}
return _textColor;
}
- (UIColor *)separatorColor {
if (!_separatorColor) {
_separatorColor = [UIColor blackColor];
}
return _separatorColor;
}
- (NSString *)titleForRowAtIndexPath:(JSIndexPath *)indexPath {
return [self.dataSource menu:self titleForRowAtIndexPath:indexPath];
}
#pragma mark - setter
- (void)setDataSource:(id<JSDropDownMenuDataSource>)dataSource {
_dataSource = dataSource;
//configure view
if ([_dataSource respondsToSelector:@selector(numberOfColumnsInMenu:)]) {
_numOfMenu = [_dataSource numberOfColumnsInMenu:self];
} else {
_numOfMenu = 1;
}
CGFloat textLayerInterval = self.frame.size.width / ( _numOfMenu * 2);
CGFloat separatorLineInterval = self.frame.size.width / _numOfMenu;
CGFloat bgLayerInterval = self.frame.size.width / _numOfMenu;
NSMutableArray *tempTitles = [[NSMutableArray alloc] initWithCapacity:_numOfMenu];
NSMutableArray *tempIndicators = [[NSMutableArray alloc] initWithCapacity:_numOfMenu];
NSMutableArray *tempBgLayers = [[NSMutableArray alloc] initWithCapacity:_numOfMenu];
for (int i = 0; i < _numOfMenu; i++) {
//bgLayer
CGPoint bgLayerPosition = CGPointMake((i+0.5)*bgLayerInterval, self.frame.size.height/2);
CALayer *bgLayer = [self createBgLayerWithColor:BackColor andPosition:bgLayerPosition];
[self.layer addSublayer:bgLayer];
[tempBgLayers addObject:bgLayer];
//title
CGPoint titlePosition = CGPointMake( (i * 2 + 1) * textLayerInterval , self.frame.size.height / 2);
NSString *titleString = [_dataSource menu:self titleForColumn:i];
CATextLayer *title = [self createTextLayerWithNSString:titleString withColor:self.textColor andPosition:titlePosition];
[self.layer addSublayer:title];
[tempTitles addObject:title];
//indicator
CAShapeLayer *indicator = [self createIndicatorWithColor:self.indicatorColor andPosition:CGPointMake(titlePosition.x + title.bounds.size.width / 2 + 8, self.frame.size.height / 2)];
[self.layer addSublayer:indicator];
[tempIndicators addObject:indicator];
//separator
if (i != _numOfMenu - 1) {
CGPoint separatorPosition = CGPointMake((i + 1) * separatorLineInterval, self.frame.size.height/2);
CAShapeLayer *separator = [self createSeparatorLineWithColor:self.separatorColor andPosition:separatorPosition];
[self.layer addSublayer:separator];
}
}
_bottomShadow.backgroundColor = self.separatorColor;
_titles = [tempTitles copy];
_indicators = [tempIndicators copy];
_bgLayers = [tempBgLayers copy];
}
#pragma mark - init method
- (instancetype)initWithOrigin:(CGPoint)origin andHeight:(CGFloat)height {
CGSize screenSize = [UIScreen mainScreen].bounds.size;
self = [self initWithFrame:CGRectMake(origin.x, origin.y, screenSize.width, height)];
if (self) {
_origin = origin;
_currentSelectedMenudIndex = -1;
_show = NO;
_hadSelected = NO;
//tableView init
_leftTableView = [[UITableView alloc] initWithFrame:CGRectMake(origin.x, self.frame.origin.y + self.frame.size.height, 0, 0) style:UITableViewStyleGrouped];
_leftTableView.rowHeight = 38;
_leftTableView.separatorColor = [UIColor colorWithRed:220.f/255.0f green:220.f/255.0f blue:220.f/255.0f alpha:1.0];
_leftTableView.dataSource = self;
_leftTableView.delegate = self;
_rightTableView = [[UITableView alloc] initWithFrame:CGRectMake(self.frame.size.width, self.frame.origin.y + self.frame.size.height, 0, 0) style:UITableViewStyleGrouped];
_rightTableView.rowHeight = 38;
_rightTableView.separatorColor = [UIColor colorWithRed:220.f/255.0f green:220.f/255.0f blue:220.f/255.0f alpha:1.0];
_rightTableView.dataSource = self;
_rightTableView.delegate = self;
UICollectionViewFlowLayout *flowLayout=[[UICollectionViewFlowLayout alloc] init];
flowLayout.minimumInteritemSpacing = 0;
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(origin.x, self.frame.origin.y + self.frame.size.height, self.frame.size.width, 0) collectionViewLayout:flowLayout];
[_collectionView registerClass:[JSCollectionViewCell class] forCellWithReuseIdentifier:@"CollectionCell"];
_collectionView.backgroundColor = [UIColor colorWithRed:220.f/255.0f green:220.f/255.0f blue:220.f/255.0f alpha:1.0];
_collectionView.dataSource = self;
_collectionView.delegate = self;
self.autoresizesSubviews = NO;
_leftTableView.autoresizesSubviews = NO;
_rightTableView.autoresizesSubviews = NO;
_collectionView.autoresizesSubviews = NO;
//self tapped
self.backgroundColor = [UIColor whiteColor];
UIGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(menuTapped:)];
[self addGestureRecognizer:tapGesture];
//background init and tapped
_backGroundView = [[UIView alloc] initWithFrame:CGRectMake(origin.x, origin.y, screenSize.width, screenSize.height)];
_backGroundView.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.0];
_backGroundView.opaque = NO;
UIGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(backgroundTapped:)];
[_backGroundView addGestureRecognizer:gesture];
//add bottom shadow
_bottomShadow = [[UIView alloc] initWithFrame:CGRectMake(0, self.frame.size.height-0.5, screenSize.width, 0.5)];
[self addSubview:_bottomShadow];
}
return self;
}
#pragma mark - init support
- (CALayer *)createBgLayerWithColor:(UIColor *)color andPosition:(CGPoint)position {
CALayer *layer = [CALayer layer];
layer.position = position;
layer.bounds = CGRectMake(0, 0, self.frame.size.width/self.numOfMenu, self.frame.size.height-1);
layer.backgroundColor = color.CGColor;
return layer;
}
- (CAShapeLayer *)createIndicatorWithColor:(UIColor *)color andPosition:(CGPoint)point {
CAShapeLayer *layer = [CAShapeLayer new];
UIBezierPath *path = [UIBezierPath new];
[path moveToPoint:CGPointMake(0, 0)];
[path addLineToPoint:CGPointMake(8, 0)];
[path addLineToPoint:CGPointMake(4, 5)];
[path closePath];
layer.path = path.CGPath;
layer.lineWidth = 1.0;
layer.fillColor = color.CGColor;
CGPathRef bound = CGPathCreateCopyByStrokingPath(layer.path, nil, layer.lineWidth, kCGLineCapButt, kCGLineJoinMiter, layer.miterLimit);
layer.bounds = CGPathGetBoundingBox(bound);
CGPathRelease(bound);
layer.position = point;
return layer;
}
- (CAShapeLayer *)createSeparatorLineWithColor:(UIColor *)color andPosition:(CGPoint)point {
CAShapeLayer *layer = [CAShapeLayer new];
UIBezierPath *path = [UIBezierPath new];
[path moveToPoint:CGPointMake(160,0)];
[path addLineToPoint:CGPointMake(160, self.frame.size.height)];
layer.path = path.CGPath;
layer.lineWidth = 1.0;
layer.strokeColor = color.CGColor;
CGPathRef bound = CGPathCreateCopyByStrokingPath(layer.path, nil, layer.lineWidth, kCGLineCapButt, kCGLineJoinMiter, layer.miterLimit);
layer.bounds = CGPathGetBoundingBox(bound);
CGPathRelease(bound);
layer.position = point;
return layer;
}
- (CATextLayer *)createTextLayerWithNSString:(NSString *)string withColor:(UIColor *)color andPosition:(CGPoint)point {
CGSize size = [self calculateTitleSizeWithString:string];
CATextLayer *layer = [CATextLayer new];
CGFloat sizeWidth = (size.width < (self.frame.size.width / _numOfMenu) - 25) ? size.width : self.frame.size.width / _numOfMenu - 25;
layer.bounds = CGRectMake(0, 0, sizeWidth, size.height);
layer.string = string;
layer.fontSize = 14.0;
layer.alignmentMode = kCAAlignmentCenter;
layer.foregroundColor = color.CGColor;
layer.contentsScale = [[UIScreen mainScreen] scale];
layer.position = point;
return layer;
}
- (CGSize)calculateTitleSizeWithString:(NSString *)string
{
CGFloat fontSize = 14.0;
NSDictionary *dic = @{NSFontAttributeName: [UIFont systemFontOfSize:fontSize]};
CGSize size = [string boundingRectWithSize:CGSizeMake(280, 0) options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading attributes:dic context:nil].size;
return size;
}
#pragma mark - gesture handle
- (void)menuTapped:(UITapGestureRecognizer *)paramSender {
CGPoint touchPoint = [paramSender locationInView:self];
//calculate index
NSInteger tapIndex = touchPoint.x / (self.frame.size.width / _numOfMenu);
if ([_delegate respondsToSelector:@selector(menu:didTapMenuAtIndex:)]) {
[_delegate menu:self didTapMenuAtIndex:tapIndex];
}
for (int i = 0; i < _numOfMenu; i++) {
if (i != tapIndex) {
[self animateIndicator:_indicators[i] Forward:NO complete:^{
[self animateTitle:_titles[i] show:NO complete:^{
}];
}];
[(CALayer *)self.bgLayers[i] setBackgroundColor:BackColor.CGColor];
}
}
BOOL displayByCollectionView = NO;
if ([_dataSource respondsToSelector:@selector(displayByCollectionViewInColumn:)]) {
displayByCollectionView = [_dataSource displayByCollectionViewInColumn:tapIndex];
}
if (displayByCollectionView) {
UICollectionView *collectionView = _collectionView;
if (tapIndex == _currentSelectedMenudIndex && _show) {
[self animateIdicator:_indicators[_currentSelectedMenudIndex] background:_backGroundView collectionView:collectionView title:_titles[_currentSelectedMenudIndex] forward:NO complecte:^{
_currentSelectedMenudIndex = tapIndex;
_show = NO;
}];
[(CALayer *)self.bgLayers[tapIndex] setBackgroundColor:BackColor.CGColor];
} else {
_currentSelectedMenudIndex = tapIndex;
[_collectionView reloadData];
if (_currentSelectedMenudIndex!=-1) {
// 需要隐藏tableview
[self animateLeftTableView:_leftTableView rightTableView:_rightTableView show:NO complete:^{
[self animateIdicator:_indicators[tapIndex] background:_backGroundView collectionView:collectionView title:_titles[tapIndex] forward:YES complecte:^{
_show = YES;
}];
}];
} else{
[self animateIdicator:_indicators[tapIndex] background:_backGroundView collectionView:collectionView title:_titles[tapIndex] forward:YES complecte:^{
_show = YES;
}];
}
[(CALayer *)self.bgLayers[tapIndex] setBackgroundColor:SelectColor.CGColor];
}
} else{
BOOL haveRightTableView = [_dataSource haveRightTableViewInColumn:tapIndex];
// UITableView *leftTableView = _leftTableView;
UITableView *rightTableView = nil;
if (haveRightTableView) {
rightTableView = _rightTableView;
// 修改左右tableview显示比例
}
if (tapIndex == _currentSelectedMenudIndex && _show) {
[self animateIdicator:_indicators[_currentSelectedMenudIndex] background:_backGroundView leftTableView:_leftTableView rightTableView:_rightTableView title:_titles[_currentSelectedMenudIndex] forward:NO complecte:^{
_currentSelectedMenudIndex = tapIndex;
_show = NO;
}];
[(CALayer *)self.bgLayers[tapIndex] setBackgroundColor:BackColor.CGColor];
} else {
_hadSelected = NO;
_currentSelectedMenudIndex = tapIndex;
if ([_dataSource respondsToSelector:@selector(currentLeftSelectedRow:)]) {
_leftSelectedRow = [_dataSource currentLeftSelectedRow:_currentSelectedMenudIndex];
}
if (rightTableView) {
[rightTableView reloadData];
}
[_leftTableView reloadData];
CGFloat ratio = [_dataSource widthRatioOfLeftColumn:_currentSelectedMenudIndex];
if (_leftTableView) {
_leftTableView.frame = CGRectMake(_leftTableView.frame.origin.x, self.frame.origin.y + self.frame.size.height, self.frame.size.width*ratio, 0);
}
if (_rightTableView) {
_rightTableView.frame = CGRectMake(_origin.x+_leftTableView.frame.size.width, self.frame.origin.y + self.frame.size.height, self.frame.size.width*(1-ratio), 0);
}
if (_currentSelectedMenudIndex!=-1) {
// 需要隐藏collectionview
[self animateCollectionView:_collectionView show:NO complete:^{
[self animateIdicator:_indicators[tapIndex] background:_backGroundView leftTableView:_leftTableView rightTableView:_rightTableView title:_titles[tapIndex] forward:YES complecte:^{
_show = YES;
}];
}];
} else{
[self animateIdicator:_indicators[tapIndex] background:_backGroundView leftTableView:_leftTableView rightTableView:_rightTableView title:_titles[tapIndex] forward:YES complecte:^{
_show = YES;
}];
}
[(CALayer *)self.bgLayers[tapIndex] setBackgroundColor:SelectColor.CGColor];
}
}
}
- (void)backgroundTapped:(UITapGestureRecognizer *)paramSender
{
BOOL displayByCollectionView = NO;
if ([_dataSource respondsToSelector:@selector(displayByCollectionViewInColumn:)]) {
displayByCollectionView = [_dataSource displayByCollectionViewInColumn:_currentSelectedMenudIndex];
}
if (displayByCollectionView) {
[self animateIdicator:_indicators[_currentSelectedMenudIndex] background:_backGroundView collectionView:_collectionView title:_titles[_currentSelectedMenudIndex] forward:NO complecte:^{
_show = NO;
}];
} else{
[self animateIdicator:_indicators[_currentSelectedMenudIndex] background:_backGroundView leftTableView:_leftTableView rightTableView:_rightTableView title:_titles[_currentSelectedMenudIndex] forward:NO complecte:^{
_show = NO;
}];
}
[(CALayer *)self.bgLayers[_currentSelectedMenudIndex] setBackgroundColor:BackColor.CGColor];
}
#pragma mark - animation method
- (void)animateIndicator:(CAShapeLayer *)indicator Forward:(BOOL)forward complete:(void(^)())complete {
[CATransaction begin];
[CATransaction setAnimationDuration:0.25];
[CATransaction setAnimationTimingFunction:[CAMediaTimingFunction functionWithControlPoints:0.4 :0.0 :0.2 :1.0]];
CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation"];
anim.values = forward ? @[ @0, @(M_PI) ] : @[ @(M_PI), @0 ];
if (!anim.removedOnCompletion) {
[indicator addAnimation:anim forKey:anim.keyPath];
} else {
[indicator addAnimation:anim forKey:anim.keyPath];
[indicator setValue:anim.values.lastObject forKeyPath:anim.keyPath];
}
[CATransaction commit];
complete();
}
- (void)animateBackGroundView:(UIView *)view show:(BOOL)show complete:(void(^)())complete {
if (show) {
[self.superview addSubview:view];
[view.superview addSubview:self];
[UIView animateWithDuration:0.2 animations:^{
view.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3];
}];
} else {
[UIView animateWithDuration:0.2 animations:^{
view.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.0];
} completion:^(BOOL finished) {
[view removeFromSuperview];
}];
}
complete();
}
/**
*动画显示下拉菜单
*/
- (void)animateLeftTableView:(UITableView *)leftTableView rightTableView:(UITableView *)rightTableView show:(BOOL)show complete:(void(^)())complete {
CGFloat ratio = [_dataSource widthRatioOfLeftColumn:_currentSelectedMenudIndex];
NSInteger rowMaxNumber = (kHeight - 128)/ 38;
if (show) {
CGFloat leftTableViewHeight = 0;
CGFloat rightTableViewHeight = 0;
if (leftTableView) {
leftTableView.frame = CGRectMake(_origin.x, self.frame.origin.y + self.frame.size.height, self.frame.size.width*ratio, 0);
[self.superview addSubview:leftTableView];
leftTableViewHeight = ([leftTableView numberOfRowsInSection:0] > rowMaxNumber) ? (rowMaxNumber * leftTableView.rowHeight) : ([leftTableView numberOfRowsInSection:0] * leftTableView.rowHeight);
}
if([self.dataSource haveRightTableViewInColumn:_currentSelectedMenudIndex]){
if (rightTableView) {
rightTableView.frame = CGRectMake(_origin.x+leftTableView.frame.size.width, self.frame.origin.y + self.frame.size.height, self.frame.size.width*(1-ratio), 0);
[self.superview addSubview:rightTableView];
rightTableViewHeight = ([rightTableView numberOfRowsInSection:0] > rowMaxNumber) ? (rowMaxNumber * rightTableView.rowHeight) : ([rightTableView numberOfRowsInSection:0] * rightTableView.rowHeight);
}
}
CGFloat tableViewHeight = MAX(leftTableViewHeight, rightTableViewHeight);
[UIView animateWithDuration:0.2 animations:^{
if (leftTableView) {
leftTableView.frame = CGRectMake(_origin.x, self.frame.origin.y + self.frame.size.height, self.frame.size.width*ratio, tableViewHeight);
}
if (rightTableView) {
rightTableView.frame = CGRectMake(_origin.x+leftTableView.frame.size.width, self.frame.origin.y + self.frame.size.height, self.frame.size.width*(1-ratio), tableViewHeight);
}
}];
} else {
[UIView animateWithDuration:0.2 animations:^{
if (leftTableView) {
leftTableView.frame = CGRectMake(_origin.x, self.frame.origin.y + self.frame.size.height, self.frame.size.width*ratio, 0);
}
if (rightTableView) {
rightTableView.frame = CGRectMake(_origin.x+leftTableView.frame.size.width, self.frame.origin.y + self.frame.size.height, self.frame.size.width*(1-ratio), 0);
}
} completion:^(BOOL finished) {
if (leftTableView) {
[leftTableView removeFromSuperview];
}
if (rightTableView) {
[rightTableView removeFromSuperview];
}
}];
}
complete();
}
/**
*动画显示下拉菜单
*/
- (void)animateCollectionView:(UICollectionView *)collectionView show:(BOOL)show complete:(void(^)())complete {
if (show) {
CGFloat collectionViewHeight = 0;
if (collectionView) {
collectionView.frame = CGRectMake(_origin.x, self.frame.origin.y + self.frame.size.height, self.frame.size.width, 0);
[self.superview addSubview:collectionView];
collectionViewHeight = (ceil([collectionView numberOfItemsInSection:0]/2.0) * 38);
}
[UIView animateWithDuration:0.2 animations:^{
if (collectionView) {
collectionView.frame = CGRectMake(_origin.x, self.frame.origin.y + self.frame.size.height, self.frame.size.width, collectionViewHeight);
}
}];
} else {
[UIView animateWithDuration:0.2 animations:^{
if (collectionView) {
collectionView.frame = CGRectMake(_origin.x, self.frame.origin.y + self.frame.size.height, self.frame.size.width, 0);
}
} completion:^(BOOL finished) {
if (collectionView) {
[collectionView removeFromSuperview];
}
}];
}
complete();
}
- (void)animateTitle:(CATextLayer *)title show:(BOOL)show complete:(void(^)())complete {
CGSize size = [self calculateTitleSizeWithString:title.string];
CGFloat sizeWidth = (size.width < (self.frame.size.width / _numOfMenu) - 25) ? size.width : self.frame.size.width / _numOfMenu - 25;
title.bounds = CGRectMake(0, 0, sizeWidth, size.height);
complete();
}
- (void)animateIdicator:(CAShapeLayer *)indicator background:(UIView *)background leftTableView:(UITableView *)leftTableView rightTableView:(UITableView *)rightTableView title:(CATextLayer *)title forward:(BOOL)forward complecte:(void(^)())complete{
[self animateIndicator:indicator Forward:forward complete:^{
[self animateTitle:title show:forward complete:^{
[self animateBackGroundView:background show:forward complete:^{
[self animateLeftTableView:leftTableView rightTableView:rightTableView show:forward complete:^{
}];
}];
}];
}];
complete();
}
- (void)animateIdicator:(CAShapeLayer *)indicator background:(UIView *)background collectionView:(UICollectionView *)collectionView title:(CATextLayer *)title forward:(BOOL)forward complecte:(void(^)())complete{
[self animateIndicator:indicator Forward:forward complete:^{
[self animateTitle:title show:forward complete:^{
[self animateBackGroundView:background show:forward complete:^{
[self animateCollectionView:collectionView show:forward complete:^{
}];
}];
}];
}];
complete();
}
#pragma mark - table datasource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// 0 左边 1 右边
NSInteger leftOrRight = 0;
if (_rightTableView==tableView) {
leftOrRight = 1;
}
NSAssert(self.dataSource != nil, @"menu's dataSource shouldn't be nil");
if ([self.dataSource respondsToSelector:@selector(menu:numberOfRowsInColumn:leftOrRight: leftRow:)]) {
return [self.dataSource menu:self numberOfRowsInColumn:self.currentSelectedMenudIndex leftOrRight:leftOrRight leftRow:_leftSelectedRow];
} else {
NSAssert(0 == 1, @"required method of dataSource protocol should be implemented");
return 0;
}
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 0.1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0.1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *identifier = @"DropDownMenuCell";
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame];
cell.selectedBackgroundView.backgroundColor = BackColor;
UILabel *titleLabel = [[UILabel alloc] init];
titleLabel.textColor = self.textColor;
titleLabel.tag = 1;
titleLabel.font = [UIFont systemFontOfSize:14.0];
[cell addSubview:titleLabel];
NSInteger leftOrRight = 0;
if (_rightTableView==tableView) {
leftOrRight = 1;
}
// UILabel *titleLabel = (UILabel*)[cell viewWithTag:1];
CGSize textSize;
if ([self.dataSource respondsToSelector:@selector(menu:titleForRowAtIndexPath:)]) {
titleLabel.text = [self.dataSource menu:self titleForRowAtIndexPath:[JSIndexPath indexPathWithCol:self.currentSelectedMenudIndex leftOrRight:leftOrRight leftRow:_leftSelectedRow row:indexPath.row]];
// 只取宽度
textSize = [titleLabel.text textSizeWithFont:[UIFont systemFontOfSize:14.0f] constrainedToSize:CGSizeMake(MAXFLOAT, 14) lineBreakMode:NSLineBreakByWordWrapping];
}
cell.backgroundColor = [UIColor whiteColor];
cell.textLabel.font = [UIFont systemFontOfSize:14.0];
cell.separatorInset = UIEdgeInsetsZero;
if (leftOrRight == 1) {
CGFloat marginX = 20;
titleLabel.frame = CGRectMake(marginX, 0, textSize.width, cell.frame.size.height);
//右边tableview
cell.backgroundColor = BackColor;
if ([titleLabel.text isEqualToString:[(CATextLayer *)[_titles objectAtIndex:_currentSelectedMenudIndex] string]]) {
UIImageView *accessoryImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ico_make"]];
accessoryImageView.frame = CGRectMake(titleLabel.frame.origin.x+titleLabel.frame.size.width+10, (self.frame.size.height-12)/2, 16, 12);
[cell addSubview:accessoryImageView];
} else{
}
} else{
CGFloat ratio = [_dataSource widthRatioOfLeftColumn:_currentSelectedMenudIndex];
CGFloat marginX = (self.frame.size.width*ratio-textSize.width)/2;
titleLabel.frame = CGRectMake(marginX, 0, textSize.width, cell.frame.size.height);
if (!_hadSelected && _leftSelectedRow == indexPath.row) {
cell.backgroundColor = BackColor;
BOOL haveRightTableView = [_dataSource haveRightTableViewInColumn:_currentSelectedMenudIndex];
if(!haveRightTableView){
UIImageView *accessoryImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ico_make"]];
accessoryImageView.frame = CGRectMake(titleLabel.frame.origin.x+titleLabel.frame.size.width+10, (self.frame.size.height-12)/2, 16, 12);
[cell addSubview:accessoryImageView];
}
} else{
}
}
return cell;
}
#pragma mark - tableview delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSInteger leftOrRight = 0;
if (_rightTableView==tableView) {
leftOrRight = 1;
} else {
_leftSelectedRow = indexPath.row;
}
if (self.delegate || [self.delegate respondsToSelector:@selector(menu:didSelectRowAtIndexPath:)]) {
BOOL haveRightTableView = [_dataSource haveRightTableViewInColumn:_currentSelectedMenudIndex];
if ((leftOrRight==0 && !haveRightTableView) || leftOrRight==1) {
[self confiMenuWithSelectRow:indexPath.row leftOrRight:leftOrRight];
}
[self.delegate menu:self didSelectRowAtIndexPath:[JSIndexPath indexPathWithCol:self.currentSelectedMenudIndex leftOrRight:leftOrRight leftRow:_leftSelectedRow row:indexPath.row]];
if (leftOrRight==0 && haveRightTableView) {
if (!_hadSelected) {
_hadSelected = YES;
[_leftTableView reloadData];
NSIndexPath *selectedIndexPath = [NSIndexPath indexPathForRow:_leftSelectedRow inSection:0];
[_leftTableView selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
}
[_rightTableView reloadData];
}
} else {
//TODO: delegate is nil
}
}
- (void)confiMenuWithSelectRow:(NSInteger)row leftOrRight:(NSInteger)leftOrRight{
CATextLayer *title = (CATextLayer *)_titles[_currentSelectedMenudIndex];
title.string = [self.dataSource menu:self titleForRowAtIndexPath:[JSIndexPath indexPathWithCol:self.currentSelectedMenudIndex leftOrRight:leftOrRight leftRow:_leftSelectedRow row:row]];
[self animateIdicator:_indicators[_currentSelectedMenudIndex] background:_backGroundView leftTableView:_leftTableView rightTableView:_rightTableView title:_titles[_currentSelectedMenudIndex] forward:NO complecte:^{
_show = NO;
}];
[(CALayer *)self.bgLayers[_currentSelectedMenudIndex] setBackgroundColor:BackColor.CGColor];
CAShapeLayer *indicator = (CAShapeLayer *)_indicators[_currentSelectedMenudIndex];
indicator.position = CGPointMake(title.position.x + title.frame.size.width / 2 + 8, indicator.position.y);
}
- (void)updateMenuTitle:(NSString *)string {
CATextLayer *title = (CATextLayer *)_titles[_currentSelectedMenudIndex];
title.string = string;
[self animateIdicator:_indicators[_currentSelectedMenudIndex] background:_backGroundView leftTableView:_leftTableView rightTableView:_rightTableView title:_titles[_currentSelectedMenudIndex] forward:NO complecte:^{
_show = NO;
}];
[(CALayer *)self.bgLayers[_currentSelectedMenudIndex] setBackgroundColor:BackColor.CGColor];
CAShapeLayer *indicator = (CAShapeLayer *)_indicators[_currentSelectedMenudIndex];
indicator.position = CGPointMake(title.position.x + title.frame.size.width / 2 + 8, indicator.position.y);
}
#pragma mark - UICollectionViewDataSource
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
// 为collectionview时 leftOrRight 为-1
if ([self.dataSource respondsToSelector:@selector(menu:numberOfRowsInColumn:leftOrRight: leftRow:)]) {
return [self.dataSource menu:self numberOfRowsInColumn:self.currentSelectedMenudIndex leftOrRight:-1 leftRow:-1];
} else {
NSAssert(0 == 1, @"required method of dataSource protocol should be implemented");
return 0;
}
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *collectionCell = @"CollectionCell";
JSCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:collectionCell forIndexPath:indexPath];
if ([self.dataSource respondsToSelector:@selector(menu:titleForRowAtIndexPath:)]) {
cell.textLabel.text = [self.dataSource menu:self titleForRowAtIndexPath:[JSIndexPath indexPathWithCol:self.currentSelectedMenudIndex leftOrRight:-1 leftRow:-1 row:indexPath.row]];
} else {
NSAssert(0 == 1, @"dataSource method needs to be implemented");
}
cell.backgroundColor = [UIColor whiteColor];
cell.selectedBackgroundView.backgroundColor = BackColor;
cell.textLabel.font = [UIFont systemFontOfSize:14.0];
cell.textLabel.textColor = self.textColor;
if ([cell.textLabel.text isEqualToString:[(CATextLayer *)[_titles objectAtIndex:_currentSelectedMenudIndex] string]]) {
cell.backgroundColor = BackColor;
cell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ico_make"]];
} else{
[cell removeAccessoryView];
}
return cell;
}
#pragma mark --UICollectionViewDelegateFlowLayout
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
return CGSizeMake((collectionView.frame.size.width-1)/2, 38);
}
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
return UIEdgeInsetsMake(0, 0, 1, 0.5);
}
#pragma mark --UICollectionViewDelegate
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
if (self.delegate || [self.delegate respondsToSelector:@selector(menu:didSelectRowAtIndexPath:)]) {
[self confiMenuWithSelectRow:indexPath.row];
[self.delegate menu:self didSelectRowAtIndexPath:[JSIndexPath indexPathWithCol:self.currentSelectedMenudIndex leftOrRight:-1 leftRow:-1 row:indexPath.row]];
} else {
//TODO: delegate is nil
}
}
- (void)confiMenuWithSelectRow:(NSInteger)row{
CATextLayer *title = (CATextLayer *)_titles[_currentSelectedMenudIndex];
title.string = [self.dataSource menu:self titleForRowAtIndexPath:[JSIndexPath indexPathWithCol:self.currentSelectedMenudIndex leftOrRight:-1 leftRow:-1 row:row]];
[self animateIdicator:_indicators[_currentSelectedMenudIndex] background:_backGroundView collectionView:_collectionView title:_titles[_currentSelectedMenudIndex] forward:NO complecte:^{
_show = NO;
}];
[(CALayer *)self.bgLayers[_currentSelectedMenudIndex] setBackgroundColor:BackColor.CGColor];
CAShapeLayer *indicator = (CAShapeLayer *)_indicators[_currentSelectedMenudIndex];
indicator.position = CGPointMake(title.position.x + title.frame.size.width / 2 + 8, indicator.position.y);
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
return 0.5;
}
@end
......@@ -35,6 +35,9 @@
/** 获取用户的所有合同uuid */
- (NSMutableArray *)getUserContractUuids;
/** 获取商户用户的合同(默认是第一个,异常状况会提示 */
- (UserInfo_contracts *)getTenantContract;
/** 保存基础信息 */
- (void)saveBaseInfo;
......
......@@ -46,5 +46,22 @@ static NSString *const zj_saved_isMall = @"zj_saved_isMall";
return arr;
}
/** 获取商户用户的合同(默认是第一个) */
- (UserInfo_contracts *)getTenantContract{
if (self.isMall) {
[MBProgressHUD j_warningMessage:@"该用户是商场用户"];
return nil;
}
UserInfo_contracts *contract = [self.user.contracts firstObject];
if (!contract) {
[MBProgressHUD j_warningMessage:@"该商户没有合同"];;
}else if(self.user.contracts.count > 1){
[MBProgressHUD j_warningMessage:@"该商户有多个合同,默认选取第一个"];
}
return contract;
}
ZJLazy(ZJPermissionManager, permission)
@end
......@@ -154,7 +154,7 @@
return;
}
WS(weakSelf);
[self.manager POST:@"hdmall/media/upload" parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
[self.manager POST:@"hdmall/media/upload/list" parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
for (ZJBaseFileModel *file in files) {
[formData appendPartWithFileData:file.data //data
name:file.keyName //接口key值
......@@ -171,10 +171,10 @@
kFalseHttpTips;
}
[weakSelf logWithUrl:@"hdmall/media/upload" Method:@"UPLOAD" param:params respones:responseObject];
[weakSelf logWithUrl:@"hdmall/media/upload/list" Method:@"UPLOAD" param:params respones:responseObject];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
[MBProgressHUD j_error:@"上传失败" complete:nil];
[weakSelf logWithUrl:@"hdmall/media/upload" Method:@"UPLOAD" param:params respones:error];
[weakSelf logWithUrl:@"hdmall/media/upload/list" Method:@"UPLOAD" param:params respones:error];
}];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment