Commit c896772f authored by 曹云霄's avatar 曹云霄

修改项说明:修复打印URL问题

parent e99978ff
...@@ -26,14 +26,16 @@ ...@@ -26,14 +26,16 @@
#import "RebateSuccessTableViewController.h" #import "RebateSuccessTableViewController.h"
#import "LuckyDrawModel.h" #import "LuckyDrawModel.h"
#import "LuckDrawResultModel.h" #import "LuckDrawResultModel.h"
#import "AirPrintManager.h"
#import <WebKit/WebKit.h>
NSString *const PROMOTIONALSTRING = @"促销信息"; NSString *const PROMOTIONALSTRING = @"促销信息";
@interface OrderdetailsViewController ()<UITableViewDelegate,UITableViewDataSource,QLPreviewControllerDataSource> @interface OrderdetailsViewController ()<UITableViewDelegate,UITableViewDataSource,QLPreviewControllerDataSource,WKNavigationDelegate>
@property (nonatomic,strong) WKWebView *webView;
/** /**
* 订单详情数据 * 订单详情数据
...@@ -761,31 +763,39 @@ NSString *const PROMOTIONALSTRING = @"促销信息"; ...@@ -761,31 +763,39 @@ NSString *const PROMOTIONALSTRING = @"促销信息";
return self.sectionTitle.count; return self.sectionTitle.count;
} }
#pragma mark -打印订单 #pragma mark -打印订单
- (void)AirprintButtonClick:(UIButton *)button - (void)AirprintButtonClick:(UIButton *)button
{ {
WS(weakSelf);
NSString *server = [NSString stringWithFormat:SERVERREQUESTURL(ORDERDETAILSURL),[Shoppersmanager manager].Shoppers.employee.departid,self.orderCode]; NSString *server = [NSString stringWithFormat:SERVERREQUESTURL(ORDERDETAILSURL),[Shoppersmanager manager].Shoppers.employee.departid,self.orderCode];
NSString *newServer = [server stringByReplacingOccurrencesOfString:@"/app" withString:@""]; NSString *newServer = [server stringByReplacingOccurrencesOfString:@"/app" withString:@""];
self.webView = [[WKWebView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:newServer]]];
self.webView.navigationDelegate = self;
}
/// 文件 #pragma mark - <WKNavigationDelegate>
// NSFileManager *fileManager = [NSFileManager defaultManager]; - (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(null_unspecified WKNavigation *)navigation
// NSString * htmlResponseStr=[NSString stringWithContentsOfURL:[NSURL URLWithString:newServer] encoding:NSUTF8StringEncoding error:Nil]; {
// NSString *resourcePath = [ [NSBundle mainBundle] resourcePath]; [self CreateMBProgressHUDLoding];
// [fileManager createDirectoryAtPath:[resourcePath stringByAppendingString:@"/Caches"] withIntermediateDirectories:YES attributes:nil error:nil]; }
// NSString * path=[resourcePath stringByAppendingString:[NSString stringWithFormat:@"/Caches/%ld.html",[newServer hash]]];
// [htmlResponseStr writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:nil];
[self callAirprintWithURL:[NSURL URLWithString:newServer] SuccessBlock:^{
[weakSelf SuccessMBProgressView:@"打印完成"]; - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
} ErrorBlock:^{ {
[self RemoveMBProgressHUDLoding];
WS(weakSelf);
[AirPrintManager printOrderWithdataSoure:[webView viewPrintFormatter] printSuccess:^{
[weakSelf SuccessMBProgressView:@"打印成功"];
} printError:^{
[weakSelf ErrorMBProgressView:@"打印失败"]; [weakSelf ErrorMBProgressView:@"打印失败"];
}]; }];
}
- (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error
{
[self ErrorMBProgressView:@"操作失败"];
} }
#pragma mark -预览订单、撤销订单 #pragma mark -预览订单、撤销订单
- (void)PreviewButtonClick:(UIButton *)button - (void)PreviewButtonClick:(UIButton *)button
{ {
......
...@@ -110,6 +110,7 @@ ...@@ -110,6 +110,7 @@
29834EC01CDF5E4E001A484F /* ScreeningFirstCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 29834EBF1CDF5E4E001A484F /* ScreeningFirstCollectionViewCell.m */; }; 29834EC01CDF5E4E001A484F /* ScreeningFirstCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 29834EBF1CDF5E4E001A484F /* ScreeningFirstCollectionViewCell.m */; };
29834EC51CDF76C1001A484F /* UserViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 29834EC31CDF76C1001A484F /* UserViewController.m */; }; 29834EC51CDF76C1001A484F /* UserViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 29834EC31CDF76C1001A484F /* UserViewController.m */; };
29834EC61CDF76C1001A484F /* UserViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 29834EC41CDF76C1001A484F /* UserViewController.xib */; }; 29834EC61CDF76C1001A484F /* UserViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 29834EC41CDF76C1001A484F /* UserViewController.xib */; };
298534601DD4B0290023BBAE /* AirPrintManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 2985345F1DD4B0290023BBAE /* AirPrintManager.m */; };
2985AEA11CE72F1500704C91 /* NSArray+ ZXPUnicode.m in Sources */ = {isa = PBXBuildFile; fileRef = 2985AE9B1CE72F1500704C91 /* NSArray+ ZXPUnicode.m */; }; 2985AEA11CE72F1500704C91 /* NSArray+ ZXPUnicode.m in Sources */ = {isa = PBXBuildFile; fileRef = 2985AE9B1CE72F1500704C91 /* NSArray+ ZXPUnicode.m */; };
2985AEA21CE72F1500704C91 /* NSDictionary+ZXPUnicode.m in Sources */ = {isa = PBXBuildFile; fileRef = 2985AE9E1CE72F1500704C91 /* NSDictionary+ZXPUnicode.m */; }; 2985AEA21CE72F1500704C91 /* NSDictionary+ZXPUnicode.m in Sources */ = {isa = PBXBuildFile; fileRef = 2985AE9E1CE72F1500704C91 /* NSDictionary+ZXPUnicode.m */; };
2985AEA31CE72F1500704C91 /* NSObject+ZXPUnicode.m in Sources */ = {isa = PBXBuildFile; fileRef = 2985AEA01CE72F1500704C91 /* NSObject+ZXPUnicode.m */; }; 2985AEA31CE72F1500704C91 /* NSObject+ZXPUnicode.m in Sources */ = {isa = PBXBuildFile; fileRef = 2985AEA01CE72F1500704C91 /* NSObject+ZXPUnicode.m */; };
...@@ -387,6 +388,8 @@ ...@@ -387,6 +388,8 @@
29834EC21CDF76C1001A484F /* UserViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserViewController.h; sourceTree = "<group>"; }; 29834EC21CDF76C1001A484F /* UserViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserViewController.h; sourceTree = "<group>"; };
29834EC31CDF76C1001A484F /* UserViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserViewController.m; sourceTree = "<group>"; }; 29834EC31CDF76C1001A484F /* UserViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserViewController.m; sourceTree = "<group>"; };
29834EC41CDF76C1001A484F /* UserViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = UserViewController.xib; sourceTree = "<group>"; }; 29834EC41CDF76C1001A484F /* UserViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = UserViewController.xib; sourceTree = "<group>"; };
2985345E1DD4B0290023BBAE /* AirPrintManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AirPrintManager.h; sourceTree = "<group>"; };
2985345F1DD4B0290023BBAE /* AirPrintManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AirPrintManager.m; sourceTree = "<group>"; };
2985AE9B1CE72F1500704C91 /* NSArray+ ZXPUnicode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+ ZXPUnicode.m"; sourceTree = "<group>"; }; 2985AE9B1CE72F1500704C91 /* NSArray+ ZXPUnicode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+ ZXPUnicode.m"; sourceTree = "<group>"; };
2985AE9C1CE72F1500704C91 /* NSArray+ZXPUnicode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+ZXPUnicode.h"; sourceTree = "<group>"; }; 2985AE9C1CE72F1500704C91 /* NSArray+ZXPUnicode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+ZXPUnicode.h"; sourceTree = "<group>"; };
2985AE9D1CE72F1500704C91 /* NSDictionary+ZXPUnicode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+ZXPUnicode.h"; sourceTree = "<group>"; }; 2985AE9D1CE72F1500704C91 /* NSDictionary+ZXPUnicode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+ZXPUnicode.h"; sourceTree = "<group>"; };
...@@ -771,6 +774,7 @@ ...@@ -771,6 +774,7 @@
2928F7DE1CD085430036D761 /* Tools */ = { 2928F7DE1CD085430036D761 /* Tools */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
2985345D1DD4B0100023BBAE /* AirPrint */,
291A37741DBA588A00299F0D /* GetJDCardView */, 291A37741DBA588A00299F0D /* GetJDCardView */,
29E2D32A1DB8AFD500443170 /* MDScratchImageView */, 29E2D32A1DB8AFD500443170 /* MDScratchImageView */,
29E2D3211DB878F200443170 /* XLPlainFlowLayout */, 29E2D3211DB878F200443170 /* XLPlainFlowLayout */,
...@@ -1245,6 +1249,15 @@ ...@@ -1245,6 +1249,15 @@
name = XXuserController; name = XXuserController;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
2985345D1DD4B0100023BBAE /* AirPrint */ = {
isa = PBXGroup;
children = (
2985345E1DD4B0290023BBAE /* AirPrintManager.h */,
2985345F1DD4B0290023BBAE /* AirPrintManager.m */,
);
path = AirPrint;
sourceTree = "<group>";
};
2985AE9A1CE72F1500704C91 /* ZXPUnicode */ = { 2985AE9A1CE72F1500704C91 /* ZXPUnicode */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -1957,6 +1970,7 @@ ...@@ -1957,6 +1970,7 @@
29C584ED1CDA429500C6F677 /* ProductDetailsViewController.m in Sources */, 29C584ED1CDA429500C6F677 /* ProductDetailsViewController.m in Sources */,
291D6A6E1D0012AB007891AE /* GoodsCategoryModel.m in Sources */, 291D6A6E1D0012AB007891AE /* GoodsCategoryModel.m in Sources */,
0447085E1CD7C06B00555827 /* LoginViewController.m in Sources */, 0447085E1CD7C06B00555827 /* LoginViewController.m in Sources */,
298534601DD4B0290023BBAE /* AirPrintManager.m in Sources */,
2928F83B1CD0A0CE0036D761 /* CustomTabbarController.m in Sources */, 2928F83B1CD0A0CE0036D761 /* CustomTabbarController.m in Sources */,
295DEA9C1DB70FB9006ED4A6 /* RightControlTableViewCell.m in Sources */, 295DEA9C1DB70FB9006ED4A6 /* RightControlTableViewCell.m in Sources */,
29A9DCAE1CEB643C00A7567A /* CustomWKWebViewController.m in Sources */, 29A9DCAE1CEB643C00A7567A /* CustomWKWebViewController.m in Sources */,
...@@ -2090,8 +2104,8 @@ ...@@ -2090,8 +2104,8 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Brand Assets"; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Brand Assets";
CLANG_ENABLE_OBJC_WEAK = YES; CLANG_ENABLE_OBJC_WEAK = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution: Shanghai Gomore Information Technology Co.,Ltd"; CODE_SIGN_IDENTITY = "iPhone Developer: 云霄 曹 (WM8ZU7YY98)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: Shanghai Gomore Information Technology Co.,Ltd"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COMPRESS_PNG_FILES = NO; COMPRESS_PNG_FILES = NO;
DEVELOPMENT_TEAM = W54V2VB863; DEVELOPMENT_TEAM = W54V2VB863;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
...@@ -2134,7 +2148,7 @@ ...@@ -2134,7 +2148,7 @@
); );
PRODUCT_BUNDLE_IDENTIFIER = com.gomore.opple; PRODUCT_BUNDLE_IDENTIFIER = com.gomore.opple;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "10361169-d429-4810-90f6-528335fe4062"; PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
STRIP_PNG_TEXT = NO; STRIP_PNG_TEXT = NO;
TARGETED_DEVICE_FAMILY = 2; TARGETED_DEVICE_FAMILY = 2;
...@@ -2149,8 +2163,8 @@ ...@@ -2149,8 +2163,8 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Brand Assets"; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = "Brand Assets";
CLANG_ENABLE_OBJC_WEAK = YES; CLANG_ENABLE_OBJC_WEAK = YES;
CODE_SIGN_IDENTITY = "iPhone Distribution: Shanghai Gomore Information Technology Co.,Ltd"; CODE_SIGN_IDENTITY = "iPhone Developer: 云霄 曹 (WM8ZU7YY98)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: Shanghai Gomore Information Technology Co.,Ltd"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COMPRESS_PNG_FILES = NO; COMPRESS_PNG_FILES = NO;
DEVELOPMENT_TEAM = W54V2VB863; DEVELOPMENT_TEAM = W54V2VB863;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
...@@ -2193,7 +2207,7 @@ ...@@ -2193,7 +2207,7 @@
); );
PRODUCT_BUNDLE_IDENTIFIER = com.gomore.opple; PRODUCT_BUNDLE_IDENTIFIER = com.gomore.opple;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "10361169-d429-4810-90f6-528335fe4062"; PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
STRIP_PNG_TEXT = NO; STRIP_PNG_TEXT = NO;
TARGETED_DEVICE_FAMILY = 2; TARGETED_DEVICE_FAMILY = 2;
......
//
// AirPrintManager.h
// Lighting
//
// Created by 曹云霄 on 2016/11/10.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface AirPrintManager : NSObject
/**
打印URL订单
@param data 数据源
@param finish 完成
@param failed 失败
*/
+ (void)printOrderWithdataSoure:(UIViewPrintFormatter *)data printSuccess:(void(^)())finish printError:(void(^)())failed;
@end
//
// AirPrintManager.m
// Lighting
//
// Created by 曹云霄 on 2016/11/10.
// Copyright © 2016年 上海勾芒科技有限公司. All rights reserved.
//
#import "AirPrintManager.h"
@implementation AirPrintManager
/**
打印URL订单
@param data 数据源
@param finish 完成
@param failed 失败
*/
+ (void)printOrderWithdataSoure:(UIViewPrintFormatter *)data printSuccess:(void(^)())finish printError:(void(^)())failed
{
UIPrintInteractionController *printControl = [UIPrintInteractionController sharedPrintController];
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = @"订单明细";
printInfo.duplex = UIPrintInfoDuplexShortEdge;
printControl.printInfo = printInfo;
printControl.showsPageRange = YES;
printControl.printFormatter = data;
void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *pic, BOOL completed, NSError *error) {
if (completed)
{
// 执行成功后的处理
finish();
}
else if (!completed && error)
{
// 执行失败后的处理
failed();
}
};
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
[printControl presentAnimated:YES completionHandler:completionHandler];
}
}
@end
...@@ -238,7 +238,6 @@ ...@@ -238,7 +238,6 @@
#pragma mark 调用airPrint无线打印机 #pragma mark 调用airPrint无线打印机
- (void)callAirprintWithdata:(NSString *)PDFpath SuccessBlock:(void(^)())success ErrorBlock:(void(^)())failed - (void)callAirprintWithdata:(NSString *)PDFpath SuccessBlock:(void(^)())success ErrorBlock:(void(^)())failed
{ {
NSData *mypdfdata = [NSData dataWithContentsOfFile:PDFpath]; NSData *mypdfdata = [NSData dataWithContentsOfFile:PDFpath];
UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController]; UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
if (pic && [UIPrintInteractionController canPrintData: mypdfdata] ) { if (pic && [UIPrintInteractionController canPrintData: mypdfdata] ) {
...@@ -269,54 +268,6 @@ ...@@ -269,54 +268,6 @@
} }
#pragma mark 调用airPrint无线打印机
- (void)callAirprintWithURL:(NSURL *)datasurl SuccessBlock:(void (^)())success ErrorBlock:(void (^)())failed
{
self.printControl = [UIPrintInteractionController sharedPrintController];
self.printControl.delegate = self;
[self.webView loadRequest:[NSURLRequest requestWithURL:datasurl]];//网页
self.webView.navigationDelegate = self;
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = @"订单明细";
printInfo.duplex = UIPrintInfoDuplexShortEdge;
self.printControl.printInfo = printInfo;
self.printControl.showsPageRange = YES;
self.printControl.printFormatter = [self.webView viewPrintFormatter];//布局打印视图绘制的内容。
void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *pic, BOOL completed, NSError *error) {
if (completed)
{
// 执行成功后的处理
success();
}
else if (!completed && error)
{
// 执行失败后的处理
failed();
}
};
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
[self.printControl presentAnimated:YES completionHandler:completionHandler];
}
}
#pragma mark - <WKNavigationDelegate>
- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(null_unspecified WKNavigation *)navigation
{
[self CreateMBProgressHUDLoding];
}
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
{
[self RemoveMBProgressHUDLoding];
}
- (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error
{
[self ErrorMBProgressView:@"打印失败"];
}
#pragma mark -提示文本,图片 #pragma mark -提示文本,图片
- (void)PromptinformationViewWithimage:(UIImage *)image withTitle:(NSString *)title withpoint:(CGPoint)point - (void)PromptinformationViewWithimage:(UIImage *)image withTitle:(NSString *)title withpoint:(CGPoint)point
{ {
......
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