Commit 9534da15ba0ef243503514c44ad44c675d97522e

Authored by yinqiaojuan
1 parent 8157c15b

0.0.1

Showing 50 changed files with 2973 additions and 53 deletions
CNLiveMyOrder.podspec
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 8
9 Pod::Spec.new do |s| 9 Pod::Spec.new do |s|
10 s.name = 'CNLiveMyOrder' 10 s.name = 'CNLiveMyOrder'
11 - s.version = '0.0.1' 11 + s.version = '0.0.2'
12 s.summary = 'A short description of CNLiveMyOrder.' 12 s.summary = 'A short description of CNLiveMyOrder.'
13 s.description = <<-DESC 13 s.description = <<-DESC
14 TODO: Add long description of the pod here. 14 TODO: Add long description of the pod here.
@@ -45,10 +45,13 @@ TODO: Add long description of the pod here. @@ -45,10 +45,13 @@ TODO: Add long description of the pod here.
45 view.dependency 'CNLiveEnvironmentConfiguration' 45 view.dependency 'CNLiveEnvironmentConfiguration'
46 view.dependency 'CNLiveUserManagement' 46 view.dependency 'CNLiveUserManagement'
47 view.dependency 'CNLiveIMBaseSDK' 47 view.dependency 'CNLiveIMBaseSDK'
  48 + #view.dependency 'CNLiveImagePickerController'
  49 + view.dependency 'TZImagePickerController'
  50 + #view.dependency 'CNLiveAVCamera'
  51 + view.dependency 'FBRetainCycleDetector'
48 view.source_files = 'CNLiveMyOrder/Classes/View/*.{h,m}' 52 view.source_files = 'CNLiveMyOrder/Classes/View/*.{h,m}'
49 end 53 end
50 s.subspec 'Controller' do |controller| 54 s.subspec 'Controller' do |controller|
51 - #controller.dependency 'CNLiveMyOrder/Model'  
52 controller.dependency 'CNLiveCommonClass' 55 controller.dependency 'CNLiveCommonClass'
53 controller.dependency 'CNLiveMyOrder/View' 56 controller.dependency 'CNLiveMyOrder/View'
54 controller.dependency 'CNLiveMyOrder/Common' 57 controller.dependency 'CNLiveMyOrder/Common'
@@ -59,6 +62,14 @@ TODO: Add long description of the pod here. @@ -59,6 +62,14 @@ TODO: Add long description of the pod here.
59 controller.dependency 'CNLiveUserManagement' 62 controller.dependency 'CNLiveUserManagement'
60 controller.dependency 'CNLiveTripartiteManagement/YYKit' 63 controller.dependency 'CNLiveTripartiteManagement/YYKit'
61 controller.dependency 'CNLiveIMBaseSDK' 64 controller.dependency 'CNLiveIMBaseSDK'
  65 + controller.dependency 'MJRefresh'
  66 + controller.dependency 'CNLiveIMBaseSDK'
  67 + controller.dependency 'CNLiveCustomUI/CNLiveBasicsUI'
  68 + controller.dependency 'CNLiveTripartiteManagement/Masonry'
  69 + controller.dependency 'CNLiveMyOrder/Model'
  70 + controller.dependency 'CNLiveTripartiteManagement/MJExtension'
  71 + controller.dependency 'CNLiveCommonCategory'
  72 + controller.dependency 'FBRetainCycleDetector'
62 controller.source_files = 'CNLiveMyOrder/Classes/Controller/*.{h,m}' 73 controller.source_files = 'CNLiveMyOrder/Classes/Controller/*.{h,m}'
63 end 74 end
64 s.subspec 'Common' do |common| 75 s.subspec 'Common' do |common|
CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/dd_dianhua.png 0 → 100644

1.2 KB

CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/dd_dianhua@2x.png 0 → 100644

1.68 KB

CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/dd_dianhua@3x.png 0 → 100644

2.2 KB

CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/dd_fuzhi2.png 0 → 100644

1.14 KB

CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/dd_fuzhi2@2x.png 0 → 100644

1.4 KB

CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/dd_fuzhi2@3x.png 0 → 100644

2.05 KB

CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/dd_wutuikuan.png 0 → 100644

3.55 KB

CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/dd_wutuikuan@2x.png 0 → 100644

6.76 KB

CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/dd_wutuikuan@3x.png 0 → 100644

10.1 KB

CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/dd_xialajiantou.png 0 → 100644

977 Bytes

CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/dd_xialajiantou@2x.png 0 → 100644

1021 Bytes

CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/dd_xialajiantou@3x.png 0 → 100644

1.03 KB

CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/drd_xing_kong.png 0 → 100644

1.1 KB

CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/drd_xing_kong@2x.png 0 → 100644

1.56 KB

CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/drd_xing_kong@3x.png 0 → 100644

2.04 KB

CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/fb_bof.png 0 → 100644

1.99 KB

CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/fb_bof@2x.png 0 → 100644

5.18 KB

CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/fb_bof@3x.png 0 → 100644

10 KB

CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/fb_shanchu.png 0 → 100644

1.28 KB

CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/fb_shanchu@2x.png 0 → 100644

1.63 KB

CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/fb_shanchu@3x.png 0 → 100644

2.08 KB

CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/pj_tianjiazhaopian.png 0 → 100644

4.19 KB

CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/pj_tianjiazhaopian@2x.png 0 → 100644

4.12 KB

CNLiveMyOrder/Assets/CNLiveMyOrder.bundle/pj_tianjiazhaopian@3x.png 0 → 100644

12.6 KB

CNLiveMyOrder/Classes/Common/CNLiveOrderHeader.h 0 → 100644
  1 +//
  2 +// CNLiveOrderHeader.h
  3 +// CNLiveMyOrder
  4 +//
  5 +// Created by 殷巧娟 on 2019/6/20.
  6 +//
  7 +
  8 +#ifndef CNLiveOrderHeader_h
  9 +#define CNLiveOrderHeader_h
  10 +
  11 +#ifndef CNRefundReason
  12 +#define CNRefundReason @"CNRefundReason"
  13 +#endif
  14 +#define CNConnectSuccNotification @"CNConnectSuccNotification"
  15 +#define CNConnectingNotification @"CNConnectingNotification"
  16 +#define CNDisconnectNotification @"CNDisconnectNotification"
  17 +#define CNEvaluateSuccessNotioncation @"CNEvaluateSuccessNotioncation" //评论成功
  18 +#define CNApplyRefundSuccessNotification @"CNApplyRefundSuccessNotification" //申请退款成功
  19 +#endif /* CNLiveOrderHeader_h */
CNLiveMyOrder/Classes/Controller/CNLiveApplyRefundController.h 0 → 100644
  1 +//
  2 +// CNLiveApplyRefundController.h
  3 +// CNLiveMyOrder
  4 +//
  5 +// Created by 殷巧娟 on 2019/6/20.
  6 +//
  7 +
  8 +#import "CNCommonViewController.h"
  9 +#import "CNLiveOrderList.h"
  10 +NS_ASSUME_NONNULL_BEGIN
  11 +
  12 +@interface CNLiveApplyRefundController : CNCommonViewController
  13 +@property (nonatomic, strong) CNLiveOrderList *list;
  14 +@end
  15 +
  16 +NS_ASSUME_NONNULL_END
CNLiveMyOrder/Classes/Controller/CNLiveApplyRefundController.m 0 → 100644
  1 +//
  2 +// CNLiveApplyRefundController.m
  3 +// CNLiveMyOrder
  4 +//
  5 +// Created by 殷巧娟 on 2019/6/20.
  6 +//
  7 +
  8 +#import "CNLiveApplyRefundController.h"
  9 +#import "CNLiveMineOrderView.h"
  10 +#import "CNSelectedRefundReasonView.h"
  11 +#import "CNLiveUploadVoucher.h"
  12 +#import "CNLiveOrderDetailContentView.h"
  13 +#import <CNLiveRequestBastKit/CNLiveNetworking.h>
  14 +#import "QMUIKit.h"
  15 +#import "MJExtension.h"
  16 +#import "CNLiveBaseKit.h"
  17 +#import "CNLiveGetImage.h"
  18 +#import "CNErrorOrNoNetView.h"
  19 +#import "CNLiveCommonCategory.h"
  20 +#import "Masonry.h"
  21 +#import "FBRetainCycleDetector.h"
  22 +#import "TIMAdapter.h"
  23 +#import "CommonLibrary.h"
  24 +#import "CNLiveEnvironmentConfiguration.h"
  25 +#import "CNLiveNetworking.h"
  26 +#import "AFNetworking.h"
  27 +#import "CNLiveOrderHeader.h"
  28 +#define Default_H 45
  29 +@interface CNLiveApplyRefundController ()<CNUploadVoucherDelegate,UIGestureRecognizerDelegate>
  30 +@property (nonatomic, strong) NSArray *images;
  31 +@property (nonatomic, strong) CNLiveOrderListOrderItem *orderItem;
  32 +@property (nonatomic, strong) UIScrollView *scrollView;
  33 +
  34 +@property (nonatomic, strong) CNLiveOrderDetailContentView *kindView;
  35 +@property (nonatomic, strong) CNLiveServiceTypeView *serviceView;
  36 +@property (nonatomic, strong) CNLiveOrderNormalView *feeView;
  37 +@property (nonatomic, strong) CNLiveOrderNormalView *freightView;
  38 +@property (nonatomic, strong) CNLiveOrderNormalView *deliveryView; //配送方式
  39 +@property (nonatomic, strong) CNLiveOrderNormalView *refunEnableView;; //是否允许退款
  40 +
  41 +@property (nonatomic, strong) CNLiveActuallyPaidView *totalView;
  42 +
  43 +@property (nonatomic, strong) CNLiveRefundReasonView *refundReasonView;
  44 +@property (nonatomic, strong) CNLiveRefundSumView *refundSumView;
  45 +@property (nonatomic, strong) CNLiveRefundNoteView *refundNoteView;
  46 +@property (nonatomic, strong) CNLiveUploadVoucher *voucherView;
  47 +
  48 +@property (nonatomic, strong) CNSelectedRefundReasonView *settingReasonView;
  49 +
  50 +@property (nonatomic, strong) UIView *line1;
  51 +@property (nonatomic, strong) UIView *line2;
  52 +@property (nonatomic, strong) UIView *line3;
  53 +@property (nonatomic, strong) UIView *line4;
  54 +@property (nonatomic, strong) UIView *line5;
  55 +@property (nonatomic, strong) UIView *line6;
  56 +@property (nonatomic, strong) UIView *line7;
  57 +
  58 +@property (nonatomic, strong) UIButton *submitBtn;
  59 +@property (nonatomic, strong) UIView *submitView;
  60 +@property (nonatomic, strong) NSString *reason;
  61 +@end
  62 +
  63 +@implementation CNLiveApplyRefundController
  64 +
  65 +- (void)dealloc {
  66 + NSLog(@"申请退款走了dealloc了吗");
  67 +}
  68 +- (void)viewDidLoad {
  69 + [super viewDidLoad];
  70 + self.title = @"申请退款";
  71 + FBRetainCycleDetector *detector = [FBRetainCycleDetector new];
  72 + [detector addCandidate:self];
  73 + NSSet *retainCycles = [detector findRetainCycles];
  74 + NSLog(@"打印retainCycles%@", retainCycles);
  75 +}
  76 +- (void)initSubviews {
  77 + [super initSubviews];
  78 +
  79 + UIWindow *window = [[UIApplication sharedApplication].windows lastObject];
  80 + [window addSubview:self.settingReasonView];
  81 +
  82 + [self.view addSubview:self.scrollView];
  83 + [self.scrollView addSubview:self.submitView];
  84 + [self.scrollView addSubview:self.kindView];
  85 + [self.scrollView addSubview:self.serviceView];
  86 + [self.scrollView addSubview:self.feeView];
  87 + [self.scrollView addSubview:self.freightView];
  88 + [self.scrollView addSubview:self.deliveryView];
  89 + [self.scrollView addSubview:self.refunEnableView];
  90 + [self.scrollView addSubview:self.totalView];
  91 + [self.scrollView addSubview:self.refundReasonView];
  92 + [self.scrollView addSubview:self.refundSumView];
  93 + [self.scrollView addSubview:self.refundNoteView];
  94 + [self.scrollView addSubview:self.voucherView];
  95 +
  96 + [self.scrollView addSubview:self.line1];
  97 + [self.scrollView addSubview:self.line2];
  98 + [self.scrollView addSubview:self.line3];
  99 + [self.scrollView addSubview:self.line4];
  100 + [self.scrollView addSubview:self.line5];
  101 + [self.scrollView addSubview:self.line6];
  102 + [self.scrollView addSubview:self.line7];
  103 + [self p_addMasonry];
  104 +}
  105 +- (void)setList:(CNLiveOrderList *)list {
  106 +
  107 + _orderItem = list.orderItem;
  108 +
  109 + self.kindView.list = list;
  110 + self.serviceView.list = list;
  111 + [self.feeView setTitle:@"服务费" subTitle:[NSString stringWithFormat:@"%.2f",(float)_orderItem.fee]];
  112 + [self.freightView setTitle:@"运费" subTitle:[NSString stringWithFormat:@"%.2f",(float)_orderItem.freight]];
  113 + [self.refunEnableView setTitle:@"是否可以退款" subTitle:_orderItem.refundable == true ? @"是" : @"否"];
  114 + [self.deliveryView setTitle:@"配送方式" subTitle:_orderItem.distributionContent];
  115 + self.totalView.list = list;
  116 +
  117 + weakself
  118 + self.refundReasonView.handle = ^{
  119 +
  120 + [weakSelf.settingReasonView show];
  121 +
  122 + };
  123 +
  124 +}
  125 +#pragma mark -TargetAction
  126 +- (void)submitBtnDidSelected {
  127 + if ([NSString isEmpty:_reason]) {
  128 + [[HUDHelper sharedInstance] tipMessage:@"退款原因不能为空"];
  129 + return;
  130 + }
  131 +
  132 + if ([NSString isEmpty:_refundSumView.sumTextField.text]) {
  133 + [[HUDHelper sharedInstance] tipMessage:@"退款金额不能为空"];
  134 + return;
  135 + }
  136 + if ([_refundSumView.sumTextField.text floatValue] <= 0) {
  137 + [[HUDHelper sharedInstance] tipMessage:@"退款金额要大于0"];
  138 + return;
  139 + }
  140 + NSNumber *totalPriceNumber = [NSNumber numberWithFloat:_orderItem.totalPrice];
  141 + NSNumber *refundPriceNumber = [NSNumber numberWithFloat:[_refundSumView.sumTextField.text floatValue]];
  142 +
  143 + if ([refundPriceNumber compare:totalPriceNumber] == NSOrderedDescending) {
  144 + [[HUDHelper sharedInstance] tipMessage:@"退款金额不能大于总金额"];
  145 + return;
  146 + }
  147 +
  148 + [QMUITips showLoadingInView:self.view];
  149 + NSDictionary *param = @{@"sid":@"10511059",
  150 + @"appId":AppId,
  151 + @"plat":@"i",
  152 + @"orderId":_orderItem.orderId,
  153 + @"note":[NSString isEmpty:_refundNoteView.noteTextField.text] ? @"" : [_refundNoteView.noteTextField.text qmui_trim],
  154 + @"refundSum":_refundSumView.sumTextField.text,
  155 + @"cause":[_reason qmui_trim]
  156 + };
  157 + [CNLiveNetworking uploadNetworkWithURLString:CNApplyRefundUrl Param:param FormDataBlock:^(id<AFMultipartFormData> formData) {
  158 + [self->_images enumerateObjectsUsingBlock:^(UIImage *image, NSUInteger idx, BOOL * _Nonnull stop) {
  159 +
  160 + NSData *imageData = UIImageJPEGRepresentation(image, 0.5);
  161 + NSString *fileName = [NSString stringWithFormat:@"Image%d", (int)idx+1];
  162 + NSString *name = [NSString stringWithFormat:@"Image%d",(int)idx+1];
  163 + /*
  164 + *该方法的参数
  165 + 1. appendPartWithFileData:要上传的照片[二进制流]
  166 + 2. name:对应网站上[upload.php中]处理文件的字段(比如upload)
  167 + 3. fileName:要保存在服务器上的文件名
  168 + 4. mimeType:上传的文件的类型
  169 + */
  170 + [formData appendPartWithFileData:imageData name:name fileName:fileName mimeType:@"image/jpeg"];
  171 + }];
  172 + } ProgressBlock:nil CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
  173 + [QMUITips hideAllToastInView:self.view animated:YES];
  174 + if (error) {
  175 + [[HUDHelper sharedInstance] tipMessage:error.description];
  176 + }else{
  177 + if ([responseObject[@"errorCode"] integerValue] == 0) {
  178 + //申请退款成功
  179 +// [[AppDelegate sharedAppDelegate] popViewController];
  180 + [self.navigationController popViewControllerAnimated:YES];
  181 + [[NSNotificationCenter defaultCenter] postNotificationName:CNApplyRefundSuccessNotification object:nil];
  182 + } else {
  183 + [[HUDHelper sharedInstance] tipMessage:@"申请退款失败"];
  184 + }
  185 + }
  186 + }];
  187 +}
  188 +- (void)scrollTap:(id)sender {
  189 +}
  190 +
  191 +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
  192 +
  193 + if ([touch.view isKindOfClass:[QMUITestView class]]) {
  194 + return YES;
  195 + } else {
  196 + [self.view endEditing:YES];
  197 + return NO;
  198 + }
  199 +
  200 +}
  201 +#pragma mark -
  202 +#pragma mark - CNUploadVoucherDelegate
  203 +- (void)updateImages:(NSArray *)images {
  204 + _images = images;
  205 +
  206 + [self.view layoutIfNeeded];
  207 + self.scrollView.contentSize = CGSizeMake(KScreenWidth, self.submitView.bottom);
  208 +}
  209 +
  210 +- (void)p_addMasonry {
  211 +
  212 + // [super viewDidLayoutSubviews];
  213 +
  214 + [self.kindView mas_makeConstraints:^(MASConstraintMaker *make) {
  215 + make.left.mas_equalTo(self.scrollView);
  216 + make.top.mas_equalTo(0);
  217 + make.width.mas_equalTo(KScreenWidth);
  218 + }];
  219 +
  220 + [self.line1 mas_makeConstraints:^(MASConstraintMaker *make) {
  221 + make.left.mas_equalTo(10);
  222 + make.size.mas_equalTo(CGSizeMake(KScreenWidth-20, 0.5));
  223 + make.bottom.mas_equalTo(self.kindView.mas_bottom);
  224 + }];
  225 +
  226 + [self.serviceView mas_makeConstraints:^(MASConstraintMaker *make) {
  227 + make.left.mas_equalTo(self.scrollView);
  228 + make.top.mas_equalTo(self.kindView.mas_bottom);
  229 + make.width.mas_equalTo(KScreenWidth);
  230 + make.height.mas_equalTo(Default_H);
  231 + }];
  232 +
  233 + [self.line2 mas_makeConstraints:^(MASConstraintMaker *make) {
  234 + make.left.mas_equalTo(10);
  235 + make.size.mas_equalTo(CGSizeMake(KScreenWidth-20, 0.5));
  236 + make.bottom.mas_equalTo(self.serviceView.mas_bottom);
  237 + }];
  238 +
  239 + [self.feeView mas_makeConstraints:^(MASConstraintMaker *make) {
  240 + make.left.mas_equalTo(self.scrollView);
  241 + make.top.mas_equalTo(self.serviceView.mas_bottom);
  242 + make.width.mas_equalTo(KScreenWidth);
  243 + make.height.mas_equalTo(Default_H);
  244 + }];
  245 +
  246 + [self.line3 mas_makeConstraints:^(MASConstraintMaker *make) {
  247 + make.left.mas_equalTo(10);
  248 + make.size.mas_equalTo(CGSizeMake(KScreenWidth-20, 0.5));
  249 + make.bottom.mas_equalTo(self.feeView.mas_bottom);
  250 + }];
  251 +
  252 + [self.freightView mas_makeConstraints:^(MASConstraintMaker *make) {
  253 + make.left.mas_equalTo(self.scrollView);
  254 + make.top.mas_equalTo(self.feeView.mas_bottom);
  255 + make.width.mas_equalTo(KScreenWidth);
  256 + make.height.mas_equalTo(Default_H);
  257 + }];
  258 +
  259 + [self.line4 mas_makeConstraints:^(MASConstraintMaker *make) {
  260 + make.left.mas_equalTo(10);
  261 + make.size.mas_equalTo(CGSizeMake(KScreenWidth-20, 0.5));
  262 + make.bottom.mas_equalTo(self.freightView.mas_bottom);
  263 + }];
  264 +
  265 + [self.deliveryView mas_remakeConstraints:^(MASConstraintMaker *make) {
  266 + make.left.mas_equalTo(0);
  267 + make.top.mas_equalTo(self.line4.mas_bottom);
  268 + make.width.mas_equalTo(KScreenWidth);
  269 + make.height.mas_equalTo(Default_H);
  270 + }];
  271 +
  272 + [self.refunEnableView mas_remakeConstraints:^(MASConstraintMaker *make) {
  273 + make.left.mas_equalTo(0);
  274 + make.top.mas_equalTo(self.deliveryView.mas_bottom).mas_offset(10);
  275 + make.width.mas_equalTo(KScreenWidth);
  276 + make.height.mas_equalTo(Default_H);
  277 + }];
  278 +
  279 + [self.totalView mas_remakeConstraints:^(MASConstraintMaker *make) {
  280 + make.left.mas_equalTo(0);
  281 + make.top.mas_equalTo(self.refunEnableView.mas_bottom).mas_offset(10);
  282 + make.width.mas_equalTo(KScreenWidth);
  283 + make.height.mas_equalTo(125);
  284 + }];
  285 +
  286 + [self.refundReasonView mas_makeConstraints:^(MASConstraintMaker *make) {
  287 + make.left.mas_equalTo(self.kindView);
  288 + make.top.mas_equalTo(self.totalView.mas_bottom).mas_offset(10);
  289 + make.width.mas_equalTo(KScreenWidth);
  290 + make.height.mas_equalTo(Default_H);
  291 + }];
  292 +
  293 + [self.line5 mas_makeConstraints:^(MASConstraintMaker *make) {
  294 + make.left.mas_equalTo(10);
  295 + make.size.mas_equalTo(CGSizeMake(KScreenWidth-20, 0.5));
  296 + make.bottom.mas_equalTo(self.refundReasonView.mas_bottom);
  297 + }];
  298 +
  299 + [self.refundSumView mas_makeConstraints:^(MASConstraintMaker *make) {
  300 + make.left.mas_equalTo(self.kindView);
  301 + make.top.mas_equalTo(self.refundReasonView.mas_bottom);
  302 + make.width.mas_equalTo(KScreenWidth);
  303 + make.height.mas_equalTo(Default_H);
  304 + }];
  305 +
  306 + [self.line6 mas_makeConstraints:^(MASConstraintMaker *make) {
  307 + make.left.mas_equalTo(10);
  308 + make.size.mas_equalTo(CGSizeMake(KScreenWidth-20, 0.5));
  309 + make.bottom.mas_equalTo(self.refundSumView.mas_bottom);
  310 + }];
  311 +
  312 + [self.refundNoteView mas_makeConstraints:^(MASConstraintMaker *make) {
  313 + make.left.mas_equalTo(self.kindView);
  314 + make.top.mas_equalTo(self.refundSumView.mas_bottom);
  315 + make.width.mas_equalTo(KScreenWidth);
  316 + make.height.mas_equalTo(Default_H);
  317 + }];
  318 +
  319 + [self.line7 mas_makeConstraints:^(MASConstraintMaker *make) {
  320 + make.left.mas_equalTo(10);
  321 + make.size.mas_equalTo(CGSizeMake(KScreenWidth-20, 0.5));
  322 + make.bottom.mas_equalTo(self.refundNoteView.mas_bottom);
  323 + }];
  324 +
  325 +
  326 + CGFloat height = (KScreenWidth - 20 - 2 * 8 - 4) / 3 - 8 + 60;
  327 +
  328 + [self.voucherView mas_makeConstraints:^(MASConstraintMaker *make) {
  329 + make.left.mas_equalTo(self.kindView);
  330 + make.top.mas_equalTo(self.refundNoteView.mas_bottom);
  331 + make.width.mas_equalTo(KScreenWidth);
  332 + make.height.mas_equalTo(height);
  333 + }];
  334 +
  335 + [self.submitView mas_makeConstraints:^(MASConstraintMaker *make) {
  336 + make.left.mas_equalTo(0);
  337 + make.top.mas_equalTo(self.voucherView.mas_bottom);
  338 + make.width.mas_equalTo(KScreenWidth);
  339 + make.height.mas_equalTo(55+37+76);
  340 +
  341 + }];
  342 +
  343 + [self.view layoutIfNeeded];
  344 + self.scrollView.contentSize = CGSizeMake(KScreenWidth, self.submitView.bottom);
  345 +
  346 +}
  347 +
  348 +
  349 +
  350 +
  351 +#pragma mark -
  352 +#pragma mark - Getter
  353 +- (UIScrollView *)scrollView
  354 +{
  355 + if (!_scrollView) {
  356 + _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, kNavigationBarHeight, KScreenWidth, KScreenHeight-kNavigationBarHeight)];
  357 + _scrollView.backgroundColor = kWeChatBgColor;
  358 + UITapGestureRecognizer *myTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(scrollTap:)];
  359 + myTap.delegate = self;
  360 + [_scrollView addGestureRecognizer:myTap];
  361 + }
  362 + return _scrollView;
  363 +}
  364 +
  365 +- (CNLiveOrderDetailContentView *)kindView
  366 +{
  367 + if (!_kindView) {
  368 + _kindView = [[CNLiveOrderDetailContentView alloc] init];
  369 + }
  370 + return _kindView;
  371 +}
  372 +
  373 +- (CNLiveServiceTypeView *)serviceView
  374 +{
  375 + if (!_serviceView) {
  376 + _serviceView = [[CNLiveServiceTypeView alloc] init];
  377 + }
  378 + return _serviceView;
  379 +}
  380 +
  381 +- (CNLiveOrderNormalView *)feeView
  382 +{
  383 + if (!_feeView) {
  384 + _feeView = [[CNLiveOrderNormalView alloc] init];
  385 + }
  386 + return _feeView;
  387 +}
  388 +
  389 +- (CNLiveOrderNormalView *)freightView
  390 +{
  391 + if (!_freightView) {
  392 + _freightView = [[CNLiveOrderNormalView alloc] init];
  393 + }
  394 + return _freightView;
  395 +}
  396 +
  397 +- (CNLiveOrderNormalView *)deliveryView
  398 +{
  399 + if (!_deliveryView) {
  400 + _deliveryView = [[CNLiveOrderNormalView alloc] init];
  401 + }
  402 + return _deliveryView;
  403 +}
  404 +
  405 +- (CNLiveActuallyPaidView *)totalView
  406 +{
  407 + if (!_totalView) {
  408 + _totalView = [[CNLiveActuallyPaidView alloc] init];
  409 + }
  410 + return _totalView;
  411 +}
  412 +
  413 +- (CNLiveOrderNormalView *)refunEnableView
  414 +{
  415 + if (!_refunEnableView) {
  416 + _refunEnableView = [[CNLiveOrderNormalView alloc] init];
  417 + }
  418 + return _refunEnableView;
  419 +}
  420 +
  421 +- (CNLiveRefundReasonView *)refundReasonView
  422 +{
  423 + if (!_refundReasonView) {
  424 + _refundReasonView = [[CNLiveRefundReasonView alloc] init];
  425 + }
  426 + return _refundReasonView;
  427 +}
  428 +
  429 +- (CNLiveRefundSumView *)refundSumView
  430 +{
  431 + if (!_refundSumView) {
  432 + _refundSumView = [[CNLiveRefundSumView alloc] init];
  433 + }
  434 + return _refundSumView;
  435 +}
  436 +
  437 +- (CNLiveRefundNoteView *)refundNoteView
  438 +{
  439 + if (!_refundNoteView) {
  440 + _refundNoteView = [[CNLiveRefundNoteView alloc] init];
  441 + }
  442 + return _refundNoteView;
  443 +}
  444 +
  445 +- (CNSelectedRefundReasonView *)settingReasonView
  446 +{
  447 + if (!_settingReasonView) {
  448 +
  449 + weakself
  450 + _settingReasonView = [[CNSelectedRefundReasonView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight) completionBlock:^(NSString *reason) {
  451 +
  452 + [weakSelf.refundReasonView.reasonBtn setTitle:reason forState:UIControlStateNormal];
  453 + [weakSelf.refundReasonView.reasonBtn setTitleColor:KTextBlackColor forState:UIControlStateNormal];
  454 + weakSelf.reason = reason;
  455 + // [weakSelf.refundReasonView setReasonText:[NSString stringWithFormat:@"退款原因: %@", reason] showMore:YES];
  456 + }];
  457 + _settingReasonView.hidden = YES;
  458 + }
  459 + return _settingReasonView;
  460 +}
  461 +
  462 +- (CNLiveUploadVoucher *)voucherView
  463 +{
  464 + if (!_voucherView) {
  465 + _voucherView = [[CNLiveUploadVoucher alloc] init];
  466 + UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(15, 15, KScreenWidth-30, 15)];
  467 + label.textColor = KTextBlackColor;
  468 + label.text = @"上传凭证";
  469 + label.font = UIFontMake(15);
  470 + _voucherView.titleLabel = label;
  471 + [_voucherView configCollectionView];
  472 + _voucherView.delegate = self;
  473 + }
  474 + return _voucherView;
  475 +}
  476 +
  477 +- (UIButton *)submitBtn
  478 +{
  479 + if (!_submitBtn) {
  480 + _submitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  481 + _submitBtn.frame = CGRectMake(20, 20, KScreenWidth-40, 55);
  482 + [_submitBtn setBackgroundImage:CNLiveUIImageWithColor(KYellowColor) forState:UIControlStateNormal];
  483 + [_submitBtn setBackgroundImage:CNLiveUIImageWithColor(KYellowHightColor) forState:UIControlStateHighlighted];
  484 + [_submitBtn setTitle:@"提交" forState:UIControlStateNormal];
  485 + _submitBtn.layer.cornerRadius = 3.;
  486 + _submitBtn.layer.masksToBounds = YES;
  487 + [_submitBtn addTarget:self action:@selector(submitBtnDidSelected) forControlEvents:UIControlEventTouchUpInside];
  488 + }
  489 + return _submitBtn;
  490 +}
  491 +
  492 +- (UIView *)submitView
  493 +{
  494 + if (!_submitView) {
  495 + _submitView = [[UIView alloc] init];
  496 + _submitView.backgroundColor = kWhiteColor;
  497 + [_submitView addSubview:self.submitBtn];
  498 + }
  499 + return _submitView;
  500 +}
  501 +
  502 +- (UIView *)line1
  503 +{
  504 + if (!_line1) {
  505 + _line1 = [[UIView alloc] init];
  506 + _line1.backgroundColor = KCommonLineColor;
  507 + }
  508 + return _line1;
  509 +}
  510 +
  511 +- (UIView *)line2
  512 +{
  513 + if (!_line2) {
  514 + _line2 = [[UIView alloc] init];
  515 + _line2.backgroundColor = KCommonLineColor;
  516 + }
  517 + return _line2;
  518 +}
  519 +
  520 +- (UIView *)line3
  521 +{
  522 + if (!_line3) {
  523 + _line3 = [[UIView alloc] init];
  524 + _line3.backgroundColor = KCommonLineColor;
  525 + }
  526 + return _line3;
  527 +}
  528 +
  529 +- (UIView *)line4
  530 +{
  531 + if (!_line4) {
  532 + _line4 = [[UIView alloc] init];
  533 + _line4.backgroundColor = KCommonLineColor;
  534 + }
  535 + return _line4;
  536 +}
  537 +
  538 +- (UIView *)line5
  539 +{
  540 + if (!_line5) {
  541 + _line5 = [[UIView alloc] init];
  542 + _line5.backgroundColor = KCommonLineColor;
  543 + }
  544 + return _line5;
  545 +}
  546 +
  547 +- (UIView *)line6
  548 +{
  549 + if (!_line6) {
  550 + _line6 = [[UIView alloc] init];
  551 + _line6.backgroundColor = KCommonLineColor;
  552 + }
  553 + return _line6;
  554 +}
  555 +
  556 +- (UIView *)line7
  557 +{
  558 + if (!_line7) {
  559 + _line7 = [[UIView alloc] init];
  560 + _line7.backgroundColor = KCommonLineColor;
  561 + }
  562 + return _line7;
  563 +}
  564 +
  565 +- (void)didReceiveMemoryWarning {
  566 + [super didReceiveMemoryWarning];
  567 + // Dispose of any resources that can be recreated.
  568 +}
  569 +
  570 +@end
