ConfirmOrderVC.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. //
  2. // ConfirmOrderVC.m
  3. // yunbaolive
  4. //
  5. // Created by ybRRR on 2020/3/13.
  6. // Copyright © 2020 cat. All rights reserved.
  7. //
  8. #import "ConfirmOrderVC.h"
  9. #import "AddressVC.h"
  10. #import "PayOrderView.h"
  11. #import "OrderDetailVC.h"
  12. @interface ConfirmOrderVC ()<UITableViewDelegate, UITableViewDataSource,addressSeletedDelegate>
  13. {
  14. UIView *addressView;
  15. NSDictionary *addressDic;
  16. UITextField * countFeild;
  17. UILabel *allprice;
  18. UILabel *payLb;
  19. MyTextView *msgText;
  20. NSArray *addArr;
  21. NSString *orderid;
  22. }
  23. @property (nonatomic, strong)UITableView *orderTable;
  24. @property (nonatomic, strong)PayOrderView *payView;
  25. @end
  26. @implementation ConfirmOrderVC
  27. - (UIStatusBarStyle)preferredStatusBarStyle {
  28. if (@available(iOS 13.0,*)) {
  29. return UIStatusBarStyleDarkContent;
  30. }
  31. return UIStatusBarStyleDefault;
  32. }
  33. -(void)requestAddressData{
  34. NSDictionary *signdic = @{@"uid":[Config getOwnID],@"token":[Config getOwnToken],@"time":[NSNumber numberWithLong: (long)[[NSDate date] timeIntervalSince1970]]};
  35. NSString *sign = [PublicObj sortString:signdic];
  36. NSDictionary *dic = @{
  37. @"uid":[Config getOwnID],
  38. @"token":[Config getOwnToken],
  39. @"time":[NSNumber numberWithLong: (long)[[NSDate date] timeIntervalSince1970]],
  40. @"sign":sign
  41. };
  42. [YBNetworking postWithUrl:@"Buyer.addressList" Dic:dic Suc:^(int code, id info, NSString *msg) {
  43. if (code == 0) {
  44. addArr = info;
  45. if (addArr.count < 1) {
  46. // [PublicView showImgNoData:self.addressTable name:@"shop_无数据" text:@"还没有收货地址"];
  47. }else{
  48. // [PublicView hiddenImgNoData:self.addressTable];
  49. for (int i = 0; i < addArr.count ; i++) {
  50. NSDictionary *dic = addArr[i];
  51. if ([minstr([dic valueForKey:@"is_default"]) isEqual:@"1"]) {
  52. addressDic = dic;
  53. }
  54. }
  55. NSIndexPath *index = [NSIndexPath indexPathForRow:0 inSection:0];
  56. [self.orderTable reloadRowsAtIndexPaths:[NSArray arrayWithObjects:index,nil] withRowAnimation:UITableViewRowAnimationNone];
  57. }
  58. }else{
  59. [MBProgressHUD showError:msg];
  60. }
  61. } Fail:^(id fail) {
  62. }];
  63. }
  64. - (void)viewDidLoad {
  65. [super viewDidLoad];
  66. self.view.backgroundColor = RGB(235, 235, 235);
  67. self.subNavi.backgroundColor = UIColor.whiteColor;
  68. self.titleL.textColor = UIColor.blackColor;
  69. [self.leftBtn setImage:[UIImage imageNamed:@"pub_back_black"] forState:0];
  70. self.naviLine.hidden = NO;
  71. self.naviLine.backgroundColor = RGB(245, 245, 245);
  72. self.titleL.text = YZMsg(@"确认订单");
  73. orderid = @"";
  74. [self.view addSubview:self.orderTable];
  75. [self requestAddressData];
  76. [self createBottom];
  77. CGFloat postage = [minstr([self.orderModel.goods_info valueForKey:@"postage"]) floatValue];
  78. CGFloat price =[minstr([self.orderDic valueForKey:@"price"]) floatValue];
  79. NSLog(@"iiiiiii----:%@",minstr([self.orderDic valueForKey:@"price"]));
  80. // NSLog(@"333333333----:%f",(float)[self.orderDic valueForKey:@"price"];
  81. payLb.text = [NSString stringWithFormat:@"¥%.2f",price *self.countNum+postage];
  82. }
  83. -(void)createBottom{
  84. UIView *bottomView = [[UIView alloc]initWithFrame:CGRectMake(0, _window_height-50-ShowDiff, _window_width, 50+ShowDiff)];
  85. bottomView.backgroundColor = UIColor.whiteColor;
  86. [self.view addSubview:bottomView];
  87. UILabel *titlelb = [[UILabel alloc]init];
  88. titlelb.frame = CGRectMake(15, _window_height-40-ShowDiff, 50+20, 40);
  89. titlelb.font = [UIFont systemFontOfSize:14];
  90. titlelb.text = YZMsg(@"应付:");
  91. titlelb.textColor = [UIColor blackColor];
  92. [self.view addSubview:titlelb];
  93. payLb = [[UILabel alloc]init];
  94. payLb.frame = CGRectMake(titlelb.right, _window_height-40-ShowDiff, 100, 40);
  95. payLb.textColor = Pink_Cor;
  96. payLb.font = [UIFont systemFontOfSize:14];
  97. [self.view addSubview:payLb];
  98. UIButton *subBtn = [UIButton buttonWithType:0];
  99. [subBtn setBackgroundColor:Pink_Cor];
  100. subBtn.frame = CGRectMake(_window_width-165, _window_height-40-ShowDiff, 150, 40);
  101. subBtn.layer.cornerRadius = 20;
  102. [subBtn setTitle:YZMsg(@"提交订单") forState:0];
  103. subBtn.titleLabel.font = [UIFont systemFontOfSize:14];
  104. [subBtn setTitleColor:[UIColor whiteColor] forState:0];
  105. [subBtn addTarget:self action:@selector(subBtnClick) forControlEvents:UIControlEventTouchUpInside];
  106. [self.view addSubview:subBtn];
  107. }
  108. -(UITableView *)orderTable{
  109. if (!_orderTable) {
  110. _orderTable = [[UITableView alloc]initWithFrame:CGRectMake(0, 64+statusbarHeight, _window_width, _window_height-64-statusbarHeight-70) style:UITableViewStylePlain];
  111. _orderTable.delegate = self;
  112. _orderTable.dataSource = self;
  113. _orderTable.separatorStyle = UITableViewCellSeparatorStyleNone;
  114. _orderTable.backgroundColor = RGB(235, 235, 235);
  115. }
  116. return _orderTable;
  117. }
  118. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  119. {
  120. return 1;
  121. }
  122. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  123. {
  124. return 6;
  125. }
  126. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  127. {
  128. if (indexPath.row == 0) {
  129. return 80;
  130. }else if (indexPath.row == 1){
  131. return 160;
  132. }else if (indexPath.row == 5){
  133. return 80;
  134. }else {
  135. return 60;
  136. }
  137. }
  138. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  139. {
  140. if (indexPath.row == 0) {
  141. UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"addresscell"];
  142. if (addArr.count < 1) {
  143. cell.textLabel.text =YZMsg(@"请设置收货人信息");
  144. cell.textLabel.font = [UIFont systemFontOfSize:14];
  145. cell.textLabel.textColor = Normal_TextColor;
  146. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  147. }else{
  148. if (addressDic == nil) {
  149. NSLog(@"jinalile ----------");
  150. cell.textLabel.text =YZMsg(@"请设置收货人信息");
  151. cell.textLabel.font = [UIFont systemFontOfSize:14];
  152. cell.textLabel.textColor = Normal_TextColor;
  153. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  154. }else{
  155. // cell.backgroundColor = RGB(250, 250, 250);
  156. UILabel *nameLb = [[UILabel alloc]init];
  157. nameLb.textColor = [UIColor blackColor];
  158. nameLb.font = [UIFont systemFontOfSize:14];
  159. nameLb.text = minstr([addressDic valueForKey:@"name"]);
  160. [cell addSubview:nameLb];
  161. [nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
  162. make.left.equalTo(cell).offset(15);
  163. make.top.equalTo(cell).offset(15);
  164. }];
  165. UILabel *phoneLb = [[UILabel alloc]init];
  166. phoneLb.textColor = [UIColor blackColor];
  167. phoneLb.font = [UIFont systemFontOfSize:14];
  168. phoneLb.text = minstr([addressDic valueForKey:@"phone"]);
  169. [cell addSubview:phoneLb];
  170. [phoneLb mas_makeConstraints:^(MASConstraintMaker *make) {
  171. make.left.equalTo(nameLb.mas_right).offset(10);
  172. make.centerY.equalTo(nameLb.mas_centerY);
  173. }];
  174. UIImageView *addImg = [[UIImageView alloc]init];
  175. addImg.image = [UIImage imageNamed:@"shop_收货地址"];
  176. [cell addSubview:addImg];
  177. [addImg mas_makeConstraints:^(MASConstraintMaker *make) {
  178. make.left.equalTo(nameLb.mas_left);
  179. make.top.equalTo(nameLb.mas_bottom).offset(10);
  180. make.width.height.mas_equalTo(15);
  181. }];
  182. UILabel *addressLb =[[UILabel alloc]init];
  183. addressLb.textColor = Normal_TextColor;
  184. addressLb.font = [UIFont systemFontOfSize:12];
  185. addressLb.text = [NSString stringWithFormat:@"%@ %@ %@ %@",minstr([addressDic valueForKey:@"province"]),minstr([addressDic valueForKey:@"city"]),minstr([addressDic valueForKey:@"area"]),minstr([addressDic valueForKey:@"address"])];
  186. [cell addSubview:addressLb];
  187. [addressLb mas_makeConstraints:^(MASConstraintMaker *make) {
  188. make.left.equalTo(addImg.mas_right).offset(10);
  189. make.right.equalTo(cell).offset(-50);
  190. make.centerY.equalTo(addImg.mas_centerY);
  191. }];
  192. }
  193. }
  194. UIImageView *lineImg = [[UIImageView alloc]init];
  195. lineImg.image = [UIImage imageNamed:@"order_线"];
  196. [cell addSubview:lineImg];
  197. [lineImg mas_makeConstraints:^(MASConstraintMaker *make) {
  198. make.left.right.equalTo(cell);
  199. make.bottom.equalTo(cell.mas_bottom).offset(-8);
  200. make.height.mas_equalTo(3);
  201. }];
  202. UIImageView *rightImgV = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"profit_right"]];
  203. [cell addSubview:rightImgV];
  204. [rightImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  205. make.right.equalTo(cell.mas_right).offset(-9);
  206. make.centerY.equalTo(cell.mas_centerY);
  207. make.width.height.mas_equalTo(20);
  208. }];
  209. cell.backgroundColor = UIColor.whiteColor;
  210. return cell;
  211. }else if (indexPath.row == 1){
  212. UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"shopCell"];
  213. UIImageView *shopImg = [[UIImageView alloc]init];
  214. shopImg.image = [UIImage imageNamed:@"店铺"];
  215. [cell addSubview:shopImg];
  216. [shopImg mas_makeConstraints:^(MASConstraintMaker *make) {
  217. make.left.top.equalTo(cell).offset(15);
  218. make.width.height.mas_equalTo(16);
  219. }];
  220. UILabel *shopLb = [[UILabel alloc]init];
  221. shopLb.textColor = UIColor.blackColor;
  222. shopLb.font = [UIFont systemFontOfSize:14];
  223. shopLb.text =minstr([self.orderModel.shop_info valueForKey:@"name"]);
  224. [cell addSubview:shopLb];
  225. [shopLb mas_makeConstraints:^(MASConstraintMaker *make) {
  226. make.left.equalTo(shopImg.mas_right).offset(10);
  227. make.centerY.equalTo(shopImg.mas_centerY);
  228. }];
  229. UIImageView *headImage = [[UIImageView alloc]init];
  230. headImage.layer.cornerRadius = 5;
  231. headImage.layer.masksToBounds = YES;
  232. [headImage sd_setImageWithURL:[NSURL URLWithString:minstr([self.orderDic valueForKey:@"thumb"])]] ;
  233. headImage.backgroundColor = RGB(250, 250, 250);
  234. [cell addSubview:headImage];
  235. [headImage mas_makeConstraints:^(MASConstraintMaker *make) {
  236. make.left.equalTo(shopImg);
  237. make.top.equalTo(shopImg.mas_bottom).offset(15);
  238. make.height.width.mas_equalTo(90);
  239. }];
  240. UILabel *nameLb = [[UILabel alloc]init];
  241. nameLb.textColor = [UIColor blackColor];
  242. nameLb.font = [UIFont boldSystemFontOfSize:15];
  243. nameLb.text =minstr([self.orderModel.goods_info valueForKey:@"name"]);
  244. [cell addSubview:nameLb];
  245. [nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
  246. make.left.equalTo(headImage.mas_right).offset(10);
  247. make.top.equalTo(headImage.mas_top).offset(10);
  248. }];
  249. UILabel *standardLb = [[UILabel alloc]init];
  250. standardLb.textColor = Normal_TextColor;
  251. standardLb.font = [UIFont systemFontOfSize:14];
  252. standardLb.text =[NSString stringWithFormat:@"%@ %@",YZMsg(@"规格:"), minstr([self.orderDic valueForKey:@"spec_name"])];
  253. [cell addSubview:standardLb];
  254. [standardLb mas_makeConstraints:^(MASConstraintMaker *make) {
  255. make.left.equalTo(headImage.mas_right).offset(10);
  256. make.top.equalTo(nameLb.mas_bottom).offset(10);
  257. }];
  258. UILabel *priceLb = [[UILabel alloc]init];
  259. priceLb.textColor = Pink_Cor;
  260. priceLb.font = [UIFont systemFontOfSize:15];
  261. priceLb.text =[NSString stringWithFormat:@"%@%@",YZMsg(@"¥"),minstr([self.orderDic valueForKey:@"price"])];
  262. [cell addSubview:priceLb];
  263. [priceLb mas_makeConstraints:^(MASConstraintMaker *make) {
  264. make.left.equalTo(headImage.mas_right).offset(10);
  265. make.bottom.equalTo(headImage.mas_bottom);
  266. }];
  267. [PublicObj lineViewWithFrame:CGRectMake(15, 160-1, _window_width-30, 1) andColor:Line_Cor andView:cell.contentView];
  268. cell.backgroundColor = UIColor.whiteColor;
  269. return cell;
  270. }else if (indexPath.row == 2){
  271. UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"countCell"];
  272. UILabel *titleCount =[[UILabel alloc]initWithFrame:CGRectMake(15, 60/2-15, 40, 30)];
  273. titleCount.font = [UIFont systemFontOfSize:14];
  274. titleCount.textColor = Normal_TextColor;
  275. titleCount.text = YZMsg(@"数量");
  276. [cell.contentView addSubview:titleCount];
  277. UIButton *addBtn = [UIButton buttonWithType:0];
  278. addBtn.frame = CGRectMake(_window_width-20-30, 60/2-10, 20, 20);
  279. [addBtn setImage:[UIImage imageNamed:@"standards_加"] forState:0];
  280. [addBtn addTarget:self action:@selector(addCount) forControlEvents:UIControlEventTouchUpInside];
  281. [cell.contentView addSubview:addBtn];
  282. countFeild = [[UITextField alloc]init];
  283. countFeild.frame = CGRectMake(addBtn.left-50, 60/2-15, 40, 30);
  284. countFeild.textAlignment = NSTextAlignmentCenter;
  285. countFeild.font = [UIFont systemFontOfSize:14];
  286. countFeild.backgroundColor = RGB(235, 235, 235);
  287. countFeild.textColor = Pink_Cor;
  288. countFeild.text =[NSString stringWithFormat:@"%d",self.countNum];
  289. countFeild.userInteractionEnabled = NO;
  290. [cell.contentView addSubview:countFeild];
  291. UIButton *reduceBtn = [UIButton buttonWithType:0];
  292. reduceBtn.frame = CGRectMake(countFeild.left-30, 60/2-10, 20, 20);
  293. [reduceBtn setImage:[UIImage imageNamed:@"standards_减"] forState:0];
  294. [reduceBtn addTarget:self action:@selector(reduceBtnClick) forControlEvents:UIControlEventTouchUpInside];
  295. [cell.contentView addSubview:reduceBtn];
  296. [PublicObj lineViewWithFrame:CGRectMake(15, 60-1, _window_width-30, 1) andColor:Line_Cor andView:cell.contentView];
  297. cell.backgroundColor = UIColor.whiteColor;
  298. return cell;
  299. }else if (indexPath.row == 3){
  300. UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"postpagCell"];
  301. UILabel *titleCount =[[UILabel alloc]initWithFrame:CGRectMake(15, 60/2-15, 40+20, 30)];
  302. titleCount.font = [UIFont systemFontOfSize:14];
  303. titleCount.textColor = Normal_TextColor;
  304. titleCount.text = YZMsg(@"邮费");
  305. [cell addSubview:titleCount];
  306. UILabel *postage =[[UILabel alloc]initWithFrame:CGRectMake(_window_width-100, 60/2-15, 85, 30)];
  307. postage.font = [UIFont systemFontOfSize:14];
  308. postage.textColor = Pink_Cor;
  309. postage.textAlignment = NSTextAlignmentRight;
  310. postage.text = [NSString stringWithFormat:@"%@%@",YZMsg(@"¥"),[self.orderModel.goods_info valueForKey:@"postage"]];
  311. [cell addSubview:postage];
  312. [PublicObj lineViewWithFrame:CGRectMake(15, 60-1, _window_width-30, 1) andColor:Line_Cor andView:cell.contentView];
  313. cell.backgroundColor = UIColor.whiteColor;
  314. return cell;
  315. }else if (indexPath.row == 4){
  316. UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"priceCell"];
  317. UILabel *titleCount =[[UILabel alloc]initWithFrame:CGRectMake(15, 60/2-15, 40, 30)];
  318. titleCount.font = [UIFont systemFontOfSize:14];
  319. titleCount.textColor = Normal_TextColor;
  320. titleCount.text = YZMsg(@"总计");
  321. [cell addSubview:titleCount];
  322. allprice =[[UILabel alloc]initWithFrame:CGRectMake(_window_width-100, 60/2-15, 85, 30)];
  323. allprice.font = [UIFont systemFontOfSize:14];
  324. allprice.textColor = Pink_Cor;
  325. allprice.textAlignment = NSTextAlignmentRight;
  326. // allprice.text = [NSString stringWithFormat:@"%@%@",YZMsg(@"¥"),minstr([self.orderDic valueForKey:@"price"])];
  327. CGFloat price =[minstr([self.orderDic valueForKey:@"price"]) floatValue];
  328. CGFloat postage = [minstr([self.orderModel.goods_info valueForKey:@"postage"]) floatValue];
  329. allprice.text = [NSString stringWithFormat:@"¥%.2f",price *self.countNum+postage];
  330. [cell addSubview:allprice];
  331. [PublicObj lineViewWithFrame:CGRectMake(15, 60-1, _window_width-30, 1) andColor:Line_Cor andView:cell.contentView];
  332. cell.backgroundColor = UIColor.whiteColor;
  333. return cell;
  334. }else{
  335. UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"messageCell"];
  336. UILabel *titleCount =[[UILabel alloc]initWithFrame:CGRectMake(15, 60/2-15, 80+20, 30)];
  337. titleCount.font = [UIFont systemFontOfSize:14];
  338. titleCount.textColor = Normal_TextColor;
  339. titleCount.text = YZMsg(@"买家留言:");
  340. [cell addSubview:titleCount];
  341. msgText = [[MyTextView alloc]init];
  342. msgText.font = [UIFont systemFontOfSize:14];
  343. msgText.placeholderColor = [UIColor lightGrayColor];
  344. msgText.placeholder = YZMsg(@"建议留言前先与商家沟通确认");
  345. msgText.textColor = [UIColor blackColor];
  346. msgText.backgroundColor = UIColor.whiteColor;
  347. [cell.contentView addSubview:msgText];
  348. [msgText mas_makeConstraints:^(MASConstraintMaker *make) {
  349. make.top.equalTo(titleCount.mas_top);
  350. make.left.equalTo(titleCount.mas_right).offset(5);
  351. make.right.equalTo(cell).offset(-15);
  352. make.height.mas_equalTo(60);
  353. }];
  354. cell.backgroundColor = UIColor.whiteColor;
  355. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  356. return cell;
  357. }
  358. }
  359. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  360. {
  361. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  362. if (indexPath.row == 0) {
  363. AddressVC *address = [[AddressVC alloc]init];
  364. address.titleStr = YZMsg(@"我的地址");
  365. address.from = @"order";
  366. address.delegate =self;
  367. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:address animated:YES];
  368. }
  369. }
  370. -(void)selectAddress:(NSDictionary *)dic
  371. {
  372. addressDic = dic;
  373. addArr = [NSArray arrayWithObject:addressDic];
  374. NSIndexPath *index = [NSIndexPath indexPathForRow:0 inSection:0];
  375. [self.orderTable reloadRowsAtIndexPaths:[NSArray arrayWithObjects:index,nil] withRowAnimation:UITableViewRowAnimationNone];
  376. }
  377. -(void)addCount{
  378. self.countNum+=1;
  379. countFeild.text =[NSString stringWithFormat:@"%d",self.countNum];
  380. CGFloat postage = [minstr([self.orderModel.goods_info valueForKey:@"postage"]) floatValue];
  381. CGFloat price =[minstr([self.orderDic valueForKey:@"price"]) floatValue];
  382. allprice.text = [NSString stringWithFormat:@"%@%.2f",YZMsg(@"¥"),price *self.countNum+postage];
  383. payLb.text = [NSString stringWithFormat:@"%@%.2f",YZMsg(@"¥"),price *self.countNum+postage];
  384. }
  385. -(void)reduceBtnClick{
  386. if (self.countNum == 1) {
  387. [MBProgressHUD showError:YZMsg(@"最小数量为1件")];
  388. return;
  389. }
  390. self.countNum-=1;
  391. countFeild.text =[NSString stringWithFormat:@"%d",self.countNum];
  392. CGFloat postage = [minstr([self.orderModel.goods_info valueForKey:@"postage"]) floatValue];
  393. CGFloat price =[minstr([self.orderDic valueForKey:@"price"]) floatValue];
  394. allprice.text = [NSString stringWithFormat:@"%@%.2f",YZMsg(@"¥"),price *self.countNum+postage];
  395. payLb.text = [NSString stringWithFormat:@"%@%.2f",YZMsg(@"¥"),price *self.countNum+postage];
  396. }
  397. -(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
  398. {
  399. [self.view endEditing:YES];
  400. }
  401. #pragma mark------提交-------
  402. -(void)subBtnClick{
  403. YBWeakSelf;
  404. if (addArr.count < 1) {
  405. [MBProgressHUD showError:YZMsg(@"请设置收货人信息")];
  406. return;
  407. }else if (addressDic == nil) {
  408. [MBProgressHUD showError:YZMsg(@"请设置收货人信息")];
  409. return;
  410. }
  411. NSString *goodid = minstr([self.orderModel.goods_info valueForKey:@"id"]);
  412. NSDictionary *signdic = @{@"uid":[Config getOwnID],@"addressid":minstr([addressDic valueForKey:@"id"]),@"goodsid":goodid,@"spec_id":minstr([self.orderDic valueForKey:@"spec_id"]), @"time":[NSNumber numberWithLong: (long)[[NSDate date] timeIntervalSince1970]]};
  413. NSString *sign = [PublicObj sortString:signdic];
  414. if (self.shareUserid.length > 0 && ![PublicObj checkNull:self.shareUserid]) {
  415. self.liveuid = @"0";
  416. }
  417. NSDictionary *dic = @{
  418. @"uid":[Config getOwnID],
  419. @"token":[Config getOwnToken],
  420. @"addressid":minstr([addressDic valueForKey:@"id"]),
  421. @"goodsid":goodid,
  422. @"spec_id":minstr([self.orderDic valueForKey:@"spec_id"]),
  423. @"nums":countFeild.text,
  424. @"message":msgText.text,
  425. @"time":[NSNumber numberWithLong: (long)[[NSDate date] timeIntervalSince1970]],
  426. @"sign":sign,
  427. @"liveuid":self.liveuid,
  428. @"shareuid":self.shareUserid
  429. };
  430. [YBNetworking postWithUrl:@"Buyer.createGoodsOrder" Dic:dic Suc:^(int code, id info, NSString *msg) {
  431. if (code == 0) {
  432. orderid = minstr([[info firstObject] valueForKey:@"orderid"]);
  433. [weakSelf showPayView:orderid];
  434. [MBProgressHUD showError:YZMsg(@"订单提交成功")];
  435. }else{
  436. [MBProgressHUD showError:msg];
  437. }
  438. } Fail:^(id fail) {
  439. }];
  440. }
  441. -(void)showPayView:(NSString *)orderID{
  442. YBWeakSelf;
  443. if (_payView) {
  444. [_payView removeFromSuperview];
  445. _payView = nil;
  446. }
  447. _payView = [[PayOrderView alloc]initWithPrice:payLb.text AndOrderId:orderID AndShopName:self.orderModel.shop_name];
  448. _payView.frame = CGRectMake(0, 0, _window_width, _window_height);
  449. _payView.hideEvent = ^(BOOL paySuccess) {
  450. // if (paySuccess) {
  451. OrderDetailVC *detail = [[OrderDetailVC alloc]init];
  452. detail.orderId = orderID;
  453. detail.fromWhere = @"orderDetail";
  454. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:detail animated:YES];
  455. // }
  456. [weakSelf.payView removeFromSuperview];
  457. weakSelf.payView = nil;
  458. };
  459. // _payView.hideEvent = ^{
  460. // };
  461. [self.view addSubview:_payView];
  462. }
  463. @end