hjx 1 рік тому
батько
коміт
94f4805889

+ 18 - 4
TOKTOK/TOKTOK/Home/BlindBox/Pay/XSTTBlindBoxPayViewController.m

@@ -18,6 +18,8 @@
 #import "XSTTEnumerationProfile.h"
 #import "XSTTBusinessManager.h"
 #import "XSTTPayManager.h"
+#import "XSTTRouteManager.h"
+#import "XSTTOrderListViewController.h"
 
 #define xstt_blindBoxPayChooseButtonTag 3000
 #define xstt_blindBoxPayChooseIconTag 4000
@@ -174,9 +176,11 @@
 - (void)createAlipayOrderSuccess:(id)data {
     @weakify(self)
     [_payManager alipayWithSign:data view:self.view seccessfulCompletion:^{
-        
+        @strongify(self)
+        [self paySuccess];
     } failureCompletion:^{
-        
+        @strongify(self)
+        [self payFailure];
     }];
 }
 
@@ -196,12 +200,22 @@
 - (void)createWechatPayOrderSuccess:(id)data orderId:(NSString *)orderId {
     @weakify(self)
     [_payManager wechatPayWithDict:data orderNo:orderId seccessfulCompletion:^{
-        
+        @strongify(self)
+        [self paySuccess];
     } failureCompletion:^{
-        
+        @strongify(self)
+        [self payFailure];
     }];
 }
 
+- (void)paySuccess {
+    [XSTTRouteManager navigationBackAndRouteTo:[[XSTTRouter alloc] initWithClass:[XSTTOrderListViewController class] property:@{} tabBarType:XSTTTabBarTypeMine]];
+}
+
+- (void)payFailure {
+    [self.view showToastWithTitle:@"支付失败"];
+}
+
 #pragma mark - UIScrollViewDelegate
 - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
     CGFloat contentOffset = scrollView.contentOffset.y;

+ 1 - 0
TOKTOK/TOKTOK/Mine/Address/EditAddress/XSTTEditAddressViewController.m