CNLiveMyOrder/Classes/Controller/CNLiveEvaluateController.h 0 → 100644
  1 +//
  2 +// CNLiveEvaluateController.h
  3 +// CNLiveMyOrder
  4 +//
  5 +// Created by 殷巧娟 on 2019/6/19.
  6 +//
  7 +
  8 +#import <CNLiveCommonClass/CNLiveCommonClass.h>
  9 +#import "CNLiveOrderList.h"
  10 +NS_ASSUME_NONNULL_BEGIN
  11 +
  12 +@interface CNLiveEvaluateController : CNCommonViewController
  13 +@property (nonatomic, strong) CNLiveOrderList *list;
  14 +@end
  15 +
  16 +NS_ASSUME_NONNULL_END
CNLiveMyOrder/Classes/Controller/CNLiveEvaluateController.m 0 → 100644
  1 +//
  2 +// CNLiveEvaluateController.m
  3 +// CNLiveMyOrder
  4 +//
  5 +// Created by 殷巧娟 on 2019/6/19.
  6 +//
  7 +
  8 +#import "CNLiveEvaluateController.h"
  9 +#import "CNLiveMineOrderView.h"
  10 +#import "CNLiveNetworking.h"
  11 +#import "CNLiveBaseKit.h"
  12 +#import "QMUIKit.h"
  13 +#import "CNLiveUploadVoucher.h"
  14 +#import "Masonry.h"
  15 +#import "CNLiveEnvironmentConfiguration.h"
  16 +#import "AFNetworking.h"
  17 +#import "CNLiveOrderHeader.h"
  18 +#import "FBRetainCycleDetector.h"
  19 +@interface CNLiveEvaluateController ()<CNLiveEvaluateStarViewDelegate,UIGestureRecognizerDelegate,QMUITextViewDelegate,CNUploadVoucherDelegate>
  20 +@property (nonatomic, assign) int score;
  21 +@property (nonatomic, strong) NSArray *images;
  22 +@property (nonatomic, assign) CGFloat keyboardHeight;
  23 +@property (nonatomic, strong) QMUIButton *closeKeyBtn; //关闭键盘btn
  24 +@property (nonatomic, strong) UIScrollView *scrollView;
  25 +@property (nonatomic, strong) CNLiveEvaluateStarView *evaluateView;
  26 +@property (nonatomic, strong) QMUITextView *textView;
  27 +@property (nonatomic, strong) CNLiveUploadVoucher *voucherView;
  28 +@end
  29 +
  30 +@implementation CNLiveEvaluateController
  31 +- (void)dealloc {
  32 + NSLog(@"评论晒单走了dealloc了吗");
  33 +}
  34 +- (void)viewDidLoad {
  35 + [super viewDidLoad];
  36 + self.title = @"评论晒单";
  37 + UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"提交" style:UIBarButtonItemStylePlain target:self action:@selector(publishAction:)];
  38 + self.navigationItem.rightBarButtonItem = item;
  39 + self.score = 6;
  40 + [self.view addSubview:self.scrollView];
  41 + [self.scrollView addSubview:self.evaluateView];
  42 + [self.scrollView addSubview:self.textView];
  43 + [self.scrollView addSubview:self.voucherView];
  44 + [self p_addMasonry];
  45 + __weak typeof(self)weakSelf = self;
  46 + _textView.qmui_keyboardWillChangeFrameNotificationBlock = ^(QMUIKeyboardUserInfo *keyboardUserInfo) {
  47 + [QMUIKeyboardManager handleKeyboardNotificationWithUserInfo:keyboardUserInfo showBlock:^(QMUIKeyboardUserInfo *keyboardUserInfo) {
  48 + [weakSelf addCloseKeyBtnWithKeyboardUserInfo:keyboardUserInfo];
  49 + } hideBlock:^(QMUIKeyboardUserInfo *keyboardUserInfo) {
  50 + }];
  51 + };
  52 + FBRetainCycleDetector *detector = [FBRetainCycleDetector new];
  53 + [detector addCandidate:self];
  54 + NSSet *retainCycles = [detector findRetainCycles];
  55 + NSLog(@"打印retainCycles%@", retainCycles);
  56 +}
  57 +#pragma mark - 点击关闭键盘透明Btn Show And Hide
  58 +- (void)addCloseKeyBtnWithKeyboardUserInfo:(QMUIKeyboardUserInfo *)keyboardUserInfo {
  59 + // 键盘
  60 + __weak typeof(self) weakSelf = self;
  61 + [QMUIKeyboardManager animateWithAnimated:YES keyboardUserInfo:keyboardUserInfo animations:^{
  62 + CGFloat distanceFromBottom = [QMUIKeyboardManager distanceFromMinYToBottomInView:self.view keyboardRect:keyboardUserInfo.endFrame];
  63 + weakSelf.keyboardHeight = distanceFromBottom;
  64 + [self closeKeyBtn];
  65 + weakSelf.closeKeyBtn.hidden = NO;
  66 +
  67 + } completion:NULL];
  68 +}
  69 +
  70 +- (void)closKeyboard
  71 +{
  72 + _closeKeyBtn.hidden = YES;
  73 + [self.view endEditing:YES];
  74 +}
  75 +- (QMUIButton *)closeKeyBtn
  76 +{
  77 + if (!_closeKeyBtn)
  78 + {
  79 + _closeKeyBtn = [[QMUIButton alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight - _keyboardHeight)];
  80 + [_closeKeyBtn addTarget:self action:@selector(closKeyboard) forControlEvents:UIControlEventTouchUpInside];
  81 + [self.view addSubview:_closeKeyBtn];
  82 + }
  83 + return _closeKeyBtn;
  84 +}
  85 +
  86 +- (void)p_addMasonry {
  87 +
  88 + CGFloat height = (KScreenWidth -20 - 2 * 8 - 4) / 3 - 8 + 60 + 20;
  89 + [self.voucherView mas_makeConstraints:^(MASConstraintMaker *make) {
  90 + make.left.mas_equalTo(self.scrollView);
  91 + make.top.mas_equalTo(self.textView.mas_bottom).mas_offset(1);
  92 + make.width.mas_equalTo(KScreenWidth);
  93 + make.height.mas_equalTo(height);
  94 + }];
  95 +}
  96 +- (void)setList:(CNLiveOrderList *)list {
  97 +
  98 + _list = list;
  99 + self.evaluateView.list = list;
  100 +}
  101 +#pragma mark -
  102 +#pragma mark - Action
  103 +- (void)publishAction:(UIBarButtonItem *)sender {
  104 + sender.enabled = NO;
  105 + [self performSelector:@selector(delayAction:) withObject:sender afterDelay:1.5];//防重复点
  106 +}
  107 +- (void)delayAction:(UIBarButtonItem *)sender {
  108 + sender.enabled = YES;
  109 + _textView.text = [_textView.text qmui_trim];
  110 + if (_textView.text.length < 15) {
  111 + [QMUITips showWithText:@"您的评价至少需要15个字!" inView:self.view hideAfterDelay:1.5];
  112 + return;
  113 + }
  114 + CNLiveOrderListIconBean *iconBean = _list.iconBean;
  115 + CNLiveOrderListOrderItem *orderItem = _list.orderItem;
  116 + [QMUITips showLoadingInView:self.view];
  117 + NSDictionary *param = @{@"appId":AppId,
  118 + @"sid":@"10511059",
  119 + @"darenId":iconBean.userId,
  120 + @"orderId":orderItem.orderId,
  121 + @"grade":[NSString stringWithFormat:@"%d", _score],//@(_score),
  122 + @"comment":_textView.text ?: @"",
  123 + @"plat":@"i"
  124 + };
  125 + [CNLiveNetworking uploadNetworkWithURLString:CNCommentDarenUrl Param:param FormDataBlock:^(id<AFMultipartFormData> formData) {
  126 + [self->_images enumerateObjectsUsingBlock:^(UIImage *image, NSUInteger idx, BOOL * _Nonnull stop) {
  127 + ///压缩(lxg)
  128 + // 图片视频压缩(LXG)
  129 + NSData *imageData = UIImageJPEGRepresentation(image, 0.6);//非原图压缩
  130 + NSString *fileName = [NSString stringWithFormat:@"Image%d", (int)idx+1];
  131 + NSString *name = [NSString stringWithFormat:@"Image%d",(int)idx+1];
  132 + /*
  133 + *该方法的参数
  134 + 1. appendPartWithFileData:要上传的照片[二进制流]
  135 + 2. name:对应网站上[upload.php中]处理文件的字段(比如upload)
  136 + 3. fileName:要保存在服务器上的文件名
  137 + 4. mimeType:上传的文件的类型
  138 + */
  139 + [formData appendPartWithFileData:imageData name:name fileName:fileName mimeType:@"image/jpeg"];
  140 +
  141 + }];
  142 + } ProgressBlock:NULL CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
  143 + if (error) {
  144 + [QMUITips hideAllToastInView:self.view animated:YES];
  145 + // [QMUITips showError:@"评价失败,请重试" inView:self.view hideAfterDelay:1.5];
  146 + [QMUITips showError:error.description inView:self.view hideAfterDelay:1.5];
  147 + }else{
  148 + [QMUITips hideAllToastInView:self.view animated:YES];
  149 + if ([responseObject[@"errorCode"] integerValue] == 0) {
  150 + [[NSNotificationCenter defaultCenter] postNotificationName:CNEvaluateSuccessNotioncation object:nil];
  151 + [QMUITips showSucceed:@"感谢您的点评!" inView:self.view hideAfterDelay:1.5];
  152 + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  153 +// [[AppDelegate sharedAppDelegate] popViewController];
  154 + [self.navigationController popViewControllerAnimated:YES];
  155 + });
  156 + } else {
  157 + [QMUITips showError:@"评价失败,请重试" inView:self.view hideAfterDelay:1.5];
  158 + }
  159 + }
  160 + }];
  161 +
  162 +}
  163 +#pragma mark -
  164 +#pragma mark - CNUploadVoucherDelegate
  165 +- (void)updateImages:(NSArray *)images {
  166 + _images = images;
  167 + self.scrollView.contentSize = CGSizeMake(KScreenWidth, self.voucherView.bottom);
  168 +}
  169 +#pragma mark - 返回
  170 +- (BOOL)shouldHoldBackButtonEvent {
  171 + return YES;
  172 +}
  173 +-(BOOL)canPopViewController
  174 +{
  175 + if ([self.textView.text isEqualToString:@""]) {
  176 + return YES;
  177 + }
  178 + else
  179 + {
  180 + UIAlertController *alter = [UIAlertController alertControllerWithTitle:@"您有评论未发送,确定要返回吗?" message:nil preferredStyle:UIAlertControllerStyleAlert];
  181 + weakself
  182 + [alter addAction:[UIAlertAction actionWithTitle:@"确认返回" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
  183 + [weakSelf.navigationController popViewControllerAnimated:YES];
  184 + }]];
  185 + [alter addAction:[UIAlertAction actionWithTitle:@"继续发布" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
  186 +
  187 + }]];
  188 + [self presentViewController:alter animated:YES completion:nil];
  189 +
  190 + }
  191 + return NO;
  192 +
  193 +}
  194 +#pragma mark - CNEvaluateStarViewDelegate
  195 +- (void)updateScore:(CGFloat)score {
  196 + _score = (int)(score*2);
  197 +}
  198 +#pragma mark - QMUITextViewDelegate
  199 +- (void)textView:(QMUITextView *)textView didPreventTextChangeInRange:(NSRange)range replacementText:(NSString *)replacementText {
  200 + [QMUITips showWithText:[NSString stringWithFormat:@"评论限制%@字以内", @(textView.maximumTextLength)] inView:self.view hideAfterDelay:1.5];
  201 +}
  202 +- (UIScrollView *)scrollView
  203 +{
  204 + if (!_scrollView) {
  205 + _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, kNavigationBarHeight, KScreenWidth, KScreenHeight-kNavigationBarHeight)];
  206 + _scrollView.contentSize = CGSizeMake(KScreenWidth, KScreenHeight-kNavigationBarHeight);
  207 + _scrollView.backgroundColor = kWhiteColor;
  208 + }
  209 + return _scrollView;
  210 +}
  211 +- (CNLiveEvaluateStarView *)evaluateView
  212 +{
  213 + if (!_evaluateView) {
  214 + _evaluateView = [[CNLiveEvaluateStarView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 91)];
  215 + _evaluateView.delagete = self;
  216 + }
  217 + return _evaluateView;
  218 +}
  219 +
  220 +- (QMUITextView *)textView
  221 +{
  222 + if (!_textView) {
  223 + _textView = [[QMUITextView alloc] initWithFrame:CGRectMake(0, _evaluateView.bottom+1, KScreenWidth, 120)];
  224 + _textView.backgroundColor = KGrayBgColor;
  225 + _textView.font = [UIFont systemFontOfSize:12];
  226 + _textView.placeholder = @"评价内容需要超过15个字~";
  227 + _textView.maximumTextLength = 1000;
  228 + [_textView setTintColor:[UIColor blueColor]];
  229 + _textView.delegate = self;
  230 + }
  231 + return _textView;
  232 +}
  233 +- (CNLiveUploadVoucher *)voucherView
  234 +{
  235 + if (!_voucherView) {
  236 + _voucherView = [[CNLiveUploadVoucher alloc] init];
  237 + [_voucherView configCollectionView];
  238 + _voucherView.delegate = self;
  239 + }
  240 + return _voucherView;
  241 +}
  242 +@end
