OtherSellOrderDetailVC.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. //
  2. // OtherSellOrderDetailVC.m
  3. // yunbaolive
  4. //
  5. // Created by ybRRR on 2020/2/19.
  6. // Copyright © 2020 cat. All rights reserved.
  7. //
  8. #import "OtherSellOrderDetailVC.h"
  9. #import "OrderHeaderView.h"
  10. #import "SellOrderDetailModel.h"
  11. #import "OrderPublicView.h"
  12. #import "OrderInfoView.h"
  13. #import "OrderPriceView.h"
  14. @interface OtherSellOrderDetailVC (){
  15. OrderHeaderView *headView;
  16. OrderInfoView *infosView;
  17. OrderPriceView *price;
  18. OrderPublicView *messagePublicView;//买家留言
  19. }
  20. @property(nonatomic, strong)UIScrollView *backScroll;
  21. @property (nonatomic, strong)SellOrderDetailModel *model;
  22. @end
  23. @implementation OtherSellOrderDetailVC
  24. -(void)doReturn{
  25. [[YBBaseAppDelegate sharedAppDelegate]popViewController:YES];
  26. }
  27. -(void)getGoodsOrderInfo{
  28. NSString *url = [purl stringByAppendingFormat:@"?service="];
  29. NSDictionary *signdic = @{@"uid":[Config getOwnID],@"token":[Config getOwnToken], @"time":[NSNumber numberWithLong: (long)[[NSDate date] timeIntervalSince1970]]};
  30. NSString *sign = [PublicObj sortString:signdic];
  31. NSDictionary *dic = @{
  32. @"uid":[Config getOwnID],
  33. @"token":[Config getOwnToken],
  34. @"orderid":self.orderModel.idStr,
  35. @"time":[NSNumber numberWithLong: (long)[[NSDate date] timeIntervalSince1970]],
  36. @"sign":sign
  37. };
  38. [YBNetworking postWithUrl:@"Seller.getGoodsOrderInfo" Dic:dic Suc:^(int code, id info, NSString *msg) {
  39. if (code ==0) {
  40. NSDictionary *infos = [info firstObject];
  41. self.model = [SellOrderDetailModel modelWithDic:infos];
  42. [self creatUI];
  43. }else{
  44. [MBProgressHUD showError:msg];
  45. }
  46. } Fail:^(id fail) {
  47. }];
  48. }
  49. - (void)viewDidLoad {
  50. [super viewDidLoad];
  51. self.navigationController.navigationBarHidden = YES;
  52. self.view.backgroundColor = RGB(245, 245, 245);
  53. _backScroll = [[UIScrollView alloc]init];
  54. _backScroll.backgroundColor = UIColor.whiteColor;
  55. [self.view addSubview:_backScroll];
  56. [_backScroll mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.top.left.right.bottom.equalTo(self.view);
  58. }];
  59. _backScroll.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  60. UIButton *returnBtn = [UIButton buttonWithType:0];
  61. returnBtn.frame = CGRectMake(0, 24+statusbarHeight, 40, 40);
  62. [returnBtn setImage:[UIImage imageNamed:@"pub_back"] forState:0];
  63. [returnBtn addTarget:self action:@selector(doReturn) forControlEvents:UIControlEventTouchUpInside];
  64. [self.view addSubview:returnBtn];
  65. [self getGoodsOrderInfo];
  66. }
  67. -(void)creatUI{
  68. [self creatHeadView];
  69. // -1 已关闭 0 待买家付款 1 待发货 2 待确认收货 3 待评价 4 已评价 5 退款
  70. if ([self.model.status isEqual:@"0"] ||[self.model.status isEqual:@"-1"]) {
  71. OrderPublicView *addressView = [[OrderPublicView alloc]init];
  72. addressView.frame = CGRectMake(0, headView.bottom, _window_width, 75);
  73. [addressView setSellOrderModelData:self.model AndIndex:1];
  74. [_backScroll addSubview:addressView];
  75. addressView.lineLb.hidden = NO;
  76. infosView = [[OrderInfoView alloc]init];
  77. infosView.sellerModel = self.model;
  78. [_backScroll addSubview:infosView];
  79. if (self.model.message.length > 0) {
  80. [infosView mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.top.equalTo(addressView.mas_bottom);
  82. make.left.right.equalTo(self.view);
  83. make.height.mas_equalTo(120);
  84. }];
  85. }else{
  86. [infosView mas_makeConstraints:^(MASConstraintMaker *make) {
  87. make.top.equalTo(addressView.mas_bottom);
  88. make.left.right.equalTo(self.view);
  89. make.height.mas_equalTo(120);
  90. }];
  91. }
  92. price = [[OrderPriceView alloc]init];
  93. [_backScroll addSubview:price];
  94. [price mas_makeConstraints:^(MASConstraintMaker *make) {
  95. make.top.equalTo(infosView.mas_bottom);
  96. make.left.right.equalTo(self.view);
  97. make.height.mas_equalTo(108);
  98. }];
  99. [price.kefuBtn setTitle:YZMsg(@"联系买家") forState:0];
  100. // [price setSellerModelData:self.model];
  101. price.models = self.model;
  102. }else{
  103. OrderPublicView* publicView = [[OrderPublicView alloc]init];
  104. [_backScroll addSubview:publicView];
  105. [publicView mas_makeConstraints:^(MASConstraintMaker *make) {
  106. make.left.right.equalTo(self.view);
  107. make.top.equalTo(headView.mas_bottom);
  108. make.height.mas_equalTo(60);
  109. }];
  110. [publicView setSellOrderModelData:self.model AndIndex:1];
  111. OrderPublicView* publicView1 = [[OrderPublicView alloc]init];
  112. [_backScroll addSubview:publicView1];
  113. [publicView1 mas_makeConstraints:^(MASConstraintMaker *make) {
  114. make.left.right.equalTo(self.view);
  115. make.top.equalTo(publicView.mas_bottom);
  116. make.height.mas_equalTo(75);
  117. }];
  118. [publicView1 setSellOrderModelData:self.model AndIndex:2];
  119. //如果有买家留言
  120. if (self.model.message.length > 0) {
  121. messagePublicView = [[OrderPublicView alloc]init];
  122. [_backScroll addSubview:messagePublicView];
  123. [messagePublicView mas_makeConstraints:^(MASConstraintMaker *make) {
  124. make.left.right.equalTo(self.view);
  125. make.top.equalTo(publicView1.mas_bottom);
  126. make.height.mas_equalTo(60);
  127. }];
  128. [messagePublicView setSellOrderModelData:self.model AndIndex:3];
  129. messagePublicView.lineLb.hidden = NO;
  130. }else{
  131. publicView1.lineLb.hidden = NO;
  132. }
  133. infosView = [[OrderInfoView alloc]init];
  134. infosView.sellerModel = self.model;
  135. [_backScroll addSubview:infosView];
  136. if (self.model.message.length > 0) {
  137. [infosView mas_makeConstraints:^(MASConstraintMaker *make) {
  138. make.top.equalTo(messagePublicView.mas_bottom);
  139. make.left.right.equalTo(self.view);
  140. make.height.mas_equalTo(120);
  141. }];
  142. }else{
  143. [infosView mas_makeConstraints:^(MASConstraintMaker *make) {
  144. make.top.equalTo(publicView1.mas_bottom);
  145. make.left.right.equalTo(self.view);
  146. make.height.mas_equalTo(120);
  147. }];
  148. }
  149. price = [[OrderPriceView alloc]init];
  150. [_backScroll addSubview:price];
  151. [price mas_makeConstraints:^(MASConstraintMaker *make) {
  152. make.top.equalTo(infosView.mas_bottom);
  153. make.left.right.equalTo(self.view);
  154. make.height.mas_equalTo(108);
  155. }];
  156. [price.kefuBtn setTitle:YZMsg(@"联系买家") forState:0];
  157. // [price setSellerModelData:self.model];
  158. price.models = self.model;
  159. }
  160. [_backScroll layoutSubviews];
  161. NSArray *orderArr;
  162. if ([self.model.status isEqual:@"0"]||[self.model.status isEqual:@"-1"]) {
  163. orderArr = @[YZMsg(@"订单编号"),YZMsg(@"下单时间")];
  164. }else{
  165. orderArr = @[YZMsg(@"订单编号"),YZMsg(@"下单时间"),YZMsg(@"支付方式"),YZMsg(@"支付时间")];
  166. }
  167. UIView *backView = [[UIView alloc]init];
  168. backView.backgroundColor = UIColor.whiteColor;
  169. backView.frame = CGRectMake(0, price.bottom, _window_width, 40*orderArr.count);
  170. [_backScroll addSubview:backView];
  171. for (int i = 0; i < orderArr.count; i ++) {
  172. UILabel *lb = [[UILabel alloc]init];
  173. lb.frame = CGRectMake(12, 40*i, _window_width*0.8, 40);
  174. lb.font = [UIFont systemFontOfSize:14];
  175. lb.textColor = [UIColor grayColor];
  176. lb.text = orderArr[i];
  177. [backView addSubview:lb];
  178. if (i == 0) {
  179. lb.text = [NSString stringWithFormat:@"%@: %@",orderArr[i],self.model.orderno];
  180. UIButton *copyBtn = [UIButton buttonWithType:0];
  181. copyBtn.frame = CGRectMake(lb.right+10, 0, 50, 40);
  182. [copyBtn setTitle:YZMsg(@"复制") forState:0];
  183. [copyBtn setTitleColor:RGB(68, 121, 255) forState:0];
  184. copyBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  185. [copyBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
  186. [backView addSubview:copyBtn];
  187. }else if (i == 1){
  188. lb.text = [NSString stringWithFormat:@"%@: %@",orderArr[i],self.model.addtime];
  189. }else if (i == 2){
  190. NSString *pay;
  191. if ([self.model.paytype isEqual:@"1"]) {
  192. pay =YZMsg(@"支付宝");
  193. }else if ([self.model.paytype isEqual:@"2"]){
  194. pay =YZMsg(@"微信");
  195. }else{
  196. pay =YZMsg(@"余额");
  197. }
  198. lb.text = [NSString stringWithFormat:@"%@: %@",orderArr[i],pay];
  199. }else{
  200. lb.text = [NSString stringWithFormat:@"%@: %@",orderArr[i],self.model.paytime];
  201. }
  202. }
  203. _backScroll.contentSize = CGSizeMake(_window_width, CGRectGetMaxY(backView.frame)+60);
  204. if ([self.model.status isEqual:@"-1"]) {
  205. [self creatBottomBtn];
  206. }
  207. }
  208. -(void)creatHeadView{
  209. headView = [[OrderHeaderView alloc]init];
  210. headView.frame = CGRectMake(0, 0, _window_width, 135);
  211. [_backScroll addSubview:headView];
  212. [headView mas_makeConstraints:^(MASConstraintMaker *make) {
  213. make.top.equalTo(_backScroll);
  214. make.left.right.equalTo(self.view);
  215. make.height.mas_equalTo(135);
  216. }];
  217. [headView setSellerData:self.model];
  218. }
  219. -(void)creatBottomBtn{
  220. UIView *bottomView = [[UIView alloc]init];
  221. bottomView.frame= CGRectMake(0, _window_height-50, _window_width, 50);
  222. bottomView.backgroundColor = [UIColor whiteColor];
  223. [self.view addSubview:bottomView];
  224. UIButton *payBtn = [UIButton buttonWithType:0];
  225. payBtn.frame = CGRectMake(_window_width-98, 12, 83, 26);
  226. [payBtn setTitle:YZMsg(@"删除订单") forState:0];
  227. [payBtn setTitleColor:[UIColor blackColor] forState:0];
  228. payBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  229. payBtn.layer.borderColor = [UIColor lightGrayColor].CGColor;
  230. payBtn.layer.cornerRadius = 2;
  231. payBtn.layer.borderWidth = 1;
  232. payBtn.layer.masksToBounds = YES;
  233. [payBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
  234. [bottomView addSubview:payBtn];
  235. }
  236. -(void)btnClick:(UIButton *)sender{
  237. NSString *titles =sender.titleLabel.text;
  238. if ([titles isEqual:YZMsg(@"复制")]){
  239. [self copyOrderNum];
  240. }else if ([titles isEqual:YZMsg(@"删除订单")]){
  241. [self delGoodsOrder];
  242. }
  243. }
  244. #pragma mark-----复制订单号-------
  245. -(void)copyOrderNum{
  246. UIPasteboard *paste = [UIPasteboard generalPasteboard];
  247. paste.string = self.model.orderno;
  248. [MBProgressHUD showError:YZMsg(@"复制成功")];
  249. }
  250. #pragma mark------删除订单----------
  251. -(void)delGoodsOrder{
  252. NSDictionary *signdic = @{@"uid":[Config getOwnID],@"token":[Config getOwnToken], @"time":[NSNumber numberWithLong: (long)[[NSDate date] timeIntervalSince1970]]};
  253. NSString *sign = [PublicObj sortString:signdic];
  254. NSDictionary *dic = @{
  255. @"uid":[Config getOwnID],
  256. @"token":[Config getOwnToken],
  257. @"orderid":self.model.orderid,
  258. @"time":[NSNumber numberWithLong: (long)[[NSDate date] timeIntervalSince1970]],
  259. @"sign":sign
  260. };
  261. [YBNetworking postWithUrl:@"Seller.delGoodsOrder" Dic:dic Suc:^(int code, id info, NSString *msg) {
  262. if (code ==0) {
  263. [MBProgressHUD showError:msg];
  264. [[YBBaseAppDelegate sharedAppDelegate]popViewController:YES];
  265. }else{
  266. [MBProgressHUD showError:msg];
  267. }
  268. } Fail:^(id fail) {
  269. }];
  270. }
  271. @end