@@ -272,6 +272,7 @@
         return dic;
     } success:^NSString * _Nullable(NSError * _Nonnull error, id  _Nullable data) {
         self->_xstt_finishEdit();
+        [self.navigationController popViewControllerAnimated:true];
         return @"上传成功";
     } failure:^NSString * _Nullable(NSError * _Nonnull error, id  _Nullable data) {
         return @"上传失败";

+ 2 - 0
TOKTOK/TOKTOK/Mine/Order/OrderDetails/XSTTOrderDetailsTableViewCell.h

@@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface XSTTOrderDetailsTableViewCell : UITableViewCell
 
+@property (nonatomic, strong) void (^xstt_buttonAction)(XSTTOrderDetailsTableViewCell *cell);
+
 - (void)reloadData:(XSTTOrderDetailsNodeModel *)data isFirst:(bool)isFirst isLast:(bool)isLast;
 
 @end

+ 3 - 1
TOKTOK/TOKTOK/Mine/Order/OrderDetails/XSTTOrderDetailsTableViewCell.m

@@ -99,7 +99,9 @@
 }
 
 - (void)buttonAction {
-    
+    if (_xstt_buttonAction) {
+        _xstt_buttonAction(self);
+    }
 }
 
 - (void)reloadData:(XSTTOrderDetailsNodeModel *)data isFirst:(bool)isFirst isLast:(bool)isLast {

+ 3 - 1
TOKTOK/TOKTOK/Mine/Order/OrderDetails/XSTTOrderDetailsTableViewController.h

@@ -6,12 +6,14 @@
 //
 
 #import "XSTTTableViewController.h"
-@class XSTTOrderDetailsNodeModel;
+@class XSTTOrderDetailsNodeModel, XSTTAddressModel;
 
 NS_ASSUME_NONNULL_BEGIN
 
 @interface XSTTOrderDetailsTableViewController : XSTTTableViewController
 
+@property (nonatomic, strong) void (^xstt_chooseNewAddress)(XSTTAddressModel *data);
+
 - (void)reloadData:(NSArray<XSTTOrderDetailsNodeModel *> *)data;
 
 @end

+ 73 - 0
TOKTOK/TOKTOK/Mine/Order/OrderDetails/XSTTOrderDetailsTableViewController.m

@@ -9,6 +9,10 @@
 #import "XSTTUIGeneralHeader.h"
 #import "XSTTOrderDetailsTableViewCell.h"
 #import "XSTTOrderDetailsModel.h"
+#import "XSTTAddressListViewController.h"
+#import <WXApi.h>
+#import "XSTTConfirmAlertViewController.h"
+#import "UIResponder+XSTTDelegate.h"
 
 @interface XSTTOrderDetailsTableViewController () {
     NSArray<XSTTOrderDetailsNodeModel *> *_data;
@@ -31,12 +35,76 @@
 }
 
 #pragma mark - Action
+- (void)changeAddress {
+    XSTTAddressListViewController *vc = XSTTAddressListViewController.new;
+    vc.xstt_type = XSTTAddressListViewTypeChoose;
+    @weakify(self)
+    vc.xstt_choseAddress = ^(XSTTAddressModel * _Nonnull data) {
+        @strongify(self)
+        if (self->_xstt_chooseNewAddress) self->_xstt_chooseNewAddress(data);
+    };
+    [self.navigationController pushViewController:vc animated:true];
+}
+
+- (void)copyExpressNumber:(NSString *)number {
+    UIPasteboard *pboard = [UIPasteboard generalPasteboard];
+    pboard.string = number;
+    if ([WXApi isWXAppInstalled] && [WXApi isWXAppSupportApi] && [number hasPrefix:@"SF"]) {
+        XSTTConfirmAlertViewController *vc = [XSTTConfirmAlertViewController alertWithTitle:@"提示" content:@"已复制快递单号,是否打开顺丰微信小程序"];
+        [vc setCancelButtonTitle:@"暂不打开" titleColor:nil action:^{
+        }];
+        @weakify(self)
+        [vc setConfirmButtonTitle:@"马上打开" titleColor:nil action:^{
+            @strongify(self)
+            [self openWXMiniProgram];
+        }];
+        [self presentViewController:vc animated:false completion:nil];
+    } else {
+        XSTTConfirmAlertViewController *vc = [XSTTConfirmAlertViewController alertWithTitle:@"提示" content:@"已复制快递单号"];
+        [vc setConfirmButtonTitle:nil titleColor:nil action:^{
+        }];
+        [self presentViewController:vc animated:false completion:nil];
+    }
+}
+
+- (void)openWXMiniProgram {
+    WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];
+    launchMiniProgramReq.userName = @"gh_f9d9fca26a50";//拉起的小程序的username
+    launchMiniProgramReq.miniProgramType = WXMiniProgramTypeRelease; //拉起小程序的类型
+    [UIResponder setWechatDelegate:self];
+    [WXApi sendReq:launchMiniProgramReq completion:^(BOOL success) {
+        [UIResponder setWechatDelegate:nil];
+    }];
+}
+
 - (void)reloadData:(NSArray<XSTTOrderDetailsNodeModel *> *)data {
     _data = data;
     [self.tableView reloadData];
 }
 
+- (void)buttonAction:(XSTTOrderDetailsTableViewCell *)cell {
+    NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
+    if (indexPath.row >= _data.count) return;
+    XSTTOrderDetailsNodeModel *model = _data[indexPath.row];
+    XSTTOrderDetailsNodeActionType type = model.xstt_nodeAction.integerValue;
+    switch (type) {
+        case XSTTOrderDetailsNodeActionTypeNone:
+        case XSTTOrderDetailsNodeActionTypeHighlight:
+            break;
+        case XSTTOrderDetailsNodeActionTypeAddress:
+            [self changeAddress];
+            break;
+        case XSTTOrderDetailsNodeActionTypeExpressNumber:
+            [self copyExpressNumber:model.xstt_busiData];
+            break;
+            
+        default:
+            break;
+    }
+}
+
 #pragma mark - Network Action
+
 #pragma mark - Delegate & DataSource
 
 static NSString * const reuseIdentifier = @"XSTTOrderDetailsTableViewCell";
@@ -45,6 +113,11 @@ static NSString * const reuseIdentifier = @"XSTTOrderDetailsTableViewCell";
     XSTTOrderDetailsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
     if (!cell) {
         cell = [[XSTTOrderDetailsTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
+        @weakify(self)
+        cell.xstt_buttonAction = ^(XSTTOrderDetailsTableViewCell * _Nonnull cell) {
+            @strongify(self)
+            [self buttonAction:cell];
+        };
     }
     [cell reloadData:_data[indexPath.row] isFirst:indexPath.row == 0 isLast:indexPath.row == _data.count - 1];
     return cell;

+ 27 - 0
TOKTOK/TOKTOK/Mine/Order/OrderDetails/XSTTOrderDetailsViewController.m

@@ -15,6 +15,7 @@
 #import "XSTTOrderDetailsModel.h"
 #import "UIViewController+XSTTNetworkManager.h"
 #import "UIView+XSTTLoadingTipsView.h"
+#import "XSTTAddressModel.h"
 
 @interface XSTTOrderDetailsViewController () {
     UIView *_headerView;
@@ -60,6 +61,17 @@
 }
 
 #pragma mark - Network Action
+- (void)changeAddress:(XSTTAddressModel *)data {
+    [self networkUseMethod:XSTTNetworkMethodPOST loadingTips:@"更改中" isLogin:true signKey:XSTTNetworkSignKeyApp url:xstt_appUrl(XSTTURLChangeBlindBoxOrderAddress) urlParameters:nil parameters:^NSDictionary * _Nonnull{
+        return @{@"bbosId": self->_bbosId, @"userAddressId": data.xstt_userAddressId, @"applyAll": @"1"};
+    } success:^NSString * _Nullable(NSError * _Nonnull error, id  _Nullable data) {
+        [self getData];
+        return @"更改地址成功";
+    } failure:^NSString * _Nullable(NSError * _Nonnull error, id  _Nullable data) {
+        return @"更改地址失败";
+    }];
+}
+
 - (void)getData {
     [self networkUseMethod:XSTTNetworkMethodGET loadingTips:@"加载中" isLogin:true signKey:XSTTNetworkSignKeyApp url:xstt_appUrl(XSTTURLGetMineBlindBoxDetails) urlParameters:nil parameters:^NSDictionary * _Nonnull{
         return @{@"bbosId": self->_bbosId};
@@ -83,6 +95,16 @@
     [self.navigationController popViewControllerAnimated:true];
 }
 
+//- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
+//    [self networkUseMethod:XSTTNetworkMethodPOST loadingTips:nil isLogin:true signKey:XSTTNetworkSignKeyApp url:xstt_appUrl(@"/box/test/order/courier_no/gen") urlParameters:nil parameters:^NSDictionary * _Nonnull{
+//        return @{@"bbosId": self->_bbosId};
+//    } success:^NSString * _Nullable(NSError * _Nonnull error, id  _Nullable data) {
+//        return nil;
+//    } failure:^NSString * _Nullable(NSError * _Nonnull error, id  _Nullable data) {
+//        return nil;
+//    }];
+//}
+
 #pragma mark - UI
 - (void)setupUI {
     self.xstt_isHiddenNavigationBar = true;
@@ -99,6 +121,11 @@
 
 - (void)createTableVC {
     _tableVC = XSTTOrderDetailsTableViewController.new;
+    @weakify(self)
+    _tableVC.xstt_chooseNewAddress = ^(XSTTAddressModel * _Nonnull data) {
+        @strongify(self)
+        [self changeAddress:data];
+    };
     [self addChildViewController:_tableVC];
     [self.view addSubview:_tableVC.tableView];
     [_tableVC.tableView makeConstraints:^(JXHConstraintMaker *make) {

+ 2 - 2
TOKTOK/TOKTOK/Public/Manager/XSTTPayManager.m

@@ -117,9 +117,9 @@
                     break;
             }
             @weakify(self)
-            [_networkManager networkUseMethod:XSTTNetworkMethodGET isLogin:false signKey:XSTTNetworkSignKeyApp url:xstt_appUrl(XSTTURLQueryOrderStatus) urlParameters:nil parameters:@{@"orderId": self->_orderNo} completion:^(NSError * _Nonnull error, id  _Nullable data) {
+            [_networkManager networkUseMethod:XSTTNetworkMethodGET isLogin:true signKey:XSTTNetworkSignKeyApp url:xstt_appUrl(XSTTURLQueryOrderStatus) urlParameters:nil parameters:@{@"orderId": self->_orderNo} completion:^(NSError * _Nonnull error, id  _Nullable data) {
                 @strongify(self)
-                if (error.code == XSTTNetworkErrorCodeSuccess) {
+                if (error.code == XSTTNetworkErrorCodeSuccess && [data[@"data"][@"status"] integerValue] == 2) {
                     self->_successAction();
                     [self cleanUp];
                 } else {