CNLiveMyOrder/Classes/Controller/CNLiveMineOrderController.m
@@ -11,6 +11,10 @@ @@ -11,6 +11,10 @@
11 #import "UIColor+CNLiveExtension.h" 11 #import "UIColor+CNLiveExtension.h"
12 #import "CNLiveOrderListCommonView.h" 12 #import "CNLiveOrderListCommonView.h"
13 #import "CNLiveOrderDetailController.h" 13 #import "CNLiveOrderDetailController.h"
  14 +#import "CNLiveEvaluateController.h"
  15 +#import "CNLiveApplyRefundController.h"
  16 +#import "FBRetainCycleDetector.h"
  17 +#define TotalTitleCount 5
14 #define Segment_Height 50 18 #define Segment_Height 50
15 #define kViewCommonGrayColor [UIColor colorWithRed:0.97 green:0.97 blue:0.97 alpha:1.00] 19 #define kViewCommonGrayColor [UIColor colorWithRed:0.97 green:0.97 blue:0.97 alpha:1.00]
16 @interface CNLiveMineOrderController ()<UIScrollViewDelegate> 20 @interface CNLiveMineOrderController ()<UIScrollViewDelegate>
@@ -49,6 +53,8 @@ @@ -49,6 +53,8 @@
49 [super viewDidLoad]; 53 [super viewDidLoad];
50 [self addTitleLables]; 54 [self addTitleLables];
51 [self serviceOrder]; 55 [self serviceOrder];
  56 + [self cellDidSelected];
  57 + [self evaluateOrderAction];
52 58
53 } 59 }
54 #pragma mark - 服务订单 60 #pragma mark - 服务订单
@@ -59,15 +65,15 @@ @@ -59,15 +65,15 @@
59 [self.scrollView addSubview:self.payTblView]; 65 [self.scrollView addSubview:self.payTblView];
60 [self.scrollView addSubview:self.goodsTblView]; 66 [self.scrollView addSubview:self.goodsTblView];
61 [self.scrollView addSubview:self.evaluateTblView]; 67 [self.scrollView addSubview:self.evaluateTblView];
62 - [self cellDidSelected]; 68 + [_scrollView setContentOffset:CGPointMake(_curSeleIndex * KScreenWidth, 0)];
63 } 69 }
64 /** 添加标题栏 */ 70 /** 添加标题栏 */
65 - (void)addTitleLables { 71 - (void)addTitleLables {
66 UIScrollView *navScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 180, 44)]; 72 UIScrollView *navScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 180, 44)];
67 - navScrollView.backgroundColor = [UIColor cyanColor]; 73 + navScrollView.backgroundColor = [UIColor whiteColor];
68 navScrollView.showsHorizontalScrollIndicator = NO; 74 navScrollView.showsHorizontalScrollIndicator = NO;
69 navScrollView.showsVerticalScrollIndicator = NO; 75 navScrollView.showsVerticalScrollIndicator = NO;
70 - // self.navigationItem.titleView = navScrollView; 76 +// self.navigationItem.titleView = navScrollView;
71 UIView *line = [[UIView alloc]initWithFrame:CGRectMake(20, navScrollView.height-4, 50, 4)]; 77 UIView *line = [[UIView alloc]initWithFrame:CGRectMake(20, navScrollView.height-4, 50, 4)];
72 line.backgroundColor = CNLiveColorWithHexString(KGreenColor); 78 line.backgroundColor = CNLiveColorWithHexString(KGreenColor);
73 line.layer.masksToBounds = YES; 79 line.layer.masksToBounds = YES;
@@ -82,12 +88,10 @@ @@ -82,12 +88,10 @@
82 UIButton *royalBtn = [UIButton buttonWithType:UIButtonTypeCustom]; 88 UIButton *royalBtn = [UIButton buttonWithType:UIButtonTypeCustom];
83 royalBtn.frame = CGRectMake(lblX, lblY, lblW, lblH); 89 royalBtn.frame = CGRectMake(lblX, lblY, lblW, lblH);
84 royalBtn.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Bold" size: 15]; 90 royalBtn.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Bold" size: 15];
85 -  
86 if (0 == i) { 91 if (0 == i) {
87 _tempBtn = royalBtn; 92 _tempBtn = royalBtn;
88 _tempBtn.selected = YES; 93 _tempBtn.selected = YES;
89 } 94 }
90 -  
91 royalBtn.tag = i; 95 royalBtn.tag = i;
92 royalBtn.userInteractionEnabled = YES; 96 royalBtn.userInteractionEnabled = YES;
93 [royalBtn addTarget:self action:@selector(lblClick:) forControlEvents:UIControlEventTouchUpInside]; 97 [royalBtn addTarget:self action:@selector(lblClick:) forControlEvents:UIControlEventTouchUpInside];
@@ -95,7 +99,6 @@ @@ -95,7 +99,6 @@
95 [royalBtn setTitleColor:CNLiveColorWithHexString(@"#4A4A4A") forState:UIControlStateNormal]; 99 [royalBtn setTitleColor:CNLiveColorWithHexString(@"#4A4A4A") forState:UIControlStateNormal];
96 [royalBtn setTitleColor:CNLiveColorWithHexString(KGreenColor) forState:UIControlStateSelected]; 100 [royalBtn setTitleColor:CNLiveColorWithHexString(KGreenColor) forState:UIControlStateSelected];
97 royalBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter; 101 royalBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
98 -  
99 [navScrollView addSubview:royalBtn]; 102 [navScrollView addSubview:royalBtn];
100 } 103 }
101 self.navigationItem.titleView = navScrollView; 104 self.navigationItem.titleView = navScrollView;
@@ -159,8 +162,44 @@ @@ -159,8 +162,44 @@
159 break; 162 break;
160 } 163 }
161 } 164 }
  165 +#pragma mark - UIScrollViewDelegate
  166 +- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
  167 + if ([scrollView isKindOfClass:[UITableView class]]) {
  168 + return;
  169 + }
  170 + [_segmentView setSelectedBtn:scrollView.contentOffset.x/self.view.width];
  171 + if (scrollView.contentOffset.y == 0) {
  172 + static float newx = 0;
  173 + _oldx = _curSeleIndex * self.view.width;
  174 + newx = scrollView.contentOffset.x ;
  175 +
  176 + if (newx != _oldx ) {
  177 + if (newx > _oldx) {
  178 + //Right
  179 + _curSeleIndex = scrollView.contentOffset.x / self.view.width * 1 ;
  180 + if (_curSeleIndex > (TotalTitleCount - 1)) {
  181 + _curSeleIndex = TotalTitleCount - 1;
  182 + }
  183 + // _selectView.type = _curSeleIndex;
  184 +
  185 + [self refreshData];
  186 +
  187 + }else if(newx < _oldx){
  188 + //Left
  189 + _curSeleIndex = scrollView.contentOffset.x / self.view.width * 1;
  190 + if (_curSeleIndex < 0) {
  191 + _curSeleIndex = 0;
  192 + }
  193 + // _selectView.type = _curSeleIndex;
  194 +
  195 + [self refreshData];
  196 + }
  197 + }
  198 + }
  199 +}
162 #pragma mark -Cell被点击 200 #pragma mark -Cell被点击
163 - (void)cellDidSelected { 201 - (void)cellDidSelected {
  202 +
164 __weak typeof(self) weakSelf = self; 203 __weak typeof(self) weakSelf = self;
165 CNLiveOrderDetailController *vc = [[CNLiveOrderDetailController alloc]init]; 204 CNLiveOrderDetailController *vc = [[CNLiveOrderDetailController alloc]init];
166 switch (_curSeleIndex) { 205 switch (_curSeleIndex) {
@@ -186,7 +225,7 @@ @@ -186,7 +225,7 @@
186 } 225 }
187 break; 226 break;
188 case 3:{ 227 case 3:{
189 - self.payTblView.orderDetaielCellDidSelectedBlock = ^(NSIndexPath * _Nonnull indexPath, NSString * _Nonnull orderId) { 228 + self.evaluateTblView.orderDetaielCellDidSelectedBlock = ^(NSIndexPath * _Nonnull indexPath, NSString * _Nonnull orderId) {
190 vc.orderId = orderId; 229 vc.orderId = orderId;
191 [weakSelf.navigationController pushViewController:vc animated:NO]; 230 [weakSelf.navigationController pushViewController:vc animated:NO];
192 }; 231 };
@@ -195,17 +234,106 @@ @@ -195,17 +234,106 @@
195 default: 234 default:
196 break; 235 break;
197 } 236 }
  237 + FBRetainCycleDetector *detector = [FBRetainCycleDetector new];
  238 + [detector addCandidate:self];
  239 + NSSet *retainCycles = [detector findRetainCycles];
  240 + NSLog(@"打印retainCycles%@", retainCycles);
  241 +}
  242 +- (void)evaluateOrderAction {
198 243
  244 + __weak typeof(self) weakSelf = self;
  245 + switch (_curSeleIndex) {
  246 + case 0:{
  247 + self.allTblView.evaluateOrderBlock = ^(CNLiveOrderList * _Nonnull orderModel) {
  248 + CNLiveEvaluateController *vc = [[CNLiveEvaluateController alloc]init];
  249 + vc.list = orderModel;
  250 + [weakSelf.navigationController pushViewController:vc animated:YES];
  251 + };
  252 +// self.allTblView.refundDetailBlock = ^(NSString * _Nonnull orderId) {
  253 +// CNLiveOrderDetailController *vc = [[CNLiveOrderDetailController alloc]init];
  254 +// vc.orderId = orderId;
  255 +// [weakSelf.navigationController pushViewController:vc animated:YES];
  256 +//
  257 +// };
  258 + self.allTblView.applyForRefundBlock = ^(CNLiveOrderList * _Nonnull orderList) {
  259 + CNLiveApplyRefundController *vc = [[CNLiveApplyRefundController alloc]init];
  260 + vc.list = orderList;
  261 + [weakSelf.navigationController pushViewController:vc animated:YES];
  262 + };
  263 + }
  264 + break;
  265 + case 1:{
  266 + self.payTblView.evaluateOrderBlock = ^(CNLiveOrderList * _Nonnull orderModel) {
  267 + CNLiveEvaluateController *vc = [[CNLiveEvaluateController alloc]init];
  268 + vc.list = orderModel;
  269 + [weakSelf.navigationController pushViewController:vc animated:YES];
  270 + };
  271 +// self.payTblView.refundDetailBlock = ^(NSString * _Nonnull orderId) {
  272 +// CNLiveOrderDetailController *vc = [[CNLiveOrderDetailController alloc]init];
  273 +// vc.orderId = orderId;
  274 +// [weakSelf.navigationController pushViewController:vc animated:YES];
  275 +//
  276 +// };
  277 + self.payTblView.applyForRefundBlock = ^(CNLiveOrderList * _Nonnull orderList) {
  278 + CNLiveApplyRefundController *vc = [[CNLiveApplyRefundController alloc]init];
  279 + vc.list = orderList;
  280 + [weakSelf.navigationController pushViewController:vc animated:YES];
  281 + };
  282 + }
  283 + break;
  284 + case 2:{
  285 + self.goodsTblView.evaluateOrderBlock = ^(CNLiveOrderList * _Nonnull orderModel) {
  286 + CNLiveEvaluateController *vc = [[CNLiveEvaluateController alloc]init];
  287 + vc.list = orderModel;
  288 + [weakSelf.navigationController pushViewController:vc animated:YES];
  289 + };
  290 +// self.goodsTblView.refundDetailBlock = ^(NSString * _Nonnull orderId) {
  291 +// CNLiveOrderDetailController *vc = [[CNLiveOrderDetailController alloc]init];
  292 +// vc.orderId = orderId;
  293 +// [weakSelf.navigationController pushViewController:vc animated:YES];
  294 +//
  295 +// };
  296 + self.goodsTblView.applyForRefundBlock = ^(CNLiveOrderList * _Nonnull orderList) {
  297 + CNLiveApplyRefundController *vc = [[CNLiveApplyRefundController alloc]init];
  298 + vc.list = orderList;
  299 + [weakSelf.navigationController pushViewController:vc animated:YES];
  300 + };
  301 + }
  302 + break;
  303 + case 3:{
  304 + self.evaluateTblView.evaluateOrderBlock = ^(CNLiveOrderList * _Nonnull orderModel) {
  305 + CNLiveEvaluateController *vc = [[CNLiveEvaluateController alloc]init];
  306 + vc.list = orderModel;
  307 + [weakSelf.navigationController pushViewController:vc animated:YES];
  308 + };
  309 +// self.evaluateTblView.refundDetailBlock = ^(NSString * _Nonnull orderId) {
  310 +//
  311 +// CNLiveOrderDetailController *vc = [[CNLiveOrderDetailController alloc]init];
  312 +// vc.orderId = orderId;
  313 +// [weakSelf.navigationController pushViewController:vc animated:YES];
  314 +// };
  315 + self.evaluateTblView.applyForRefundBlock = ^(CNLiveOrderList * _Nonnull orderList) {
  316 + CNLiveApplyRefundController *vc = [[CNLiveApplyRefundController alloc]init];
  317 + vc.list = orderList;
  318 + [weakSelf.navigationController pushViewController:vc animated:YES];
  319 + };
  320 + }
  321 + break;
  322 + default:
  323 + break;
  324 + }
199 } 325 }
200 #pragma mark - Lazy 326 #pragma mark - Lazy
201 - (CNLiveSegmentView *)segmentView{ 327 - (CNLiveSegmentView *)segmentView{
202 __weak typeof(self) weakSelf = self; 328 __weak typeof(self) weakSelf = self;
203 if (!_segmentView) { 329 if (!_segmentView) {
204 - _segmentView = [[CNLiveSegmentView alloc] initWithFrame:CGRectMake(0, kNavigationBarHeight, KScreenWidth, Segment_Height) titles:@[@"全部",@"待付款", @"待收货", @"待评价"] curIndex:_curSeleIndex selectedBlock:^(NSInteger index) {  
205 - CGFloat x = index * self.view.width; 330 + _segmentView = [[CNLiveSegmentView alloc] initWithFrame:CGRectMake(0, kNavigationBarHeight, KScreenWidth, Segment_Height) titles:@[@"全部",@"待付款", @"待收货", @"待评价"] curIndex:weakSelf.curSeleIndex selectedBlock:^(NSInteger index) {
  331 + CGFloat x = index * weakSelf.view.width;
206 weakSelf.curSeleIndex = index; 332 weakSelf.curSeleIndex = index;
207 [weakSelf.scrollView setContentOffset:CGPointMake(x, 0) animated:NO]; 333 [weakSelf.scrollView setContentOffset:CGPointMake(x, 0) animated:NO];
208 - [self refreshData]; 334 + [weakSelf refreshData];
  335 + [weakSelf cellDidSelected];
  336 + [weakSelf evaluateOrderAction];
209 }]; 337 }];
210 } 338 }
211 return _segmentView; 339 return _segmentView;
CNLiveMyOrder/Classes/Controller/CNLiveOrderDetailController.m
@@ -19,7 +19,13 @@ @@ -19,7 +19,13 @@
19 #import "CNLiveOrderList.h" 19 #import "CNLiveOrderList.h"
20 #import "Masonry.h" 20 #import "Masonry.h"
21 #import "CNAddPopFuncView.h" 21 #import "CNAddPopFuncView.h"
22 -//#import <FBRetainCycleDetector/FBRetainCycleDetector.h> 22 +#import "CNErrorOrNoNetView.h"
  23 +#import "CNLiveOrderEventHandle.h"
  24 +#import "CNLiveEvaluateController.h"
  25 +#import "TIMAdapter.h"
  26 +#import "CommonLibrary.h"
  27 +#import "CNLiveApplyRefundController.h"
  28 +#import "FBRetainCycleDetector.h"
23 #define Default_H 45 29 #define Default_H 45
24 #define OrderIdKey @"OrderIdKey" //订单号 30 #define OrderIdKey @"OrderIdKey" //订单号
25 @interface CNLiveOrderDetailController ()<CNLiveRefundVoucherViewDelegate,CNAddPopFuncViewDelegate> 31 @interface CNLiveOrderDetailController ()<CNLiveRefundVoucherViewDelegate,CNAddPopFuncViewDelegate>
@@ -57,7 +63,7 @@ @@ -57,7 +63,7 @@
57 @property (nonatomic, assign) BOOL showReason; //是否显示退款原因view 63 @property (nonatomic, assign) BOOL showReason; //是否显示退款原因view
58 @property (nonatomic, assign) BOOL refund; //是否为退款状态 64 @property (nonatomic, assign) BOOL refund; //是否为退款状态
59 @property (nonatomic, assign) BOOL showVoucher; //是否显示凭证view 65 @property (nonatomic, assign) BOOL showVoucher; //是否显示凭证view
60 -//@property (nonatomic, strong) CNCutDown *cutdownTimer; 66 +@property (nonatomic, strong) CNCutDown *cutdownTimer;
61 @property (nonatomic, assign) BOOL isShowPicOrVideo; //隐藏状态栏 67 @property (nonatomic, assign) BOOL isShowPicOrVideo; //隐藏状态栏
62 @property (nonatomic, strong) NSDictionary *qrParameterDic; // 保存生成的二维码数据 68 @property (nonatomic, strong) NSDictionary *qrParameterDic; // 保存生成的二维码数据
63 @property (nonatomic, strong) UIButton *moreBtn;//右上角按钮 69 @property (nonatomic, strong) UIButton *moreBtn;//右上角按钮
@@ -79,7 +85,7 @@ @@ -79,7 +85,7 @@
79 - (void)viewWillDisappear:(BOOL)animated { 85 - (void)viewWillDisappear:(BOOL)animated {
80 [super viewWillDisappear:animated]; 86 [super viewWillDisappear:animated];
81 [QMUITips hideAllToastInView:self.view animated:YES]; 87 [QMUITips hideAllToastInView:self.view animated:YES];
82 -// [_cutdownTimer destroyTimer]; //销毁计时器 88 + [_cutdownTimer destroyTimer]; //销毁计时器
83 } 89 }
84 90
85 - (void)viewWillAppear:(BOOL)animated { 91 - (void)viewWillAppear:(BOOL)animated {
@@ -97,10 +103,13 @@ @@ -97,10 +103,13 @@
97 _refund = NO; 103 _refund = NO;
98 _showVoucher = NO; 104 _showVoucher = NO;
99 [self loadData]; 105 [self loadData];
100 -// FBRetainCycleDetector *detector = [FBRetainCycleDetector new];  
101 -// [detector addCandidate:self];  
102 -// NSSet *retainCycles = [detector findRetainCycles];  
103 -// NSLog(@"%@", retainCycles); 106 +
  107 + //底部工具栏响应事件
  108 + [self bottomFuncEvent];
  109 + FBRetainCycleDetector *detector = [FBRetainCycleDetector new];
  110 + [detector addCandidate:self];
  111 + NSSet *retainCycles = [detector findRetainCycles];
  112 + NSLog(@"订单页面%@", retainCycles);
104 113
105 } 114 }
106 - (void)initNavBar 115 - (void)initNavBar
@@ -435,7 +444,7 @@ @@ -435,7 +444,7 @@
435 __weak typeof(self) weakSelf = self; 444 __weak typeof(self) weakSelf = self;
436 [self.scrollView removeAllSubviews]; 445 [self.scrollView removeAllSubviews];
437 446
438 -// [_cutdownTimer destroyTimer]; 447 + [_cutdownTimer destroyTimer];
439 448
440 [QMUITips showLoadingInView:self.view]; 449 [QMUITips showLoadingInView:self.view];
441 [CNLiveNetworking setupShowDataResult:NO]; 450 [CNLiveNetworking setupShowDataResult:NO];
@@ -448,6 +457,7 @@ @@ -448,6 +457,7 @@
448 }; 457 };
449 [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:CNOrderCheckUrl Param:param CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { 458 [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:CNOrderCheckUrl Param:param CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
450 NSLog(@"打印这个页面%@-----%@",responseObject, error); 459 NSLog(@"打印这个页面%@-----%@",responseObject, error);
  460 +
451 [QMUITips hideAllToastInView:self.view animated:YES]; 461 [QMUITips hideAllToastInView:self.view animated:YES];
452 NSDictionary *data = [responseObject objectForKey:@"data"]; 462 NSDictionary *data = [responseObject objectForKey:@"data"];
453 NSString *errMessage =[responseObject objectForKey:@"errorMessage"]; 463 NSString *errMessage =[responseObject objectForKey:@"errorMessage"];
@@ -590,17 +600,53 @@ @@ -590,17 +600,53 @@
590 weakSelf.scrollView.backgroundColor = kWhiteColor; 600 weakSelf.scrollView.backgroundColor = kWhiteColor;
591 [weakSelf showEmptyViewWithImage:[UIImage imageNamed:@"zhuangtai_kong"] text:@"个人订单" detailText:@"该订单不是您的个人订单" buttonTitle:@"点击退出" buttonAction:@selector(exitOrderDetail:)]; 601 [weakSelf showEmptyViewWithImage:[UIImage imageNamed:@"zhuangtai_kong"] text:@"个人订单" detailText:@"该订单不是您的个人订单" buttonTitle:@"点击退出" buttonAction:@selector(exitOrderDetail:)];
592 }else { 602 }else {
593 -// [self showErrorRetryType:RetryTypeError noNet:NO]; 603 + [self showErrorRetryType:RetryTypeError noNet:NO];
594 } 604 }
595 } 605 }
596 } 606 }
597 }]; 607 }];
598 608
599 } 609 }
  610 +- (void)showErrorRetryType:(RetryType)type noNet:(BOOL)noNet {
  611 + [CNErrorOrNoNetView showErrorByType:type view:self.view hidenRetry:NO handle:^{
  612 + [self loadData];
  613 + }];
  614 +}
