ASJumpHandler.m 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. //
  2. // ASJumpHandler.m
  3. // Asteria
  4. //
  5. // Created by xingyu on 2024/7/12.
  6. //
  7. #import "ASJumpHandler.h"
  8. #import "ASOrderListViewController.h"
  9. #import "Cart_MyCartC.h"
  10. #import "ASMessageListViewController.h"
  11. #import "ASProductListViewController.h"
  12. #import "ASGoodsDetailsViewController.h"
  13. #import "ASPointsHomeViewController.h"
  14. #import "ASVipCenterViewController.h"
  15. #import "ASCouponsListViewController.h"
  16. @implementation ASJumpHandler
  17. static ASJumpHandler *jumpHandler = nil;
  18. + (instancetype)shareInstance{
  19. static dispatch_once_t onceToken;
  20. dispatch_once(&onceToken, ^{
  21. jumpHandler = [[ASJumpHandler alloc] init];
  22. });
  23. return jumpHandler;
  24. }
  25. - (void)handleMessage:(NSString *)title messageId:(NSString *)mid pushPara:(NSString *)push_para pushType:(NSInteger)type {
  26. [self handleJumpWithTitle:title jumpData:push_para type:type];
  27. }
  28. - (void)handleJumpWithTitle:(NSString *)title jumpData:(NSString *)jumpData type:(NSInteger)type {
  29. UIViewController *topVC = topViewController();
  30. /// 跳转类型 0:url 1:商品列表 2:订单列表 3:商品详情 4:购物车 5:消息列表
  31. /// 2024-02-27新增: 6.explore首页 7.explore详情 8.我的积分 9.koc 10.vip Center 11.我的优惠券 12. 登录注册, 13.签到 14.首页
  32. switch (type) {
  33. case 0:
  34. [Fuction_Tool push_BaseWebUrl:jumpData webTitle:title];
  35. break;
  36. case 1:
  37. [self pushToProductList:title typeid:jumpData];
  38. break;
  39. case 2:
  40. {
  41. if (!ASUserInfoManager.shared.isLogin) {
  42. [Fuction_Tool pop_toLoginVC];
  43. return;
  44. }
  45. if (![topVC isKindOfClass:[ASOrderListViewController class]]) {
  46. ASOrderListViewController *orderC = [[ASOrderListViewController alloc] init];
  47. [topVC.navigationController pushViewController:orderC animated:true];
  48. }
  49. }
  50. break;
  51. case 3:
  52. [self goto_WKM_GoodsDetailsC:jumpData];
  53. break;
  54. case 4:
  55. {
  56. if (![topVC isKindOfClass:[Cart_MyCartC class]]) {
  57. Cart_MyCartC *cartC = [[Cart_MyCartC alloc]init];
  58. [topVC.navigationController pushViewController:cartC animated:true];
  59. }
  60. }
  61. break;
  62. case 5: {
  63. if (!ASUserInfoManager.shared.isLogin) {
  64. [Fuction_Tool pop_toLoginVC];
  65. return;
  66. }
  67. if (![topVC isKindOfClass:[ASMessageListViewController class]]) {
  68. ASMessageListViewController *mesVC = [[ASMessageListViewController alloc]init];
  69. [topVC.navigationController pushViewController:mesVC animated:true];
  70. }
  71. }
  72. break;
  73. case 6:// explore列表
  74. {
  75. // [Fuction_Tool navPopRootToExpolerVC];
  76. }
  77. break;
  78. case 7:// explore详情
  79. {
  80. // [self goto_exploreDetailsC:push_para];
  81. }
  82. break;
  83. case 8:// 积分
  84. {
  85. if (!ASUserInfoManager.shared.isLogin) {
  86. [Fuction_Tool pop_toLoginVC];
  87. return;
  88. }
  89. [self to_pointsVc];
  90. }
  91. break;
  92. case 9:// koc
  93. {
  94. if (!ASUserInfoManager.shared.isLogin) {
  95. [Fuction_Tool pop_toLoginVC];
  96. return;
  97. }
  98. [self to_KocVc];
  99. }
  100. break;
  101. case 10:// vip center
  102. {
  103. if (!ASUserInfoManager.shared.isLogin) {
  104. [Fuction_Tool pop_toLoginVC];
  105. return;
  106. }
  107. [self to_vipCenter];
  108. }
  109. break;
  110. case 11:// 我的优惠券
  111. {
  112. if (!ASUserInfoManager.shared.isLogin) {
  113. [Fuction_Tool pop_toLoginVC];
  114. return;
  115. }
  116. NSInteger index = jumpData.integerValue;
  117. [self to_couponsVc:index];
  118. }
  119. break;
  120. case 12://登录注册
  121. {
  122. [Fuction_Tool pop_toLoginVC];
  123. }
  124. break;
  125. case 13://签到
  126. {
  127. if (!ASUserInfoManager.shared.isLogin) {
  128. [Fuction_Tool pop_toLoginVC];
  129. return;
  130. }
  131. [self to_checkInVc];
  132. }
  133. break;
  134. case 14:// 首页
  135. [Fuction_Tool popToHomeVc];
  136. break;
  137. default:
  138. if (jumpData.isValidUrl) {
  139. [Fuction_Tool push_BaseWebUrl:jumpData webTitle:title];
  140. }
  141. break;
  142. }
  143. }
  144. -(void)pushToProductList:(NSString *)name typeid:(NSString *)typeId {
  145. if (typeId == nil || [typeId isEqualToString:@""]) {
  146. return;
  147. }
  148. if (name == nil || [name isEqualToString:@""]) {
  149. name = @"Products";
  150. }
  151. ASProductListViewController *vc = [[ASProductListViewController alloc] init];
  152. vc.titleName = name;
  153. vc.type = typeId;
  154. [[Current_normalTool topViewController].navigationController pushViewController:vc animated:YES];
  155. }
  156. -(void)goto_WKM_GoodsDetailsC:(NSString *)entity_id {
  157. ASGoodsDetailsViewController *vc = [[ASGoodsDetailsViewController alloc]init];
  158. vc.entity_id = entity_id;
  159. [[Current_normalTool topViewController].navigationController pushViewController:vc animated:YES];
  160. }
  161. //// 跳explore详情
  162. //-(void)goto_exploreDetailsC:(NSString *)entity_id {
  163. // UIViewController *topC = [Current_normalTool topViewController];
  164. // if ([topC isKindOfClass:AP_ExploreDetailsC.class]) {
  165. // return;
  166. // }
  167. // AP_ExploreDetailsC *vc = [[AP_ExploreDetailsC alloc]init];
  168. // ExploreListM *m = [[ExploreListM alloc] init];
  169. // m.listId = entity_id;
  170. // vc.listModel = m;
  171. // [[Current_normalTool topViewController].navigationController pushViewController:vc animated:YES];
  172. //
  173. //}
  174. - (void)to_pointsVc {
  175. UIViewController *topC = [Current_normalTool topViewController];
  176. if ([topC isKindOfClass:ASPointsHomeViewController.class]) {
  177. return;
  178. }
  179. ASPointsHomeViewController *vc = [[ASPointsHomeViewController alloc] init];
  180. [topC.navigationController pushViewController:vc animated:true];
  181. }
  182. - (void)to_KocVc {
  183. // UIViewController *vc = [Current_normalTool topViewController];
  184. // if ([vc isKindOfClass:KWBrandAMBViewController.class] || [vc isKindOfClass:[APKocTotalViewController class]]) {
  185. // return;
  186. // }
  187. // UIWindow *w = UIApplication.sharedApplication.windows.firstObject;
  188. // [MBProgressHUD showHUDAddedTo:w animated:true];
  189. // __block BOOL hadPush = false;
  190. // [[KWBalanceInfoManager shareInstance] updateApplyStatus:^(BOOL flag) {
  191. // [MBProgressHUD hideHUDForView:w animated:true];
  192. // if (hadPush) {
  193. // return;
  194. // }
  195. // hadPush = true;
  196. // if (![KWBalanceInfoManager shareInstance].isApply) {
  197. // KWBrandAMBViewController *vc = [KWBrandAMBViewController new];
  198. // [[Current_normalTool topViewController].navigationController pushViewController:vc animated:true];
  199. // } else {
  200. // APKocTotalViewController *vc = [[APKocTotalViewController alloc] init];
  201. // [[Current_normalTool topViewController].navigationController pushViewController:vc animated:true];
  202. // }
  203. // }];
  204. }
  205. - (void)to_vipCenter {
  206. UIViewController *vc = [Current_normalTool topViewController];
  207. // [MBProgressHUD showHUDAddedTo:vc.view animated:true];
  208. // __block BOOL hadPush = false;
  209. //
  210. // [KWLoginedManager.shareInstance getAllLevelInfo:^(bool flag) {
  211. // if (hadPush) {
  212. // return;
  213. // }
  214. // hadPush = true;
  215. // [MBProgressHUD hideHUDForView:vc.view animated:true];
  216. // ASVipCenterViewController *vc = [[ASVipCenterViewController alloc] init];
  217. // vc.currentLeave = KWLoginedManager.shareInstance.levelInfo.level;
  218. // [[Current_normalTool topViewController].navigationController pushViewController:vc animated:true];
  219. // }];
  220. ASVipCenterViewController *vipCenterVC = [[ASVipCenterViewController alloc] init];
  221. // vipCenterVC.currentLeave = KWLoginedManager.shareInstance.levelInfo.level;
  222. [vc.navigationController pushViewController:vipCenterVC animated:true];
  223. }
  224. - (void)to_couponsVc:(NSInteger)index {
  225. ASCouponsListViewController *vc = [[ASCouponsListViewController alloc] init];
  226. [[Current_normalTool topViewController].navigationController pushViewController:vc animated:true];
  227. }
  228. - (void)to_checkInVc {
  229. // WK_CheckPointsC *vc = [[WK_CheckPointsC alloc] init];
  230. // KWLoginedUserModel *m = [KWLoginedManager.shareInstance getCurrentLoginedUser];
  231. // vc.points = m.points;
  232. // [[Current_normalTool topViewController].navigationController pushViewController:vc animated:true];
  233. }
  234. @end