123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- //
- // YOUPAILZWriteGameInfoView.m
- // VQU
- //
- // Created by CY on 2021/4/26.
- // Copyright © 2021 leo. All rights reserved.
- //
- #import "YOUPAILZWriteGameInfoView.h"
- #import "YOUPAILZRecordAudioView.h"
- #import "YOUPAILZGameModel.h"
- #import "LZPickerWindow.h"
- #import "UIViewController+TFPresent.h"
- #import "PGPickerView.h"
- @interface YOUPAILZWriteGameInfoView ()<LZPickerWindowDelegate,PGPickerViewDelegate,PGPickerViewDataSource>
- @property (nonatomic,readwrite) NSString *youpaiplevel; // 段位
- @property (nonatomic,readwrite) NSString *youpaipregion; // 大区
- @property (nonatomic,readwrite) NSString *youpaipprice; // 价格
- @property (nonatomic,weak) YOUPAILZRecordAudioView *youpaiprecordAudioView;
- @property (nonatomic,weak)UIButton *youpaipsubmitBtn;
- @property (nonatomic,strong)YOUPAILZGameModel *youpaipgameModel;
- @property (nonatomic,assign) NSInteger youpaipselectedBtnIndex;
- @property (nonatomic,strong) NSMutableArray <UILabel *>*youpaiplabs;
- @property (nonatomic,assign) NSInteger youpaippickerSelectedIndex;
- @property (nonatomic,assign) BOOL youpaipisVerifyState;
- @end
- @implementation YOUPAILZWriteGameInfoView
- - (instancetype)initWithModel:(YOUPAILZGameModel *)gameModel{
- if (self = [super init]) {
- self.youpaipgameModel = gameModel;
- [self youpaifsetupUI];
- }
- return self;
- }
- - (void)youpaifsetupUI{
-
- UIScrollView *scrollView = [[UIScrollView alloc] init];
- scrollView.showsVerticalScrollIndicator = NO;
- scrollView.showsHorizontalScrollIndicator = NO;
- scrollView.backgroundColor = HexColorFromRGB(0xF6F6F6);
- [self addSubview:scrollView];
- [scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.right.bottom.offset(0.0f);
- }];
-
-
- UIView *bgV = [[UIView alloc] init];
- bgV.backgroundColor = [UIColor whiteColor];
- [scrollView addSubview:bgV];
- [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.top.offset(0.0f);
- make.width.offset(KScreenWidth);
- }];
- self.youpaiplabs = [NSMutableArray array];
- NSArray *contents = @[@"段位:",@"可接大区:"];
- CGFloat height = 0.0f;
- for (NSInteger i = 0; i < contents.count; i ++) {
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.frame = CGRectMake(16.0f, 20.0f + i * 45.0f + (i + 1) * 5.0f, KScreenWidth - 32.0f, 45.0f);
- btn.backgroundColor = HexColorFromRGB(0xF6F6F6);
- btn.layer.cornerRadius = 8.0f;
- btn.clipsToBounds = YES;
- btn.tag = i;
- [btn addTarget:self action:@selector(youpaifbtnClick:) forControlEvents:UIControlEventTouchUpInside];
- UILabel *titleL = [[UILabel alloc] init];
- titleL.font = LCFont14;
- titleL.textColor = HexColorFromRGB(0x333333);
- titleL.text = contents[i];
- [btn addSubview:titleL];
- [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(19.0f);
- make.top.bottom.offset(0.0f);
- }];
-
- UIImageView *arrowImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_game_arrow"]];
- [btn addSubview:arrowImgV];
- [arrowImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.offset(-19.0f);
- make.centerY.equalTo(btn);
- make.size.mas_offset(CGSizeMake(14.0f, 14.0f));
- }];
-
- UILabel *contentL = [[UILabel alloc] init];
- contentL.font = LCFont14;
- contentL.textColor = HexColorFromRGB(0x333333);
- [btn addSubview:contentL];
- [contentL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(titleL.mas_right);
- make.top.bottom.offset(0.0f);
- }];
- [self.youpaiplabs addObject:contentL];
- [bgV addSubview:btn];
-
- height = btn.mj_y + btn.mj_h;
- }
- height += 25.0f;
-
- UIView *line = [[UIView alloc] init];
- line.backgroundColor = HexColorFromRGB(0xF6F6F6);
- [bgV addSubview:line];
- [line mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(0.0f);
- make.top.offset(height);
- make.height.offset(5.0f);
- make.width.offset(KScreenWidth);
- }];
-
- UILabel *audioL = [[UILabel alloc] init];
- audioL.font = LCFont17;
- audioL.textColor = HexColorFromRGB(0x333333);
- audioL.text = @"语音介绍";
- [bgV addSubview:audioL];
- [audioL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(16.0f);
- make.top.equalTo(line.mas_bottom).offset(16.0f);
- }];
- UILabel *audioDescL = [[UILabel alloc] init];
- audioDescL.font = LCFont12;
- audioDescL.textColor = HexColorFromRGB(0x999999);
- audioDescL.numberOfLines = 0;
- audioDescL.text = @"录制一段自我介绍语音(介绍自己擅长位置、英雄、游戏成就皆可)";
- [bgV addSubview:audioDescL];
- [audioDescL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(16.0f);
- make.width.offset(KScreenWidth - 32.0f);
- make.top.equalTo(audioL.mas_bottom).offset(5.0f);
- }];
-
- YOUPAILZRecordAudioView *recordAudioView = [[YOUPAILZRecordAudioView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, KScreenWidth, 195.0f) model:self.youpaipgameModel];
- [bgV addSubview:recordAudioView];
- self.youpaiprecordAudioView = recordAudioView;
- [recordAudioView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(0.0f);
- make.top.equalTo(audioDescL.mas_bottom);
- make.width.offset(KScreenWidth);
- make.height.offset(195.0f);
- make.bottom.offset(0.0f);
- }];
-
- UIButton *submitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- submitBtn.layer.cornerRadius = 24.0f;
- submitBtn.clipsToBounds = YES;
- submitBtn.backgroundColor = HexColorFromRGB(0xA7A9FD);
- submitBtn.titleLabel.font = LCFont(20.0f);
- [submitBtn setTitle:@"提交审核" forState:UIControlStateNormal];
- [submitBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- [submitBtn addTarget:self action:@selector(youpaifsubmitBtnClick:) forControlEvents:UIControlEventTouchUpInside];
- [scrollView addSubview:submitBtn];
- self.youpaipsubmitBtn = submitBtn;
- [submitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(60.0f);
- make.width.offset(KScreenWidth-120.0f);
- make.top.equalTo(bgV.mas_bottom).offset(100.0f);
- make.height.offset(48.0f);
- }];
-
- [scrollView layoutIfNeeded];
- scrollView.contentSize = CGSizeMake(KScreenWidth, submitBtn.mj_h + submitBtn.mj_y + 56.0f);
- }
- - (void)youpaifbtnClick:(UIButton *)sender{
- if (self.youpaipisVerifyState) {
- return;
- }
- self.youpaipselectedBtnIndex = sender.tag;
- LZPickerWindow *vc = [[LZPickerWindow alloc] init];
- vc.isTouchDismiss = YES;
- vc.delegate = self;
- [[LCTools getCurrentVC] TFPresentVC:vc completion:^{}];
- vc.pickerView.dataSource = self;
- vc.pickerView.delegate = self;
- }
- - (void)youpaifsubmitBtnClick:(UIButton *)sender{
- if (![self.youpaipgameModel youpaifverifyGameInfo]) {
- return;
- }
- [ZCHUDHelper showWithStatus:@"上传中..."];
- [LCCommonHttp uploadWithImages:@[self.youpaipgameModel.youpaipselectedImage] Type:@"game/img" successBlock:^(NSArray<NSString *> *ossImagePaths) {
- if (ossImagePaths.count != 0) {
- self.youpaipgameModel.youpaipscreenshot = ossImagePaths[0];
- [LCCommonHttp uploadWithAudioPath:self.youpaipgameModel.youpaipaudioUrl.resourceSpecifier Type:@"game/mp3" successBlock:^(NSString *ossFilePath) {
- if (ossFilePath.length != 0) {
- self.youpaipgameModel.youpaipmp3 = ossFilePath;
- if (self.youpaipgameModel.youpaipmp3.length != 0 && self.youpaipgameModel.youpaipscreenshot.length != 0) {
- [self youpaifuploadFileFinish];
- if ([[NSFileManager defaultManager] fileExistsAtPath:self.youpaipgameModel.youpaipaudioUrl.resourceSpecifier]){
- [[NSFileManager defaultManager] removeItemAtPath:self.youpaipgameModel.youpaipaudioUrl.resourceSpecifier error:nil];
- }
- }
- }
- }];
- }
- }];
-
-
- }
- - (void)youpaifuploadFileFinish{
- NSDictionary *params = @{
- @"game_id":self.youpaipgameModel.youpaipid,
- @"screenshot":self.youpaipgameModel.youpaipscreenshot,
- @"mp3":self.youpaipgameModel.youpaipmp3,
- @"mp3_second":@(self.youpaipgameModel.youpaipaudioDuration),
- @"region":self.youpaipgameModel.youpaipselectedRegion.youpaipid,
- @"dan":self.youpaipgameModel.youpaipselectedLevel.youpaipid,
- };
- [LCHttpHelper requestWithURLString:GameCertificationSubmit parameters:params needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
- [ZCHUDHelper dismiss];
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {
- [self.youpaipsubmitBtn setTitle:@"平台审核中" forState:UIControlStateNormal];
- self.youpaipsubmitBtn.backgroundColor = HexColorFromRGB(0xCCCCCC);
- self.youpaipsubmitBtn.userInteractionEnabled = NO;
- [self youpaifremoveUploadGameImageVC];
- self.youpaipisVerifyState = YES;
- self.youpaipgameModel.youpaipapplying = 1;
- }else{
- [ZCHUDHelper showTitle:[dict objectForKey:@"message"]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
- }
- - (void)youpaifremoveUploadGameImageVC{
- NSArray *vcs = [LCTools getCurrentVC].navigationController.viewControllers;
- NSMutableArray *newVcs = vcs.mutableCopy;
- for (UIViewController *vc in newVcs) {
- if ([vc isKindOfClass:NSClassFromString(@"YOUPAILZGameCertificationVC")] && vc != [LCTools getCurrentVC]) {
- [newVcs removeObject:vc];
- break;
- }
- }
- [[LCTools getCurrentVC].navigationController setViewControllers:newVcs.copy];
- }
- #pragma mark - PGPickerViewDataSource
- // returns the number of 'columns' to display.
- - (NSInteger)numberOfComponentsInPickerView:(PGPickerView *)pickerView{
- return 1;
- }
- // returns the # of rows in each component..
- - (NSInteger)pickerView:(PGPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
- if (self.youpaipselectedBtnIndex == 0) {
- return self.youpaipgameModel.youpaipdans.count;
- }else{
- return self.youpaipgameModel.youpaipregions.count;
- }
- }
- - (NSString *)pickerView:(PGPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
- if (self.youpaipselectedBtnIndex == 0) {
- return self.youpaipgameModel.youpaipdans[row].youpaipname;
- }else{
- return self.youpaipgameModel.youpaipregions[row].youpaipname;
- }
- }
- #pragma mark - PGPickerViewDelegate
- - (void)pickerView:(PGPickerView *)pickerView title:(NSString *)title didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
- self.youpaippickerSelectedIndex = row;
- }
- #pragma mark - LZPickerWindowDelegate
- - (void)confirmClick{
- if (self.youpaipselectedBtnIndex == 0) {
- self.youpaipgameModel.youpaipselectedLevel = self.youpaipgameModel.youpaipdans[self.youpaippickerSelectedIndex];
- self.youpaiplabs[self.youpaipselectedBtnIndex].text = self.youpaipgameModel.youpaipselectedLevel.youpaipname;
- }else{
- self.youpaipgameModel.youpaipselectedRegion = self.youpaipgameModel.youpaipregions[self.youpaippickerSelectedIndex];
- self.youpaiplabs[self.youpaipselectedBtnIndex].text = self.youpaipgameModel.youpaipselectedRegion.youpaipname;
- }
-
- }
- @end
|