600 #pragma mark -targetAction 615 #pragma mark -targetAction
601 - (void)exitOrderDetail:(UIButton *)btn { 616 - (void)exitOrderDetail:(UIButton *)btn {
602 [self.navigationController popToRootViewControllerAnimated:NO]; 617 [self.navigationController popToRootViewControllerAnimated:NO];
603 } 618 }
  619 +#pragma mark - Timer
  620 +- (void)initTimer:(NSInteger)duration {
  621 +
  622 + [self.statusView updateCutdown:duration];
  623 +
  624 + weakself
  625 + _cutdownTimer = [[CNCutDown alloc] initWithDuration:duration interval:60 unitEvent:^(NSInteger seconds) {
  626 +
  627 + [weakSelf.statusView updateCutdown:seconds];
  628 +
  629 + } zeroEvent:^{
  630 +
  631 + //剩余0s, 确认收货,并刷新页面
  632 + [CNLiveOrderEventHandle confirmRecv:weakSelf.list itemId:weakSelf.itemId superView:weakSelf.view complete:^(BOOL ret) {
  633 + if (ret) {
  634 + [weakSelf loadData];
  635 + }
  636 + }];
  637 +
  638 + // [CNOrderEventHandle confirmRecv:weakSelf.list superView:weakSelf.view complete:^(BOOL ret) {
  639 + //
  640 + // if (ret) {
  641 + // [weakSelf loadData];
  642 + // }
  643 + //
  644 + // }];
  645 +
  646 + }];
  647 +
  648 +}
  649 +
604 - (void)rightNavItemAction:(UIButton *)sender { 650 - (void)rightNavItemAction:(UIButton *)sender {
605 651
606 } 652 }
@@ -643,7 +689,7 @@ @@ -643,7 +689,7 @@
643 if ( orderItem.status == 6) { //待收货 689 if ( orderItem.status == 6) { //待收货
644 690
645 //待收货状态显示收货倒计时 691 //待收货状态显示收货倒计时
646 -// [self initTimer:orderItem.countdown]; 692 + [self initTimer:orderItem.countdown];
647 693
648 [self funcItemType:2]; 694 [self funcItemType:2];
649 } 695 }
@@ -779,6 +825,130 @@ @@ -779,6 +825,130 @@
779 } 825 }
780 826
781 } 827 }
  828 +- (void)bottomFuncEvent {
  829 + weakself
  830 + self.funcView.funcBlock = ^(CNLiveMineOrderButtonItemType tag) {
  831 +
  832 + switch (tag) {
  833 + case CNLiveMineOrderButtonItemTypeCancel: { //取消订单
  834 + [CNLiveOrderEventHandle cancelOrder:weakSelf.list superView:weakSelf.view complete:^(BOOL ret) {
  835 + if (ret) {
  836 + [weakSelf.navigationController popViewControllerAnimated:YES];
  837 + }
  838 + }];
  839 + }
  840 + break;
  841 +
  842 + case CNLiveMineOrderButtonItemTypeError: { //订单有误
  843 + [CNLiveOrderEventHandle orderError:weakSelf.list superView:weakSelf.view complete:^(BOOL ret) {
  844 + if (ret) {
  845 + [weakSelf.navigationController popViewControllerAnimated:YES];
  846 +
  847 + }
  848 + }];
  849 + }
  850 + break;
  851 +
  852 + case CNLiveMineOrderButtonItemTypeConfirm: { //提交订单
  853 +
  854 + if (!weakSelf.addressView.addressModel) {
  855 + [QMUITips showError:@"亲,您还未添加收货人信息" inView:weakSelf.view hideAfterDelay:1.5];
  856 + return ;
  857 + }
  858 +
  859 + [CNLiveOrderEventHandle submitOrder:weakSelf.list address:weakSelf.addressView.addressModel superView:weakSelf.view complete:^(BOOL ret) {
  860 + if (ret) {
  861 + if (ret) {
  862 + [weakSelf.navigationController popViewControllerAnimated:YES];
  863 +
  864 + }
  865 + }
  866 + }];
  867 +
  868 + }
  869 + break;
  870 +
  871 + case CNLiveMineOrderButtonItemTypeEvaluate: { //评价订单
  872 + CNLiveEvaluateController *vc = [[CNLiveEvaluateController alloc]init];
  873 + [CNLiveOrderEventHandle evaluateOrder:weakSelf.list jumpBlock:^(CNLiveOrderList * _Nonnull orderList) {
  874 + vc.list = orderList;
  875 + [weakSelf.navigationController pushViewController:vc animated:YES];
  876 + }];
  877 +
  878 +
  879 + }
  880 + break;
  881 +
  882 + case CNLiveMineOrderButtonItemTypeDelete: { //删除订单
  883 + [CNLiveOrderEventHandle deleteOrder:weakSelf.list itemId:weakSelf.itemId superView:weakSelf.view complete:^(BOOL ret) {
  884 + if (ret) {
  885 + [weakSelf.navigationController popViewControllerAnimated:YES];
  886 + }
  887 + }];
  888 +
  889 + }
  890 + break;
  891 +
  892 + case CNLiveMineOrderButtonItemTypeContactDaRen: { //联系达人
  893 + [CNLiveOrderEventHandle contactUser:weakSelf.list pop:weakSelf.fromChat jumpBlock:^(BOOL isPop) {
  894 +
  895 + }];
  896 + }
  897 + break;
  898 +
  899 + case CNLiveMineOrderButtonItemTypePay: { //去付款
  900 +// [CNOrderEventHandle pay:weakSelf.list payBlock:nil];
  901 + }
  902 + break;
  903 +
  904 + case CNLiveMineOrderButtonItemTypeReminder: { //催单
  905 + [CNLiveOrderEventHandle reminderOrder:weakSelf.list superView:weakSelf.view complete:^(NSString *msg) {
  906 + [[HUDHelper sharedInstance] tipMessage:msg];
  907 + }];
  908 +
  909 + }
  910 + break;
  911 +
  912 + case CNLiveMineOrderButtonItemTypeRefund: { //申请退款
  913 + CNLiveApplyRefundController *applyVc = [[CNLiveApplyRefundController alloc]init]
  914 + ;
  915 + [CNLiveOrderEventHandle applyForRefund:weakSelf.list jumpBlock:^(CNLiveOrderList * _Nonnull orderList) {
  916 + applyVc.list = orderList;
  917 + [weakSelf.navigationController pushViewController:applyVc animated:YES];
  918 + }];
  919 + }
  920 + break;
  921 +
  922 + case CNLiveMineOrderButtonItemTypeRefundDetail: { //退款详情
  923 +// [CNOrderEventHandle refundDetail:weakSelf.list];
  924 + [CNLiveOrderEventHandle refundDetail:weakSelf.list jumpBlock:^(NSString * _Nonnull orderId) {
  925 +
  926 + }];
  927 +
  928 + }
  929 + break;
  930 +
  931 + case CNLiveMineOrderButtonItemTypeConfirmReceipt: { //确认收货
  932 + [CNLiveOrderEventHandle confirmRecv:weakSelf.list itemId:weakSelf.itemId superView:weakSelf.view complete:^(BOOL ret) {
  933 + if (ret) {
  934 + [weakSelf loadData];
  935 + }
  936 + }];
  937 +
  938 + }
  939 + break;
  940 +
  941 + case CNLiveMineOrderButtonItemTypeConfirmLogistics: { //查看物流
  942 +
  943 + }
  944 + break;
  945 +
  946 + default:
  947 + break;
  948 + }
  949 +
  950 + };
  951 +}
782 #pragma mark - CNAddPopFuncViewDelegate 952 #pragma mark - CNAddPopFuncViewDelegate
783 - (void)popFuncView:(CNAddPopFuncView *)popView indexPath:(NSInteger)row 953 - (void)popFuncView:(CNAddPopFuncView *)popView indexPath:(NSInteger)row
784 { 954 {
@@ -1015,12 +1185,8 @@ @@ -1015,12 +1185,8 @@
1015 } 1185 }
1016 return _line7; 1186 return _line7;
1017 } 1187 }
1018 -  
1019 - (void)didReceiveMemoryWarning { 1188 - (void)didReceiveMemoryWarning {
1020 [super didReceiveMemoryWarning]; 1189 [super didReceiveMemoryWarning];
1021 } 1190 }
1022 1191
1023 -  
1024 -  
1025 -  
1026 @end 1192 @end
CNLiveMyOrder/Classes/Controller/CNLiveRefundController.h 0 → 100644
  1 +//
  2 +// CNLiveRefundController.h
  3 +// CNLiveMyOrder
  4 +//
  5 +// Created by 殷巧娟 on 2019/6/20.
  6 +//
  7 +
  8 +#import "CNCommonViewController.h"
  9 +
  10 +NS_ASSUME_NONNULL_BEGIN
  11 +
  12 +@interface CNLiveRefundController : CNCommonViewController
  13 +
  14 +@end
  15 +
  16 +NS_ASSUME_NONNULL_END
CNLiveMyOrder/Classes/Controller/CNLiveRefundController.m 0 → 100644
  1 +//
  2 +// CNLiveRefundController.m
  3 +// CNLiveMyOrder
  4 +//
  5 +// Created by 殷巧娟 on 2019/6/20.
  6 +//
  7 +
  8 +#import "CNLiveRefundController.h"
  9 +#import "CNLiveMineOrderTableViewCell.h"
  10 +#import "CNLiveOrderModel.h"
  11 +#import "CNLiveOrderDetailController.h"
  12 +#import "CNLiveNoOrderView.h"
  13 +#import "CNLiveGetImage.h"
  14 +#import "QMUIKit.h"
  15 +#import "CNLiveOrderHeader.h"
  16 +#import "CNLiveEnvironmentConfiguration.h"
  17 +#import <CNLiveRequestBastKit/CNLiveNetworking.h>
  18 +#import "CNLiveOrderModel.h"
  19 +#import "MJRefresh.h"
  20 +#import "CNLiveBaseKit.h"
  21 +#import "CNLiveOrderEventHandle.h"
  22 +#import "CNLiveOrderDetailController.h"
  23 +#import "TIMAdapter.h"
  24 +#import "CommonLibrary.h"
  25 +#import "CNLiveGetImage.h"
  26 +#import "CNErrorOrNoNetView.h"
  27 +#import "MJExtension.h"
  28 +#import "CNLiveApplyRefundController.h"
  29 +#import "FBRetainCycleDetector.h"
  30 +@interface CNLiveRefundController ()<UITableViewDelegate,UITableViewDataSource,CNLiveMineOrderTableViewCellDelegate>
  31 +@property (nonatomic, strong) NSMutableArray *listArr; //数据源
  32 +@property (nonatomic, strong) UITableView *tableView;
  33 +@property (nonatomic, strong) CNLiveNoOrderView *noDataView;
  34 +@property (nonatomic, assign) NSInteger page;
  35 +@property (nonatomic, assign) BOOL next;
  36 +
  37 +@end
  38 +
  39 +@implementation CNLiveRefundController
  40 +
  41 +- (void)dealloc {
  42 + NSLog(@"退款/售后走了dealloc了吗");
  43 +}
  44 +- (void)viewWillAppear:(BOOL)animated {
  45 +
  46 + [super viewWillAppear:animated];
  47 + self.tabBarController.tabBar.hidden = YES;
  48 +
  49 +}
  50 +- (void)viewDidLoad {
  51 + [super viewDidLoad];
  52 + self.title = @"退款 / 售后";
  53 + _page = 1;
  54 + _next = YES;
  55 + [self requestDataWithPage:_page refresh:YES];
  56 +// UIBarButtonItem *callItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"dd_dianhua"] style:UIBarButtonItemStylePlain target:self action:@selector(callItemAction)];
  57 + UIBarButtonItem *callItem = [[UIBarButtonItem alloc] initWithImage:[CNLiveGetImage cnliveGetImageWithName:@"dd_dianhua" bundle:@"CNLiveMyOrder.bundle/CNLiveMyOrder" targetClass:[self class]] style:UIBarButtonItemStylePlain target:self action:@selector(callItemAction)];
  58 + self.navigationItem.rightBarButtonItem = callItem;
  59 + [self.view addSubview:self.tableView];
  60 +// [self.noDataView setImageName:@"dd_wutuikuan" title:@"您还没有相关退款的订单" customTopH:109];
  61 + [self.noDataView setImageName:[CNLiveGetImage cnliveGetImageWithName:@"dd_wutuikuan" bundle:@"CNLiveMyOrder.bundle/CNLiveMyOrder" targetClass:[self class]] title:@"您还没有相关退款的订单" customTopH:109];
  62 + FBRetainCycleDetector *detector = [FBRetainCycleDetector new];
  63 + [detector addCandidate:self];
  64 + NSSet *retainCycles = [detector findRetainCycles];
  65 + NSLog(@"打印retainCycles%@", retainCycles);
  66 +}
  67 +- (void)callItemAction {
  68 +
  69 + NSString *callPhone = [NSString stringWithFormat:@"telprompt://%@",@"010-65832485"];
  70 +
  71 + CGFloat version = [[[UIDevice currentDevice] systemVersion] floatValue];
  72 + if (version >= 10.0) {
  73 + /// 大于等于10.0系统使用此openURL方法
  74 + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone] options:@{} completionHandler:nil];
  75 + } else {
  76 + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]];
  77 + }
  78 +
  79 +}
  80 +- (void)requestDataWithPage:(NSInteger)page refresh:(BOOL)refresh {
  81 + weakself
  82 +// if (![[[NSUserDefaults standardUserDefaults] objectForKey:CNConnectSuccNotification] boolValue]) {
  83 +// [QMUITips showError:@"网络不给力" inView:[UIApplication sharedApplication].delegate.window hideAfterDelay:1.5];
  84 +// return;
  85 +// }
  86 + [QMUITips showLoadingInView:self.view];
  87 + NSDictionary *param = @{@"appId":AppId,
  88 + @"plat":@"i",
  89 + @"sid":@"10511059",
  90 + @"status":@"4",
  91 + @"pageNo":[NSString stringWithFormat:@"%ld", (long)page],
  92 + @"pageSize":@"15"
  93 + };
  94 +
  95 + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:CNGetOrderListUrl Param:param CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
  96 + [QMUITips hideAllToastInView:weakSelf.view animated:YES];
  97 + NSDictionary *data = [responseObject objectForKey:@"data"];
  98 +
  99 + if (!error) {
  100 + if (refresh) {
  101 + weakSelf.page = 1;
  102 + [weakSelf.listArr removeAllObjects];
  103 + [weakSelf.tableView.mj_header endRefreshing];
  104 + } else {
  105 + [weakSelf.tableView.mj_footer endRefreshing];
  106 + }
  107 + CNLiveOrderModel *model = [CNLiveOrderModel mj_objectWithKeyValues:data];
  108 +
  109 + weakSelf.next = model.hasNext;
  110 + weakSelf.tableView.mj_footer.hidden = !weakSelf.next;
  111 + if (model.orderList.count == 0) {
  112 + //noData
  113 + [weakSelf.tableView addSubview:self.noDataView];
  114 +
  115 + } else {
  116 +
  117 + [weakSelf.noDataView removeFromSuperview];
  118 +
  119 + for (CNLiveOrderList *orderList in model.orderList) {
  120 + [weakSelf.listArr addObject:orderList];
  121 + }
  122 + }
  123 + [weakSelf.tableView reloadData];
  124 + }else {
  125 +
  126 + [QMUITips showError:error.localizedDescription inView:self.view hideAfterDelay:1.5];
  127 +
  128 + if (refresh) {
  129 + [weakSelf.tableView.mj_header endRefreshing];
  130 + } else {
  131 + [weakSelf.tableView.mj_footer endRefreshing];
  132 + }
  133 +
  134 + if (error.code == -1009) {
  135 + [weakSelf showErrorRetryType:RetryTypeNoNet noNet:YES];
  136 + } else {
  137 + [weakSelf showErrorRetryType:RetryTypeError noNet:NO];
  138 + }
  139 + }
  140 + }];
  141 +}
  142 +- (void)showErrorRetryType:(RetryType)type noNet:(BOOL)noNet {
  143 + [CNErrorOrNoNetView showErrorByType:type view:self.view hidenRetry:self.listArr.count > 0 handle:^{
  144 + [self refreshList];
  145 + }];
  146 +}
  147 +
  148 +//刷新
  149 +- (void)refreshList {
  150 + _page = 1;
  151 + _next = YES;
  152 + [self requestDataWithPage:_page refresh:YES];
  153 +}
  154 +
  155 +//加载更多
  156 +- (void)loadMoreData {
  157 +
  158 + _page += 1;
  159 +
  160 + if (_next) {
  161 + [self requestDataWithPage:_page refresh:NO];
  162 + } else {
  163 + if (_page != 1) {
  164 + [[HUDHelper sharedInstance] tipMessage:@"没有更多了"];
  165 + [self.tableView.mj_footer endRefreshing];
  166 + }
  167 + }
  168 +}
  169 +
  170 +
  171 +#pragma mark - CNLiveMineOrderTableViewCellDelegate
  172 +- (void)cellWithOrderModel:(CNLiveOrderList *)model type:(CNLiveMineOrderButtonItemType)type {
  173 +
  174 + switch (type) {
  175 + case CNLiveMineOrderButtonItemTypeContactDaRen: { //联系达人
  176 + [CNLiveOrderEventHandle contactUser:model pop:NO jumpBlock:^(BOOL isPop) {
  177 + }];
  178 + }
  179 + break;
  180 +
  181 + case CNLiveMineOrderButtonItemTypeRefundDetail: { //退款详情
  182 + [CNLiveOrderEventHandle refundDetail:model jumpBlock:^(NSString * _Nonnull orderId) {
  183 + CNLiveOrderDetailController *vc = [[CNLiveOrderDetailController alloc]init];
  184 + vc.orderId = orderId;
  185 + [self.navigationController pushViewController:vc animated:YES];
  186 + }];
  187 + }
  188 + break;
  189 +
  190 + case CNLiveMineOrderButtonItemTypeReminder: { //催单
  191 + [CNLiveOrderEventHandle reminderOrder:model superView:self.view complete:^(NSString * _Nonnull msg) {
  192 + [[HUDHelper sharedInstance] tipMessage:msg];
  193 + }];
  194 +
  195 + }
  196 + break;
  197 +
  198 + case CNLiveMineOrderButtonItemTypeRefund: { //申请退款
  199 + CNLiveApplyRefundController *vc = [[CNLiveApplyRefundController alloc]init];
  200 + [CNLiveOrderEventHandle applyForRefund:model jumpBlock:^(CNLiveOrderList * _Nonnull orderList) {
  201 + vc.list = orderList;
  202 + [self.navigationController pushViewController:vc animated:YES];
  203 + }];
  204 + }
  205 + break;
  206 +
  207 + case CNLiveMineOrderButtonItemTypeConfirmReceipt: { //确认收货
  208 +
  209 + [CNLiveOrderEventHandle confirmRecv:model itemId:@"" superView:self.view complete:^(BOOL ret) {
  210 + if (ret) {
  211 + [self requestDataWithPage:0 refresh:YES];
  212 + }
  213 + }];
  214 +
  215 + }
  216 + break;
  217 +
  218 + default:
  219 + break;
  220 + }
  221 +
  222 +}
  223 +
  224 +#pragma mark - UITableViewDelegate,UITableViewDataSource
  225 +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  226 + return self.listArr.count;
  227 +}
  228 +
  229 +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  230 +
  231 + static NSString *cellId = @"CNMineOrderTableViewCell";
  232 + CNLiveMineOrderTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
  233 + if (!cell) {
  234 + cell = [[CNLiveMineOrderTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
  235 + }
  236 + CNLiveOrderList *model = _listArr[indexPath.row];
  237 + cell.delegate = self;
  238 + [cell configOrderList:model delegate:self];
  239 + return cell;
  240 +}
  241 +
  242 +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  243 + CNLiveOrderList *model = _listArr[indexPath.row];
  244 + return [model.orderItem cellHeight];
  245 +
  246 +}
  247 +
  248 +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  249 + [self.tableView qmui_clearsSelection];
  250 + CNLiveMineOrderTableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
  251 +// [CNLiveOrderEventHandle orderDetail:cell.list];
  252 + [CNLiveOrderEventHandle orderDetail:cell.list orderBlock:^(NSString * _Nonnull orderId) {
  253 + CNLiveOrderDetailController *vc = [[CNLiveOrderDetailController alloc]init];
  254 + vc.orderId = orderId;
  255 + [self.navigationController pushViewController:vc animated:YES];
  256 + }];
  257 +
  258 +}
  259 +
  260 +#pragma mark -
  261 +#pragma mark - Getter
  262 +- (NSMutableArray *)listArr
  263 +{
  264 + if (!_listArr) {
  265 + _listArr = [[NSMutableArray alloc] init];
  266 + }
  267 + return _listArr;
  268 +}
  269 +
  270 +- (UITableView *)tableView
  271 +{
  272 + if (!_tableView) {
  273 + _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, kNavigationBarHeight, KScreenWidth, KScreenHeight-kNavigationBarHeight) style:UITableViewStylePlain];
  274 + _tableView.backgroundColor = kWeChatBgColor;
  275 + _tableView.delegate = self;
  276 + _tableView.dataSource = self;
  277 + _tableView.tableFooterView = [UIView new];
  278 + _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  279 + _tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(refreshList)];
  280 + _tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
  281 + }
  282 + return _tableView;
  283 +}
  284 +
  285 +- (CNLiveNoOrderView *)noDataView
  286 +{
  287 + if (!_noDataView) {
  288 + _noDataView = [[CNLiveNoOrderView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight-kNavigationBarHeight)];
  289 + }
  290 + return _noDataView;
  291 +}
  292 +
  293 +
  294 +
  295 +@end
