|
@@ -209,12 +209,12 @@
|
|
|
}
|
|
|
cell.switchBtn.hidden = !(indexPath.row == 2);
|
|
|
if (indexPath.row == 2) {
|
|
|
- [cell.switchBtn setIsOpen:arc4random()%2 == 1 animate:false];
|
|
|
-// [cell.switchBtn setIsOpen:self.userInfo.is_subscribed animate:false];
|
|
|
-// @weakify(self);
|
|
|
-// [cell.switchBtn setClickBack:^{
|
|
|
-// [weak_self configSubscrib:!weak_self.userInfo.is_subscribed];
|
|
|
-// }];
|
|
|
+ BOOL isSub = ASUserInfoManager.shared.userInfo.is_subscribed;
|
|
|
+ [cell.switchBtn setIsOpen:isSub animate:false];
|
|
|
+ __weak typeof(self) weakSelf = self;
|
|
|
+ [cell.switchBtn setClickBack:^{
|
|
|
+ [weakSelf configSubscrib:!isSub];
|
|
|
+ }];
|
|
|
} else {
|
|
|
cell.switchBtn.clickBack = nil;
|
|
|
}
|
|
@@ -306,28 +306,23 @@
|
|
|
}
|
|
|
|
|
|
|
|
|
-//- (void)configSubscrib:(BOOL)is_subscribed {
|
|
|
-// NSDictionary *param = @{@"is_subscribed":[NSNumber numberWithBool:is_subscribed]};
|
|
|
-// @weakify(self);
|
|
|
-// [MBProgressHUD showHUDAddedTo:self.view animated:true];
|
|
|
-// [PPNetworkHelper POST:SaveSub parameters:param success:^(id responseObject) {
|
|
|
-// [MBProgressHUD hideHUDForView:weak_self.view animated:true];
|
|
|
-// if (RequestSuccess) {
|
|
|
-// weak_self.userInfo.is_subscribed = is_subscribed;
|
|
|
-// [KWLoginedManager.shareInstance getUserInfo:^(bool flag) {
|
|
|
-//
|
|
|
-// }];
|
|
|
-// } else {
|
|
|
-// NSString *errMsg = [NSString stringWithFormat:@"%@", RequestErrorMsg];
|
|
|
-// [self.view makeToast:errMsg];
|
|
|
-// }
|
|
|
-// [weak_self.tableV reloadData];
|
|
|
-// } failure:^(NSError *error) {
|
|
|
-// [MBProgressHUD hideHUDForView:weak_self.view animated:true];
|
|
|
-// [self.view makeToast:@"请求失败"];
|
|
|
-// [weak_self.tableV reloadData];
|
|
|
-// }];
|
|
|
-//
|
|
|
-//}
|
|
|
+- (void)configSubscrib:(BOOL)is_subscribed {
|
|
|
+ NSDictionary *param = @{
|
|
|
+ @"extension_attributes":@{
|
|
|
+ @"is_subscribed":[NSNumber numberWithBool:is_subscribed]
|
|
|
+ }
|
|
|
+ };
|
|
|
+ @weakify(self);
|
|
|
+ [MBProgressHUD showHUDAddedTo:self.view animated:true];
|
|
|
+ [ASNetTools.shared putWithPath:putUserInfo param:param success:^(id _Nonnull json) {
|
|
|
+ ASUserInfoManager.shared.userInfo.is_subscribed = is_subscribed;
|
|
|
+ [weak_self.tableV reloadData];
|
|
|
+ } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
|
|
|
+ [MBProgressHUD hideHUDForView:weak_self.view animated:true];
|
|
|
+ [self.view makeToast:@"请求失败"];
|
|
|
+ [weak_self.tableV reloadData];
|
|
|
+ }];
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
@end
|