Files
yuyin_ios/SweetParty/主类/旧项目依赖(以后调整)/MH_ZhuanZengView.m
2025-08-08 11:05:33 +08:00

108 lines
3.8 KiB
Objective-C
Executable File

//
// MH_ZhuanZengView.m
// MoHuanXingYu
//
// Created by 马方圆 on 2021/5/18.
// Copyright © 2021 MoHuanXingYu. All rights reserved.
//
#import "MH_ZhuanZengView.h"
#import "GDMineModel.h"
#import "TXMicIMService.h"
@interface MH_ZhuanZengView ()
@property (weak, nonatomic) IBOutlet UIImageView *maskImg;
@property (weak, nonatomic) IBOutlet UIImageView *userIcon;
@property (weak, nonatomic) IBOutlet UILabel *nickName;
@property (weak, nonatomic) IBOutlet UILabel *userID;
@property (weak, nonatomic) IBOutlet UITextField *jineTF;
@property (weak, nonatomic) IBOutlet UILabel *moneyLab;
@property (weak, nonatomic) IBOutlet UIImageView *liangImg;
@property (weak, nonatomic) IBOutlet UIButton *confirmBtn;
@property(nonatomic, strong) GDMineModel *mineModel;// 模型
@end
@implementation MH_ZhuanZengView
- (void)awakeFromNib{
[super awakeFromNib];
//获取账户余额
[self getUserInfoMethod];
__weak __typeof(self)weakSelf = self;
[self.maskImg dg_Tapped:^{
[weakSelf removeFromSuperview];
}];
[self.confirmBtn setJianBianWithCGSize:CGSizeMake(ScreenWidth-27*2, 49)];
// self.jineTF.attributedPlaceholder = [[NSMutableAttributedString alloc] initWithString:@"请输入转赠金额" attributes:@{NSForegroundColorAttributeName:[kWhiteColor colorWithAlphaComponent:0.6]}];
}
#pragma mark - network request
/** 获取个人信息接口 */
- (void)getUserInfoMethod
{
WEAK_SELF;
[BJHttpTool BJ_get_user_infoWithParameters:@{} success:^(id response) {
weakSelf.mineModel = [GDMineModel mj_objectWithKeyValues:response[@"data"]];
weakSelf.moneyLab.text = NSStringFormat(@"%@",self.mineModel.integral);
// [weakSelf refreshUI];
} failure:^(NSError *error) {
}];
}
- (void)setUserInfoModel:(BJOperationAlertUserModel *)userInfoModel{
_userInfoModel = userInfoModel;
[self.userIcon sd_setImageWithURL:[NSURL URLWithString:self.userInfoModel.head_pic] placeholderImage:kDefaultUserIcon];
self.nickName.text = self.userInfoModel.nick_name;
if ([self.userInfoModel.special_uid intValue]>0) {
self.liangImg.image = userID_liang;
self.userID.text = self.userInfoModel.special_uid;
}else{
self.liangImg.image = userID_simgple;
self.userID.text = self.userInfoModel.uid;
}
}
- (IBAction)completeMethod:(id)sender {
if (self.jineTF.text.length==0) {
[SVProgressHUD showErrorWithStatus:@"请输入转赠金额"];
return;
}
[BJHttpTool BJ_user_give_integralParameters:@{@"reveive_uid":self.userInfoModel.uid,
@"integral":self.jineTF.text,
@"last_login_device":[XYUUID uuidForKeychain]}
success:^(id response) {
// NSString *str = [NSString stringWithFormat:@"给您发了%@金币", self.jineTF.text];
// [self startSendCoinMsg:str targetId:C_string(self.userInfoModel.uid) reSendCount:3];
[self removeFromSuperview];
[SVProgressHUD showSuccessWithStatus:response[@"msg"]];
} failure:^(NSError *error) {
}];
}
- (void)startSendCoinMsg:(NSString *)str targetId:(NSString *)targetId reSendCount:(NSInteger)reSendCount {
if (reSendCount <= 0) {
return;
}
NSString *businessID = BussinessID_Hongbao;
NSString *text = str;
NSDictionary *param = @{@"businessID":businessID, @"text":text};
[[V2TIMManager sharedInstance] sendC2CCustomMessage:param.mj_JSONData to:targetId succ:^{
NSLog(@"转赠消息发送成功");
}fail:^(int code, NSString *msg) {
NSLog(@"转赠消息发送失败");
//发送失败重新发送
[self startSendCoinMsg:str targetId:targetId reSendCount:reSendCount-1];
}];
}
@end