CNLiveMyOrder/Classes/View/CNLiveMineOrderView.m
@@ -13,6 +13,10 @@ @@ -13,6 +13,10 @@
13 #import <QMUIKit/QMUIKit.h> 13 #import <QMUIKit/QMUIKit.h>
14 #import "CNLiveCommonCategory.h" 14 #import "CNLiveCommonCategory.h"
15 #import "CNLiveBaseKit.h" 15 #import "CNLiveBaseKit.h"
  16 +#import "CNLiveGetImage.h"
  17 +#import "TIMAdapter.h"
  18 +#import "CommonLibrary.h"
  19 +#import "CNLiveGetImage.h"
16 #define Large_Font [UIFont systemFontOfSize:15.0f] 20 #define Large_Font [UIFont systemFontOfSize:15.0f]
17 #define Default_Font [UIFont systemFontOfSize:15.0f] 21 #define Default_Font [UIFont systemFontOfSize:15.0f]
18 #define Small_Font [UIFont systemFontOfSize:14.0f] 22 #define Small_Font [UIFont systemFontOfSize:14.0f]
@@ -22,7 +26,6 @@ @@ -22,7 +26,6 @@
22 #define Default_Space 15 26 #define Default_Space 15
23 //25 27 //25
24 #define OrderContent_H 80 28 #define OrderContent_H 80
25 -#define kDefaultUserIcon [UIImage imageNamed:@"touxiang2"]  
26 @interface CNLiveMineOrderView () 29 @interface CNLiveMineOrderView ()
27 @property (nonatomic, strong) UILabel *titleLab; 30 @property (nonatomic, strong) UILabel *titleLab;
28 @end 31 @end
@@ -115,7 +118,7 @@ @@ -115,7 +118,7 @@
115 - (void)setList:(CNLiveOrderList *)list { 118 - (void)setList:(CNLiveOrderList *)list {
116 _list = list; 119 _list = list;
117 CNLiveOrderListIconBean *iconBean = list.iconBean; 120 CNLiveOrderListIconBean *iconBean = list.iconBean;
118 - [self.iconView sd_setImageWithURL:[NSURL URLWithString:iconBean.image] placeholderImage:kDefaultUserIcon]; 121 + [self.iconView sd_setImageWithURL:[NSURL URLWithString:iconBean.image] placeholderImage:[CNLiveGetImage cnliveGetImageWithName:@"touxiang2" bundle:@"CNLiveMyOrder.bundle/CNLiveMyOrder" targetClass:[self class]]];
119 [self.nameBtn setTitle:iconBean.nickName forState:UIControlStateNormal]; 122 [self.nameBtn setTitle:iconBean.nickName forState:UIControlStateNormal];
120 123
121 } 124 }
@@ -164,7 +167,8 @@ @@ -164,7 +167,8 @@
164 - (UIImageView *)detailView{ 167 - (UIImageView *)detailView{
165 if (!_detailView) { 168 if (!_detailView) {
166 _detailView = [UIImageView new]; 169 _detailView = [UIImageView new];
167 - _detailView.image = [UIImage imageNamed:@"pyq_gengduo"]; 170 +// _detailView.image = [UIImage imageNamed:@"pyq_gengduo"];
  171 + _detailView.image = [CNLiveGetImage cnliveGetImageWithName:@"pyq_gengduo" bundle:@"CNLiveMyOrder.bundle/CNLiveMyOrder" targetClass:[self class]];
168 } 172 }
169 return _detailView; 173 return _detailView;
170 } 174 }
@@ -1445,7 +1449,7 @@ @@ -1445,7 +1449,7 @@
1445 1449
1446 UIPasteboard*pasteboard = [UIPasteboard generalPasteboard]; 1450 UIPasteboard*pasteboard = [UIPasteboard generalPasteboard];
1447 pasteboard.string = orderItem.orderId; 1451 pasteboard.string = orderItem.orderId;
1448 -// [[HUDHelper sharedInstance] tipMessage:@"复制成功且可以粘贴对应编号"]; 1452 + [[HUDHelper sharedInstance] tipMessage:@"复制成功且可以粘贴对应编号"];
1449 } 1453 }
1450 - (void)updateCutdown:(NSInteger)seconds { 1454 - (void)updateCutdown:(NSInteger)seconds {
1451 1455
@@ -1535,7 +1539,8 @@ @@ -1535,7 +1539,8 @@
1535 if (!_copyingBtn) { 1539 if (!_copyingBtn) {
1536 _copyingBtn = [UIButton buttonWithType:UIButtonTypeCustom]; 1540 _copyingBtn = [UIButton buttonWithType:UIButtonTypeCustom];
1537 [_copyingBtn setTitle:@"复制编号" forState:UIControlStateNormal]; 1541 [_copyingBtn setTitle:@"复制编号" forState:UIControlStateNormal];
1538 - [_copyingBtn setImage:[UIImage imageNamed:@"dd_fuzhi2"] forState:UIControlStateNormal]; 1542 +// [_copyingBtn setImage:[UIImage imageNamed:@"dd_fuzhi2"] forState:UIControlStateNormal];
  1543 + [_copyingBtn setImage:[CNLiveGetImage cnliveGetImageWithName:@"dd_fuzhi2" bundle:@"CNLiveMyOrder.bundle/CNLiveMyOrder" targetClass:[self class]] forState:UIControlStateNormal];
1539 [_copyingBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 1544 [_copyingBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
1540 _copyingBtn.titleLabel.font = UIFontCNMake(14); 1545 _copyingBtn.titleLabel.font = UIFontCNMake(14);
1541 [_copyingBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 5, 0, 0)]; 1546 [_copyingBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 5, 0, 0)];
@@ -1584,8 +1589,9 @@ @@ -1584,8 +1589,9 @@
1584 - (UIButton *)contactBtn{ 1589 - (UIButton *)contactBtn{
1585 if (!_contactBtn) { 1590 if (!_contactBtn) {
1586 _contactBtn = [UIButton buttonWithType:UIButtonTypeCustom]; 1591 _contactBtn = [UIButton buttonWithType:UIButtonTypeCustom];
1587 - [_contactBtn setImage:[UIImage imageNamed:@"dd_sixindaren"] forState:UIControlStateNormal];  
1588 - [_contactBtn setTitle:@"联系达人" forState:UIControlStateNormal]; 1592 +// [_contactBtn setImage:[UIImage imageNamed:@"dd_sixindaren"] forState:UIControlStateNormal];
  1593 + [_contactBtn setImage:[CNLiveGetImage cnliveGetImageWithName:@"dd_sixindaren" bundle:@"CNLiveMyOrder.bundle/CNLiveMyOrder" targetClass:[self class]] forState:UIControlStateNormal];
  1594 + [_contactBtn setTitle:@"联系达人" forState:UIControlStateNormal];
1589 [_contactBtn setTitleColor:KTextBlackColor forState:UIControlStateNormal]; 1595 [_contactBtn setTitleColor:KTextBlackColor forState:UIControlStateNormal];
1590 _contactBtn.titleLabel.font = UIFontCNMake(14); 1596 _contactBtn.titleLabel.font = UIFontCNMake(14);
1591 [_contactBtn addTarget:self action:@selector(contactBtnDidSelected) forControlEvents:UIControlEventTouchUpInside]; 1597 [_contactBtn addTarget:self action:@selector(contactBtnDidSelected) forControlEvents:UIControlEventTouchUpInside];
@@ -1953,7 +1959,8 @@ @@ -1953,7 +1959,8 @@
1953 - (UIImageView *)firstSuccView{ 1959 - (UIImageView *)firstSuccView{
1954 if (!_firstSuccView) { 1960 if (!_firstSuccView) {
1955 _firstSuccView = [[UIImageView alloc] init]; 1961 _firstSuccView = [[UIImageView alloc] init];
1956 - _firstSuccView.image = [UIImage imageNamed:@"dd_tuikuanchenggong"]; 1962 +// _firstSuccView.image = [UIImage imageNamed:@"dd_tuikuanchenggong"];
  1963 + _firstSuccView.image = [CNLiveGetImage cnliveGetImageWithName:@"dd_tuikuanchenggong" bundle:@"CNLiveMyOrder.bundle/CNLiveMyOrder" targetClass:[self class]];
1957 _firstSuccView.hidden = YES; 1964 _firstSuccView.hidden = YES;
1958 } 1965 }
1959 return _firstSuccView; 1966 return _firstSuccView;
@@ -1962,7 +1969,8 @@ @@ -1962,7 +1969,8 @@
1962 - (UIImageView *)secondSuccView{ 1969 - (UIImageView *)secondSuccView{
1963 if (!_secondSuccView) { 1970 if (!_secondSuccView) {
1964 _secondSuccView = [[UIImageView alloc] init]; 1971 _secondSuccView = [[UIImageView alloc] init];
1965 - _secondSuccView.image = [UIImage imageNamed:@"dd_tuikuanchenggong"]; 1972 +// _secondSuccView.image = [UIImage imageNamed:@"dd_tuikuanchenggong"];
  1973 + _secondSuccView.image = [CNLiveGetImage cnliveGetImageWithName:@"dd_tuikuanchenggong" bundle:@"CNLiveMyOrder.bundle/CNLiveMyOrder" targetClass:[self class]];
1966 _secondSuccView.hidden = YES; 1974 _secondSuccView.hidden = YES;
1967 } 1975 }
1968 return _secondSuccView; 1976 return _secondSuccView;
@@ -1971,7 +1979,8 @@ @@ -1971,7 +1979,8 @@
1971 - (UIImageView *)thirdSuccView{ 1979 - (UIImageView *)thirdSuccView{
1972 if (!_thirdSuccView) { 1980 if (!_thirdSuccView) {
1973 _thirdSuccView = [[UIImageView alloc] init]; 1981 _thirdSuccView = [[UIImageView alloc] init];
1974 - _thirdSuccView.image = [UIImage imageNamed:@"dd_tuikuanchenggong"]; 1982 +// _thirdSuccView.image = [UIImage imageNamed:@"dd_tuikuanchenggong"];
  1983 + _thirdSuccView.image = [CNLiveGetImage cnliveGetImageWithName:@"dd_tuikuanchenggong" bundle:@"CNLiveMyOrder.bundle/CNLiveMyOrder" targetClass:[self class]];
1975 _thirdSuccView.hidden = YES; 1984 _thirdSuccView.hidden = YES;
1976 } 1985 }
1977 return _thirdSuccView; 1986 return _thirdSuccView;
@@ -2106,7 +2115,8 @@ @@ -2106,7 +2115,8 @@
2106 _reasonBtn = [CNLiveSelectRefundButton buttonWithType:UIButtonTypeCustom]; 2115 _reasonBtn = [CNLiveSelectRefundButton buttonWithType:UIButtonTypeCustom];
2107 [_reasonBtn setTitle:@"点击选取退款原因" forState:UIControlStateNormal]; 2116 [_reasonBtn setTitle:@"点击选取退款原因" forState:UIControlStateNormal];
2108 [_reasonBtn setTitleColor:KGray153Color forState:UIControlStateNormal]; 2117 [_reasonBtn setTitleColor:KGray153Color forState:UIControlStateNormal];
2109 - [_reasonBtn setImage:[UIImage imageNamed:@"dd_xialajiantou"] forState:UIControlStateNormal]; 2118 +// [_reasonBtn setImage:[UIImage imageNamed:@"dd_xialajiantou"] forState:UIControlStateNormal];
  2119 + [_reasonBtn setImage:[CNLiveGetImage cnliveGetImageWithName:@"dd_xialajiantou" bundle:@"CNLiveMyOrder.bundle/CNLiveMyOrder" targetClass:[self class]] forState:UIControlStateNormal];
2110 [_reasonBtn addTarget:self action:@selector(moreBtnDidSelected) forControlEvents:UIControlEventTouchUpInside]; 2120 [_reasonBtn addTarget:self action:@selector(moreBtnDidSelected) forControlEvents:UIControlEventTouchUpInside];
2111 } 2121 }
2112 return _reasonBtn; 2122 return _reasonBtn;
@@ -2570,7 +2580,8 @@ @@ -2570,7 +2580,8 @@
2570 - (CNStarsControl *)starsControlView 2580 - (CNStarsControl *)starsControlView
2571 { 2581 {
2572 if (!_starsControlView) { 2582 if (!_starsControlView) {
2573 - _starsControlView = [CNStarsControl.alloc initWithFrame:CGRectMake(_iconImgView.right+19, 36, 185 , 55) stars:5 starSize:CGSizeMake(25, 25) noramlStarImage:[UIImage imageNamed:@"drd_xing_kong"] highlightedStarImage:[UIImage imageNamed:@"drd_xing_quan"]]; 2583 +// _starsControlView = [CNStarsControl.alloc initWithFrame:CGRectMake(_iconImgView.right+19, 36, 185 , 55) stars:5 starSize:CGSizeMake(25, 25) noramlStarImage:[UIImage imageNamed:@"drd_xing_kong"] highlightedStarImage:[UIImage imageNamed:@"drd_xing_quan"]];
  2584 + _starsControlView = [CNStarsControl.alloc initWithFrame:CGRectMake(_iconImgView.right+19, 36, 185 , 55) stars:5 starSize:CGSizeMake(25, 25) noramlStarImage:[CNLiveGetImage cnliveGetImageWithName:@"drd_xing_kong" bundle:@"CNLiveMyOrder.bundle/CNLiveMyOrder" targetClass:[self class]] highlightedStarImage:[CNLiveGetImage cnliveGetImageWithName:@"drd_xing_quan" bundle:@"CNLiveMyOrder.bundle/CNLiveMyOrder" targetClass:[self class]]];
2574 _starsControlView.delegate = self; 2585 _starsControlView.delegate = self;
2575 _starsControlView.allowFraction = YES; 2586 _starsControlView.allowFraction = YES;
2576 _starsControlView.score = 3.f; 2587 _starsControlView.score = 3.f;
CNLiveMyOrder/Classes/View/CNLiveOrderEventHandle.h
@@ -40,7 +40,7 @@ NS_ASSUME_NONNULL_BEGIN @@ -40,7 +40,7 @@ NS_ASSUME_NONNULL_BEGIN
40 /** 40 /**
41 * 订单详情 41 * 订单详情
42 */ 42 */
43 -+ (void)orderDetailByOrderId:(NSString *)orderId; 43 +// + (void)orderDetailByOrderId:(NSString *)orderId;
44 /** 44 /**
45 * 申请退款 45 * 申请退款
46 */ 46 */
CNLiveMyOrder/Classes/View/CNLiveOrderEventHandle.m
@@ -97,7 +97,8 @@ @@ -97,7 +97,8 @@
97 NSDictionary *param = @{@"appId":AppId, 97 NSDictionary *param = @{@"appId":AppId,
98 @"plat":@"i", 98 @"plat":@"i",
99 @"sid":@"10511059", 99 @"sid":@"10511059",
100 - @"nickName":CNUserShareModel.nickname ?: @"", 100 +// @"nickName":CNUserShareModel.nickname ?: @"",
  101 + @"nickName":@"胖成球的丸子哥",
101 @"darenId":user.userId ?: @"", 102 @"darenId":user.userId ?: @"",
102 @"orderId":orderItem.orderId ?: @"" 103 @"orderId":orderItem.orderId ?: @""
103 }; 104 };
@@ -107,19 +108,22 @@ @@ -107,19 +108,22 @@
107 @"plat":@"i", 108 @"plat":@"i",
108 @"test":@"0", 109 @"test":@"0",
109 @"sid":@"10511059", 110 @"sid":@"10511059",
110 - @"nickName":CNUserShareModel.nickname ?: @"", 111 +// @"nickName":CNUserShareModel.nickname ?: @"",
  112 + @"nickName":@"胖成球的丸子哥",
111 @"darenId":user.userId ?: @"", 113 @"darenId":user.userId ?: @"",
112 @"orderId":orderItem.orderId ?: @"" 114 @"orderId":orderItem.orderId ?: @""
113 }; 115 };
114 #endif 116 #endif
  117 +
115 [CNLiveNetworking setupShowDataResult:NO]; 118 [CNLiveNetworking setupShowDataResult:NO];
116 [CNLiveNetworking setAllowRequestDefaultArgument:YES]; 119 [CNLiveNetworking setAllowRequestDefaultArgument:YES];
117 [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:CNRemindOrderUrl Param:param CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { 120 [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:CNRemindOrderUrl Param:param CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
  121 +
  122 + [QMUITips hideAllTipsInView:view];
118 NSDictionary *data = [responseObject objectForKey:@"data"]; 123 NSDictionary *data = [responseObject objectForKey:@"data"];
119 NSString *errMessage =[responseObject objectForKey:@"errorMessage"]; 124 NSString *errMessage =[responseObject objectForKey:@"errorMessage"];
120 NSString *errorCode = [NSString stringWithFormat:@"%@",[responseObject objectForKey:@"errorCode"]]; 125 NSString *errorCode = [NSString stringWithFormat:@"%@",[responseObject objectForKey:@"errorCode"]];
121 if (error) { 126 if (error) {
122 -  
123 if ((orderItem.status == 5 || orderItem.status == 10) && error.code == 45000) { 127 if ((orderItem.status == 5 || orderItem.status == 10) && error.code == 45000) {
124 128
125 if (complete) { 129 if (complete) {
@@ -136,11 +140,11 @@ @@ -136,11 +140,11 @@
136 } 140 }
137 141
138 } else { 142 } else {
139 - if ([errorCode isEqualToString:@"0"]) { 143 +// if ([errorCode isEqualToString:@"0"]) {
140 if (complete) { 144 if (complete) {
141 complete(@"催单成功"); 145 complete(@"催单成功");
142 } 146 }
143 - } 147 +// }
144 } 148 }
145 }]; 149 }];
146 } 150 }
CNLiveMyOrder/Classes/View/CNLiveOrderListCommonView.m
@@ -59,6 +59,7 @@ @@ -59,6 +59,7 @@
59 @"status":_status, 59 @"status":_status,
60 @"pageNo":[NSString stringWithFormat:@"%ld", (long)page], 60 @"pageNo":[NSString stringWithFormat:@"%ld", (long)page],
61 @"pageSize":@"15"}; 61 @"pageSize":@"15"};
  62 +
62 [CNLiveNetworking setCacheVersion:page]; 63 [CNLiveNetworking setCacheVersion:page];
63 [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:CNGetOrderListUrl Param:param CacheType:CNLiveNetworkCacheTypeCacheNetwork CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) { 64 [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodPOST URLString:CNGetOrderListUrl Param:param CacheType:CNLiveNetworkCacheTypeCacheNetwork CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
64 65
@@ -77,7 +78,7 @@ @@ -77,7 +78,7 @@
77 CNLiveOrderModel *model = [CNLiveOrderModel mj_objectWithKeyValues:[responseObject objectForKey:@"data"]]; 78 CNLiveOrderModel *model = [CNLiveOrderModel mj_objectWithKeyValues:[responseObject objectForKey:@"data"]];
78 79
79 weakSelf.next = model.hasNext; 80 weakSelf.next = model.hasNext;
80 - weakSelf.tableView.mj_footer.hidden = !_next; 81 + weakSelf.tableView.mj_footer.hidden = !weakSelf.next;
81 82
82 if (model.orderList.count == 0) { 83 if (model.orderList.count == 0) {
83 //noData 84 //noData
@@ -194,7 +195,7 @@ @@ -194,7 +195,7 @@
194 195
195 case CNLiveMineOrderButtonItemTypeDelete: { //删除订单 196 case CNLiveMineOrderButtonItemTypeDelete: { //删除订单
196 197
197 - [CNLiveOrderEventHandle deleteOrder:model itemId:nil superView:self complete:^(BOOL ret) { 198 + [CNLiveOrderEventHandle deleteOrder:model itemId:@"" superView:self complete:^(BOOL ret) {
198 if (ret == YES) { 199 if (ret == YES) {
199 [self refreshData]; 200 [self refreshData];
200 } 201 }
@@ -242,12 +243,11 @@ @@ -242,12 +243,11 @@
242 break; 243 break;
243 244
244 case CNLiveMineOrderButtonItemTypeRefundDetail: { //退款详情 245 case CNLiveMineOrderButtonItemTypeRefundDetail: { //退款详情
245 -// [CNOrderEventHandle refundDetail:model];  
246 - [CNLiveOrderEventHandle refundDetail:model jumpBlock:^(NSString * _Nonnull orderId) {  
247 - if (self.refundDetailBlock) {  
248 - self.refundDetailBlock(orderId);  
249 - }  
250 - }]; 246 +// [CNLiveOrderEventHandle refundDetail:model jumpBlock:^(NSString * _Nonnull orderId) {
  247 +// if (self.refundDetailBlock) {
  248 +// self.refundDetailBlock(orderId);
  249 +// }
  250 +// }];
251 } 251 }
252 break; 252 break;
253 253
CNLiveMyOrder/Classes/View/CNLiveUploadVoucher.h 0 → 100644
  1 +//
  2 +// CNLiveUploadVoucher.h
  3 +// CNLiveMyOrder
  4 +//
  5 +// Created by 殷巧娟 on 2019/6/20.
  6 +//
  7 +
  8 +#import <UIKit/UIKit.h>
  9 +@protocol CNUploadVoucherDelegate <NSObject>
  10 +
  11 +- (void)updateImages:(NSArray *)images;
  12 +
  13 +@end
  14 +NS_ASSUME_NONNULL_BEGIN
  15 +
  16 +@interface CNLiveUploadVoucher : UIView
  17 +@property (nonatomic, assign) id<CNUploadVoucherDelegate> delegate;
  18 +
  19 +@property (nonatomic, strong) UILabel *titleLabel;
  20 +
  21 +- (void)configCollectionView;
  22 +@end
  23 +
  24 +NS_ASSUME_NONNULL_END
CNLiveMyOrder/Classes/View/CNLiveUploadVoucher.m 0 → 100644
  1 +//
  2 +// CNLiveUploadVoucher.m
  3 +// CNLiveMyOrder
  4 +//
  5 +// Created by 殷巧娟 on 2019/6/20.
  6 +//
  7 +
  8 +#import "CNLiveUploadVoucher.h"
  9 +#import "TZImagePickerController.h"
  10 +#import "TZImageManager.h"
  11 +#import "LxGridViewFlowLayout.h"
  12 +#import "TZTestCell.h"
  13 +#import <AssetsLibrary/AssetsLibrary.h>
  14 +#import <Photos/Photos.h>
  15 +#import <YYKit/YYKit.h>
  16 +#import "TZLocationManager.h"
  17 +//#import "CNImagePickerController.h"
  18 +#import "Masonry.h"
  19 +#import "CNLiveBaseKit.h"
  20 +#import "CNLiveGetImage.h"
  21 +#define iOS7Later ([UIDevice currentDevice].systemVersion.floatValue >= 7.0f)
  22 +#define iOS8Later ([UIDevice currentDevice].systemVersion.floatValue >= 8.0f)
  23 +///
  24 +#define iOS9Later ([UIDevice currentDevice].systemVersion.floatValue >= 9.0f)
  25 +#define iOS9_1Later ([UIDevice currentDevice].systemVersion.floatValue >= 9.1f)
  26 +@interface CNLiveUploadVoucher ()<TZImagePickerControllerDelegate,UINavigationControllerDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UIImagePickerControllerDelegate>
  27 +@property (nonatomic, strong) NSMutableArray *selectedPhotos;
  28 +@property (nonatomic, strong) NSMutableArray *selectedAssets;
  29 +@property (nonatomic, assign) BOOL isSelectOriginalPhoto;
  30 +@property (nonatomic, assign) CGFloat itemWH;
  31 +@property (nonatomic, assign) CGFloat margin;
  32 +@property (nonatomic, assign) CGFloat collHeight;
  33 +@property (nonatomic, assign) NSInteger add ; //是否隐藏+号
  34 +@property (nonatomic, assign) CGFloat colTop; //collectionView 距离顶部坐标
  35 +@property (nonatomic, strong) UIImagePickerController *imagePickerVc;
  36 +@property (nonatomic, strong) UILabel *titleLab;
  37 +@property (nonatomic, strong) UICollectionView *collectionView;
  38 +@property (strong, nonatomic) LxGridViewFlowLayout *layout;
  39 +@property (strong, nonatomic) CLLocation *location;
  40 +@end
  41 +
  42 +@implementation CNLiveUploadVoucher
  43 +- (void)dealloc
  44 +{
  45 + NSLog(@"CNUploadVoucher dealloc");
  46 +}
  47 +- (instancetype)initWithFrame:(CGRect)frame
  48 +{
  49 + self = [super initWithFrame:frame];
  50 + if (self) {
  51 + self.backgroundColor = [UIColor whiteColor];
  52 + _add = 1;
  53 + _selectedPhotos = [[NSMutableArray alloc] init];
  54 + _selectedAssets = [[NSMutableArray alloc] init];
  55 + }
  56 + return self;
  57 +}
  58 +- (void)deleteBtnClik:(UIButton *)sender {
  59 + [_selectedPhotos removeObjectAtIndex:sender.tag];
  60 + [_selectedAssets removeObjectAtIndex:sender.tag];
  61 + __weak typeof(self) weakSelf = self;
  62 + [weakSelf.collectionView performBatchUpdates:^{
  63 + NSIndexPath *indexPath = [NSIndexPath indexPathForItem:sender.tag inSection:0];
  64 + [weakSelf.collectionView deleteItemsAtIndexPaths:@[indexPath]];
  65 + } completion:^(BOOL finished) {
  66 + weakSelf.add = 1;
  67 + [self updateHeight];
  68 + }];
  69 +
  70 +}
  71 +- (void)configCollectionView {
  72 + // 如不需要长按排序效果,将LxGridViewFlowLayout类改成UICollectionViewFlowLayout即可
  73 + _layout = [[LxGridViewFlowLayout alloc] init];
  74 + _margin = 8;
  75 + _itemWH = (KScreenWidth - 20 - 2 * _margin - 4) / 3 - _margin;
  76 + _layout.itemSize = CGSizeMake(_itemWH, _itemWH);
  77 + _layout.minimumInteritemSpacing = _margin;
  78 + _layout.minimumLineSpacing = _margin;
  79 +
  80 + _colTop = 20;
  81 + if (self.titleLabel) {
  82 + _colTop += self.titleLabel.height+15;
  83 + [self addSubview:self.titleLabel];
  84 + }
  85 + _collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(10, _colTop, KScreenWidth-20, _itemWH+10) collectionViewLayout:_layout];
  86 + _collectionView.alwaysBounceVertical = YES;
  87 + _collectionView.backgroundColor = [UIColor whiteColor];
  88 + _collectionView.contentInset = UIEdgeInsetsMake(4, 4, 4, 4);
  89 + _collectionView.dataSource = self;
  90 + _collectionView.delegate = self;
  91 + _collectionView.scrollEnabled = NO;
  92 + _collectionView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
  93 + [self addSubview:_collectionView];
  94 + [_collectionView registerClass:[TZTestCell class] forCellWithReuseIdentifier:@"TZTestCell"];
  95 +}
  96 +
  97 +#pragma mark UICollectionView
  98 +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  99 + return _selectedPhotos.count + _add;
  100 +}
  101 +
  102 +
  103 +- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  104 + TZTestCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TZTestCell" forIndexPath:indexPath];
  105 + cell.videoImageView.hidden = YES;
  106 + cell.gifLable.hidden = YES;
  107 +
  108 + if (indexPath.row == _selectedPhotos.count) {
  109 +// cell.imageView.image = [UIImage imageNamed:@"pj_tianjiazhaopian"];
  110 + cell.imageView.image = [CNLiveGetImage cnliveGetImageWithName:@"pj_tianjiazhaopian" bundle:@"CNLiveMyOrder.bundle/CNLiveMyOrder" targetClass:[self class]];
  111 + cell.deleteBtn.hidden = YES;
  112 + } else {
  113 + cell.imageView.image = _selectedPhotos[indexPath.row];
  114 + cell.asset = _selectedAssets[indexPath.row];
  115 + cell.deleteBtn.hidden = NO;
  116 + }
  117 +
  118 + cell.deleteBtn.tag = indexPath.row;
  119 + [cell.deleteBtn addTarget:self action:@selector(deleteBtnClik:) forControlEvents:UIControlEventTouchUpInside];
  120 + return cell;
  121 +}
  122 +
  123 +- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  124 +
  125 + if (indexPath.row == _selectedPhotos.count) {
  126 +
  127 + [self createAlertViewTitleArray:@[@"拍照",@"从相册选取"] textColor:KTextBlackColor font:[UIFont systemFontOfSize:15.0f] actionBlock:^(UIButton *button, NSInteger didRow) {
  128 +
  129 + switch (didRow) {
  130 + case 0: {
  131 + [self takePhoto];
  132 + }
  133 + break;
  134 +
  135 + case 1: {
  136 + [self pushTZImagePickerController];
  137 + }
  138 + break;
  139 +
  140 + default:
  141 + break;
  142 + }
  143 +
  144 + }];
  145 +
  146 + } else { //预览照片
  147 + __weak typeof(self) weakSelf = self;
  148 + TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc]initWithMaxImagesCount:9 delegate:self];
  149 +
  150 +// CNImagePickerController *imagePickerVc = [[CNImagePickerController alloc] initWithSelectedAssets:_selectedAssets selectedPhotos:_selectedPhotos index:indexPath.row];
  151 +// [imagePickerVc configTZImagePicker];
  152 +// imagePickerVc.maxImagesCount = 9;
  153 + imagePickerVc.allowPickingGif = NO;
  154 + imagePickerVc.allowPickingOriginalPhoto = YES;
  155 + imagePickerVc.allowPickingMultipleVideo = NO;
  156 + imagePickerVc.isSelectOriginalPhoto = _isSelectOriginalPhoto;
  157 + [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
  158 + weakSelf.selectedPhotos = [NSMutableArray arrayWithArray:photos];
  159 + weakSelf.selectedAssets = [NSMutableArray arrayWithArray:assets];
  160 + weakSelf.isSelectOriginalPhoto = isSelectOriginalPhoto;
  161 + [weakSelf.collectionView reloadData];
  162 + weakSelf.collectionView.contentSize = CGSizeMake(0, ((weakSelf.selectedPhotos.count + 2) / 3 ) * (weakSelf.margin + weakSelf.itemWH));
  163 +
  164 + }];
  165 + [self.viewController presentViewController:imagePickerVc animated:YES completion:nil];
  166 +
  167 +//
  168 + }
  169 +}
  170 +
  171 +#pragma mark - LxGridViewDataSource
  172 +/// 以下三个方法为长按排序相关代码
  173 +- (BOOL)collectionView:(UICollectionView *)collectionView canMoveItemAtIndexPath:(NSIndexPath *)indexPath {
  174 + return indexPath.item < _selectedPhotos.count;
  175 +}
  176 +
  177 +- (BOOL)collectionView:(UICollectionView *)collectionView itemAtIndexPath:(NSIndexPath *)sourceIndexPath canMoveToIndexPath:(NSIndexPath *)destinationIndexPath {
  178 + return (sourceIndexPath.item < _selectedPhotos.count && destinationIndexPath.item < _selectedPhotos.count);
  179 +}
  180 +
  181 +- (void)collectionView:(UICollectionView *)collectionView itemAtIndexPath:(NSIndexPath *)sourceIndexPath didMoveToIndexPath:(NSIndexPath *)destinationIndexPath {
  182 + UIImage *image = _selectedPhotos[sourceIndexPath.item];
  183 + [_selectedPhotos removeObjectAtIndex:sourceIndexPath.item];
  184 + [_selectedPhotos insertObject:image atIndex:destinationIndexPath.item];
  185 +
  186 + id asset = _selectedAssets[sourceIndexPath.item];
  187 + [_selectedAssets removeObjectAtIndex:sourceIndexPath.item];
  188 + [_selectedAssets insertObject:asset atIndex:destinationIndexPath.item];
  189 +
  190 + [_collectionView reloadData];
  191 +
  192 + if (self.delegate && [self.delegate respondsToSelector:@selector(updateImages:)]) {
  193 + [self.delegate updateImages:_selectedAssets];
  194 + }
  195 +}
  196 +
  197 +#pragma mark - TZImagePickerController
  198 +- (void)pushTZImagePickerController {
  199 + TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc]initWithMaxImagesCount:9 delegate:self];
  200 +
  201 +// CNImagePickerController *imagePickerVc = [[CNImagePickerController alloc]initWithMaxImagesCount:9 columnNumber:4 delegate:self pushPhotoPickerVc:YES];
  202 +
  203 +// [imagePickerVc configTZImagePicker];//配置
  204 +//#pragma mark - 五类个性化设置,这些参数都可以不传,此时会走默认设置
  205 + imagePickerVc.isSelectOriginalPhoto = _isSelectOriginalPhoto;
  206 +
  207 + imagePickerVc.selectedAssets = _selectedAssets; //目前已经选中的图片数组
  208 + imagePickerVc.allowTakePicture = NO; //在内部显示拍照按钮
  209 + imagePickerVc.allowPickingVideo = NO; //是否允许选择视频
  210 + imagePickerVc.allowPickingImage = YES; //是否允许选择图片
  211 + imagePickerVc.allowPickingOriginalPhoto = YES; //选择原图
  212 + imagePickerVc.allowPickingGif = NO; //选择Gif
  213 + imagePickerVc.allowPickingMultipleVideo = NO; // 是否可以多选视频
  214 + imagePickerVc.sortAscendingByModificationDate = YES;//排序
  215 +
  216 + imagePickerVc.showSelectBtn = NO;
  217 + imagePickerVc.allowCrop = NO; //是否允许裁剪
  218 + imagePickerVc.needCircleCrop = NO; //是否使用圆形裁剪
  219 +
  220 + // 你可以通过block或者代理,来得到用户选择的照片.
  221 + [imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
  222 +
  223 +
  224 + }];
  225 +//
  226 + [self.viewController presentViewController:imagePickerVc animated:YES completion:nil];
  227 +}
  228 +
  229 +#pragma mark - UIImagePickerController
  230 +- (void)takePhoto {
  231 + AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
  232 + if ((authStatus == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied) && iOS7Later) {
  233 + // 无相机权限 做一个友好的提示
  234 + if (iOS8Later) {
  235 + // UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"无法使用相机" message:@"请在iPhone的“设置-隐私-相机“中允许访问相机" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"", nil];//设置
  236 + UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"无法使用相机" message:@"请在iPhone的“设置-隐私-相机“中允许访问相机" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:nil, nil];//设置
  237 +
  238 + [alert show];
  239 + }
  240 + } else if (authStatus == AVAuthorizationStatusNotDetermined) {
  241 + // fix issue 466, 防止用户首次拍照拒绝授权时相机页黑屏
  242 + if (iOS7Later) {
  243 + [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
  244 + if (granted) {
  245 + dispatch_sync(dispatch_get_main_queue(), ^{
  246 + [self takePhoto];
  247 + });
  248 + }
  249 + }];
  250 + } else {
  251 + [self takePhoto];
  252 + }
  253 + // 拍照之前还需要检查相册权限
  254 + } else if ([self authorizationStatus] == 2) { // 已被拒绝,没有相册权限,将无法保存拍的照片
  255 + if (iOS8Later) {
  256 + UIAlertView * alert = [[UIAlertView alloc]initWithTitle:@"无法访问相册" message:@"请在iPhone的“设置-隐私-相册“中允许访问相册" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:nil, nil];//设置
  257 + [alert show];
  258 + }
  259 + } else if ([self authorizationStatus] == 0) { // 未请求过相册权限
  260 + [[TZImageManager manager] requestAuthorizationWithCompletion:^{
  261 + [self takePhoto];
  262 + }];
  263 + } else {
  264 + [self pushImagePickerController];
  265 + }
  266 +}
  267 +- (NSInteger)authorizationStatus {
  268 + if (iOS8Later) {
  269 + return [PHPhotoLibrary authorizationStatus];
  270 + } else {
  271 + return [ALAssetsLibrary authorizationStatus];
  272 + }
  273 + return NO;
  274 +}
  275 +
  276 +// 调用相机
  277 +- (void)pushImagePickerController {
  278 +
  279 + UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
  280 + if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
  281 + self.imagePickerVc.sourceType = sourceType;
  282 + if(iOS8Later) {
  283 + _imagePickerVc.modalPresentationStyle = UIModalPresentationOverCurrentContext;
  284 + }
  285 + [self.viewController presentViewController:_imagePickerVc animated:YES completion:nil];
  286 + } else {
  287 + NSLog(@"模拟器中无法打开照相机,请在真机中使用");
  288 + }
  289 +}
  290 +
  291 +- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
  292 + [picker dismissViewControllerAnimated:YES completion:nil];
  293 + NSString *type = [info objectForKey:UIImagePickerControllerMediaType];
  294 + if ([type isEqualToString:@"public.image"]) {
  295 + TZImagePickerController *tzImagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:1 delegate:self];
  296 + tzImagePickerVc.sortAscendingByModificationDate = YES;
  297 + [tzImagePickerVc showProgressHUD];
  298 + UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
  299 + [[TZImageManager manager] savePhotoWithImage:image completion:^(PHAsset *asset, NSError *error) {
  300 + [tzImagePickerVc hideProgressHUD];
  301 + if (error) {
  302 + [tzImagePickerVc hideProgressHUD];
  303 + NSLog(@"图片保存失败%@",error);
  304 + }else {
  305 + [[TZImageManager manager]getCameraRollAlbum:NO allowPickingImage:YES needFetchAssets:YES completion:^(TZAlbumModel *model) {
  306 + [[TZImageManager manager]getAssetsFromFetchResult:model.result completion:^(NSArray<TZAssetModel *> *models) {
  307 + [tzImagePickerVc hideProgressHUD];
  308 + TZAssetModel *assetModel = [models firstObject];
  309 + if (tzImagePickerVc.sortAscendingByModificationDate) {
  310 + assetModel = [models lastObject];
  311 + }
  312 + [self refreshCollectionViewWithAddedAsset:assetModel.asset image:image];
  313 + } ];
  314 + } ];
  315 + }
  316 + }];
  317 +
  318 + }
  319 +}
  320 +
  321 +- (void)refreshCollectionViewWithAddedAsset:(id)asset image:(UIImage *)image {
  322 + [_selectedAssets addObject:asset];
  323 + [_selectedPhotos addObject:image];
  324 + [_collectionView reloadData];
  325 +
  326 + if (_selectedPhotos.count == 9) {
  327 + _add = 0;
  328 + } else {
  329 + _add = 1;
  330 + }
  331 +
  332 + [self updateHeight];
  333 +
  334 +}
  335 +
  336 +- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
  337 + if ([picker isKindOfClass:[UIImagePickerController class]]) {
  338 + [picker dismissViewControllerAnimated:YES completion:nil];
  339 + }
  340 +}
  341 +
  342 +#pragma mark - UIActionSheetDelegate
  343 +
  344 +- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
  345 + if (buttonIndex == 0) { // take photo / 去拍照
  346 + [self takePhoto];
  347 + } else if (buttonIndex == 1) {
  348 + [self pushTZImagePickerController];
  349 + }
  350 +}
  351 +
  352 +#pragma mark - UIAlertViewDelegate
  353 +- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
  354 + if (buttonIndex == 1) { // 去设置界面,开启相机访问权限
  355 + if (iOS8Later) {
  356 + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
  357 + }
  358 + }
  359 +}
  360 +
  361 +#pragma mark - TZImagePickerControllerDelegate
  362 +- (void)tz_imagePickerControllerDidCancel:(TZImagePickerController *)picker {
  363 + // NSLog(@"cancel");
  364 +}
  365 +
  366 +- (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto infos:(NSArray<NSDictionary *> *)infos {
  367 + _selectedPhotos = [NSMutableArray arrayWithArray:photos];
  368 + _selectedAssets = [NSMutableArray arrayWithArray:assets];
  369 + _isSelectOriginalPhoto = isSelectOriginalPhoto;
  370 +
  371 + if (_selectedPhotos.count == 9) {
  372 + _add = 0;
  373 + } else {
  374 + _add = 1;
  375 + }
  376 +
  377 + [self updateHeight];
  378 +
  379 +}
  380 +
  381 +//更新自身高度
  382 +- (void)updateHeight {
  383 +
  384 + NSInteger num = 0;
  385 + if (_selectedAssets.count == 9) {
  386 + num = 9;
  387 + } else {
  388 + num = _selectedAssets.count+1;
  389 + }
  390 +
  391 + NSInteger integer = num/3;
  392 + NSInteger remainder = num%3;
  393 +
  394 + if (remainder > 0) {
  395 + integer += 1;
  396 + }
  397 +
  398 + _collectionView.frame = CGRectMake(10, _colTop, KScreenWidth-20, _itemWH*integer + integer*_margin +10);
  399 + [_collectionView reloadData];
  400 +
  401 + CGFloat h = _collectionView.height + integer*_margin + 60;
  402 + [self mas_updateConstraints:^(MASConstraintMaker *make) {
  403 + make.height.mas_equalTo(h);
  404 + }];
  405 +
  406 + if (self.delegate && [self.delegate respondsToSelector:@selector(updateImages:)]) {
  407 + [self.delegate updateImages:_selectedPhotos];
  408 + }
  409 +
  410 +}
  411 +
  412 +
  413 +// Decide album show or not't
  414 +// 决定相册显示与否
  415 +- (BOOL)isAlbumCanSelect:(NSString *)albumName result:(id)result {
  416 + return YES;
  417 +}
  418 +
  419 +// Decide asset show or not't
  420 +// 决定asset显示与否
  421 +- (BOOL)isAssetCanSelect:(id)asset {
  422 + return YES;
  423 +}
  424 +
  425 +#pragma mark -
  426 +#pragma mark - Getter
  427 +- (UILabel *)titleLab
  428 +{
  429 + if (!_titleLab) {
  430 + _titleLab = [[UILabel alloc] init];
  431 + _titleLab.font = [UIFont systemFontOfSize:15];
  432 + _titleLab.text = @"上传照片";
  433 + }
  434 + return _titleLab;
  435 +}
  436 +
  437 +- (UIImagePickerController *)imagePickerVc {
  438 + if (_imagePickerVc == nil) {
  439 + _imagePickerVc = [[UIImagePickerController alloc] init];
  440 + _imagePickerVc.delegate = self;
  441 + // set appearance / 改变相册选择页的导航栏外观
  442 + if (iOS7Later) {
  443 + _imagePickerVc.navigationBar.barTintColor = self.viewController.navigationController.navigationBar.barTintColor;
  444 + }
  445 + _imagePickerVc.navigationBar.tintColor = self.viewController.navigationController.navigationBar.tintColor;
  446 + UIBarButtonItem *tzBarItem, *BarItem;
  447 + if (iOS9Later) {
  448 + tzBarItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[TZImagePickerController class]]];
  449 + BarItem = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UIImagePickerController class]]];
  450 + } else {
  451 + tzBarItem = [UIBarButtonItem appearanceWhenContainedIn:[TZImagePickerController class], nil];
  452 + BarItem = [UIBarButtonItem appearanceWhenContainedIn:[UIImagePickerController class], nil];
  453 + }
  454 + NSDictionary *titleTextAttributes = [tzBarItem titleTextAttributesForState:UIControlStateNormal];
  455 + [BarItem setTitleTextAttributes:titleTextAttributes forState:UIControlStateNormal];
  456 +
  457 + }
  458 + return _imagePickerVc;
  459 +}
  460 +
  461 +#pragma clang diagnostic pop
  462 +
  463 +
  464 +@end
