// // YYPMSendGiftView.m // YaYin // // Created by bj_szd on 2023/7/12. // Copyright © 2023 YaYin. All rights reserved. // #import "YYPMSendGiftView.h" #import "BJRoomGiftModel.h" @interface YYPMSendGiftView () @property (nonatomic, strong) BJRoomGiftModel *model; @end @implementation YYPMSendGiftView - (void)awakeFromNib { [super awakeFromNib]; [self createUI]; } - (void)createUI { [self.applyBtn setJianBianWithCGSize:CGSizeMake(ScreenWidth-32*2, 44)]; WEAK_SELF [self.touchImgV dg_Tapped:^{ [weakSelf removeFromSuperview]; }]; } - (void)setRid:(NSString *)rid { _rid = rid; [self fetchGiftData]; } - (void)fetchGiftData { NSDictionary *params = @{@"rid":C_string(self.rid)}; [[AFNetworkRequset shared] postRequestWithParams:params Path:@"/api/auction_room/get_auction_info" Loading:NO Hud:NO Success:^(id _Nonnull responseDic) { BJRoomGiftModel *model = [BJRoomGiftModel mj_objectWithKeyValues:responseDic[@"data"]]; self.model = model; [self onUpdateUIWith:model]; } Failure:^(id _Nonnull errorData) { }]; } - (void)onUpdateUIWith:(BJRoomGiftModel *)model { [self.giftImgV sd_setImageWithURL:[NSURL URLWithString:model.base_image]]; self.giftNameLab.text = model.gift_name; self.giftPriceLab.text = [NSString stringWithFormat:@"%@", model.gift_price]; [self.avatarImgV sd_setImageWithURL:[NSURL URLWithString:model.head_pic] placeholderImage:kDefaultUserIcon]; self.nicknameLab.text = model.nick_name; self.balanceLab.text = model.integral; } - (IBAction)onApplyUp:(id)sender { if (self.model == nil) { return; } NSDictionary *params = @{@"rid":C_string(self.rid), @"gid":C_string(self.model.gid), @"num":@(1), @"to_uid_list":C_string(self.model.uid), @"pack":@(1) }; [[AFNetworkRequset shared] postRequestWithParams:params Path:@"/api/gift/send_gift" Loading:NO Hud:YES Success:^(id _Nonnull responseDic) { [self removeFromSuperview]; } Failure:^(id _Nonnull errorData) { }]; } - (IBAction)onRecharge:(id)sender { [UIViewController goRechageCtrl]; } @end