WaitSendGoodsVC.m 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. //
  2. // WaitSendGoodsVC.m
  3. // yunbaolive
  4. //
  5. // Created by ybRRR on 2020/2/19.
  6. // Copyright © 2020 cat. All rights reserved.
  7. //
  8. #import "WaitSendGoodsVC.h"
  9. #import "SendGoodsInfo.h"
  10. #import "OrderPublicView.h"
  11. #import "SellOrderPublicView.h"
  12. #import "SellOrderDetailModel.h"
  13. #import "LogisticsCell.h"
  14. @interface WaitSendGoodsVC ()<UITableViewDelegate, UITableViewDataSource,SendGoodsInfoDelegate,UIGestureRecognizerDelegate>
  15. {
  16. SendGoodsInfo *logisticsView;
  17. }
  18. @property (nonatomic, strong)SellOrderDetailModel *model;
  19. @property (nonatomic, strong)UITableView *logisticsTable;
  20. @property (nonatomic, strong)NSArray *dataArr;
  21. @property (nonatomic, assign)BOOL isShowLogistics;
  22. @end
  23. @implementation WaitSendGoodsVC
  24. #pragma mark-----卖家获取商品订单详情-------
  25. -(void)getGoodsOrderInfo{
  26. NSString *url = [purl stringByAppendingFormat:@"?service=Seller.getGoodsOrderInfo"];
  27. NSDictionary *signdic = @{@"uid":[Config getOwnID],@"token":[Config getOwnToken], @"time":[NSNumber numberWithLong: (long)[[NSDate date] timeIntervalSince1970]]};
  28. NSString *sign = [PublicObj sortString:signdic];
  29. NSDictionary *dic = @{
  30. @"uid":[Config getOwnID],
  31. @"token":[Config getOwnToken],
  32. @"orderid":self.orderModel.idStr,
  33. @"time":[NSNumber numberWithLong: (long)[[NSDate date] timeIntervalSince1970]],
  34. @"sign":sign
  35. };
  36. [YBNetworking postWithUrl:@"Seller.getGoodsOrderInfo" Dic:dic Suc:^(int code, id info, NSString *msg) {
  37. if (code ==0) {
  38. NSDictionary *infos = [info firstObject];
  39. self.model = [SellOrderDetailModel modelWithDic:infos];
  40. [self createUI];
  41. }else{
  42. [MBProgressHUD showError:msg];
  43. }
  44. } Fail:^(id fail) {
  45. }];
  46. }
  47. #pragma mark-----获取物流公司列表-------
  48. -(void)getExpressList{
  49. NSString *url = [purl stringByAppendingFormat:@"?service=Seller.getExpressList"];
  50. NSDictionary *dic = @{
  51. @"uid":[Config getOwnID],
  52. @"token":[Config getOwnToken]
  53. };
  54. [YBNetworking postWithUrl:@"Seller.getExpressList" Dic:dic Suc:^(int code, id info, NSString *msg) {
  55. if (code ==0) {
  56. NSArray *infos = info;
  57. self.dataArr = infos;
  58. self.logisticsTable.hidden = NO;
  59. [self.logisticsTable reloadData];
  60. logisticsView.accessBtn.selected = YES;
  61. }else{
  62. [MBProgressHUD showError:msg];
  63. }
  64. } Fail:^(id fail) {
  65. }];
  66. }
  67. - (UIStatusBarStyle)preferredStatusBarStyle {
  68. if (@available(iOS 13.0,*)) {
  69. return UIStatusBarStyleDarkContent;
  70. }
  71. return UIStatusBarStyleDefault;
  72. }
  73. - (void)viewDidLoad {
  74. [super viewDidLoad];
  75. self.titleL.text = YZMsg(@"订单详情");
  76. self.subNavi.backgroundColor = UIColor.whiteColor;
  77. self.titleL.textColor = UIColor.blackColor;
  78. [self.leftBtn setImage:[UIImage imageNamed:@"pub_back_black"] forState:0];
  79. self.naviLine.hidden = NO;
  80. self.naviLine.backgroundColor = RGB(245, 245, 245);
  81. self.dataArr = [NSArray array];
  82. [self getGoodsOrderInfo];
  83. }
  84. -(void)createUI{
  85. backScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 64+statusbarHeight, _window_width, _window_height-64-statusbarHeight)];
  86. backScroll.backgroundColor = UIColor.whiteColor;
  87. [self.view addSubview:backScroll];
  88. UITapGestureRecognizer *taps = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hideKeyBoard)];
  89. taps.delegate = self;
  90. [backScroll addGestureRecognizer:taps];
  91. UIView *headBack = [[UIView alloc]init];
  92. headBack.frame = CGRectMake(0, 0, _window_width, 90);
  93. // headBack.backgroundColor = Normal_Color;
  94. CAGradientLayer *gl = [CAGradientLayer layer];
  95. gl.frame = CGRectMake(0, 0, _window_width, 90);
  96. gl.colors = @[
  97. (__bridge id)[UIColor colorWithRed:252/255.0 green:88/255.0 blue:192/255.0 alpha:1.00].CGColor,
  98. (__bridge id)[UIColor colorWithRed:252/255.0 green:64/255.0 blue:140/255.0 alpha:1.00].CGColor,
  99. ];
  100. gl.locations = @[@(0),@(1)];
  101. [headBack.layer addSublayer:gl];
  102. headBack.backgroundColor = [UIColor colorWithRed:234/255.0 green:55/255.0 blue:127/255.0 alpha:1.00];
  103. [backScroll addSubview:headBack];
  104. UILabel *titleLb = [[UILabel alloc]init];
  105. titleLb.frame = CGRectMake(12, 12, _window_width-24, 20);
  106. titleLb.font = [UIFont systemFontOfSize:15];
  107. titleLb.text = self.model.status_name;
  108. titleLb.textColor = [UIColor whiteColor];
  109. [headBack addSubview:titleLb];
  110. UILabel *infoLb = [[UILabel alloc]init];
  111. infoLb.font = [UIFont systemFontOfSize:13];
  112. infoLb.textColor = [UIColor whiteColor];
  113. infoLb.frame = CGRectMake(12, titleLb.bottom, _window_width-24, 40);
  114. infoLb.numberOfLines = 0;
  115. infoLb.lineBreakMode =NSLineBreakByWordWrapping;
  116. infoLb.text = self.model.status_desc;;
  117. [headBack addSubview:infoLb];
  118. YBWeakSelf;
  119. logisticsView = [[SendGoodsInfo alloc]initWithFrame:CGRectMake(0, headBack.bottom, _window_width, 220)];
  120. NSDictionary *dic = @{@"num":self.model.orderno};
  121. logisticsView.delegate = self;
  122. [logisticsView setData:dic];
  123. logisticsView.selEvent = ^{
  124. weakSelf.isShowLogistics = !weakSelf.isShowLogistics;
  125. if (weakSelf.isShowLogistics) {
  126. [weakSelf getExpressList];
  127. }else{
  128. weakSelf.logisticsTable.hidden= YES;
  129. logisticsView.accessBtn.selected = NO;
  130. }
  131. };
  132. [backScroll addSubview:logisticsView];
  133. OrderPublicView *addressView = [[OrderPublicView alloc]init];
  134. addressView.frame = CGRectMake(0, logisticsView.bottom, _window_width, 60);
  135. [addressView setSellOrderModelData:self.model AndIndex:1];
  136. [backScroll addSubview:addressView];
  137. UIButton *copyBtn = [UIButton buttonWithType:0];
  138. copyBtn.frame =CGRectMake(_window_width-100, addressView.bottom, 83, 26);
  139. copyBtn.layer.cornerRadius = 5;
  140. copyBtn.layer.borderColor = [UIColor grayColor].CGColor;
  141. copyBtn.layer.borderWidth = 1;
  142. copyBtn.layer.masksToBounds = YES;
  143. [copyBtn setTitle:YZMsg(@"复制地址") forState:0];
  144. copyBtn.titleLabel.font = [UIFont systemFontOfSize:10];
  145. [copyBtn setTitleColor:[UIColor grayColor] forState:0];
  146. [copyBtn addTarget:self action:@selector(copyAddress) forControlEvents:UIControlEventTouchUpInside];
  147. [backScroll addSubview:copyBtn];
  148. OrderPublicView *msgView = [[OrderPublicView alloc]init];
  149. msgView.frame = CGRectMake(0, copyBtn.bottom, _window_width, 60);
  150. [msgView setSellOrderModelData:self.model AndIndex:2];
  151. msgView.lineLb.hidden = NO;
  152. [backScroll addSubview:msgView];
  153. CGFloat textHeight = [PublicObj heightOfString:self.model.message andFont:[UIFont systemFontOfSize:12] andWidth:_window_width-50];
  154. msgView.size = CGSizeMake(_window_width, 50+textHeight);
  155. SellOrderPublicView *infos = [[SellOrderPublicView alloc]init];
  156. infos.frame = CGRectMake(0, msgView.bottom, _window_width, 200);
  157. [infos setOrderModel:self.model];
  158. [backScroll addSubview:infos];
  159. backScroll.contentSize = CGSizeMake(_window_width, headBack.height+logisticsView.height+addressView.height+copyBtn.height+msgView.height+infos.height+20);
  160. [backScroll addSubview:self.logisticsTable];
  161. }
  162. -(UITableView *)logisticsTable{
  163. if (!_logisticsTable) {
  164. _logisticsTable = [[UITableView alloc]initWithFrame:CGRectMake(15, logisticsView.bottom-60, _window_width-30, 150) style:UITableViewStylePlain];
  165. _logisticsTable.delegate = self;
  166. _logisticsTable.dataSource = self;
  167. _logisticsTable.separatorStyle = UITableViewCellSeparatorStyleNone;
  168. _logisticsTable.hidden = YES;
  169. }
  170. return _logisticsTable;
  171. }
  172. - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
  173. [self.view endEditing:YES];
  174. }
  175. -(void)copyAddress{
  176. UIPasteboard *paste = [UIPasteboard generalPasteboard];
  177. paste.string = self.model.address_format;
  178. [MBProgressHUD showError:YZMsg(@"复制成功")];
  179. }
  180. #pragma mark---------------
  181. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  182. {
  183. return 1;
  184. }
  185. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  186. {
  187. return self.dataArr.count;
  188. }
  189. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  190. {
  191. return 60;
  192. }
  193. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  194. {
  195. NSDictionary *dic = self.dataArr[indexPath.row];
  196. LogisticsCell *cell = [LogisticsCell cellWithTab:tableView andIndexPath:indexPath];
  197. cell.dataDic = dic;
  198. return cell;
  199. }
  200. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  201. {
  202. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  203. NSDictionary *dic = self.dataArr[indexPath.row];
  204. [logisticsView setExpress:dic];
  205. self.logisticsTable.hidden = YES;
  206. }
  207. #pragma mark------确认发货------------
  208. -(void)sendGoodsExpressid:(NSString *)expressid Number:(NSString *)number
  209. {
  210. if (number.length < 1) {
  211. [MBProgressHUD showError:YZMsg(@"请填写物流单号")];
  212. return;
  213. }
  214. if (expressid.length < 1) {
  215. [MBProgressHUD showError:YZMsg(@"请选择物流公司")];
  216. return;
  217. }
  218. NSString *url = [purl stringByAppendingFormat:@"?service=Seller.setExpressInfo"];
  219. NSDictionary *signdic = @{@"uid":[Config getOwnID],@"token":[Config getOwnToken],@"orderid":self.orderModel.idStr,@"expressid":expressid, @"time":[NSNumber numberWithLong: (long)[[NSDate date] timeIntervalSince1970]]};
  220. NSString *sign = [PublicObj sortString:signdic];
  221. NSDictionary *dic = @{
  222. @"uid":[Config getOwnID],
  223. @"token":[Config getOwnToken],
  224. @"orderid":self.orderModel.idStr,
  225. @"expressid":expressid,
  226. @"express_number":number,
  227. @"time":[NSNumber numberWithLong: (long)[[NSDate date] timeIntervalSince1970]],
  228. @"sign":sign
  229. };
  230. [YBNetworking postWithUrl:@"Seller.setExpressInfo" Dic:dic Suc:^(int code, id info, NSString *msg) {
  231. if (code ==0) {
  232. [MBProgressHUD showError:msg];
  233. [[YBBaseAppDelegate sharedAppDelegate]popViewController:YES];
  234. }else{
  235. [MBProgressHUD showError:msg];
  236. }
  237. } Fail:^(id fail) {
  238. }];
  239. }
  240. - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
  241. NSLog(@"s0000000000:%@",NSStringFromClass([touch.view class]));
  242. if ([NSStringFromClass([touch.view class]) isEqual:@"UITableViewCellContentView"]) {
  243. return NO;
  244. }
  245. return YES;
  246. }
  247. -(void)hideKeyBoard{
  248. [self.view endEditing:YES];
  249. }
  250. @end