Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
万
万科
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张杰
万科
Commits
3d042ba4
Commit
3d042ba4
authored
Jul 11, 2016
by
Sandy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上传图片等功能实现
parent
96921baf
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
144 additions
and
64 deletions
+144
-64
UIImage+Helper.h
vanke/3rd/General/Categories/UIImage+Helper.h
+29
-1
UIImage+Helper.m
vanke/3rd/General/Categories/UIImage+Helper.m
+48
-1
ICRHTTPController.h
vanke/3rd/HTTPController/ICRHTTPController.h
+2
-0
ICRHTTPController.m
vanke/3rd/HTTPController/ICRHTTPController.m
+27
-0
VankeConfig.h
vanke/VankeConfig.h
+9
-11
VankeProjectSummaryAPI.m
vanke/controller/VankeProjectSummaryAPI.m
+1
-1
VankeFloorDetailWebViewController.m
...view_iPhone/templates/VankeFloorDetailWebViewController.m
+0
-2
VankeAffairsBoard_iPhone.m
.../view_iPhone/templates/affairs/VankeAffairsBoard_iPhone.m
+0
-11
VankeServiceDashBoard_iPhone.xml
...ew_iPhone/templates/main/VankeServiceDashBoard_iPhone.xml
+2
-2
ChooseProjectTableViewController.m
.../salesInput/Controller/ChooseProjectTableViewController.m
+0
-1
HistoryViewController.m
...e/templates/salesInput/Controller/HistoryViewController.m
+2
-3
SalesInputViewController.m
...emplates/salesInput/Controller/SalesInputViewController.m
+24
-31
No files found.
vanke/3rd/General/Categories/UIImage+Helper.h
View file @
3d042ba4
...
...
@@ -18,7 +18,35 @@
-
(
UIImage
*
)
imageWithGradientTintColor
:(
UIColor
*
)
tintColor
;
-
(
UIImage
*
)
imageWithTintColor
:(
UIColor
*
)
tintColor
blendMode
:(
CGBlendMode
)
blendMode
;
/**
* 图片压缩到指定大小(具体看图片大小,过大的图片无法压缩到指定大小)
*
* @param kb 压缩后图片大小
*
* @return
*/
-
(
NSData
*
)
scaledToSpaceMaxSize
:(
NSInteger
)
kb
;
/**
* 压缩图片到指定高宽
*
* @param newSize 新的图片尺寸
*
* @return
*/
-
(
UIImage
*
)
scaledToSize
:(
CGSize
)
newSize
;
/**
* 按比例压缩图片至指定宽度
*
* @param newWidth 指定宽度
*
* @return
*/
-
(
UIImage
*
)
scaledToWidth
:(
NSInteger
)
newWidth
;
/** 计算图片大小 */
-
(
CGFloat
)
dataSize
;
@end
@interface
UIImage
(
Color
)
...
...
vanke/3rd/General/Categories/UIImage+Helper.m
View file @
3d042ba4
...
...
@@ -7,7 +7,11 @@
//
#import "UIImage+Helper.h"
#ifdef DEBUG
#define CLog(format, ...) NSLog((@"[Line %d] %s " format), __LINE__, __PRETTY_FUNCTION__, ## __VA_ARGS__)
#else
#define CLog(format, ...)
#endif
@implementation
UIImage
(
Helper
)
// if newImage's width or heigth < 1, image will be cliped
...
...
@@ -98,6 +102,49 @@
return
tintedImage
;
}
-
(
NSData
*
)
scaledToSpaceMaxSize
:(
NSInteger
)
kb
{
//压缩到指定大小以内
CGFloat
compression
=
0
.
5
f
;
CGFloat
maxCompression
=
0
.
1
f
;
NSUInteger
maxlength
=
kb
*
1024
;
NSData
*
imgData
=
UIImageJPEGRepresentation
(
self
,
compression
);
CLog
(
@"处理之前的大小--->%lukB"
,(
unsigned
long
)
imgData
.
length
/
1024
);
while
([
imgData
length
]
>
maxlength
&&
compression
>
maxCompression
)
{
compression
-=
0
.
1
;
imgData
=
UIImageJPEGRepresentation
(
self
,
compression
);
}
CLog
(
@"处理之后的大小--->%lukB"
,(
unsigned
long
)
imgData
.
length
/
1024
);
return
imgData
;
}
-
(
UIImage
*
)
scaledToSize
:(
CGSize
)
newSize
{
UIGraphicsBeginImageContextWithOptions
(
newSize
,
YES
,
0
);
[
self
drawInRect
:
CGRectMake
(
0
,
0
,
newSize
.
width
,
newSize
.
height
)];
UIImage
*
scaledImage
=
UIGraphicsGetImageFromCurrentImageContext
();
UIGraphicsEndImageContext
();
return
scaledImage
;
}
-
(
UIImage
*
)
scaledToWidth
:(
NSInteger
)
newWidth
{
CLog
(
@"旧尺寸%@"
,
NSStringFromCGSize
(
self
.
size
));
CGSize
newSize
=
CGSizeMake
(
newWidth
,
newWidth
/
self
.
size
.
width
*
self
.
size
.
height
);
UIGraphicsBeginImageContextWithOptions
(
newSize
,
YES
,
0
);
[
self
drawInRect
:
CGRectMake
(
0
,
0
,
newSize
.
width
,
newSize
.
height
)];
UIImage
*
scaledImage
=
UIGraphicsGetImageFromCurrentImageContext
();
UIGraphicsEndImageContext
();
CLog
(
@"新尺寸%@"
,
NSStringFromCGSize
(
scaledImage
.
size
));
return
scaledImage
;
}
/** 计算图片大小 */
-
(
CGFloat
)
dataSize
{
NSData
*
data
=
UIImageJPEGRepresentation
(
self
,
1
);
CGFloat
size
=
data
.
length
/
1024
;
CLog
(
@"data size=%.0f kB, size=%@"
,
size
,
NSStringFromCGSize
(
self
.
size
));
return
size
;
}
@end
...
...
vanke/3rd/HTTPController/ICRHTTPController.h
View file @
3d042ba4
...
...
@@ -93,8 +93,10 @@ typedef NS_ENUM(NSUInteger, ICRAttachmentType) {
failure
:(
void
(
^
)(
id
))
fail
;
-
(
void
)
postUrl
:(
NSString
*
)
url
params
:(
id
)
params
success
:(
void
(
^
)(
id
data
))
succ
failure
:(
void
(
^
)(
id
data
))
fail
;
-
(
void
)
getUrl
:(
NSString
*
)
url
params
:(
id
)
params
success
:(
void
(
^
)(
id
data
))
succ
failure
:(
void
(
^
)(
id
data
))
fail
;
-
(
void
)
POST
:(
NSString
*
)
requestUrl
pictures
:(
NSArray
*
)
pictures
param
:(
NSDictionary
*
)
params
complete
:(
void
(
^
)(
id
responseObject
,
NSError
*
error
))
complete
;
@end
...
...
vanke/3rd/HTTPController/ICRHTTPController.m
View file @
3d042ba4
...
...
@@ -21,6 +21,8 @@
#import "VankeCommonModel.h"
#import "ICRDataBaseController.h"
#import "VankeConfig.h"
#import "NSData+BeeExtension.h"
#import "UIImage+Helper.h"
//#import "ICRStoreResult.h"
#define MAX_CONCURRENCY_UPLOAD 1
...
...
@@ -731,8 +733,33 @@ acceptTypeJson:YES
fail
(
error
);
}];
}
-
(
void
)
POST
:
(
NSString
*
)
requestUrl
pictures
:
(
NSArray
*
)
pictures
param
:
(
NSDictionary
*
)
params
complete
:
(
void
(
^
)(
id
responseObject
,
NSError
*
error
))
complete
{
NSString
*
url
=
[
VANKE_SERVER_BASE_URL
stringByAppendingFormat
:
@"/%@"
,
requestUrl
];
AFHTTPRequestOperationManager
*
manager
=
[
AFHTTPRequestOperationManager
manager
];
AFJSONRequestSerializer
*
requestSerializer
=
[
self
requestNeedToken
:
YES
acceptTypeJson
:
YES
failure
:
nil
];
manager
.
requestSerializer
=
requestSerializer
;
[
manager
POST
:
url
parameters
:
params
constructingBodyWithBlock
:^
(
id
<
AFMultipartFormData
>
formData
)
{
for
(
UIImage
*
image
in
pictures
)
{
UIImage
*
imageScaled
=
[
image
scaledToWidth
:
400
];
NSData
*
data
=
[
imageScaled
scaledToSpaceMaxSize
:
95
];
[
formData
appendPartWithFileData
:
data
//图片data
name
:
@"file"
//接口key值
fileName
:
[
NSString
stringWithFormat
:
@"%@.%@"
,[
data
MD5String
],
@"jpg"
]
//图片名称,必须有后缀
mimeType
:
@"image/jpeg"
];
//文件类型,后台接受使用
}
}
success
:^
(
AFHTTPRequestOperation
*
operation
,
id
responseObject
)
{
complete
(
responseObject
,
nil
);
}
failure
:^
(
AFHTTPRequestOperation
*
operation
,
NSError
*
error
)
{
complete
(
nil
,
error
);
}];
}
@end
vanke/VankeConfig.h
View file @
3d042ba4
...
...
@@ -21,19 +21,15 @@
// 百度天气服务地址
#define VANKE_BAIDU_WEATHER_SERVER_URL @"http://api.map.baidu.com/telematics/v3/weather"
// 正式环境
#define VANKE_SERVER_BASE_URL @"http://140.206.62.178:8080/wanke-server/rest" //正式
// //正式环境
//#define VANKE_SERVER_BASE_URL @"http://140.206.62.178:8080/wanke-server/rest" //正式
// //后台多媒体文件基准地址
//#define VANKE_SERVER_MEDIA_BASE_URL @"http://140.206.62.178:8080" //正式
// 测试环境
//#define VANKE_SERVER_BASE_URL @"http://218.244.151.129:7580/wanke-server/rest"
//#define VANKE_SERVER_BASE_URL @"http://139.196.39.77:8080/wanke-server/rest"
// 后台多媒体文件基准地址
#define VANKE_SERVER_MEDIA_BASE_URL @"http://140.206.62.178:8080" //正式
//#define VANKE_SERVER_MEDIA_BASE_URL @"http://192.168.199.198:8080" //川哥环境
//#define VANKE_SERVER_MEDIA_BASE_URL @"http://218.244.151.129:7580"
// 测试环境
#define VANKE_SERVER_BASE_URL @"http://139.196.39.77:8080/wanke-server/rest"
#define VANKE_SERVER_MEDIA_BASE_URL @"http://139.196.39.77:8080"
// 后台服务企业认证码
...
...
@@ -45,4 +41,6 @@
// 后台服务认证用户密码
#define VANKE_SERVER_PASSWORD @"password"
#endif
/* VankeConfig_h */
vanke/controller/VankeProjectSummaryAPI.m
View file @
3d042ba4
...
...
@@ -27,7 +27,7 @@
return
;
}
[
self
http_get
:
@"
/
project/queryclassificationby"
].
PARAM
(
@"salesDateEquals"
,
self
.
salesDate
).
PARAM
(
@"passengerDateEquals"
,
self
.
passengerDate
).
PARAM
(
@"trafficDateEquals"
,
self
.
trafficDate
).
PARAM
(
@"rentalDateEquals"
,
self
.
rentalDateEquals
).
TIMEOUT
(
10
);
[
self
http_get
:
@"project/queryclassificationby"
].
PARAM
(
@"salesDateEquals"
,
self
.
salesDate
).
PARAM
(
@"passengerDateEquals"
,
self
.
passengerDate
).
PARAM
(
@"trafficDateEquals"
,
self
.
trafficDate
).
PARAM
(
@"rentalDateEquals"
,
self
.
rentalDateEquals
).
TIMEOUT
(
10
);
}
else
if
(
self
.
succeed
)
{
...
...
vanke/view_iPhone/templates/VankeFloorDetailWebViewController.m
View file @
3d042ba4
...
...
@@ -135,8 +135,6 @@
}
-
(
void
)
didReceiveMemoryWarning
{
[
super
didReceiveMemoryWarning
];
// Dispose of any resources that can be recreated.
...
...
vanke/view_iPhone/templates/affairs/VankeAffairsBoard_iPhone.m
View file @
3d042ba4
...
...
@@ -129,32 +129,21 @@ ON_SIGNAL3(VankeAffairsBoard_iPhone, btnSaleInput, signal) {
// [GEToast showWithText:@"销售录入正在开发中..." bottomOffset:60.0f duration:1.0f];
VankeCommonModel
*
model
=
[
VankeCommonModel
sharedInstance
];
SalesInputViewController
*
salesVC
=
[[
SalesInputViewController
alloc
]
init
];
WS
(
weakSelf
)
if
([[
model
getAuthOrgs
]
count
]
>
1
)
{
ChooseProjectTableViewController
*
chooseVC
=
[[
ChooseProjectTableViewController
alloc
]
init
];
chooseVC
.
arrAuthorized
=
[
model
getAuthOrgs
];
chooseVC
.
chooseAuthorized
=
^
(
AuthorizedOrg
*
author
){
salesVC
.
authorizedOrg
=
author
;
[
weakSelf
.
navigationController
pushViewController
:
salesVC
animated
:
YES
];
};
UINavigationController
*
navc
=
[[
UINavigationController
alloc
]
initWithRootViewController
:
chooseVC
];
[
self
.
navigationController
presentViewController
:
navc
animated
:
YES
completion
:
nil
];
}
else
{
salesVC
.
authorizedOrg
=
[
model
getAuthOrgs
][
0
];
[
self
.
navigationController
pushViewController
:
salesVC
animated
:
YES
];
}
}
ON_SIGNAL3
(
VankeAffairsBoard_iPhone
,
btnServiceApply
,
signal
)
{
...
...
vanke/view_iPhone/templates/main/VankeServiceDashBoard_iPhone.xml
View file @
3d042ba4
...
...
@@ -39,7 +39,7 @@
}
.sales-wrapper {
height: 3
3
%;
height: 3
2
%;
width: 100%;
}
...
...
@@ -50,7 +50,7 @@
.row2-wrapper,
.row3-wrapper {
height: 3
3
%;
height: 3
2
%;
width: 100%;
}
...
...
vanke/view_iPhone/templates/salesInput/Controller/ChooseProjectTableViewController.m
View file @
3d042ba4
...
...
@@ -67,7 +67,6 @@
-
(
void
)
tableView
:
(
UITableView
*
)
tableView
didSelectRowAtIndexPath
:
(
NSIndexPath
*
)
indexPath
{
self
.
chooseAuthorized
(
self
.
arrAuthorized
[
indexPath
.
row
]);
[
self
dismissViewControllerAnimated
:
YES
completion
:
nil
];
...
...
vanke/view_iPhone/templates/salesInput/Controller/HistoryViewController.m
View file @
3d042ba4
...
...
@@ -67,7 +67,6 @@
self
.
scrollView
=
[[
UIScrollView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
150
,
SCREEN_WIDTH
,
SCREEN_HEIGHT
-
150
-
64
)];
self
.
scrollView
.
bounces
=
NO
;
self
.
scrollView
.
delegate
=
self
;
[
self
.
view
addSubview
:
self
.
scrollView
];
}
...
...
@@ -98,7 +97,7 @@
label
.
font
=
[
UIFont
systemFontOfSize
:
19
];
label
.
textAlignment
=
NSTextAlignmentCenter
;
if
(
i
!=
0
)
{
[
self
.
scrollView
insertSubview
:
label
belowSubview
:[
self
.
scrollView
viewWithTag
:
1000
+
i
-
1
]];
//防止前面的
别
挡住
[
self
.
scrollView
insertSubview
:
label
belowSubview
:[
self
.
scrollView
viewWithTag
:
1000
+
i
-
1
]];
//防止前面的
被
挡住
}
else
{
[
self
.
scrollView
addSubview
:
label
];
}
...
...
vanke/view_iPhone/templates/salesInput/Controller/SalesInputViewController.m
View file @
3d042ba4
...
...
@@ -23,6 +23,7 @@
#import "ChooseProjectTableViewController.h"
#import "SaleInputPictureTableViewCell.h"
#import "TZImagePickerController.h"
#import "UIImage+Helper.h"
#define kCellCount 20
#define kCellID @"SalesInputTableViewCell.h"
#define kPicCellId @"SaleInputPictureTableViewCell.h"
...
...
@@ -189,29 +190,10 @@ ON_WILL_APPEAR( signal )
#pragma mark - 四类个性化设置,这些参数都可以不传,此时会走默认设置
imagePickerVc
.
isSelectOriginalPhoto
=
NO
;
// 1.如果你需要将拍照按钮放在外面,不要传这个参数
imagePickerVc
.
selectedAssets
=
_selectedAssets
;
// optional, 可选的
// imagePickerVc.allowTakePicture = self.showTakePhotoBtnSwitch.isOn; // 在内部显示拍照按钮
// 2. Set the appearance
// 2. 在这里设置imagePickerVc的外观
imagePickerVc
.
navigationBar
.
barTintColor
=
kMainOrangeColor
;
// imagePickerVc.oKButtonTitleColorDisabled = [UIColor lightGrayColor];
imagePickerVc
.
oKButtonTitleColorNormal
=
kMainOrangeColor
;
// 3. Set allow picking video & photo & originalPhoto or not
// 3. 设置是否可以选择视频/图片/原图
// imagePickerVc.allowPickingVideo = self.allowPickingVideoSwitch.isOn;
// imagePickerVc.allowPickingImage = self.allowPickingImageSwitch.isOn;
imagePickerVc
.
allowPickingOriginalPhoto
=
NO
;
//
// // 4. 照片排列按修改时间升序
// imagePickerVc.sortAscendingByModificationDate = self.sortAscendingSwitch.isOn;
#pragma mark - 到这里为止
// You can get the photos by block, the same as by delegate.
// 你可以通过block或者代理,来得到用户选择的照片.
[
imagePickerVc
setDidFinishPickingPhotosHandle
:
^
(
NSArray
<
UIImage
*>
*
photos
,
NSArray
*
assets
,
BOOL
isSelectOriginalPhoto
)
{
_selectedAssets
=
[
NSMutableArray
arrayWithArray
:
assets
];
_arrPics
=
[
NSMutableArray
arrayWithArray
:
photos
];
...
...
@@ -329,14 +311,10 @@ ON_WILL_APPEAR( signal )
ICRHTTPController
*
httpCtrl
=
[
ICRHTTPController
sharedController
];
[
httpCtrl
getUrl
:
@"salesinput/query"
params
:
params
success
:^
(
id
data
)
{
if
([
data
[
@"data"
][
@"records"
]
count
]
>
0
)
{
NSNumber
*
amount
=
data
[
@"data"
][
@"records"
][
0
][
@"amount"
];
NSString
*
amountStr
=
[
NSString
stringWithFormat
:
@"%.0f"
,
[
amount
floatValue
]];
weakSelf
.
todayTotalAmount
=
amountStr
;
weakSelf
.
totalView
.
labelTotalAmount
.
text
=
amountStr
;
}
else
{
weakSelf
.
todayTotalAmount
=
@"0"
;
weakSelf
.
totalView
.
labelTotalAmount
.
text
=
@"0"
;
...
...
@@ -425,14 +403,30 @@ ON_WILL_APPEAR( signal )
}
-
(
void
)
submit
{
if
(
self
.
shop
==
nil
)
{
UIAlertView
*
alertView
=
[[
UIAlertView
alloc
]
initWithTitle
:
@"提示"
message
:
@"请选择店铺!"
delegate
:
nil
cancelButtonTitle
:
@"确定"
otherButtonTitles
:
nil
,
nil
];
[
alertView
show
];
}
else
{
[
self
httpPostAttachments
];
}
}
-
(
void
)
httpPostAttachments
{
ICRHTTPController
*
httpCtrl
=
[
ICRHTTPController
sharedController
];
NSString
*
string
=
[
NSString
stringWithFormat
:
@"attachment/upload_by_file?entity_type=%@&entity_uuid=%@"
,
@"salesInput"
,
@"860576037625827160708160529115460847"
];
WS
(
weakSelf
);
[
httpCtrl
POST
:
string
pictures
:
self
.
arrPics
param
:
nil
complete
:^
(
id
responseObject
,
NSError
*
error
)
{
NSMutableArray
*
arrUuid
=
[
NSMutableArray
array
];
for
(
NSDictionary
*
data
in
responseObject
[
@"data"
])
{
[
arrUuid
addObject
:
data
[
@"uuid"
]];
}
NSString
*
entityUuid
=
responseObject
[
@"data"
][
0
][
@"entityUuid"
];
ICRHTTPController
*
httpCtrl
=
[
ICRHTTPController
sharedController
];
NSDictionary
*
params
=
[
self
getParams
];
NSDictionary
*
params
=
[
weakSelf
getParamsAttachmentUuid
:
entityUuid
pictureUuids
:
arrUuid
];
NSString
*
url
=
[
NSString
stringWithFormat
:
@"salesinput/submit?time=%@&operId=%@&operName=%@"
,[[
NSDate
date
]
httpParameterString
],
[[[
VankeCommonModel
sharedInstance
]
getLoginInfo
]
user_uuid
],
[[[
VankeCommonModel
sharedInstance
]
getLoginInfo
]
user_name
]];
NSString
*
utf8String
=
[
url
stringByAddingPercentEscapesUsingEncoding
:
NSUTF8StringEncoding
];
...
...
@@ -444,16 +438,15 @@ ON_WILL_APPEAR( signal )
}
failure
:^
(
id
data
)
{
}];
}
}];
}
-
(
NSDictionary
*
)
getParams
{
-
(
NSDictionary
*
)
getParamsAttachmentUuid
:
(
NSString
*
)
attachmentUuid
pictureUuids
:
(
NSMutableArray
*
)
pictures
{
NSMutableArray
*
lines
=
[
NSMutableArray
array
];
for
(
int
i
=
0
;
i
<
self
.
arrPaymentType
.
count
;
i
++
)
{
NSString
*
bill
=
[
self
.
cellDataDic
objectForKey
:[
NSIndexPath
indexPathForRow
:
i
inSection
:
0
]][
1
];
NSString
*
amount
=
[
self
.
cellDataDic
objectForKey
:[
NSIndexPath
indexPathForRow
:
i
inSection
:
0
]][
0
];
PaymentTypeModel
*
model
=
self
.
arrPaymentType
[
i
];
...
...
@@ -462,14 +455,14 @@ ON_WILL_APPEAR( signal )
@"transactions"
:
[
NSNumber
numberWithFloat
:
[
bill
floatValue
]],
@"amount"
:
[
NSNumber
numberWithFloat
:
[
amount
floatValue
]]};
[
lines
addObject
:
pay
];
}
NSDictionary
*
myDictionary
=
@{
@"projectId"
:
self
.
authorizedOrg
.
code
,
@"shopCode"
:
self
.
shop
.
code
,
@"shopName"
:
self
.
shop
.
name
,
@"salesDate"
:
self
.
topView
.
textfieldDate
.
text
,
@"attachments"
:
pictures
?
pictures
:
[
NSNull
null
],
@"attachmentUuid"
:
attachmentUuid
?
attachmentUuid
:
[
NSNull
null
],
@"lines"
:
lines
};
return
myDictionary
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment