|
@@ -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;
|