123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- //
- // YOUPAILZBigCastChargeSettingVC.m
- // MSYOUPAI
- //
- // Created by CY on 2022/3/9.
- // Copyright © 2022 MS. All rights reserved.
- //
- #import "YOUPAILZBigCastChargeSettingVC.h"
- #import "YOUPAIMineNickNameCell.h"
- #import "YOUPAIZYSettingCell.h"
- #import "YOUPAILZBigCastSetPriceModel.h"
- #import "YOUPAILZBigCastSetSelectedPricePickerVC.h"
- @interface YOUPAILZBigCastChargeSettingVC ()<UITableViewDelegate,UITableViewDataSource,UITextViewDelegate>
- @property (nonatomic, weak)UITableView *youpaiptableView;
- @property (nonatomic, strong)NSArray *youpaipdataSource;
- @property (nonatomic, strong) NSString *youpaipvideo_price; // 视频价格
- @property (nonatomic, strong) NSString *youpaipmsg_price; // 消息价格
- @property (nonatomic, assign) BOOL youpaipopen_video_status; // 是否开启视频 0关闭 1开启
- @property (nonatomic, strong) NSMutableArray <YOUPAILZBigCastSetPriceModel *>* youpaipchatPrices;
- @property (nonatomic, strong) NSMutableArray <YOUPAILZBigCastSetPriceModel *>* youpaipvideoPrices;
- @property (nonatomic, strong) NSString *youpaipanchorStarlevelUrl;
- @end
- @implementation YOUPAILZBigCastChargeSettingVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.view.backgroundColor = [UIColor whiteColor];
- self.title = @"收费设置";
- [self youpaifRequestGetAnchorSettingWithShowPick:0];
- [self youpaifinitData];
- [self youpaifloadAnchorStarlevel];
- }
- - (void)youpaifinitUI{
- UITableView *tableView = [[UITableView alloc]initWithFrame:CGRectMake(0,NavBarHeight, KScreenWidth, KScreenHeight-NavBarHeight) style:UITableViewStyleGrouped];
- tableView.showsVerticalScrollIndicator = NO;
- tableView.rowHeight = 54.0f;
- tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- tableView.backgroundColor = [UIColor whiteColor];
- tableView.estimatedSectionHeaderHeight = 0;
- tableView.estimatedSectionFooterHeight = 0;
- tableView.dataSource = self;
- tableView.delegate = self;
- [self.view addSubview:tableView];
- self.youpaiptableView = tableView;
-
- UIView *footerV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 150.0f)];
- self.youpaiptableView.tableFooterView = footerV;
-
- NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
- [paragraphStyle setLineSpacing:6];
- NSString *text = @"收费设置说明\n对方主动给你发消息,扣费依据本页设定;同性之间聊天不收费\n\n双方亲密度达到一定数值后,相互关注发消息免费\n星级越高,可设置的价格越高,查看如何提高星级";
- NSMutableAttributedString *str = [[NSMutableAttributedString alloc]initWithString:text];
-
- [str addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [text length])];
- [str addAttribute:NSLinkAttributeName value:@"upgradeLevel://" range:[text rangeOfString:@"如何提高星级"]];
-
- UITextView * textview = [[UITextView alloc]init];
- textview.editable = NO;
- textview.scrollEnabled = NO;
- textview.delegate = self;
- textview.backgroundColor = [UIColor clearColor];
- textview.font = LCFont(12);
- textview.attributedText = str;
- textview.textColor = LZA3AABEColor;
- textview.linkTextAttributes = @{NSForegroundColorAttributeName:LZ7C69FEColor,
- NSUnderlineStyleAttributeName:[NSNumber numberWithInt:NSUnderlineStyleNone]
- };
- [footerV addSubview:textview];
- [textview mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(14);
- make.width.mas_equalTo(KScreenWidth - 28.0f);
- make.top.offset(30.0f);
- make.height.offset(120.0f);
- }];
- }
- - (void)youpaifloadAnchorStarlevel{
- @weakify(self);
- [LCHttpHelper requestWithURLString:UserCenter parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self);
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- if ([[[dict objectForKey:@"data"] allKeys] containsObject:@"webUrl"]) {
- self.youpaipanchorStarlevelUrl = [NSString stringWithFormat:@"%@",[[[dict objectForKey:@"data"]objectForKey:@"webUrl"] objectForKey:@"anchorStarlevel"]];
- }
- }
- } failure:^(NSError *error) {
-
- }];
- }
- #pragma mark --UITextViewDelegate
- - (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange interaction:(UITextItemInteraction)interaction{
- if ([[URL scheme]isEqualToString:@"upgradeLevel"]) {// 如何提高星级
- ZCBaseWebVC * vc = [[ZCBaseWebVC alloc]init];
- vc.contentUrl = self.youpaipanchorStarlevelUrl;
- vc.needHideNav = YES;
- [self.navigationController pushViewController:vc animated:YES];
- return NO;
- }
- return YES;
- }
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
- return self.youpaipdataSource.count;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- NSDictionary *sectionModel = self.youpaipdataSource[section];
- NSArray *rows = [sectionModel objectForKey:@"rows"];
- return rows.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- NSDictionary *sectionModel = self.youpaipdataSource[indexPath.section];
- NSArray *rows = [sectionModel objectForKey:@"rows"];
- NSDictionary *cellModel = rows[indexPath.row];
- NSString *cellName = [cellModel objectForKey:@"cellName"];
- if ([cellName isEqual:@"YOUPAILZBigCastMoneySettingCell"]) {
- YOUPAILZBigCastMoneySettingCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
- if (cell == nil) {
- cell = [[YOUPAILZBigCastMoneySettingCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
- }
- cell.titleLab.text = [cellModel objectForKey:@"title"];
- if ([[cellModel objectForKey:@"type"] isEqual:@"message_price"]) {
- cell.vlaueLab.text = self.youpaipmsg_price;
- }else if ([[cellModel objectForKey:@"type"] isEqual:@"video_price"]){
- cell.vlaueLab.text = self.youpaipvideo_price;
- }
- return cell;
- }else if([cellName isEqual:@"YOUPAIZYSettingCell"]){
- YOUPAIZYSettingCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
- if (cell == nil) {
- cell = [[YOUPAIZYSettingCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
- }
- NSString *title = cellModel[@"title"];
- cell.youpaipheadLabel.text = title;
- cell.youpaiprightSwitch.hidden = NO;
- cell.youpaiparrowImgView.hidden = YES;
- cell.youpaiprightSwitch.selected = self.youpaipopen_video_status;
- [cell.youpaiprightSwitch addTarget:self action:@selector(youpaifopenVideoBtnClick:) forControlEvents:UIControlEventTouchUpInside];
- return cell;
- }
- return [UITableViewCell new];
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
- return CGFLOAT_MIN;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
- NSDictionary *sectionModel = self.youpaipdataSource[section];
- if ([[sectionModel objectForKey:@"hasFooter"] boolValue]) {
- return 6.0f;
- }
- return CGFLOAT_MIN;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
- NSDictionary *sectionModel = self.youpaipdataSource[indexPath.section];
- NSArray *rows = [sectionModel objectForKey:@"rows"];
- NSDictionary *cellModel = rows[indexPath.row];
- if ([[cellModel objectForKey:@"type"] isEqual:@"message_price"]) {
- [self youpaifshowChatPricePick];
- }else if ([[cellModel objectForKey:@"type"] isEqual:@"video_price"]){
- [self youpaifshowVideoPricePick];
- }
-
- }
- - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
- NSDictionary *sectionModel = self.youpaipdataSource[section];
- if ([[sectionModel objectForKey:@"hasFooter"] boolValue]) {
- UIView *footerV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 6)];
- footerV.backgroundColor = LZF7F8FAColor;
- return footerV;
- }
- return nil;
- }
- - (void)youpaifopenVideoBtnClick:(UIButton *)sender{
- sender.selected = !sender.selected;
- NSInteger status = 0;
- if (sender.selected == NO) {//将状态置为1空闲
- status = 0;
- }else{
- status = 1;
- }
- @weakify(self);
- [LCHttpHelper requestWithURLString:BigCastSetVideoStatus parameters:@{@"status":@(status)} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self);
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {
- if (status==1) {
- [LCSaveData saveVideoOpenStatu:YES];
- self.youpaipopen_video_status = YES;
- }else{
- [LCSaveData saveVideoOpenStatu:NO];
- self.youpaipopen_video_status = NO;
- }
- }
- [self.youpaiptableView reloadData];
- } failure:^(NSError *error) {
-
- }];
- }
- - (void)youpaifinitData{
- @weakify(self);
- [LCHttpHelper requestWithURLString:AnchorGetPrice parameters:@{} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self);
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- self.youpaipvideo_price = [[dict objectForKey:@"data"] objectForKey:@"video_price"];
- self.youpaipmsg_price = [[dict objectForKey:@"data"] objectForKey:@"msg_price"];
- self.youpaipopen_video_status = [[[dict objectForKey:@"data"] objectForKey:@"open_video_status"] boolValue];
- self.youpaipdataSource = @[
- @{@"hasFooter":@(YES),@"rows":@[@{@"cellName":@"YOUPAILZBigCastMoneySettingCell",@"title":@"消息价格",@"type":@"message_price"}]},
- @{@"hasFooter":@(NO),@"rows":@[
- @{@"cellName":@"YOUPAIZYSettingCell",@"title":@"视频接听",@"type":@"video_call"},
- @{@"cellName":@"YOUPAILZBigCastMoneySettingCell",@"title":@"视频价格设置",@"type":@"video_price"},
- ]},
- ];
-
- [self youpaifinitUI];
- }
- } failure:^(NSError *error) {
-
- }];
-
- }
- - (void)youpaifshowChatPricePick{
- if (self.youpaipchatPrices.count != 0) {
- YOUPAILZBigCastSetSelectedPricePickerVC *vc = [[YOUPAILZBigCastSetSelectedPricePickerVC alloc] init];
- vc.dataSouce = self.youpaipchatPrices;
- @weakify(self);
- [vc setConfirmBtnClickBlock:^(YOUPAILZBigCastSetPriceModel * _Nonnull model) {
- @strongify(self);
- [self youpaifSettingPriceWithModel:model type:@"5"];
- }];
- [self TFPresentVC:vc completion:nil];
- }else{
- [self youpaifRequestGetAnchorSettingWithShowPick:1];
- }
- }
- - (void)youpaifshowVideoPricePick{
- if (self.youpaipvideoPrices.count != 0) {
- YOUPAILZBigCastSetSelectedPricePickerVC *vc = [[YOUPAILZBigCastSetSelectedPricePickerVC alloc] init];
- vc.dataSouce = self.youpaipvideoPrices;
- @weakify(self);
- [vc setConfirmBtnClickBlock:^(YOUPAILZBigCastSetPriceModel * _Nonnull model) {
- @strongify(self);
- [self youpaifSettingPriceWithModel:model type:@"2"];
- }];
- [self TFPresentVC:vc completion:nil];
- }else{
- [self youpaifRequestGetAnchorSettingWithShowPick:2];
- }
- }
- - (void)youpaifSettingPriceWithModel:(YOUPAILZBigCastSetPriceModel *)model type:(NSString *)type{
- @weakify(self);
- [LCHttpHelper requestWithURLString:SetSkillPrice parameters:@{@"price_id":model.youpaipid,@"type":type} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self);
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- [ZCHUDHelper showTitle:@"价格设置成功"];
- if ([type isEqual:@"5"]) { // 文字
- self.youpaipmsg_price = [NSString stringWithFormat:@"%@%@/条",model.youpaipcoins,model.youpaipcontent];
- }else if ([type isEqual:@"2"]) { // 视频
- self.youpaipvideo_price = [NSString stringWithFormat:@"%@%@/分钟",model.youpaipcoins,model.youpaipcontent];
- }
- [self.youpaiptableView reloadData];
- }
- } failure:^(NSError *error) {
- }];
- }
- - (void)youpaifRequestGetAnchorSettingWithShowPick:(NSInteger)showPick{
- @weakify(self);
- [LCHttpHelper requestWithURLString:GetAnchorSetting parameters:@{} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self);
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- self.youpaipchatPrices = [YOUPAILZBigCastSetPriceModel mj_objectArrayWithKeyValuesArray:[[dict objectForKey:@"data"] objectForKey:@"chat"]];
- self.youpaipvideoPrices = [YOUPAILZBigCastSetPriceModel mj_objectArrayWithKeyValuesArray:[[dict objectForKey:@"data"] objectForKey:@"video"]];
- if (showPick == 1) {
- [self youpaifshowChatPricePick];
- }else if (showPick == 2){
- [self youpaifshowVideoPricePick];
- }
- }
- } failure:^(NSError *error) {
-
- }];
- }
- @end
|