CNLiveMyOrder/Classes/View/CNSelectedRefundReasonView.h 0 → 100644
  1 +//
  2 +// CNSelectedRefundReasonView.h
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by iOS on 2018/3/9.
  6 +// Copyright © 2018年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +typedef void(^ReasonBlock)(NSString *reason);
  12 +@interface CNSelectedRefundReasonView : UIView
  13 +
  14 +- (instancetype)initWithFrame:(CGRect)frame completionBlock:(ReasonBlock)completion;
  15 +
  16 +- (void)show;
  17 +
  18 +- (void)dismiss;
  19 +
  20 +@end
  21 +
  22 +
  23 +@interface CNSelectedRefundReasonCell : UITableViewCell
  24 +
  25 +@property (nonatomic, strong) NSString *text;
  26 +
  27 +@end
CNLiveMyOrder/Classes/View/CNSelectedRefundReasonView.m 0 → 100644
  1 +//
  2 +// CNSelectedRefundReasonView.m
  3 +// CNLiveNetAdd
  4 +//
  5 +// Created by iOS on 2018/3/9.
  6 +// Copyright © 2018年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "CNSelectedRefundReasonView.h"
  10 +#import "CNLiveOrderHeader.h"
  11 +#import "Masonry.h"
  12 +#import "CNLiveBaseKit.h"
  13 +#import <CNLiveRequestBastKit/CNLiveNetworking.h>
  14 +#import "TIMAdapter.h"
  15 +#import "CommonLibrary.h"
  16 +#import "QMUIKit.h"
  17 +#import "CNLiveEnvironmentConfiguration.h"
  18 +#define Cell_H 55
  19 +
  20 +@interface CNSelectedRefundReasonView ()<UITableViewDelegate, UITableViewDataSource>
  21 +{
  22 +}
  23 +
  24 +@property (nonatomic, strong) UITableView *tableView;
  25 +@property (nonatomic, copy) ReasonBlock reasonBlock;
  26 +@property (nonatomic, strong) UIButton *closeBtn;
  27 +@property (nonatomic, strong) UIView *bgView;
  28 +@property (nonatomic, strong) NSMutableArray *listArr;
  29 +@property (nonatomic, assign) CGFloat height;
  30 +
  31 +@end
  32 +
  33 +@implementation CNSelectedRefundReasonView
  34 +
  35 +- (instancetype)initWithFrame:(CGRect)frame completionBlock:(ReasonBlock)completion
  36 +{
  37 + self = [super initWithFrame:frame];
  38 + if (self) {
  39 + self.backgroundColor = [UIColor clearColor];
  40 +
  41 + NSArray *arr = [[NSUserDefaults standardUserDefaults] objectForKey:CNRefundReason];
  42 + _listArr = [NSMutableArray arrayWithArray:arr];
  43 +
  44 + _reasonBlock = completion;
  45 + _height = _listArr.count < 7 ? _listArr.count*Cell_H : 6*Cell_H;
  46 +
  47 + if (_height == _listArr.count*Cell_H) {
  48 + _tableView.scrollEnabled = NO;
  49 + }
  50 +
  51 + [self addSubview:self.bgView];
  52 + [self.bgView addSubview:self.closeBtn];
  53 + [self.bgView addSubview:self.tableView];
  54 + [self p_addMasonry];
  55 +
  56 + }
  57 + return self;
  58 +}
  59 +
  60 +- (void)p_addMasonry {
  61 +
  62 + [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  63 + make.top.mas_equalTo(0);
  64 + make.left.right.mas_equalTo(self.bgView);
  65 + make.bottom.mas_equalTo(self.closeBtn.mas_top).mas_offset(-10);
  66 + }];
  67 +
  68 + [self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  69 + make.left.right.mas_equalTo(self.bgView);
  70 + make.height.mas_equalTo(Cell_H);
  71 + make.bottom.mas_equalTo(self.bgView.mas_bottom);
  72 + }];
  73 +
  74 +}
  75 +
  76 +- (void)closeBtnAction {
  77 + [self dismiss];
  78 +}
  79 +
  80 +- (void)show {
  81 +
  82 + self.hidden = NO;
  83 +
  84 + if (_listArr.count == 0) {
  85 + [self loadData];
  86 + return;
  87 + }
  88 + __weak typeof(self) weakSelf = self;
  89 + [UIView animateWithDuration:0.25 animations:^{
  90 + self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5f];
  91 + self.bgView.frame = CGRectMake(0, KScreenHeight-weakSelf.height-Cell_H-10, KScreenWidth, weakSelf.height+Cell_H+10);
  92 + }];
  93 +}
  94 +
  95 +- (void)dismiss {
  96 + __weak typeof(self)weakSelf = self;
  97 + [UIView animateWithDuration:0.25 animations:^{
  98 + self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.0f];
  99 + self.bgView.frame = CGRectMake(0, KScreenHeight, KScreenWidth, weakSelf.height+Cell_H+10);
  100 + } completion:^(BOOL finished) {
  101 + self.hidden = YES;
  102 + }];
  103 +}
  104 +
  105 +- (void)loadData {
  106 + weakself
  107 + [CNLiveNetworking setAllowRequestDefaultArgument:NO];
  108 + [CNLiveNetworking requestNetworkWithMethod:CNLiveRequestMethodGET URLString:CNRefunfReasonUrl Param:@{} CacheType:CNLiveNetworkCacheTypeNetworkOnly CompletionBlock:^(NSURLSessionTask *requestTask, id responseObject, NSError *error) {
  109 + if (error) {
  110 + [[HUDHelper sharedInstance] tipMessage:error.localizedDescription];
  111 + [QMUITips showError:@"获取退款原因失败,请返回重试" inView:self hideAfterDelay:1.5];
  112 + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  113 + [weakSelf dismiss];
  114 + });
  115 +
  116 + [weakSelf dismiss];
  117 +
  118 + }else{
  119 + [[NSUserDefaults standardUserDefaults] setObject:responseObject forKey:CNRefundReason];
  120 + [[NSUserDefaults standardUserDefaults] synchronize];
  121 + NSArray *arr = [[NSUserDefaults standardUserDefaults] objectForKey:CNRefundReason];
  122 + weakSelf.listArr = [NSMutableArray arrayWithArray:arr];
  123 + weakSelf.height = weakSelf.listArr.count < 7 ? weakSelf.listArr.count*Cell_H : 6*Cell_H;
  124 + }
  125 + if (weakSelf.height == weakSelf.listArr.count*Cell_H) {
  126 + weakSelf.tableView.scrollEnabled = NO;
  127 + }
  128 + [UIView animateWithDuration:0.25 animations:^{
  129 + weakSelf.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5f];
  130 + weakSelf.bgView.frame = CGRectMake(0, KScreenHeight-weakSelf.height-Cell_H-10, KScreenWidth, weakSelf.height+Cell_H+10);
  131 + }];
  132 +
  133 + [weakSelf.tableView reloadData];
  134 + }];
  135 +}
  136 +
  137 +- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  138 + [self dismiss];
  139 +}
  140 +
  141 +#pragma mark -
  142 +#pragma mark - UITableViewDelegate / UITableViewDataSource
  143 +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  144 + return _listArr.count;
  145 +}
  146 +
  147 +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  148 +
  149 + static NSString *cellId = @"CNSelectedRefundReasonCell";
  150 + CNSelectedRefundReasonCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
  151 + if (!cell) {
  152 + cell = [[CNSelectedRefundReasonCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
  153 + }
  154 + NSString *str = _listArr[indexPath.row];
  155 + if ([str hasPrefix:@"/"]) {
  156 + //去除首字母/
  157 + cell.text = [[str componentsSeparatedByString:@"/"] lastObject];
  158 +
  159 + }
  160 + else
  161 + cell.text = _listArr[indexPath.row];
  162 +
  163 + return cell;
  164 +
  165 +}
  166 +
  167 +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  168 + return Cell_H;
  169 +}
  170 +
  171 +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  172 + [self.tableView qmui_clearsSelection];
  173 +
  174 + CNSelectedRefundReasonCell *cell = [tableView cellForRowAtIndexPath:indexPath];
  175 + NSString *text = cell.text;
  176 + if (self.reasonBlock) {
  177 + self.reasonBlock(text);
  178 + }
  179 + [self dismiss];
  180 +
  181 +}
  182 +
  183 +-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
  184 +{
  185 + //分割线补全
  186 + if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
  187 + [cell setLayoutMargins:UIEdgeInsetsZero];
  188 + }
  189 + if ([cell respondsToSelector:@selector(setSeparatorInset:)]){
  190 + [cell setSeparatorInset:UIEdgeInsetsZero];
  191 + }
  192 +}
  193 +
  194 +#pragma mark -
  195 +#pragma mark - Getter
  196 +- (UITableView *)tableView
  197 +{
  198 + if (!_tableView) {
  199 + _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, _height) style:UITableViewStylePlain];
  200 + _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 1)];
  201 + _tableView.backgroundColor = KGrayBgColor;
  202 + _tableView.delegate = self;
  203 + _tableView.dataSource = self;
  204 + }
  205 + return _tableView;
  206 +}
  207 +
  208 +- (UIButton *)closeBtn
  209 +{
  210 + if (!_closeBtn) {
  211 + _closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  212 + _closeBtn.frame = CGRectMake(0, _bgView.height-Cell_H, KScreenWidth, Cell_H);
  213 + [_closeBtn setBackgroundColor:kWhiteColor];
  214 + _closeBtn.titleLabel.font = UIFontMake(15);
  215 + [_closeBtn setTitle:@"关闭" forState:UIControlStateNormal];
  216 + [_closeBtn setTitleColor:KYellowColor forState:UIControlStateNormal];
  217 + [_closeBtn addTarget:self action:@selector(closeBtnAction) forControlEvents:UIControlEventTouchUpInside];
  218 + }
  219 + return _closeBtn;
  220 +}
  221 +
  222 +- (UIView *)bgView
  223 +{
  224 + if (!_bgView) {
  225 + _bgView = [[UIView alloc] initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, _height+Cell_H+10)];
  226 + _bgView.backgroundColor = KGrayBgColor;
  227 + }
  228 + return _bgView;
  229 +}
  230 +
  231 +@end
  232 +
  233 +
  234 +
  235 +@interface CNSelectedRefundReasonCell ()
  236 +
  237 +@property (nonatomic, strong) UILabel *textLab;
  238 +
  239 +@end
  240 +
  241 +@implementation CNSelectedRefundReasonCell
  242 +
  243 +- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  244 +{
  245 + self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  246 + if (self) {
  247 + self.selectionStyle = UITableViewCellSelectionStyleNone;
  248 + [self.contentView addSubview:self.textLab];
  249 + }
  250 + return self;
  251 +}
  252 +
  253 +- (void)setText:(NSString *)text{
  254 + _text = text;
  255 + _textLab.text = text;
  256 +}
  257 +
  258 +
  259 +#pragma mark - Getter
  260 +- (UILabel *)textLab
  261 +{
  262 + if (!_textLab) {
  263 + _textLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 55)];
  264 + _textLab.font = UIFontMake(15);
  265 + _textLab.textColor = KTextBlackColor;
  266 + _textLab.textAlignment = NSTextAlignmentCenter;
  267 + }
  268 + return _textLab;
  269 +}
  270 +
  271 +@end
