ASJumpHandler.m 8.9 KB

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