宠物店修改
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#import "ESPTouchResult.h"
|
||||
#import "ESPTouchTask.h"
|
||||
#import "IfishDataUnity.h"
|
||||
#import "MyMD5.h"
|
||||
#import <GWP2P/GWP2P.h>
|
||||
@interface ConnectingAquarVC ()<IFishHotpotUDPHelperDelegate>
|
||||
Strong HKPieChartView *progressView;
|
||||
@@ -67,6 +68,7 @@ Copy NSString *deviceId;
|
||||
// // Do any additional setup after loading the view.
|
||||
self.timer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(timerAction) userInfo:nil repeats:YES];
|
||||
[[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
|
||||
[self showStoreNameView];
|
||||
|
||||
}
|
||||
//AP模式配网
|
||||
@@ -263,7 +265,7 @@ Copy NSString *deviceId;
|
||||
|
||||
BOOL networkOk = NO;
|
||||
AFNetworkReachabilityStatus status = [AFNetworkReachabilityManager sharedManager].networkReachabilityStatus;
|
||||
if (status == AFNetworkReachabilityStatusReachableViaWiFi) {
|
||||
if (status == AFNetworkReachabilityStatusReachableViaWiFi||status == AFNetworkReachabilityStatusUnknown) {
|
||||
if (![[self currentWifiSSID].lowercaseString hasPrefix:@"ifish"]) {
|
||||
networkOk = YES;
|
||||
}
|
||||
@@ -285,9 +287,20 @@ Copy NSString *deviceId;
|
||||
self.bindTimer = nil;
|
||||
}
|
||||
self.retryTimes = 0;
|
||||
[self bindDeviceWithSsid:self.macAddress];
|
||||
if (self.deviceType==DEVICEPETS)
|
||||
{
|
||||
[self showStoreNameView];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self bindDeviceWithSsid:self.macAddress];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
- (void)udpHelperMessage:(NSString *)msg {
|
||||
self.HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
|
||||
self.HUD.mode = MBProgressHUDModeIndeterminate;
|
||||
@@ -298,6 +311,55 @@ Copy NSString *deviceId;
|
||||
[self.timer invalidate];
|
||||
self.timer = nil;
|
||||
}
|
||||
-(UIView *)mask
|
||||
{
|
||||
if (!_mask)
|
||||
{
|
||||
UIView*mask=[[UIView alloc]initWithFrame:self.view.bounds];
|
||||
mask.backgroundColor=[UIColor lightGrayColor];
|
||||
mask.alpha=0.5;
|
||||
_mask=mask;
|
||||
UITapGestureRecognizer*tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(dismissStore)];
|
||||
[mask addGestureRecognizer:tap];
|
||||
}
|
||||
|
||||
return _mask;
|
||||
}
|
||||
-(void)dismissStore
|
||||
{
|
||||
[self.storeNameView removeFromSuperview];
|
||||
[self.mask removeFromSuperview];
|
||||
[self.progressView endProgressWithString:@"绑定已经取消..."];
|
||||
}
|
||||
-(void)showStoreNameView
|
||||
{
|
||||
[self.HUD hide:YES];
|
||||
[self.storeNameView removeFromSuperview];
|
||||
StoreNameView*store=[[[NSBundle mainBundle] loadNibNamed:@"StoreNameView" owner:self options:nil] lastObject];
|
||||
store.frame=CGRectMake((SCREEN_WIDTH-280)/2.0, 100, 280, 280);
|
||||
|
||||
self.storeNameView=store;
|
||||
WEAK_SELF;
|
||||
store.cancelBlock=^(){
|
||||
[weakSelf.mask removeFromSuperview];
|
||||
[weakSelf.storeNameView removeFromSuperview];
|
||||
[weakSelf.HUD show:YES];
|
||||
[weakSelf.progressView endProgressWithString:@"绑定已经取消..."];
|
||||
|
||||
};
|
||||
store.sureBlock=^(NSString*name)
|
||||
{
|
||||
[weakSelf.mask removeFromSuperview];
|
||||
[weakSelf.storeNameView removeFromSuperview];
|
||||
weakSelf.storeName=name;
|
||||
[self bindDeviceWithSsid:self.macAddress];
|
||||
[weakSelf.HUD show:YES];
|
||||
};
|
||||
|
||||
[self.view addSubview:self.mask];
|
||||
[self.view addSubview:self.storeNameView];
|
||||
|
||||
}
|
||||
#pragma mark - bind
|
||||
-(void)bindDeviceWithSsid:(NSString*)bssid{
|
||||
NSLog(@"设备bssid_%@",bssid);
|
||||
@@ -306,7 +368,21 @@ Copy NSString *deviceId;
|
||||
self.HUD.labelText = @"正在绑定设备";
|
||||
[self appendTrakContent:[NSString stringWithFormat:@"绑定参数 userID:%@", userId]];
|
||||
[self appendTrakContent:[NSString stringWithFormat:@"绑定参数 macaddress:%@", bssid]];
|
||||
[AFHttpTool bindDeviceWithUserId:userId macAddress:bssid success:^(id response) {
|
||||
NSString*url=[NSString stringWithFormat:@"%@%@",kBindDevice,userId];
|
||||
NSMutableDictionary*bind=[[NSMutableDictionary alloc]initWithDictionary:@{@"macAddress":bssid}];
|
||||
NSString* timestamp=[NSString stringWithFormat:@"%lld",[[NSDate date] timeIntervalSince1970]*1000];
|
||||
NSString*token=[MyMD5 md5:[NSString stringWithFormat:@"%@%@ifish8",userId,timestamp]];
|
||||
|
||||
if (self.deviceType==DEVICEPETS)
|
||||
{
|
||||
url=[NSString stringWithFormat:@"%@",[NSString stringWithFormat:@"%@/api/user/bindPetDevice.do",JIEKOUPORT]];
|
||||
bind[@"token"]=token;
|
||||
bind[@"timestamp"]=timestamp;
|
||||
bind[@"storeName"]=self.storeName.length?self.storeName:@"宠物店";
|
||||
bind[@"userId"]=userId;
|
||||
|
||||
}
|
||||
[AFHttpTool requestWihtMethod:RequestMethodTypePost url:url params:bind success:^(id response) {
|
||||
[self endProgress];
|
||||
self.isBindingDevice = NO;
|
||||
self.macAddress = nil;
|
||||
|
||||
Reference in New Issue
Block a user