CNLiveMyOrder/Classes/View/LxGridViewFlowLayout.h 0 → 100755
  1 +//
  2 +// LxGridViewFlowLayout.h
  3 +// LxGridView
  4 +//
  5 +
  6 +#import <UIKit/UIKit.h>
  7 +
  8 +/*
  9 + 此类来源于DeveloperLx的优秀开源项目:LxGridView
  10 + github链接:https://github.com/DeveloperLx/LxGridView
  11 + 我对这个类的代码做了一些修改;
  12 + 感谢DeveloperLx的优秀代码~
  13 + */
  14 +
  15 +@interface LxGridViewFlowLayout : UICollectionViewFlowLayout
  16 +
  17 +@property (nonatomic,assign) BOOL panGestureRecognizerEnable;
  18 +
  19 +@end
  20 +
  21 +@protocol LxGridViewDataSource <UICollectionViewDataSource>
  22 +
  23 +@optional
  24 +
  25 +- (void)collectionView:(UICollectionView *)collectionView
  26 + itemAtIndexPath:(NSIndexPath *)sourceIndexPath
  27 + willMoveToIndexPath:(NSIndexPath *)destinationIndexPath;
  28 +- (void)collectionView:(UICollectionView *)collectionView
  29 + itemAtIndexPath:(NSIndexPath *)sourceIndexPath
  30 + didMoveToIndexPath:(NSIndexPath *)destinationIndexPath;
  31 +
  32 +- (BOOL)collectionView:(UICollectionView *)collectionView
  33 +canMoveItemAtIndexPath:(NSIndexPath *)indexPath;
  34 +- (BOOL)collectionView:(UICollectionView *)collectionView
  35 + itemAtIndexPath:(NSIndexPath *)sourceIndexPath
  36 + canMoveToIndexPath:(NSIndexPath *)destinationIndexPath;
  37 +
  38 +@end
  39 +
  40 +@protocol LxGridViewDelegateFlowLayout <UICollectionViewDelegateFlowLayout>
  41 +
  42 +@optional
  43 +
  44 +- (void)collectionView:(UICollectionView *)collectionView
  45 + layout:(UICollectionViewLayout *)collectionViewLayout
  46 +willBeginDraggingItemAtIndexPath:(NSIndexPath *)indexPath;
  47 +- (void)collectionView:(UICollectionView *)collectionView
  48 + layout:(UICollectionViewLayout *)collectionViewLayout
  49 +didBeginDraggingItemAtIndexPath:(NSIndexPath *)indexPath;
  50 +- (void)collectionView:(UICollectionView *)collectionView
  51 + layout:(UICollectionViewLayout *)collectionViewLayout
  52 +willEndDraggingItemAtIndexPath:(NSIndexPath *)indexPath;
  53 +- (void)collectionView:(UICollectionView *)collectionView
  54 + layout:(UICollectionViewLayout *)collectionViewLayout
  55 +didEndDraggingItemAtIndexPath:(NSIndexPath *)indexPath;
  56 +
  57 +@end
