Cart_CheckoutC.m 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. //
  2. // Cart_CheckoutC.m
  3. // Asteria
  4. //
  5. // Created by 王猛 on 2024/2/16.
  6. //
  7. #import "Cart_CheckoutC.h"
  8. #import "ASAddressListViewController.h"
  9. #import "ASCheckoutTopView.h"
  10. #import "ASCheckoutBottomView.h"
  11. #import "CartCheckTableV.h"
  12. #import "CartVM.h"
  13. #import "ASUserModel.h"
  14. #import "ASGoodsDetailsVM.h"
  15. #import "ASAddGiftGoodsView.h"
  16. @interface Cart_CheckoutC ()<RY_baseVMprotocol>
  17. @property (nonatomic, strong) CartVM *VM;
  18. @property (nonatomic, strong) ASCheckoutTopView *topView;
  19. @property (nonatomic, strong) ASCheckoutBottomView *bottomView;
  20. @property (nonatomic, strong) CartCheckTableV *TableV;
  21. @property (nonatomic, strong) MyCartCouponCellData *couponCellM;
  22. @property (nonatomic, strong) MyCartGrandTotalCellData *totalCellM;
  23. @property (nonatomic, strong) ASCheckoutPointData *pointCellM;
  24. @property (nonatomic, strong) ASCheckoutAddressData *addressCellM;
  25. @property (nonatomic, strong) ASCheckoutShipMethodData *shipmethodCellM;
  26. @property (nonatomic, strong) ASCheckoutCommentData *commentCellM;
  27. //存放支付方式
  28. @property (nonatomic, strong) NSArray *paymentArray;
  29. //选中支付方式
  30. @property (nonatomic, strong) ASCheckoutPaymentModel *paymentModel;
  31. //手动添加赠品至购物车
  32. @property (nonatomic, strong) ASGoodsDetailsVM *goodsDetailsVM;
  33. @property (nonatomic, strong) ASAddGiftGoodsView *addGiftView;
  34. @property (nonatomic, strong) NSMutableArray *addGiftParamArr;
  35. @property (nonatomic, assign) int index;
  36. @property (nonatomic, assign) int giftShowCount;
  37. @end
  38. @implementation Cart_CheckoutC
  39. - (void)viewDidLoad {
  40. [super viewDidLoad];
  41. self.title = @"Checkout";
  42. //获取支付方式
  43. [self requestPaymentMode];
  44. //获取运输方式
  45. [self requestGetShipMethodByAddress];
  46. //获取购物车信息(地址信息)
  47. [self requestCartInfo];
  48. }
  49. - (void)initSubviews {
  50. [super initSubviews];
  51. self.addGiftParamArr = [[NSMutableArray alloc] initWithCapacity:1];
  52. self.index = 0;
  53. self.giftShowCount = 0;
  54. IPhoneXHeigh
  55. [self setupTableV:[CartCheckTableV class] Frame:CGRectMake(0, securitytop_Y , KScreenWidth, KScreenHeight - securitytop_Y)];
  56. self.TableV.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
  57. self.TableV.tableHeaderView = self.topView;
  58. self.TableV.tableFooterView = self.bottomView;
  59. @weakify(self)
  60. self.TableV.tapClose = ^(NSInteger num, id data) {
  61. //num = 0 删除商品 ,1 修改数量 countV
  62. @strongify(self)
  63. if([data isKindOfClass:[CartTotalsItemsM class]]){
  64. switch (num) {
  65. case 0:
  66. [self reqNet_DEL_cartsMineItems:(CartTotalsItemsM *)data];
  67. break;
  68. case 1:
  69. [self reqnet_Cart_cartsMineItems_Post:(CartTotalsItemsM *)data];
  70. break;
  71. default:
  72. break;
  73. }
  74. }else if ([data isKindOfClass:[MyCartCouponCellData class]]){
  75. MyCartCouponCellData *couponM = (MyCartCouponCellData *)data;
  76. if(num ==0){ //使用优惠券
  77. [self reqNet_PUT_cartsMineCoupons:couponM.coupon_code];
  78. }else if(num == 1){//删除优惠券
  79. [self reqNet_DEL_cartsMineCoupons];
  80. }
  81. } else if ([data isKindOfClass:[ASCheckoutPointData class]]) {
  82. ASCheckoutPointData *pointData = (ASCheckoutPointData *)data;
  83. if(num ==0){ //使用积分
  84. [self requestUseLimitPoint:pointData.usePoint];
  85. }else if(num == 1){//取消使用积分
  86. [self requestCancelUsePoint];
  87. }
  88. } else if ([data isKindOfClass:[ASCheckoutCommentData class]]) {
  89. ASCheckoutCommentData *commentData = (ASCheckoutCommentData *)data;
  90. if(num ==0){ //使用积分
  91. self.commentCellM.commentStr = commentData.commentStr;
  92. }
  93. } else if ([data isKindOfClass:[ASCheckoutShipMethodData class]]) {
  94. //选择运输方式、、、、并设置
  95. ASCheckoutShipMethodData *shipMethodData = (ASCheckoutShipMethodData *)data;
  96. self.shipmethodCellM = shipMethodData;
  97. for (int i = 0; i < self.shipmethodCellM.shipMethodArray.count; i++) {
  98. ASCheckoutShipMethodModel *shipModel = [self.shipmethodCellM.shipMethodArray objectAtIndex:i];
  99. if (i == num) {
  100. shipModel.isSelect = YES;
  101. self.shipmethodCellM.shipMethodModel = shipModel;
  102. } else {
  103. shipModel.isSelect = NO;
  104. }
  105. }
  106. [self requestSetShipMethodByAddress];
  107. }
  108. };
  109. }
  110. - (void)ry_respnsData:(id)data
  111. parseAry:(NSMutableArray *)arry
  112. sucess:(BOOL)sucessOrFail
  113. mark:(NSString *)mark
  114. reqNetType:(ReqNetType)reqNetType{
  115. [MBProgressHUD hideHUDForView:self.view animated:YES];
  116. if([mark isEqualToString:Cart_cartsMineTotals]){
  117. if(sucessOrFail){
  118. CartTotalsM *model = [arry firstObject];
  119. self.totalsM = model;
  120. [self updateData];
  121. }
  122. } else if ([mark isEqualToString:Chectout_getPaymentMode]) {
  123. if(sucessOrFail){
  124. // 更新支付方式
  125. self.paymentArray = arry;
  126. if (self.paymentArray.count > 0) {
  127. self.paymentModel = self.paymentArray[0];
  128. [self.bottomView setBottomPayStyle:self.paymentModel.code];
  129. }
  130. //首次进入展示购物车数据UI
  131. [self updateData];
  132. }
  133. } else if ([mark isEqualToString:Cart_cartInfo]) {
  134. if(sucessOrFail){
  135. // 获取上次下单地址
  136. NSDictionary *dic = (NSDictionary *)data;
  137. NSArray *array = [[dic objectForKey:@"extension_attributes"] objectForKey:@"shipping_assignments"];
  138. if (array.count > 0) {
  139. NSDictionary *shipping_assignments = array[0];
  140. NSDictionary *shippingDic = [shipping_assignments objectForKey:@"shipping"];
  141. NSDictionary *addressDic = [shippingDic objectForKey:@"address"];
  142. // ASAddressModel *addressModel = [ASAddressModel defualtData];
  143. ASAddressReginModel *reginModel = [ASAddressReginModel mj_objectWithKeyValues:addressDic];
  144. ASAddressModel *addressModel = [ASAddressModel mj_objectWithKeyValues:addressDic];
  145. addressModel.region = reginModel;
  146. if (!NIL(addressModel.postcode)) {
  147. self.addressCellM.addressModel = addressModel;
  148. if (self.shipmethodCellM.shipMethodModel) {
  149. //默认设置第一个运输方式
  150. [self requestSetShipMethodByAddress];
  151. }
  152. }
  153. }
  154. //首次进入展示购物车数据UI
  155. [self updateData];
  156. }
  157. } else if ([mark isEqualToString:Chectout_addShipAddress_id]) {
  158. if(sucessOrFail){
  159. NSArray *shipMethodArr = (NSArray *)data;
  160. if (shipMethodArr.count > 0) {
  161. self.shipmethodCellM.shipMethodArray = [ASCheckoutShipMethodModel mj_objectArrayWithKeyValuesArray:shipMethodArr];
  162. ASCheckoutShipMethodModel *firstModel = self.shipmethodCellM.shipMethodArray[0];
  163. firstModel.isSelect = YES;
  164. self.shipmethodCellM.shipMethodModel = firstModel;
  165. self.shipmethodCellM.shipmethodSymbol = self.totalsM.currency_symbol;
  166. //默认设置第一个运输方式
  167. [self requestSetShipMethodByAddress];
  168. }
  169. [self reqNet_Cart_cartsMineTotals];
  170. }
  171. } else if ([mark isEqualToString:Chectout_getShipMethod]) {
  172. if(sucessOrFail){
  173. NSArray *shipMethodArr = (NSArray *)data;
  174. if (shipMethodArr.count > 0) {
  175. self.shipmethodCellM.shipMethodArray = [ASCheckoutShipMethodModel mj_objectArrayWithKeyValuesArray:shipMethodArr];
  176. ASCheckoutShipMethodModel *firstModel = self.shipmethodCellM.shipMethodArray[0];
  177. firstModel.isSelect = YES;
  178. self.shipmethodCellM.shipMethodModel = firstModel;
  179. self.shipmethodCellM.shipmethodSymbol = self.totalsM.currency_symbol;
  180. if (self.addressCellM.addressModel) {
  181. //默认设置第一个运输方式
  182. [self requestSetShipMethodByAddress];
  183. }
  184. }
  185. }
  186. [self updateData];
  187. } else if ([mark isEqualToString:Cart_cartsMineItems_Post]
  188. || [mark isEqualToString:DEL_cartsMineItems]
  189. || [mark isEqualToString:PUT_cartsMineCoupons]
  190. || [mark isEqualToString:Chectout_PUT_usePoints]
  191. || [mark isEqualToString:Chectout_DEL_cancelusePoints]
  192. || [mark isEqualToString:Chectout_setShipMethod]
  193. || [mark isEqualToString:Chectout_giftAddCart]){
  194. if(sucessOrFail){
  195. if ([mark isEqualToString:Chectout_giftAddCart]) {
  196. self.index --;
  197. if (self.index == 0) {
  198. [self reqNet_Cart_cartsMineTotals];
  199. }
  200. } else {
  201. [self reqNet_Cart_cartsMineTotals];
  202. }
  203. }else{
  204. [self.view makeToast:(NSString *)data duration:2 position:CSToastPositionCenter];
  205. }
  206. } else if ([mark isEqualToString:Goods_productGetProductsById]) {
  207. //请求赠品详情
  208. GoodsInformationM *model = (GoodsInformationM *)[arry firstObject];
  209. NSMutableDictionary *param = [NSMutableDictionary dictionaryWithDictionary:@{@"product_id":model.Id, @"isPromoItems":@"yes"}];
  210. if (model.options.count > 0) {
  211. NSMutableDictionary *optionDic = [NSMutableDictionary dictionary];
  212. for (OptionsModel *optionM in model.options) {
  213. OptionsValuesM *valuesM = optionM.values[0];
  214. NSString *tempStr =[NSString stringWithFormat:@"options[%@]",optionM.option_id];
  215. optionDic[tempStr] =valuesM.option_type_id;
  216. }
  217. [param addEntriesFromDictionary:optionDic];
  218. }
  219. [self.addGiftParamArr addObject:param];
  220. if (self.giftShowCount < 2 && self.addGiftParamArr.count == 1 && self.addGiftView.hidden) {
  221. self.addGiftView.hidden = NO;
  222. [self.addGiftView setGiftData:model.add_gooodsImgUrl];
  223. }
  224. }
  225. }
  226. - (void)updateData{
  227. [self.topView setTopViewData:self.totalsM.items_qty price:[NSString stringWithFormat:@"%@%@",self.totalsM.currency_symbol,self.totalsM.subtotal]];
  228. [self.TableV.infodata removeAllObjects];
  229. self.TableV.infodata = [NSMutableArray arrayWithArray:self.totalsM.items];
  230. //邮寄地址--邮寄方式
  231. if (self.addressCellM.addressModel) {
  232. [self.TableV.infodata addObject:self.addressCellM];
  233. }
  234. //运输方式
  235. [self.TableV.infodata addObject:self.shipmethodCellM];
  236. //优惠券
  237. self.couponCellM.couponAry =[NSMutableArray arrayWithArray: [ASNetTools shared].xxx_couponAry];
  238. self.couponCellM.coupon_code = self.totalsM.coupon_code;
  239. self.couponCellM.discount_amount = self.totalsM.discount_amount;
  240. self.couponCellM.currency_symbol = self.totalsM.currency_symbol;
  241. [self.TableV.infodata addObject:self.couponCellM];
  242. //积分
  243. NSDictionary *pointScaleDic = [Current_normalTool dicFromjsonStr:[self.totalsM.extension_attributes objectForKey:@"mw_earn_points_data"]];
  244. if (pointScaleDic.count > 0) {
  245. self.pointCellM.pointScale = [[pointScaleDic allValues] objectAtIndex:0];
  246. self.pointCellM.priceScale = [[pointScaleDic allKeys] objectAtIndex:0];
  247. }
  248. self.pointCellM.usePoint = [NSString stringWithFormat:@"%@", [self.totalsM.extension_attributes objectForKey:@"mw_rwrdpoints_amnt"]];
  249. self.pointCellM.usePrice = [NSString stringWithFormat:@"%@", [self.totalsM.extension_attributes objectForKey:@"mw_rwrdpoints_cur_amnt"]];
  250. self.pointCellM.pointBalance = [ASUserInfoManager shared].userPoints;
  251. self.pointCellM.priceSymbol = self.totalsM.currency_symbol;
  252. [self.TableV.infodata addObject:self.pointCellM];
  253. //备注
  254. [self.TableV.infodata addObject:self.commentCellM];
  255. //价格明细
  256. self.totalCellM.total_segments = [NSMutableArray arrayWithArray:self.totalsM.total_segments];
  257. self.totalCellM.currency_symbol = self.totalsM.currency_symbol;
  258. [self.TableV.infodata addObject:self.totalCellM];
  259. //支付方式数据
  260. [self.TableV.infodata addObjectsFromArray:self.paymentArray];
  261. //手动添加赠品功能
  262. [self.addGiftParamArr removeAllObjects];
  263. NSDictionary *freeData = (NSDictionary *)[[self.totalsM.extension_attributes objectForKey:@"free_data"] mj_JSONObject];
  264. BOOL is_show = [[freeData objectForKey:@"is_show"] boolValue];
  265. if (is_show && self.giftShowCount< 2) {//显示存在赠品
  266. NSArray *productArr = [freeData objectForKey:@"products"];
  267. if (productArr.count > 0) { //存在赠品
  268. for (int i = 0; i < productArr.count; i++) {
  269. NSDictionary *productDic = productArr[i];
  270. NSString *entity_id = productDic[@"entity_id"];
  271. [self reqNet_GoodsDetails_productGetProduct:entity_id];
  272. }
  273. }
  274. }
  275. [self.TableV reloadData];
  276. }
  277. - (void)tapcellTriggereventIndex:(NSIndexPath *)index model:(id)model{
  278. if([model isKindOfClass:[CartTotalsItemsM class]]){
  279. CartTotalsItemsM *itemM = (CartTotalsItemsM *)model;
  280. if(itemM.isGift){
  281. return;
  282. }
  283. UIViewController *viewController = [[CTMediator sharedInstance] Goods_GoodsDetailsC:@{@"entity_id":itemM.product_id}];
  284. [self.navigationController pushViewController:viewController animated:YES];
  285. } else if ([model isKindOfClass:[ASCheckoutPaymentModel class]]) {
  286. ASCheckoutPaymentModel *paymentModel = (ASCheckoutPaymentModel *)model;
  287. if (paymentModel.isSelect) {
  288. return;
  289. }
  290. for (int i = 0; i < self.TableV.infodata.count; i++) {
  291. id itemModel = self.TableV.infodata[i];
  292. if ([itemModel isKindOfClass:[ASCheckoutPaymentModel class]]) {
  293. ASCheckoutPaymentModel *tempModel = (ASCheckoutPaymentModel *)itemModel;
  294. if (index.row == i) {
  295. tempModel.isSelect = YES;
  296. self.paymentModel = tempModel;
  297. [self.bottomView setBottomPayStyle:tempModel.code];
  298. } else {
  299. tempModel.isSelect = NO;
  300. }
  301. }
  302. }
  303. [self.TableV reloadData];
  304. } else if ([model isKindOfClass:[ASCheckoutAddressData class]]) {
  305. ASAddressListViewController *vc = [ASAddressListViewController new];
  306. vc.isSelMode = true;
  307. vc.sel_Id = self.addressCellM.addressModel.Id;
  308. @weakify(self)
  309. vc.selectAddressBlock = ^(ASAddressModel * _Nonnull addressM) {
  310. @strongify(self)
  311. self.addressCellM.addressModel = addressM;
  312. [self requestAddShipAddress];
  313. };
  314. [self.navigationController pushViewController:vc animated:true];
  315. }
  316. }
  317. #pragma mark - **************** reqNet ****************
  318. //获取支付方式
  319. - (void)requestPaymentMode {
  320. [self.VM ry_requestGetApi:Chectout_getPaymentMode param:@{}];
  321. }
  322. //添加邮寄地址
  323. - (void)requestAddShipAddress {
  324. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  325. [self.VM ry_requestPostApi:Chectout_addShipAddress_id param:@{@"addressId":self.addressCellM.addressModel.Id}];
  326. }
  327. //根据邮寄地址获取邮寄方式
  328. - (void)requestGetShipMethodByAddress {
  329. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  330. [self.VM ry_requestGetApi:Chectout_getShipMethod param:@{}];
  331. }
  332. //设置邮寄方式
  333. - (void)requestSetShipMethodByAddress {
  334. NSDictionary *addressDic1 = (NSDictionary *)[self.addressCellM.addressModel.region mj_JSONObject];
  335. NSDictionary *addressDic = (NSDictionary *)[self.addressCellM.addressModel mj_JSONObject];
  336. NSMutableDictionary *param = [NSMutableDictionary dictionaryWithDictionary:addressDic];
  337. [param addEntriesFromDictionary:addressDic1];
  338. [param removeObjectForKey:@"extension_attributes"];//移除格式不正确的无用参数
  339. if (NIL(self.shipmethodCellM.shipMethodModel.method_code) || NIL(self.shipmethodCellM.shipMethodModel.carrier_code)) {
  340. [self.view makeToast:@"运输方式获取失败"];
  341. return;
  342. }
  343. NSDictionary *params = @{@"shipping_address":param,
  344. @"shipping_method_code":self.shipmethodCellM.shipMethodModel.method_code,
  345. @"shipping_carrier_code":self.shipmethodCellM.shipMethodModel.carrier_code};
  346. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  347. [self.VM ry_requestPostApi:Chectout_setShipMethod param:@{@"addressInformation":params}];
  348. }
  349. //获取购物车信息(地址信息)
  350. - (void)requestCartInfo {
  351. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  352. [self.VM ry_requestGetApi:Cart_cartInfo param:@{}];
  353. }
  354. ///获取购物车信息(报价整合)
  355. -(void)reqNet_Cart_cartsMineTotals{
  356. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  357. [self.VM ry_requestGetApi:Cart_cartsMineTotals param:@{}];
  358. }
  359. ///修改商品的数量
  360. -(void)reqnet_Cart_cartsMineItems_Post:(CartTotalsItemsM *)itemM{
  361. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  362. NSDictionary *cartItemDic = @{
  363. @"item_id":itemM.item_id,
  364. @"qty":itemM.qty,
  365. @"quote_id":self.totalsM.cart_id
  366. };
  367. NSMutableDictionary *param = [NSMutableDictionary dictionaryWithDictionary:@{
  368. @"cartItem":cartItemDic
  369. }];
  370. [self.VM ry_requestPostApi:Cart_cartsMineItems_Post param:param];
  371. }
  372. ///删除商品
  373. -(void)reqNet_DEL_cartsMineItems:(CartTotalsItemsM *)itemM{
  374. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  375. [self.VM ry_requestDeleteApi:DEL_cartsMineItems paramStr:itemM.item_id];
  376. }
  377. -(void)reqNet_PUT_cartsMineCoupons:(NSString *)coupon{
  378. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  379. self.giftShowCount = 0;
  380. [self.VM ry_requestPutApi:PUT_cartsMineCoupons param:coupon];
  381. }
  382. -(void)reqNet_DEL_cartsMineCoupons{
  383. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  384. [self.VM ry_requestDeleteApi:DEL_cartsMineCoupons paramStr:@""];
  385. }
  386. //使用指定积分
  387. - (void)requestUseLimitPoint:(NSString *)point {
  388. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  389. [self.VM ry_requestPutApi:Chectout_PUT_usePoints param:point];
  390. }
  391. //取消使用积分
  392. - (void)requestCancelUsePoint {
  393. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  394. [self.VM ry_requestDeleteApi:Chectout_DEL_cancelusePoints paramStr:@""];
  395. }
  396. //下单
  397. -(void)requestSureOrder{
  398. NSString *paymentCode = self.paymentModel.code;
  399. if ([paymentCode isEqualToString:@"paypal_express"]) {//paypal
  400. for (int i=0; i<self.totalCellM.total_segments.count; i++) {
  401. NSDictionary *dic = self.totalCellM.total_segments[i];
  402. NSString *code = MM_str(dic[@"code"]);
  403. if ([code isEqualToString:@"grand_total"]){ //subBottomV
  404. NSString *priceStr = [NSString stringWithFormat:@"%@",dic[@"value"]];
  405. // [self PayPalWithAmount:priceStr currencyCode:ASCurrencyManager.shared.currentCur shortDescription:@"购买商品"];
  406. return;
  407. }
  408. }
  409. return;
  410. } else if ([paymentCode isEqualToString:@"stripe_payments"]) {//visa
  411. } else if ([paymentCode isEqualToString:@"afterpay_payment"]) {//afterpay
  412. } else if ([paymentCode isEqualToString:@"klarna_kco"]) {//klarna
  413. } else {
  414. }
  415. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  416. NSDictionary *param = @{@"method":paymentCode};
  417. [ASNetTools.shared putWithPath:Chectout_PUT_sureOrder param:@{@"paymentMethod":param} success:^(id _Nonnull json) {
  418. [MBProgressHUD hideHUDForView:self.view animated:YES];
  419. NSLog(@"=======%@", json);
  420. } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
  421. [MBProgressHUD hideHUDForView:self.view animated:YES];
  422. NSLog(@"=======%@=====%@", code, msg);
  423. }];
  424. }
  425. //请求赠品商品详情
  426. -(void)reqNet_GoodsDetails_productGetProduct:(NSString *)enterId{
  427. NSMutableDictionary * params = [[NSMutableDictionary alloc] init];
  428. // [params setObject:@"55475" forKey:@"productId"];
  429. [params setObject:enterId forKey:@"productId"];
  430. [params setObject:ASCurrencyManager.shared.currentCur forKey:@"currencyCode"];
  431. // [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  432. [self.goodsDetailsVM ry_requestGetApi:Goods_productGetProductsById param:params];
  433. }
  434. //赠品加车
  435. - (void)requestGiftAddCart {
  436. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  437. for (int i = 0; i < self.addGiftParamArr.count; i++) {
  438. NSDictionary *param = self.addGiftParamArr[i];
  439. self.index ++;
  440. self.giftShowCount = 2;
  441. [self.VM ry_formDataRequestPostApi:Chectout_giftAddCart param:param];
  442. }
  443. }
  444. #pragma mark --- 懒加载 ---
  445. - (void)ucm_bindvmmodel{
  446. self.VM = [[CartVM alloc] initDelegate:self];
  447. self.goodsDetailsVM = [[ASGoodsDetailsVM alloc] initDelegate:self];
  448. }
  449. - (MyCartCouponCellData *)couponCellM {
  450. if (!_couponCellM) {
  451. _couponCellM = [[MyCartCouponCellData alloc] init];
  452. }
  453. return _couponCellM;
  454. }
  455. - (MyCartGrandTotalCellData *)totalCellM {
  456. if (!_totalCellM) {
  457. _totalCellM = [[MyCartGrandTotalCellData alloc] init];
  458. }
  459. return _totalCellM;
  460. }
  461. - (ASCheckoutPointData *)pointCellM {
  462. if (!_pointCellM) {
  463. _pointCellM = [[ASCheckoutPointData alloc] init];
  464. }
  465. return _pointCellM;
  466. }
  467. - (ASCheckoutAddressData *)addressCellM {
  468. if (!_addressCellM) {
  469. _addressCellM = [[ASCheckoutAddressData alloc] init];
  470. }
  471. return _addressCellM;
  472. }
  473. - (ASCheckoutShipMethodData *)shipmethodCellM {
  474. if (!_shipmethodCellM) {
  475. _shipmethodCellM = [[ASCheckoutShipMethodData alloc] init];
  476. }
  477. return _shipmethodCellM;
  478. }
  479. - (ASCheckoutCommentData *)commentCellM {
  480. if (!_commentCellM) {
  481. _commentCellM = [[ASCheckoutCommentData alloc] init];
  482. _commentCellM.commentStr = @"";
  483. }
  484. return _commentCellM;
  485. }
  486. - (ASCheckoutTopView *)topView {
  487. if (!_topView) {
  488. // IPhoneXHeigh
  489. _topView = [[ASCheckoutTopView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 60)];
  490. @weakify(self)
  491. _topView.isFlodBlock = ^(BOOL isFlod) {
  492. @strongify(self)
  493. self.TableV.isFlod = isFlod;
  494. [self.TableV reloadData];
  495. };
  496. }
  497. return _topView;
  498. }
  499. - (ASCheckoutBottomView *)bottomView {
  500. if (!_bottomView) {
  501. _bottomView = [[ASCheckoutBottomView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 100)];
  502. @weakify(self)
  503. _bottomView.bottomBlock = ^{
  504. @strongify(self)
  505. // [self.view makeToast:@"调起支付"];
  506. [self requestSureOrder];
  507. };
  508. }
  509. return _bottomView;
  510. }
  511. - (ASAddGiftGoodsView *)addGiftView {
  512. if (!_addGiftView) {
  513. _addGiftView = [[ASAddGiftGoodsView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
  514. @weakify(self)
  515. _addGiftView.addBlock = ^(int type) {
  516. @strongify(self)
  517. self.addGiftView.hidden = YES;
  518. if (type == 1) {
  519. [self requestGiftAddCart];
  520. } else {
  521. self.giftShowCount ++;
  522. }
  523. };
  524. _addGiftView.hidden = YES;
  525. [[UIApplication sharedApplication].keyWindow addSubview:_addGiftView];
  526. }
  527. return _addGiftView;
  528. }
  529. #pragma mark - **************** reqNet ****************
  530. @end