691 lines
24 KiB
Objective-C
691 lines
24 KiB
Objective-C
//
|
|
// FishDoctorViewController.m
|
|
// Ifish
|
|
//
|
|
// Created by imac on 17/2/20.
|
|
// Copyright © 2017年 lianlian. All rights reserved.
|
|
//
|
|
|
|
#import "FishDoctorViewController.h"
|
|
#import "FishDocSection0ViewImgCell.h"
|
|
#import "FishDocSection0ViewlablCell.h"
|
|
#import "FishDocSection1View1Cell.h"
|
|
#import "FIshDocsection1TableView2Cell.h"
|
|
#import "FIshDocSectionTableView3Cell.h"
|
|
#import "UITextView+AddKeybordDoneVIew.h"
|
|
#define QESTIONVIEW_TAG 11116666
|
|
#define DOCTORGOLDCELLL 11117777
|
|
#import "IfishDoctorTiJiaoViewCell.h"
|
|
#import "IfishAiLiShopGoodsViewCell.h"
|
|
typedef NS_ENUM(NSInteger, IfishDoctorPayType){
|
|
|
|
IfishDoctorPayType10 = 0,
|
|
IfishDoctorPayType20,
|
|
IfishDoctorPayType50
|
|
};
|
|
#define TENBTN_TAG 1000001
|
|
#define TWENTY_TAG 1000002
|
|
#define FIFITY_TAG 1000003
|
|
#import "WoDeRenWuViewController.h"
|
|
#import "PushMasssageWebViewController.h"
|
|
#import "IfishGoodsData.h"
|
|
#import "IfishAlibcWebViewController.h"
|
|
#import <AlibcTradeSDK/AlibcTradeSDK.h>
|
|
#import "IfishDocAliGoodsListTitleViewCell.h"
|
|
@interface FishDoctorViewController ()<UITableViewDelegate,UITableViewDataSource,UITextViewDelegate,ShopTtemListDelegate>
|
|
@property(nonatomic,strong)UITableView *tableView;
|
|
@property(nonatomic) BOOL isEdite;
|
|
@property (nonatomic) IfishDoctorPayType paytype;
|
|
@property (nonatomic,strong) NSMutableArray *bannerDataArr;
|
|
@property (nonatomic) BOOL isPushed;
|
|
@property (nonatomic,strong) NSMutableArray *goodsArr;
|
|
@end
|
|
|
|
@implementation FishDoctorViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
// Do any additional setup after loading the view.
|
|
_bannerDataArr = [[NSMutableArray alloc] init];
|
|
_goodsArr = [[NSMutableArray alloc] init];
|
|
|
|
[self addTitleViewWithTitle:@"鱼医生"];
|
|
[self creatTab];
|
|
_isEdite = NO;
|
|
_isPushed = NO;
|
|
_paytype = IfishDoctorPayType10;
|
|
[self initBannerData];
|
|
[self loadGoodsData];
|
|
}
|
|
|
|
#pragma mark - 鱼医生广告位
|
|
|
|
-(void)initBannerData{
|
|
__weak typeof (self)weakSelf = self;
|
|
[AFHttpTool getIfishBannerData:IfishAdTypeYuYiSheng success:^(id response) {
|
|
|
|
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
|
NSString *result=reDic[@"result"];
|
|
if ([result isEqualToString:@"100"]) {
|
|
NSArray *data= reDic[@"data"];
|
|
if (data&&data.count!=0) {
|
|
for (NSDictionary *dic in data) {
|
|
IfishBannerData *bannerdata = [[IfishBannerData alloc] initWithDict:dic];
|
|
[_bannerDataArr addObject:bannerdata];
|
|
}
|
|
|
|
NSIndexPath *indexPath =[NSIndexPath indexPathForRow:0 inSection:0];
|
|
NSArray *arr =@[indexPath];
|
|
[weakSelf.tableView reloadRowsAtIndexPaths:arr withRowAnimation:UITableViewRowAnimationNone];
|
|
//[weakSelf.tableView reloadData];
|
|
}
|
|
|
|
}else{
|
|
|
|
//[weakSelf.view makeToast:@"广告位获取失败"];
|
|
}
|
|
|
|
|
|
} failure:^(NSError *err) {
|
|
|
|
}];
|
|
}
|
|
|
|
#pragma mark - 商品列表加载
|
|
-(void)loadGoodsData{
|
|
|
|
[AFHttpTool getIfishGoodsListWith:IfishGoodsTypeYuYinSheng success:^(id response) {
|
|
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
|
__weak typeof (self)weskSelf=self;
|
|
if ([reDic[@"result"] isEqualToString:@"100"]){
|
|
NSArray*goodsArr=reDic[@"data"];
|
|
for (NSDictionary *goodsDic in goodsArr) {
|
|
IfishGoodsData *goodsData=[[IfishGoodsData alloc] initWithDict:goodsDic];
|
|
|
|
[_goodsArr addObject:goodsData];
|
|
}
|
|
|
|
NSIndexSet *asset = [NSIndexSet indexSetWithIndex:2];
|
|
[weskSelf.tableView reloadSections:asset withRowAnimation:UITableViewRowAnimationNone];
|
|
}
|
|
|
|
} failure:^(NSError *err) {
|
|
NSLog(@"%@errrrrr",err);
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
-(void)viewWillAppear:(BOOL)animated{
|
|
[super viewWillAppear:animated];
|
|
|
|
//[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
|
|
//[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboradWillShow:) name:UIKeyboardWillShowNotification object:nil];
|
|
if (_isPushed) {
|
|
NSIndexPath *indexPath =[NSIndexPath indexPathForRow:0 inSection:0];
|
|
NSArray *arr =@[indexPath];
|
|
[self.tableView reloadRowsAtIndexPaths:arr withRowAnimation:UITableViewRowAnimationNone];
|
|
}
|
|
}
|
|
|
|
-(void)viewWillDisappear:(BOOL)animated{
|
|
[super viewWillDisappear:animated];
|
|
//[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
|
|
//[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
|
|
|
|
}
|
|
|
|
-(void)goBackAction
|
|
{
|
|
|
|
if (_isEdite) {
|
|
[self.navigationController popViewControllerAnimated:YES];
|
|
return;
|
|
}
|
|
|
|
FIshDocsection1TableView2Cell *cell =[self.view viewWithTag:QESTIONVIEW_TAG];
|
|
|
|
if (cell.qustionView.text.length >0) {
|
|
|
|
UIAlertController*ac=[UIAlertController alertControllerWithTitle:@"" message:@"您填写的内容尚未提交,是否退出?" preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
[self presentViewController:ac animated:YES completion:nil];
|
|
[ac addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction*action){
|
|
|
|
|
|
}]];
|
|
[ac addAction:[UIAlertAction actionWithTitle:@"退出" style:UIAlertActionStyleDefault handler:^(UIAlertAction*action){
|
|
|
|
[self.navigationController popViewControllerAnimated:YES];
|
|
|
|
}]];
|
|
|
|
}else{
|
|
|
|
[self.navigationController popViewControllerAnimated:YES];
|
|
}
|
|
|
|
}
|
|
|
|
-(void)creatTab{
|
|
|
|
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height) style:UITableViewStylePlain];
|
|
self.tableView.delegate = self;
|
|
self.tableView.dataSource = self;
|
|
self.tableView.scrollEnabled = YES;
|
|
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
|
self.tableView.showsVerticalScrollIndicator = NO;
|
|
self.tableView.backgroundColor = [UIColor whiteColor];
|
|
[self.view addSubview:self.tableView];
|
|
|
|
[self.tableView registerNib:[UINib nibWithNibName:@"FishDocSection0ViewImgCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"FishDocSection0ViewImgCell"];
|
|
|
|
}
|
|
|
|
#pragma mark - Table view data source
|
|
|
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
|
|
|
return 3;
|
|
}
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
if (section ==0) {
|
|
|
|
return 3;
|
|
|
|
}else if (section ==1){
|
|
return 1;
|
|
|
|
}else{
|
|
|
|
return 2;
|
|
}
|
|
|
|
}
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
if (indexPath.section ==0 && indexPath.row ==0) {
|
|
|
|
FishDocSection0ViewImgCell *cell= [tableView dequeueReusableCellWithIdentifier:@"FishDocSection0ViewImgCell" forIndexPath:indexPath];
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
|
|
if (_bannerDataArr.count !=0) {
|
|
NSArray *ads =self.bannerDataArr;
|
|
NSMutableArray *imgs = [[NSMutableArray alloc] init];
|
|
[ads enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
if ([obj isKindOfClass:[IfishBannerData class]]) {
|
|
IfishBannerData *banner = (IfishBannerData *)obj;
|
|
[imgs addObject:banner.adImage];
|
|
}
|
|
|
|
}];
|
|
|
|
cell.doctorAdview.adList = imgs;
|
|
__weak typeof (self)weakSelf = self;
|
|
cell.doctorAdview.tapActionBlock =^(LXAdScrollView *adScrollView) {
|
|
IfishBannerData *bdata = _bannerDataArr[adScrollView.currentPage];
|
|
[weakSelf tapAdWithLink:bdata.adLink];
|
|
};
|
|
|
|
}else{
|
|
//默认加载本地
|
|
cell.doctorAdview.adList = @[@"fishdoctor_banner"];
|
|
cell.doctorAdview.tapActionBlock =^(LXAdScrollView *adScrollView) {
|
|
|
|
};
|
|
}
|
|
return cell;
|
|
}else if (indexPath.section ==0 && indexPath.row ==1){
|
|
|
|
FishDocSection1View1Cell *cell = [tableView dequeueReusableCellWithIdentifier:@"FishDocSection1View1Cell"];
|
|
if (!cell) {
|
|
cell = [[[NSBundle mainBundle]loadNibNamed:@"FishDocSection1View1Cell" owner:self options:nil]lastObject];
|
|
|
|
}
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
return cell;
|
|
}else if (indexPath.section ==0 && indexPath.row ==2){
|
|
FIshDocsection1TableView2Cell *cell = [tableView dequeueReusableCellWithIdentifier:@"FIshDocsection1TableView2Cell"];
|
|
if (!cell) {
|
|
cell = [[[NSBundle mainBundle]loadNibNamed:@"FIshDocsection1TableView2Cell" owner:self options:nil]lastObject];
|
|
|
|
}
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
cell.tag =QESTIONVIEW_TAG;
|
|
cell.qustionView.delegate =self;
|
|
//[cell.qustionView keybordViewAddDoneView];
|
|
return cell;
|
|
}else if (indexPath.section ==1 && indexPath.row ==0){
|
|
|
|
IfishDoctorTiJiaoViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"IfishDoctorTiJiaoViewCell"];
|
|
if (!cell) {
|
|
cell = [[[NSBundle mainBundle]loadNibNamed:@"IfishDoctorTiJiaoViewCell" owner:self options:nil]lastObject];
|
|
|
|
}
|
|
cell.tag = DOCTORGOLDCELLL;
|
|
[cell.tenGoldBtn addTarget:self action:@selector(goldBtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
cell.tenGoldBtn.tag = TENBTN_TAG;
|
|
[cell.twentyGoldBtn addTarget:self action:@selector(goldBtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
cell.twentyGoldBtn.tag = TWENTY_TAG;
|
|
[cell.fiftyGoldBtn addTarget:self action:@selector(goldBtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
cell.fiftyGoldBtn.tag = FIFITY_TAG;
|
|
[cell.tijiaoBtn addTarget:self action:@selector(tiJiaoBtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
cell.tijiaoBtn.backgroundColor = RGB(67,186, 255);
|
|
|
|
[cell.getMoreGoldLabel addTarget:self action:@selector(getMoreGoldAction) forControlEvents:UIControlEventTouchUpInside];
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
[cell loadCurrentLael];
|
|
return cell;
|
|
|
|
}else if (indexPath.section ==2&&indexPath.row==0){
|
|
|
|
|
|
IfishDocAliGoodsListTitleViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"IfishDocAliGoodsListTitleViewCell"];
|
|
if (!cell) {
|
|
cell = [[[NSBundle mainBundle]loadNibNamed:@"IfishDocAliGoodsListTitleViewCell" owner:self options:nil]lastObject];
|
|
|
|
}
|
|
return cell;
|
|
|
|
}else if (indexPath.section ==2&&indexPath.row==1){
|
|
static NSString *identfire=@"IfishAiLiShopGoodsViewCell";
|
|
|
|
IfishAiLiShopGoodsViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identfire];
|
|
|
|
if (!cell) {
|
|
|
|
cell=[[IfishAiLiShopGoodsViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identfire];
|
|
}
|
|
cell.delegate = self;
|
|
[cell setGoodsdataArr:_goodsArr];
|
|
[cell refreshCollellction];
|
|
return cell;
|
|
|
|
|
|
}
|
|
|
|
// else if (indexPath.section ==1 && indexPath.row ==2){
|
|
//
|
|
// FIshDocSectionTableView3Cell *cell = [tableView dequeueReusableCellWithIdentifier:@"FIshDocSectionTableView3Cell"];
|
|
// if (!cell) {
|
|
// cell = [[[NSBundle mainBundle]loadNibNamed:@"FIshDocSectionTableView3Cell" owner:self options:nil]lastObject];
|
|
//
|
|
// }
|
|
// [cell.tiJiaoBtn addTarget:self action:@selector(tiJiaoBtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
//
|
|
// cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
// return cell;
|
|
// }
|
|
|
|
return nil;
|
|
|
|
}
|
|
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
if (indexPath.section ==0 &&indexPath.row ==0) {
|
|
|
|
return self.view.frame.size.width * 0.427;
|
|
|
|
}else if (indexPath.section ==0 &&indexPath.row ==1){
|
|
|
|
return 44;
|
|
|
|
}else if (indexPath.section ==0 &&indexPath.row ==2){
|
|
|
|
return self.view.frame.size.width * 0.25;
|
|
|
|
}else if (indexPath.section ==1 &&indexPath.row ==0){
|
|
|
|
return 206;
|
|
|
|
}else if (indexPath.section ==2 &&indexPath.row ==0){
|
|
|
|
return 30.0;
|
|
|
|
}else if (indexPath.section ==2&&indexPath.row ==1){
|
|
CGFloat Itemwidth = (kScreenSize.width-1)/2;
|
|
CGFloat ItemH = Itemwidth*1.38 +1;
|
|
if (_goodsArr.count!=0) {
|
|
|
|
int total = (int)[_goodsArr count];
|
|
int rowCount =total%2==0?total/2:total/2+1;
|
|
return ItemH*rowCount;
|
|
}
|
|
return ItemH*2;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
|
if (section ==2) {
|
|
|
|
return 10.0f;
|
|
}
|
|
return 0.1f;
|
|
|
|
}
|
|
|
|
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
|
|
|
|
UIView *header=[[UIView alloc] init];
|
|
header.backgroundColor = TABLE_BACKGROUD_COLOR;
|
|
return header;
|
|
|
|
}
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
[super didReceiveMemoryWarning];
|
|
// Dispose of any resources that can be recreated.
|
|
}
|
|
|
|
/*
|
|
#pragma mark - Navigation
|
|
|
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
|
// Get the new view controller using [segue destinationViewController].
|
|
// Pass the selected object to the new view controller.
|
|
}
|
|
*/
|
|
|
|
#pragma mark - questionTextViewDelegate
|
|
|
|
#pragma mark--UITextViewDelegate
|
|
// 设置textView的默认提示文字
|
|
-(void)textViewDidChange:(UITextView *)textView{
|
|
|
|
FIshDocsection1TableView2Cell *cell =[self.view viewWithTag:QESTIONVIEW_TAG];
|
|
if (textView.text.length ==0) {
|
|
|
|
[cell.palceHoolderLab setHidden:NO];
|
|
|
|
}else{
|
|
|
|
[cell.palceHoolderLab setHidden:YES];
|
|
}
|
|
}
|
|
|
|
-(void)textViewDidBeginEditing:(UITextView *)textView{
|
|
FIshDocsection1TableView2Cell *cell =[self.view viewWithTag:QESTIONVIEW_TAG];
|
|
[cell.palceHoolderLab setHidden:YES];
|
|
|
|
}
|
|
|
|
-(BOOL)textViewShouldBeginEditing:(UITextView *)textView{
|
|
|
|
return YES;
|
|
}
|
|
|
|
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
|
|
if ([text isEqualToString:@"\n"]) {
|
|
FIshDocsection1TableView2Cell *cell =[self.view viewWithTag:QESTIONVIEW_TAG];
|
|
if (textView == cell.qustionView) {
|
|
if (textView.text.length ==0) {
|
|
[cell.palceHoolderLab setHidden:NO];
|
|
|
|
}else{
|
|
[cell.palceHoolderLab setHidden:YES];
|
|
}
|
|
|
|
[cell.qustionView resignFirstResponder];
|
|
}
|
|
return NO;
|
|
}
|
|
return YES;
|
|
|
|
}
|
|
|
|
- (void)keyboradWillShow:(NSNotification *)notification{
|
|
FIshDocsection1TableView2Cell *cell =[self.view viewWithTag:QESTIONVIEW_TAG];
|
|
CGRect keyboardFrame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
|
|
|
|
CGRect cellRect = [cell convertRect:cell.bounds toView:self.view];
|
|
|
|
CGFloat buttonMargin =(cellRect.origin.y + cellRect.size.height + 10);
|
|
|
|
CGFloat transformY = keyboardFrame.origin.y - buttonMargin;
|
|
|
|
double duration = [[notification.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
|
|
[UIView animateWithDuration:duration animations:^{
|
|
|
|
if (keyboardFrame.origin.y < self.view.frame.size.height) {
|
|
self.view.transform = CGAffineTransformMakeTranslation(0,transformY);
|
|
}else{
|
|
self.view.transform = CGAffineTransformMakeTranslation(0, 0);
|
|
}
|
|
NSLog(@"transformY%f",transformY);
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
-(void)keyboardWillHide:(NSNotification *)notify {
|
|
|
|
double duration = [[notify.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
|
|
|
|
[UIView animateWithDuration:duration animations:^{
|
|
|
|
self.view.transform = CGAffineTransformMakeTranslation(0,0);
|
|
}];
|
|
}
|
|
|
|
#pragma mark - 10 金币
|
|
|
|
-(void)goldBtnAction:(UIButton*)btn{
|
|
|
|
[self resetBtnsImg:btn];
|
|
|
|
}
|
|
|
|
#pragma mark - 20 金币
|
|
|
|
-(void)twentyGoldBtnAction:(UIButton*)btn{
|
|
_paytype = IfishDoctorPayType20;
|
|
|
|
}
|
|
|
|
#pragma mark - 50 金币
|
|
|
|
-(void)fiftyGoldBtnAction{
|
|
_paytype = IfishDoctorPayType50;
|
|
}
|
|
|
|
-(void)resetBtnsImg:(UIButton *)btn{
|
|
|
|
IfishDoctorTiJiaoViewCell *cell = [self.view viewWithTag:DOCTORGOLDCELLL];
|
|
switch (btn.tag) {
|
|
case TENBTN_TAG:
|
|
{
|
|
_paytype = IfishDoctorPayType10;
|
|
cell.tenLabe.textColor = RGB(254, 131, 134);
|
|
cell.twentyLabel.textColor = RGB(153, 153, 153);
|
|
cell.fifiTyLabel.textColor = RGB(153, 153, 153);
|
|
|
|
[cell.tenGoldBtn setBackgroundImage:[UIImage imageNamed:@"fishdoctor_iocn_default_gold"] forState:UIControlStateNormal];
|
|
[cell.twentyGoldBtn setBackgroundImage:[UIImage imageNamed:@"fishdoctor_iocn_default_twentygold"] forState:UIControlStateNormal];
|
|
[cell.fiftyGoldBtn setBackgroundImage:[UIImage imageNamed:@"fishdoctor_iocn_default_fiftygold"] forState:UIControlStateNormal];
|
|
|
|
}
|
|
break;
|
|
|
|
case TWENTY_TAG:
|
|
{
|
|
_paytype = IfishDoctorPayType20;
|
|
cell.tenLabe.textColor = RGB(153, 153, 153);
|
|
cell.twentyLabel.textColor = RGB(254, 131, 134);
|
|
cell.fifiTyLabel.textColor = RGB(153, 153, 153);
|
|
[cell.twentyGoldBtn setBackgroundImage:[UIImage imageNamed:@"fishdoctor_iocn__twentygold"] forState:UIControlStateNormal];
|
|
[cell.tenGoldBtn setBackgroundImage:[UIImage imageNamed:@"fishdoctor_iocn_gold"] forState:UIControlStateNormal];
|
|
[cell.fiftyGoldBtn setBackgroundImage:[UIImage imageNamed:@"fishdoctor_iocn_default_fiftygold"] forState:UIControlStateNormal];
|
|
|
|
}
|
|
break;
|
|
|
|
case FIFITY_TAG:
|
|
{
|
|
_paytype = IfishDoctorPayType50;
|
|
cell.tenLabe.textColor = RGB(153, 153, 153);
|
|
cell.twentyLabel.textColor = RGB(153, 153, 153);
|
|
cell.fifiTyLabel.textColor = RGB(254, 131, 134);
|
|
[cell.fiftyGoldBtn setBackgroundImage:[UIImage imageNamed:@"fishdoctor_iocn__fiftygold"] forState:UIControlStateNormal];
|
|
[cell.tenGoldBtn setBackgroundImage:[UIImage imageNamed:@"fishdoctor_iocn_gold"] forState:UIControlStateNormal];
|
|
[cell.twentyGoldBtn setBackgroundImage:[UIImage imageNamed:@"fishdoctor_iocn_default_twentygold"] forState:UIControlStateNormal];
|
|
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
#pragma mark - tiJiaoBtnAction
|
|
|
|
-(void)tiJiaoBtnAction:(UIButton*)btn{
|
|
|
|
IfishUserAsset *useaseet =[dataContorl getAllIfishUserAsset];
|
|
if (useaseet.goldValue <10) {
|
|
|
|
[self.view makeToast:@"金币不足"];
|
|
return;
|
|
}
|
|
|
|
FIshDocsection1TableView2Cell *cell =[self.view viewWithTag:QESTIONVIEW_TAG];
|
|
if (cell.qustionView.text.length==0) {
|
|
|
|
[self.view makeToast:@"问题内容不能为空"];
|
|
return;
|
|
}
|
|
|
|
if (cell.qustionView.text.length>200) {
|
|
[self.view makeToast:@"问题内容不能超过200字"];
|
|
return;
|
|
}
|
|
|
|
|
|
NSString *payTourSum =nil;
|
|
switch (_paytype) {
|
|
|
|
case IfishDoctorPayType10:
|
|
{
|
|
payTourSum = @"0";
|
|
}
|
|
break;
|
|
case IfishDoctorPayType20:
|
|
{
|
|
payTourSum = @"1";
|
|
}
|
|
break;
|
|
case IfishDoctorPayType50:
|
|
{
|
|
payTourSum = @"2";
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
btn.userInteractionEnabled=NO;
|
|
btn.backgroundColor=[UIColor lightGrayColor];
|
|
NSString *userId = [dataContorl dataControlGetUserIdInfo];
|
|
__weak typeof (self) weakSelf = self;
|
|
[AFHttpTool fishDoctorQuestion:userId questionContent:cell.qustionView.text payTourSum:payTourSum success:^(id response) {
|
|
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
|
NSString *result=reDic[@"result"];
|
|
btn.userInteractionEnabled = YES;
|
|
btn.backgroundColor = RGB(67, 186, 255);
|
|
if ([result isEqualToString:@"100"]) {
|
|
NSDictionary *data=reDic[@"data"];
|
|
IfishUserAsset *userAsset = [dataContorl getAllIfishUserAsset];
|
|
userAsset.goldValue = [[data objectForKey:@"goldValue"] integerValue];
|
|
[dataContorl resetUserAsset:userAsset];
|
|
[weakSelf.view makeToast:@"提交成功,请耐心等待商家解答。"];
|
|
IfishDoctorTiJiaoViewCell *cell = [self.view viewWithTag:DOCTORGOLDCELLL];
|
|
[cell loadCurrentLael];
|
|
|
|
FIshDocsection1TableView2Cell *quescell =[self.view viewWithTag:QESTIONVIEW_TAG];
|
|
[quescell.palceHoolderLab setHidden:NO];
|
|
quescell.qustionView.text = @"";
|
|
_isEdite = YES;
|
|
//鱼医生提问加金币
|
|
[[IfishUserObsever sharedInstance] addGoldWith:IFISHDOCTOR addType:IFISHADDGOLDTYPE1];
|
|
}else if ([result isEqualToString:@"215"]){
|
|
[weakSelf.view makeToast:@"金币不足"];
|
|
}else{
|
|
[weakSelf.view makeToast:@"请求错误"];
|
|
}
|
|
|
|
} failure:^(NSError *err) {
|
|
btn.userInteractionEnabled = YES;
|
|
btn.backgroundColor = RGB(67, 186, 255);
|
|
[weakSelf.view makeToast:@"网络异常"];
|
|
}];
|
|
|
|
}
|
|
|
|
#pragma mark- 如何获取更多金币
|
|
|
|
-(void)getMoreGoldAction{
|
|
_isPushed = YES;
|
|
WoDeRenWuViewController *rewuVC= [[WoDeRenWuViewController alloc] init];
|
|
self.hidesBottomBarWhenPushed = YES;
|
|
[self.navigationController pushViewController:rewuVC animated:YES];
|
|
|
|
}
|
|
|
|
#pragma mark - banner 点击事件
|
|
|
|
-(void)tapAdWithLink:(NSString *)pushlink
|
|
{
|
|
if (![pushlink isKindOfClass:[NSNull class]] && pushlink &&![pushlink isEqualToString:@""]) {
|
|
_isPushed = YES;
|
|
//字条串是否包含有某字符串
|
|
if ([pushlink rangeOfString:@"taobao"].location == NSNotFound) {
|
|
self.hidesBottomBarWhenPushed = YES;
|
|
PushMasssageWebViewController*webVC=[[PushMasssageWebViewController alloc]init];
|
|
webVC.pushlink =pushlink;
|
|
webVC.pushtitle = @"详情";
|
|
[self.navigationController pushViewController:webVC animated:YES];
|
|
self.hidesBottomBarWhenPushed = NO;
|
|
|
|
}else {
|
|
|
|
[self tapTtemListAt:pushlink];
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
#pragma mark - 商品列表点击事件
|
|
// 宝贝详情页面
|
|
-(void)tapTtemListAt:(NSString *)goodslink
|
|
{
|
|
//535991514644
|
|
//id<AlibcTradePage> page = [AlibcTradePageFactory itemDetailPage: @"535991514644"];
|
|
//根据链接打开页面
|
|
id<AlibcTradePage> page = [AlibcTradePageFactory page:goodslink];
|
|
AlibcTradeShowParams* showParam = [[AlibcTradeShowParams alloc] init];
|
|
showParam.openType = AlibcOpenTypeH5;
|
|
|
|
//自定义web
|
|
IfishAlibcWebViewController* myView = [[IfishAlibcWebViewController alloc] init];
|
|
NSInteger ret = [[AlibcTradeSDK sharedInstance].tradeService show:self.navigationController webView:myView.webView page:page showParams:showParam taoKeParams:nil trackParam:nil tradeProcessSuccessCallback:^(AlibcTradeResult * _Nullable result) {
|
|
|
|
} tradeProcessFailedCallback:^(NSError * _Nullable error) {
|
|
|
|
}]; //返回1,说明h5打开,否则不应该展示页面
|
|
if (ret == 1) {
|
|
|
|
self.hidesBottomBarWhenPushed = YES;
|
|
[self.navigationController pushViewController:myView animated:YES];
|
|
//[self presentViewController:myView animated:YES completion:^{
|
|
|
|
//}];
|
|
}
|
|
}
|
|
|
|
|
|
@end
|