zoukankan      html  css  js  c++  java
  • 跳转到天猫客户端

    NSString *urlString = @"http://detail.tmall.com/item.htm?spm=a215v.7217581.610138.10.sO6nZp&id=36615660686&areaId=410100&cat_id=2&rn=ebe1860b08257aacbac424ed12d5208c&user_id=1098342976&is_b=1";
                NSURL *url;
                if([urlString rangeOfString:@"detail.tmall."].location != NSNotFound)   //判断Url是否是天猫商品的链接
                {
                    NSRange range = [urlString rangeOfString:@"id="]; //在URL中找到商品的ID
                    if(range.location != NSNotFound)
                    {
                        NSString *productID = [urlString substringWithRange:NSMakeRange(range.location + 3, 11)];
                        NSString *appUrl = [NSString stringWithFormat:@"tmall://tmallclient/?{"action":"item:id=%@"}", productID];
                        url = [NSURL URLWithString:[appUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
                        if ([[UIApplication sharedApplication] canOpenURL:url])
                        {
                            // 如果已经安装天猫客户端,就使用客户端打开链接
                            [[UIApplication sharedApplication] openURL:url];
                        }
                        else
                        {
                            //客户手机上没有装天猫客户端,这时启动浏览器以网页的方式浏览该商品。
                            url = [NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
                            [[UIApplication sharedApplication] openURL:url];
                        }
                    }
                }

  • 相关阅读:
    认识v$fixed_view_definition
    V$、GV$、X$、V_$、GV_$之间的关系
    ORACLE OEM
    ORACLE表空间
    linux
    系统数据库备份恢复
    linux -- #!/bin/bash
    linux -- ubuntu 脚本开机自启动
    linux -- chown修改文件拥有者和所在组
    php -- php控制linux关机、重启、注销
  • 原文地址:https://www.cnblogs.com/tian-sun/p/5019935.html
Copyright © 2011-2022 走看看