0 \ No newline at end of file 58 \ No newline at end of file
CNLiveMyOrder/Classes/View/LxGridViewFlowLayout.m 0 → 100755
  1 +//
  2 +// LxGridViewFlowLayout.m
  3 +// LxGridView
  4 +//
  5 +
  6 +#import "LxGridViewFlowLayout.h"
  7 +#import "TZTestCell.h"
  8 +#import "UIView+Extension.h"
  9 +
  10 +#define stringify __STRING
  11 +
  12 +static CGFloat const PRESS_TO_MOVE_MIN_DURATION = 0.1;
  13 +static CGFloat const MIN_PRESS_TO_BEGIN_EDITING_DURATION = 0.6;
  14 +
  15 +CG_INLINE CGPoint CGPointOffset(CGPoint point, CGFloat dx, CGFloat dy)
  16 +{
  17 + return CGPointMake(point.x + dx, point.y + dy);
  18 +}
  19 +
  20 +/*
  21 + 此类来源于DeveloperLx的优秀开源项目:LxGridView
  22 + github链接:https://github.com/DeveloperLx/LxGridView
  23 + 我对这个类的代码做了一些修改;
  24 + 感谢DeveloperLx的优秀代码~
  25 + */
  26 +
  27 +@interface LxGridViewFlowLayout () <UIGestureRecognizerDelegate>
  28 +
  29 +@property (nonatomic,readonly) id<LxGridViewDataSource> dataSource;
  30 +@property (nonatomic,readonly) id<LxGridViewDelegateFlowLayout> delegate;
  31 +
  32 +@end
  33 +
  34 +@implementation LxGridViewFlowLayout
  35 +{
  36 + UILongPressGestureRecognizer * _longPressGestureRecognizer;
  37 + UIPanGestureRecognizer * _panGestureRecognizer;
  38 + NSIndexPath * _movingItemIndexPath;
  39 + UIView * _beingMovedPromptView;
  40 + CGPoint _sourceItemCollectionViewCellCenter;
  41 +
  42 + CADisplayLink * _displayLink;
  43 + CFTimeInterval _remainSecondsToBeginEditing;
  44 +}
  45 +
  46 +#pragma mark - setup
  47 +
  48 +- (void)dealloc
  49 +{
  50 + [_displayLink invalidate];
  51 +
  52 + [self removeGestureRecognizers];
  53 + [self removeObserver:self forKeyPath:@stringify(collectionView)];
  54 +}
  55 +
  56 +- (instancetype)init
  57 +{
  58 + if (self = [super init]) {
  59 + [self setup];
  60 + }
  61 + return self;
  62 +}
  63 +
  64 +- (instancetype)initWithCoder:(NSCoder *)coder
  65 +{
  66 + if (self = [super initWithCoder:coder]) {
  67 + [self setup];
  68 + }
  69 + return self;
  70 +}
  71 +
  72 +- (void)setup
  73 +{
  74 + [self addObserver:self forKeyPath:@stringify(collectionView) options:NSKeyValueObservingOptionNew context:nil];
  75 +}
  76 +
  77 +- (void)addGestureRecognizers
  78 +{
  79 + self.collectionView.userInteractionEnabled = YES;
  80 +
  81 + _longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(longPressGestureRecognizerTriggerd:)];
  82 + _longPressGestureRecognizer.cancelsTouchesInView = NO;
  83 + _longPressGestureRecognizer.minimumPressDuration = PRESS_TO_MOVE_MIN_DURATION;
  84 + _longPressGestureRecognizer.delegate = self;
  85 +
  86 + for (UIGestureRecognizer * gestureRecognizer in self.collectionView.gestureRecognizers) {
  87 + if ([gestureRecognizer isKindOfClass:[UILongPressGestureRecognizer class]]) {
  88 + [gestureRecognizer requireGestureRecognizerToFail:_longPressGestureRecognizer];
  89 + }
  90 + }
  91 +
  92 + [self.collectionView addGestureRecognizer:_longPressGestureRecognizer];
  93 +
  94 + _panGestureRecognizer = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(panGestureRecognizerTriggerd:)];
  95 + _panGestureRecognizer.delegate = self;
  96 + [self.collectionView addGestureRecognizer:_panGestureRecognizer];
  97 +
  98 + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillResignActive:) name:UIApplicationWillResignActiveNotification object:nil];
  99 +}
  100 +
  101 +- (void)removeGestureRecognizers
  102 +{
  103 + if (_longPressGestureRecognizer) {
  104 + if (_longPressGestureRecognizer.view) {
  105 + [_longPressGestureRecognizer.view removeGestureRecognizer:_longPressGestureRecognizer];
  106 + }
  107 + _longPressGestureRecognizer = nil;
  108 + }
  109 +
  110 + if (_panGestureRecognizer) {
  111 + if (_panGestureRecognizer.view) {
  112 + [_panGestureRecognizer.view removeGestureRecognizer:_panGestureRecognizer];
  113 + }
  114 + _panGestureRecognizer = nil;
  115 + }
  116 +
  117 + [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillResignActiveNotification object:nil];
  118 +}
  119 +
  120 +#pragma mark - getter and setter implementation
  121 +
  122 +- (id<LxGridViewDataSource>)dataSource
  123 +{
  124 + return (id<LxGridViewDataSource>)self.collectionView.dataSource;
  125 +}
  126 +
  127 +- (id<LxGridViewDelegateFlowLayout>)delegate
  128 +{
  129 + return (id<LxGridViewDelegateFlowLayout>)self.collectionView.delegate;
  130 +}
  131 +
  132 +#pragma mark - override UICollectionViewLayout methods
  133 +
  134 +- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect
  135 +{
  136 + NSArray * layoutAttributesForElementsInRect = [super layoutAttributesForElementsInRect:rect];
  137 +
  138 + for (UICollectionViewLayoutAttributes * layoutAttributes in layoutAttributesForElementsInRect) {
  139 +
  140 + if (layoutAttributes.representedElementCategory == UICollectionElementCategoryCell) {
  141 + layoutAttributes.hidden = [layoutAttributes.indexPath isEqual:_movingItemIndexPath];
  142 + }
  143 + }
  144 + return layoutAttributesForElementsInRect;
  145 +}
  146 +
  147 +- (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath
  148 +{
  149 + UICollectionViewLayoutAttributes * layoutAttributes = [super layoutAttributesForItemAtIndexPath:indexPath];
  150 + if (layoutAttributes.representedElementCategory == UICollectionElementCategoryCell) {
  151 + layoutAttributes.hidden = [layoutAttributes.indexPath isEqual:_movingItemIndexPath];
  152 + }
  153 + return layoutAttributes;
  154 +}
  155 +
  156 +#pragma mark - gesture
  157 +
  158 +- (void)setPanGestureRecognizerEnable:(BOOL)panGestureRecognizerEnable
  159 +{
  160 + _panGestureRecognizer.enabled = panGestureRecognizerEnable;
  161 +}
  162 +
  163 +- (BOOL)panGestureRecognizerEnable
  164 +{
  165 + return _panGestureRecognizer.enabled;
  166 +}
  167 +
  168 +- (void)longPressGestureRecognizerTriggerd:(UILongPressGestureRecognizer *)longPress
  169 +{
  170 + switch (longPress.state) {
  171 + case UIGestureRecognizerStatePossible:
  172 + break;
  173 + case UIGestureRecognizerStateBegan:
  174 + {
  175 + if (_displayLink == nil) {
  176 + _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(displayLinkTriggered:)];
  177 + _displayLink.frameInterval = 6;
  178 + [_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
  179 +
  180 + _remainSecondsToBeginEditing = MIN_PRESS_TO_BEGIN_EDITING_DURATION;
  181 + }
  182 +
  183 + _movingItemIndexPath = [self.collectionView indexPathForItemAtPoint:[longPress locationInView:self.collectionView]];
  184 + if ([self.dataSource respondsToSelector:@selector(collectionView:canMoveItemAtIndexPath:)] && [self.dataSource collectionView:self.collectionView canMoveItemAtIndexPath:_movingItemIndexPath] == NO) {
  185 + _movingItemIndexPath = nil;
  186 + return;
  187 + }
  188 +
  189 + if ([self.delegate respondsToSelector:@selector(collectionView:layout:willBeginDraggingItemAtIndexPath:)]) {
  190 + [self.delegate collectionView:self.collectionView layout:self willBeginDraggingItemAtIndexPath:_movingItemIndexPath];
  191 + }
  192 +
  193 + UICollectionViewCell *sourceCollectionViewCell = [self.collectionView cellForItemAtIndexPath:_movingItemIndexPath];
  194 + TZTestCell *sourceCell = (TZTestCell *)sourceCollectionViewCell;
  195 +
  196 + _beingMovedPromptView = [[UIView alloc]initWithFrame:CGRectOffset(sourceCollectionViewCell.frame, -10, -10)];
  197 + _beingMovedPromptView.width += 20;
  198 + _beingMovedPromptView.height += 20;
  199 +
  200 + sourceCollectionViewCell.highlighted = YES;
  201 + UIView * highlightedSnapshotView = [sourceCell snapshotView];
  202 + highlightedSnapshotView.frame = _beingMovedPromptView.bounds;
  203 + highlightedSnapshotView.alpha = 1;
  204 +
  205 + sourceCollectionViewCell.highlighted = NO;
  206 + UIView * snapshotView = [sourceCell snapshotView];
  207 + snapshotView.frame = _beingMovedPromptView.bounds;
  208 + snapshotView.alpha = 0;
  209 +
  210 + [_beingMovedPromptView addSubview:snapshotView];
  211 + [_beingMovedPromptView addSubview:highlightedSnapshotView];
  212 + [self.collectionView addSubview:_beingMovedPromptView];
  213 +
  214 + _sourceItemCollectionViewCellCenter = sourceCollectionViewCell.center;
  215 +
  216 + typeof(self) __weak weakSelf = self;
  217 + [UIView animateWithDuration:0
  218 + delay:0
  219 + options:UIViewAnimationOptionBeginFromCurrentState
  220 + animations:^{
  221 +
  222 + typeof(self) __strong strongSelf = weakSelf;
  223 + if (strongSelf) {
  224 + highlightedSnapshotView.alpha = 0;
  225 + snapshotView.alpha = 1;
  226 + }
  227 + }
  228 + completion:^(BOOL finished) {
  229 +
  230 + typeof(self) __strong strongSelf = weakSelf;
  231 + if (strongSelf) {
  232 + [highlightedSnapshotView removeFromSuperview];
  233 +
  234 + if ([strongSelf.delegate respondsToSelector:@selector(collectionView:layout:didBeginDraggingItemAtIndexPath:)]) {
  235 + [strongSelf.delegate collectionView:strongSelf.collectionView layout:strongSelf didBeginDraggingItemAtIndexPath:_movingItemIndexPath];
  236 + }
  237 + }
  238 + }];
  239 +
  240 + [self invalidateLayout];
  241 + }
  242 + break;
  243 + case UIGestureRecognizerStateChanged:
  244 + break;
  245 + case UIGestureRecognizerStateEnded:
  246 + case UIGestureRecognizerStateCancelled:
  247 + {
  248 + [_displayLink invalidate];
  249 + _displayLink = nil;
  250 +
  251 + NSIndexPath * movingItemIndexPath = _movingItemIndexPath;
  252 +
  253 + if (movingItemIndexPath) {
  254 + if ([self.delegate respondsToSelector:@selector(collectionView:layout:willEndDraggingItemAtIndexPath:)]) {
  255 + [self.delegate collectionView:self.collectionView layout:self willEndDraggingItemAtIndexPath:movingItemIndexPath];
  256 + }
  257 +
  258 + _movingItemIndexPath = nil;
  259 + _sourceItemCollectionViewCellCenter = CGPointZero;
  260 +
  261 + UICollectionViewLayoutAttributes * movingItemCollectionViewLayoutAttributes = [self layoutAttributesForItemAtIndexPath:movingItemIndexPath];
  262 +
  263 + _longPressGestureRecognizer.enabled = NO;
  264 +
  265 + typeof(self) __weak weakSelf = self;
  266 + [UIView animateWithDuration:0.2
  267 + delay:0
  268 + options:UIViewAnimationOptionBeginFromCurrentState
  269 + animations:^{
  270 + typeof(self) __strong strongSelf = weakSelf;
  271 + if (strongSelf) {
  272 + _beingMovedPromptView.center = movingItemCollectionViewLayoutAttributes.center;
  273 + }
  274 + }
  275 + completion:^(BOOL finished) {
  276 +
  277 + _longPressGestureRecognizer.enabled = YES;
  278 +
  279 + typeof(self) __strong strongSelf = weakSelf;
  280 + if (strongSelf) {
  281 + [_beingMovedPromptView removeFromSuperview];
  282 + _beingMovedPromptView = nil;
  283 + [strongSelf invalidateLayout];
  284 +
  285 + if ([strongSelf.delegate respondsToSelector:@selector(collectionView:layout:didEndDraggingItemAtIndexPath:)]) {
  286 + [strongSelf.delegate collectionView:strongSelf.collectionView layout:strongSelf didEndDraggingItemAtIndexPath:movingItemIndexPath];
  287 + }
  288 + }
  289 + }];
  290 + }
  291 + }
  292 + break;
  293 + case UIGestureRecognizerStateFailed:
  294 + break;
  295 + default:
  296 + break;
  297 + }
  298 +}
  299 +
  300 +- (void)panGestureRecognizerTriggerd:(UIPanGestureRecognizer *)pan
  301 +{
  302 + switch (pan.state) {
  303 + case UIGestureRecognizerStatePossible:
  304 + break;
  305 + case UIGestureRecognizerStateBegan:
  306 + case UIGestureRecognizerStateChanged:
  307 + {
  308 + CGPoint panTranslation = [pan translationInView:self.collectionView];
  309 + _beingMovedPromptView.center = CGPointOffset(_sourceItemCollectionViewCellCenter, panTranslation.x, panTranslation.y);
  310 +
  311 + NSIndexPath * sourceIndexPath = _movingItemIndexPath;
  312 + NSIndexPath * destinationIndexPath = [self.collectionView indexPathForItemAtPoint:_beingMovedPromptView.center];
  313 +
  314 + if ((destinationIndexPath == nil) || [destinationIndexPath isEqual:sourceIndexPath]) {
  315 + return;
  316 + }
  317 +
  318 + if ([self.dataSource respondsToSelector:@selector(collectionView:itemAtIndexPath:canMoveToIndexPath:)] && [self.dataSource collectionView:self.collectionView itemAtIndexPath:sourceIndexPath canMoveToIndexPath:destinationIndexPath] == NO) {
  319 + return;
  320 + }
  321 +
  322 + if ([self.dataSource respondsToSelector:@selector(collectionView:itemAtIndexPath:willMoveToIndexPath:)]) {
  323 + [self.dataSource collectionView:self.collectionView itemAtIndexPath:sourceIndexPath willMoveToIndexPath:destinationIndexPath];
  324 + }
  325 +
  326 + _movingItemIndexPath = destinationIndexPath;
  327 +
  328 + typeof(self) __weak weakSelf = self;
  329 + [self.collectionView performBatchUpdates:^{
  330 + typeof(self) __strong strongSelf = weakSelf;
  331 + if (strongSelf) {
  332 + if (sourceIndexPath && destinationIndexPath) {
  333 + [strongSelf.collectionView deleteItemsAtIndexPaths:@[sourceIndexPath]];
  334 + [strongSelf.collectionView insertItemsAtIndexPaths:@[destinationIndexPath]];
  335 + }
  336 + }
  337 + } completion:^(BOOL finished) {
  338 + typeof(self) __strong strongSelf = weakSelf;
  339 + if ([strongSelf.dataSource respondsToSelector:@selector(collectionView:itemAtIndexPath:didMoveToIndexPath:)]) {
  340 + [strongSelf.dataSource collectionView:strongSelf.collectionView itemAtIndexPath:sourceIndexPath didMoveToIndexPath:destinationIndexPath];
  341 + }
  342 + }];
  343 + }
  344 + break;
  345 + case UIGestureRecognizerStateEnded:
  346 + break;
  347 + case UIGestureRecognizerStateCancelled:
  348 + break;
  349 + case UIGestureRecognizerStateFailed:
  350 + break;
  351 + default:
  352 + break;
  353 + }
  354 +}
  355 +
  356 +- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
  357 +{
  358 + if ([_panGestureRecognizer isEqual:gestureRecognizer]) {
  359 + return _movingItemIndexPath != nil;
  360 + }
  361 + return YES;
  362 +}
  363 +
  364 +- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
  365 +{
  366 + // only _longPressGestureRecognizer and _panGestureRecognizer can recognize simultaneously
  367 + if ([_longPressGestureRecognizer isEqual:gestureRecognizer]) {
  368 + return [_panGestureRecognizer isEqual:otherGestureRecognizer];
  369 + }
  370 + if ([_panGestureRecognizer isEqual:gestureRecognizer]) {
  371 + return [_longPressGestureRecognizer isEqual:otherGestureRecognizer];
  372 + }
  373 + return NO;
  374 +}
  375 +
  376 +#pragma mark - displayLink
  377 +
  378 +- (void)displayLinkTriggered:(CADisplayLink *)displayLink
  379 +{
  380 + if (_remainSecondsToBeginEditing <= 0) {
  381 + [_displayLink invalidate];
  382 + _displayLink = nil;
  383 + }
  384 +
  385 + _remainSecondsToBeginEditing = _remainSecondsToBeginEditing - 0.1;
  386 +}
  387 +
  388 +#pragma mark - KVO and notification
  389 +
  390 +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
  391 +{
  392 + if ([keyPath isEqualToString:@stringify(collectionView)]) {
  393 + if (self.collectionView) {
  394 + [self addGestureRecognizers];
  395 + }
  396 + else {
  397 + [self removeGestureRecognizers];
  398 + }
  399 + }
  400 +}
  401 +
  402 +- (void)applicationWillResignActive:(NSNotification *)notificaiton
  403 +{
  404 + _panGestureRecognizer.enabled = NO;
  405 + _panGestureRecognizer.enabled = YES;
  406 +}
  407 +
  408 +@end
CNLiveMyOrder/Classes/View/TZTestCell.h 0 → 100644
  1 +//
  2 +// TZTestCell.h
  3 +// TZImagePickerController
  4 +//
  5 +// Created by 谭真 on 16/1/3.
  6 +// Copyright © 2016年 谭真. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@interface TZTestCell : UICollectionViewCell
  12 +
  13 +@property (nonatomic, strong) UIImageView *imageView;
  14 +@property (nonatomic, strong) UIImageView *videoImageView;
  15 +@property (nonatomic, strong) UIButton *deleteBtn;
  16 +@property (nonatomic, strong) UILabel *gifLable;
  17 +@property (nonatomic, assign) NSInteger row;
  18 +@property (nonatomic, strong) id asset;
  19 +
  20 +//zx
  21 +@property (nonatomic, strong) UILabel *addPicLable;
  22 +- (UIView *)snapshotView;
  23 +
  24 +@end
  25 +@interface NSString (TzExtension)
  26 +- (BOOL)tz_containsString:(NSString *)string;
  27 +@end
  28 +
CNLiveMyOrder/Classes/View/TZTestCell.m 0 → 100644
  1 +//
  2 +// TZTestCell.m
  3 +// TZImagePickerController
  4 +//
  5 +// Created by 谭真 on 16/1/3.
  6 +// Copyright © 2016年 谭真. All rights reserved.
  7 +//
  8 +
  9 +#import "TZTestCell.h"
  10 +#import <Photos/Photos.h>
  11 +#import <AssetsLibrary/AssetsLibrary.h>
  12 +#import "UIColor+CNLiveExtension.h"
  13 +#import "UIView+Extension.h"
  14 +#import "Masonry.h"
  15 +#import "CNLiveGetImage.h"
  16 +#define iOS8Later ([UIDevice currentDevice].systemVersion.floatValue >= 8.0f)
  17 +@implementation TZTestCell
  18 +
  19 +- (instancetype)initWithFrame:(CGRect)frame {
  20 + self = [super initWithFrame:frame];
  21 + if (self) {
  22 + self.backgroundColor = [UIColor whiteColor];
  23 + _imageView = [[UIImageView alloc] init];
  24 + _imageView.backgroundColor = [UIColor colorWithWhite:1.000 alpha:0.500];
  25 + _imageView.contentMode = UIViewContentModeScaleAspectFill;
  26 + [self addSubview:_imageView];
  27 + self.clipsToBounds = YES;
  28 +
  29 + _videoImageView = [[UIImageView alloc] init];
  30 +// _videoImageView.image = [UIImage imageNamed:@"fb_bof"];
  31 + _videoImageView.image = [CNLiveGetImage cnliveGetImageWithName:@"fb_bof" bundle:@"CNLiveMyOrder.bundle/CNLiveMyOrder" targetClass:[self class]];
  32 + _videoImageView.contentMode = UIViewContentModeScaleAspectFill;
  33 + _videoImageView.hidden = YES;
  34 + [self addSubview:_videoImageView];
  35 +
  36 + _deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  37 +// [_deleteBtn setImage:[UIImage imageNamed:@"fb_shanchu"] forState:UIControlStateNormal];//photo_delete
  38 + [_deleteBtn setImage:[CNLiveGetImage cnliveGetImageWithName:@"fb_shanchu" bundle:@"CNLiveMyOrder.bundle/CNLiveMyOrder" targetClass:[self class]] forState:UIControlStateNormal];
  39 + _deleteBtn.imageEdgeInsets = UIEdgeInsetsMake(-10, 0, 0, -10);
  40 + _deleteBtn.alpha = 0.6;
  41 + [self addSubview:_deleteBtn];
  42 +
  43 + _gifLable = [[UILabel alloc] init];
  44 + _gifLable.text = @"GIF";
  45 + _gifLable.textColor = [UIColor whiteColor];
  46 + _gifLable.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.8];
  47 + _gifLable.textAlignment = NSTextAlignmentCenter;
  48 + _gifLable.font = [UIFont systemFontOfSize:10];
  49 + [self addSubview:_gifLable];
  50 + _addPicLable = [[UILabel alloc] init];
  51 + _addPicLable.text = @"";
  52 + _addPicLable.textColor = CNLiveColorWithHexString(@"#FFAAAAAA");
  53 + _addPicLable.textAlignment = NSTextAlignmentCenter;
  54 + _addPicLable.font = [UIFont systemFontOfSize:12];
  55 + [self addSubview:_addPicLable];
  56 + _addPicLable.hidden = YES;
  57 + }
  58 + return self;
  59 +}
  60 +
  61 +- (void)layoutSubviews {
  62 + [super layoutSubviews];
  63 + _imageView.frame = self.bounds;
  64 + _gifLable.frame = CGRectMake(self.width - 25, self.height - 14, 25, 14);
  65 + _deleteBtn.frame = CGRectMake(self.width - 36, 0, 36, 36);
  66 + CGFloat width = self.width / 3.0;
  67 + _videoImageView.frame = CGRectMake(width, width, width, width);
  68 + [_addPicLable mas_makeConstraints:^(MASConstraintMaker *make) {
  69 + make.centerX.mas_equalTo(self.mas_centerX);
  70 + make.bottom.mas_equalTo(self.mas_bottom).mas_offset(-24);
  71 + }];
  72 +}
  73 +
  74 +- (void)setAsset:(id)asset {
  75 + _asset = asset;
  76 + if ([asset isKindOfClass:[PHAsset class]]) {
  77 + PHAsset *phAsset = asset;
  78 + _videoImageView.hidden = phAsset.mediaType != PHAssetMediaTypeVideo;
  79 + _gifLable.hidden = ![[phAsset valueForKey:@"filename"] tz_containsString:@"GIF"];
  80 + } else if ([asset isKindOfClass:[ALAsset class]]) {
  81 + ALAsset *alAsset = asset;
  82 + _videoImageView.hidden = ![[alAsset valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo];
  83 + _gifLable.hidden = YES;
  84 + }
  85 + }
  86 +
  87 +- (void)setRow:(NSInteger)row {
  88 + _row = row;
  89 + _deleteBtn.tag = row;
  90 +}
  91 +
  92 +- (UIView *)snapshotView {
  93 + UIView *snapshotView = [[UIView alloc]init];
  94 +
  95 + UIView *cellSnapshotView = nil;
  96 +
  97 + if ([self respondsToSelector:@selector(snapshotViewAfterScreenUpdates:)]) {
  98 + cellSnapshotView = [self snapshotViewAfterScreenUpdates:NO];
  99 + } else {
  100 + CGSize size = CGSizeMake(self.bounds.size.width + 20, self.bounds.size.height + 20);
  101 + UIGraphicsBeginImageContextWithOptions(size, self.opaque, 0);
  102 + [self.layer renderInContext:UIGraphicsGetCurrentContext()];
  103 + UIImage * cellSnapshotImage = UIGraphicsGetImageFromCurrentImageContext();
  104 + UIGraphicsEndImageContext();
  105 + cellSnapshotView = [[UIImageView alloc]initWithImage:cellSnapshotImage];
  106 + }
  107 +
  108 + snapshotView.frame = CGRectMake(0, 0, cellSnapshotView.frame.size.width, cellSnapshotView.frame.size.height);
  109 + cellSnapshotView.frame = CGRectMake(0, 0, cellSnapshotView.frame.size.width, cellSnapshotView.frame.size.height);
  110 +
  111 + [snapshotView addSubview:cellSnapshotView];
  112 + return snapshotView;
  113 +}
  114 +
  115 +@end
  116 +
  117 +@implementation NSString (TzExtension)
  118 +
  119 +- (BOOL)tz_containsString:(NSString *)string {
  120 + if (iOS8Later) {
  121 + return [self containsString:string];
  122 + } else {
  123 + NSRange range = [self rangeOfString:string];
  124 + return range.location != NSNotFound;
  125 + }
  126 +}
  127 +
  128 +@end
Example/CNLiveMyOrder.xcodeproj/project.pbxproj
@@ -432,6 +432,7 @@ @@ -432,6 +432,7 @@
432 "${BUILT_PRODUCTS_DIR}/QMUIKit/QMUIKit.framework", 432 "${BUILT_PRODUCTS_DIR}/QMUIKit/QMUIKit.framework",
433 "${BUILT_PRODUCTS_DIR}/Realm/Realm.framework", 433 "${BUILT_PRODUCTS_DIR}/Realm/Realm.framework",
434 "${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework", 434 "${BUILT_PRODUCTS_DIR}/SDWebImage/SDWebImage.framework",
  435 + "${BUILT_PRODUCTS_DIR}/TZImagePickerController/TZImagePickerController.framework",
435 "${BUILT_PRODUCTS_DIR}/YYKit/YYKit.framework", 436 "${BUILT_PRODUCTS_DIR}/YYKit/YYKit.framework",
436 ); 437 );
437 name = "[CP] Embed Pods Frameworks"; 438 name = "[CP] Embed Pods Frameworks";
@@ -456,6 +457,7 @@ @@ -456,6 +457,7 @@
456 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/QMUIKit.framework", 457 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/QMUIKit.framework",
457 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Realm.framework", 458 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Realm.framework",
458 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework", 459 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SDWebImage.framework",
  460 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/TZImagePickerController.framework",
459 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYKit.framework", 461 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YYKit.framework",
460 ); 462 );
461 runOnlyForDeploymentPostprocessing = 0; 463 runOnlyForDeploymentPostprocessing = 0;
Example/CNLiveMyOrder/CNLiveMyOrder-Info.plist
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 <plist version="1.0"> 3 <plist version="1.0">
4 <dict> 4 <dict>
5 <key>CFBundleDevelopmentRegion</key> 5 <key>CFBundleDevelopmentRegion</key>
6 - <string>en</string> 6 + <string>zh_CN</string>
7 <key>CFBundleDisplayName</key> 7 <key>CFBundleDisplayName</key>
8 <string>${PRODUCT_NAME}</string> 8 <string>${PRODUCT_NAME}</string>
9 <key>CFBundleExecutable</key> 9 <key>CFBundleExecutable</key>
@@ -24,6 +24,17 @@ @@ -24,6 +24,17 @@
24 <string>1.0</string> 24 <string>1.0</string>
25 <key>LSRequiresIPhoneOS</key> 25 <key>LSRequiresIPhoneOS</key>
26 <true/> 26 <true/>
  27 + <key>NSAppTransportSecurity</key>
  28 + <dict>
  29 + <key>NSAllowsArbitraryLoads</key>
  30 + <true/>
  31 + </dict>
  32 + <key>NSCameraUsageDescription</key>
  33 + <string>需要允许开启相机才能使用拍照功能</string>
  34 + <key>NSMicrophoneUsageDescription</key>
  35 + <string>需要允许开启麦克风才能使用录制视频和语音等服务</string>
  36 + <key>NSPhotoLibraryUsageDescription</key>
  37 + <string>需要允许打开相册才能访问相册照片和保存照片</string>
27 <key>UILaunchStoryboardName</key> 38 <key>UILaunchStoryboardName</key>
28 <string>LaunchScreen</string> 39 <string>LaunchScreen</string>
29 <key>UIMainStoryboardFile</key> 40 <key>UIMainStoryboardFile</key>
Example/CNLiveMyOrder/Controller/CNLiveViewController.m
@@ -12,6 +12,8 @@ @@ -12,6 +12,8 @@
12 #import "CNLiveSelectModuleView.h" 12 #import "CNLiveSelectModuleView.h"
13 #import "CNLiveBaseKit.h" 13 #import "CNLiveBaseKit.h"
14 #import "CNLiveMineOrderController.h" 14 #import "CNLiveMineOrderController.h"
  15 +#import "CNLiveRefundController.h"
  16 +#import <FBRetainCycleDetector/FBRetainCycleDetector.h>
15 //#import "TIMAdapter.h" 17 //#import "TIMAdapter.h"
16 //#import "CommonLibrary.h" 18 //#import "CommonLibrary.h"
17 @interface CNLiveViewController () 19 @interface CNLiveViewController ()
@@ -98,6 +100,8 @@ @@ -98,6 +100,8 @@
98 { 100 {
99 // CNRefundController *vc = [[CNRefundController alloc] init]; 101 // CNRefundController *vc = [[CNRefundController alloc] init];
100 // [[AppDelegate sharedAppDelegate] pushViewController:vc withBackTitle:@" "]; 102 // [[AppDelegate sharedAppDelegate] pushViewController:vc withBackTitle:@" "];
  103 + CNLiveRefundController *vc = [[CNLiveRefundController alloc]init];
  104 + [weakSelf.navigationController pushViewController:vc animated:YES];
101 } 105 }
102 break; 106 break;
103 default: 107 default:
Example/Podfile
@@ -25,6 +25,7 @@ target &#39;CNLiveMyOrder_Example&#39; do @@ -25,6 +25,7 @@ target &#39;CNLiveMyOrder_Example&#39; do
25 # pod 'CNLiveRequestBastKit' 25 # pod 'CNLiveRequestBastKit'
26 # pod 'CNLiveTripartiteManagement/MJRefresh' 26 # pod 'CNLiveTripartiteManagement/MJRefresh'
27 #pod 'CNLiveCustomUI/CNLiveBasicsUI' 27 #pod 'CNLiveCustomUI/CNLiveBasicsUI'
  28 + # pod 'YYCache'
28 target 'CNLiveMyOrder_Tests' do 29 target 'CNLiveMyOrder_Tests' do
29 inherit! :search_paths 30 inherit! :search_paths
30 #依赖三方私有库,如果里面有.a的时候加上这个 31 #依赖三方私有库,如果里面有.a的时候加上这个
@@ -32,6 +33,7 @@ target &#39;CNLiveMyOrder_Example&#39; do @@ -32,6 +33,7 @@ target &#39;CNLiveMyOrder_Example&#39; do
32 end 33 end
33 pod 'MLeaksFinder' 34 pod 'MLeaksFinder'
34 pod 'FBRetainCycleDetector', '~> 0.1.4' 35 pod 'FBRetainCycleDetector', '~> 0.1.4'
  36 + # pod 'YYCache'
35 # post_install do |installer| 37 # post_install do |installer|
36 # installer.pods_project.build_configuration_list.build_configurations.each do |configuration| 38 # installer.pods_project.build_configuration_list.build_configurations.each do |configuration|
37 # configuration.build_settings['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'YES' 39 # configuration.build_settings['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'YES'