- (IBAction)openTBShop:(UIButton*)sender {
NSString *urlStr1 = @"https://fenteng.tmall.com/?spm=a1z10.3-b-s.w4006-17215551185.2.49321e55xIquu1&q=%BC%D0%C3%DE&type=p&search=y&newHeader_b=s_from&searcy_type=item&from=.shop.pc_2_searchbutton&scene=taobao_shop";
// 天猫
urlStr1 = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,(CFStringRef)urlStr1,NULL,NULL,kCFStringEncodingUTF8));
if([urlStr1rangeOfString:@"tmall.com"].location!=NSNotFound) {
// NSString *itemId = [urlStr1 substringWithRange:NSMakeRange([urlStr1 rangeOfString:@"id"].location+3, 8)];
// NSString *urlString = [NSString stringWithFormat:@"tmall://tmallclient/?{\"action\":\"shopid:id=%@\"}",@"64585238"];跳转到店铺详情页
NSString *urlString = [NSString stringWithFormat:@"tmall://page.tm/shop?shopId=%@",@"64585238"];//跳转到天猫店铺主页
NSString *urlString = [NSString stringWithFormat:@"taobao://page.tb/shop?shopId=%@",@"36243719"];////跳转到淘宝店铺主页
NSURL *url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
return;
}
else
{
CGFloatwidth = [UIScreen mainScreen].bounds.size.width;
CGFloat height = [UIScreen mainScreen].bounds.size.height;
UIWebView*webView = [[UIWebViewalloc]initWithFrame:CGRectMake(0,0, width, height)];
_webView= webView;
webView.scrollView.delegate=self;
[webViewsetDelegate:self];
[self.viewaddSubview:webView];
NSURLRequest*request =[NSURLRequestrequestWithURL:[NSURLURLWithString:urlStr1]];
[_webViewloadRequest:request];
}
}
}
网友评论