如何识别是否为微信浏览器打开,并弹出图片?

WBOY
Libérer: 2016-09-25 09:23:09
original
1146 Les gens l'ont consulté

用微信打开这个网站的首页点击商品的时候回出现这张图片:微信内无法购买,请点击右上角。
但是在商品分享的页面就没有了这个识别,点击去天猫抢购直接就跳转到淘宝了,我想在点击抢购的时候也加一个识别,但是不知道在哪里增加,这个程序用的thinkPHP框架,需要哪里的代码我也不清楚,谁能帮帮我吗

如何识别是否为微信浏览器打开,并弹出图片?
如何识别是否为微信浏览器打开,并弹出图片?

<code>


<include file="public:head"></include>
<script src="__STATIC__/jwap/js/jquery-1.8.0.js"></script>
<link type="text/css" rel="stylesheet" href="__STATIC__/jwap/css/alert.css">
<link type="text/css" rel="stylesheet" href="__STATIC__/jwap/css/global.css">


       
<div class="main">
<include file="public:header"></include>
<include file="public:top"></include>
        <div class="app">
    <header class="head" id="head">
        <div class="fixtop">
                        <span id="t-find"><a class="btn btn-left btn-back" href="javascript:window.history.go(-1)" title="返回上一页"></a></span>
                        <span id="t-index">商品详情</span>
                        <span id="t-user"><a class="btn btn-left btn-back-home" href="%7B:C('ftx_header_html')%7D" title="返回首页"></a></span>
                    </div>        
    </header>
        
            <div id="item">
                <div class="item-good">
                    <div class="img_show">
                        <ul id="target" class="clear">
                            <li><a href="%7B:U('jump/index',array('id'=>%24item%5B'num_iid'%5D))%7D" rel="nofollow"> <img  src="%7B%24item%5B'pic_url'%5D%7D" alt="如何识别是否为微信浏览器打开,并弹出图片? " ></a></li>
                        </ul>                
                    </div>
                    <div class="list-price buy">
<span class="price-new ml"><i>¥</i>{$item.coupon_price}</span><i class="del f14 ml2">¥{$item.price}</i><if condition="$item.cu neq ''"><em class="icon-gai ml2">{$item.cu}</em></if> </div>
                    <h1>{$item.title}</h1>
                    <div class="better_change">
                        <h3>精挑细选</h3>
                        <ul class="better_show clear">
                            <li>
                                <div class="better_info">
                                    <i class="xp"></i>
                                    <span>新品特价</span>
                                </div>
                            </li>
                            <li>
                                <div class="better_info">
                                    <i class="xs"></i>
                                    <span>限时特卖</span>
                                </div>
                            </li>
                            <li>
                                <div class="better_info">
                                    <i class="cx"></i>
                                    <span>诚信品牌</span>
                                </div>
                            </li>
                            <li>
                                <div class="better_info">
                                    <i class="tj"></i>
                                    <span>人气推荐</span>
                                </div>
                            </li>
                            <li class="last">
                                <div class="better_info">
                                    <i class="by"></i>
                                    <span>全国包邮</span>
                                </div>
                            </li>
                        </ul>
                    </div>

                </div>
                <if condition="$item.class eq 'start'">
                    <a class="btn-pay buy">即将开始</a>
                <elseif condition="$item.class eq 'gone'"></elseif>
                    <a class="btn-pay buy">已卖光</a>
                <elseif condition="$item.class eq 'gone'"></elseif>
                    <a class="btn-pay buy">已结束</a>
                <elseif condition="$item.class eq 'buy'"></elseif>
        <if condition="$item.shop_type eq 'B' "><a href="%7B:U('jump/index',array('id'=>%24item%5B'num_iid'%5D))%7D" target="_self" class="btn-pay buy" rel="nofollow">去天猫抢购</a></if>
        <if condition="$item.shop_type eq 'C' "><a href="%7B:U('jump/index',array('id'=>%24item%5B'num_iid'%5D))%7D" target="_self" class="btn-pay buy" rel="nofollow">去淘宝抢购</a></if>
        <if condition="$item.shop_type eq 'M' "><a href="%7B:U('jump/index',array('id'=>%24item%5B'id'%5D))%7D" target="_self" class="btn-pay buy" rel="nofollow">去美丽说抢购</a></if>    
        </if>            
                <div class="bady-part">
                    <div id="bady-tab" class="bady-tab clear">
                        <ul>
                            <li>
<a href="javascript:;">图文详情</a> </li>
                            <li>
<a href="javascript:;">产品参数</a> </li>
                            <li>
<a href="javascript:;">商品评论</a> </li>
                        </ul>
                    </div>
                    <div class="tab1">
                    {$item.desc}
                    </div>
                     <!-- 商品评论 -->
                    <div class="com-big tab3" style="display: none;">
                        <div class="com-list">
                            <ul>
                                <volist name="feedback" id="feedback">
                                <li>
                                    <div class="rate-user-info">
                                        <span class="rate-user">{$feedback.nicker}
                                            <span class="rate-user-grade">
                                                <em class="tm-icon t3"> </em>
                                                <em class="tm-icon vip-icon blue_2"></em>
                                            </span>
                                        </span>
                                        <span class="rate-right fr"> <em class="rate-time">2015-07-30 14:53:31</em><em>评论来自 <if condition="$item.shop_type eq 'C' ">淘宝</if><if condition="$item.shop_type eq 'B' ">天猫</if><if condition="$item.shop_type eq 'M' ">美丽说</if></em></span>
                                        <div class="rate-leirong">{$feedback.feedback}</div>
                                    </div>
                                </li>
                                </volist>
                          </ul>
                        </div>
                    </div>
                    
                    <!-- 规格参数 -->
                    <div class="com-big tab2" style="display: none;">
                        <div class="com-list">
                            <ul>
                                <volist name="props" id="guige">
                                <li>
                                    <div class="shop_info clear">
                                        <span>{$guige.name}:</span>
                                        <strong>{$guige.value}</strong>
                                    </div>
                                </li>
                               </volist>
                            </ul>
                        </div>
                    </div>
                    
                   
                </div>
            </div>

                 <div class="normal item-recommend clear">
                <h3><span>猜你还喜欢:</span></h3>
                <ul class="goods-list clear" id="goods_block">
                <include file="public:hotitems"></include>
                </ul>
            </div>
                 <div class="normal user-like clear">
                    <h3>已有{$wholike}人收藏</h3>
                    <p>
                    <volist name="whos" id="val">
               <a href="%7B:U('user/like')%7D" target="_self"><img src="%7B:avatar(%24val%5B'id'%5D,%2032)%7D"    style="max-width:90%" height="32px" alt="{$val.username}" title="{$val.username}"></a>
               </volist>                    
                    </p>                    
                </div>
                <div class="buy_btn clear">
                <a href="%7B:C('ftx_header_html')%7D" class="go_home"><img  src="__STATIC__/jwap/images/home.png" alt="如何识别是否为微信浏览器打开,并弹出图片? " >返回首页</a>
                <div class="buy_info">
                <if condition="$item.class eq 'start'">
                            <a class="go_tmall">即将开始</a>
                        <elseif condition="$item.class eq 'gone'"></elseif>
                            <a class="go_tmall">已卖光</a>
                        <elseif condition="$item.class eq 'gone'"></elseif>
                            <a class="go_tmall">已结束</a>
                        <elseif condition="$item.class eq 'buy'"></elseif>
                            <eq name="item.is_quan" value="1">
                
                            <a href="%7B%24item.quan_url%7D" target="_self" class="go_tmall buy" rel="nofollow">领取{$item.quan_price}元优惠券<i class="gtbuy"></i></a>
                            <if condition="$item.shop_type eq 'B' "><a href="%7B:U('jump/index',array('id'=>%24item%5B'num_iid'%5D))%7D" target="_self" class="app_load  buy" rel="nofollow">去天猫抢购</a></if>
                            <if condition="$item.shop_type eq 'C' "><a href="%7B:U('jump/index',array('id'=>%24item%5B'num_iid'%5D))%7D" target="_self" class="app_load buy" rel="nofollow">去淘宝抢购</a></if>
                            <if condition="$item.shop_type eq 'M' "><a isconvert="1" href="%7B:U('jump/index',array('id'=>%24item%5B'id'%5D))%7D" target="_self" class="app_load  buy" rel="nofollow">去美丽说</a></if>
                            </eq>
                            
                            <eq name="item.is_quan" value="0">
                            <if condition="$item.shop_type eq 'B' "><a href="%7B:U('jump/index',array('id'=>%24item%5B'num_iid'%5D))%7D" target="_self" class="go_tmall" rel="nofollow">去天猫抢购<i></i></a></if>
                            <if condition="$item.shop_type eq 'C' "><a href="%7B:U('jump/index',array('id'=>%24item%5B'num_iid'%5D))%7D" target="_self" class="go_tmall" rel="nofollow">去淘宝抢购<i></i></a></if>
                            <if condition="$item.shop_type eq 'M' "><a isconvert="1" href="%7B:U('jump/index',array('id'=>%24item%5B'id'%5D))%7D" target="_self" class="go_tmall" rel="nofollow">去美丽说<i></i></a></if>
                
                        <a class="app_load joa_load_app" data-pid="{$item.num_iid}" title="{$item.title}" href="javascript:;">点这里<br>放入收藏夹</a>
                        </eq>
                    </if>
</div>
                
            </div>
            
            <include file="public:footer"></include>
<script type="text/javascript">
var FTXIAER = {
    root: "__ROOT__",
    site: "{:C('ftx_header_html')}",
    uid: "<?php echo $visitor['id'];?>", 
    url: {}
};
var lang = {};
<volist name=":L('js_lang')" id="val">lang.{$key} = "{$val}";
</script>
           </div>
           </div>

    
    <script type="text/javascript">
        $("#bady-tab li").eq(0).addClass("active");        
        $('#bady-tab li').on('click', function(){
        $("#bady-tab li").removeClass("active");
        $(this).addClass("active");
        $(".tab1,.tab2,.tab3").hide();
        $(".tab"+($(this).index()+1)).show();
        });        
    </script>
    <script type="text/javascript" src="__STATIC__/jwap/js/like.js"></script>
    <include file="public:footjs"></include>

</code>
Copier après la connexion

这个是商品详情页

<code>


<include file="public:head"></include>    
<link type="text/css" rel="stylesheet" href="__STATIC__/jwap/css/alert.css">
<link type="text/css" rel="stylesheet" href="__STATIC__/jwap/css/global.css">


<if condition="C('ftx_popup_status') eq '1'">
  <link type="text/css" rel="stylesheet" href="__STATIC__/jwap/css/popup.css">
<div id="popup_scroll">
    <div id="popup_opacity"></div>
    <div id="popup_content">
        <div id="popup"><dl><dt>
<div id="closebtn" style="float:right;"><img src="__STATIC__/jwap/images/alert-close.png"    style="max-width:90%" height="32px" alt="先逛逛"></div>
<a href="%7B:C('ftx_popup_url')%7D" data-gid="521" class="popup_show_maidian"><img  src="%7B:C('ftx_site_url')%7D%7B:C('ftx_popup_img')%7D"    style="max-width:90%"  style="max-width:90%" alt="如何识别是否为微信浏览器打开,并弹出图片? " ></a>
</dt></dl></div>
</div>
</div>
<script type="text/javascript" src="__STATIC__/jwap/js/popup.js"></script>
</if>
<div class="main">    
<include file="public:header"></include>
<include file="public:top"></include>
<include file="public:dapp"></include>
<div class="app">
    <div class="search_warp">
    <span id="classify" class="classify"><a href="javascript:;" class="btn btn-left btn-type"></a></span>
        <div class="search" style="float: none;">
        <form name="search" action="%7B:C('search/index')%7D" method="get" id="search">
<input type="hidden" name="m" value="search"><input type="hidden" name="a" value="index"><div class="seek_main">
<input type="text" name="k" onclick="if(this.value=='请输入内容'){this.value='';this.className='seek_input seek_input_h'}" onblur="if(this.value==''){this.value='请输入内容';this.className='seek_input seek_input_f'}" class="seek_input seek_input_f" value="请输入内容"><button type="submit" id="k" onclick="document.getElementById('k').value=encodeURI(document.getElementById('k').value);getId('search').submit()" class="seek_btn" value="搜本站"><img  src="__STATIC__/jwap/images/search.png" alt="如何识别是否为微信浏览器打开,并弹出图片? " ></button>
</div>
</form>
</div>
        
      </div>    
    <header id="head" class="head">
        <div class="fixtop">
        <span id="classify" class="classify"><a href="javascript:;" class="btn btn-left btn-type"></a></span>
        <span id="t-index">{:C('ftx_site_name')}</span>
        <span id="user"><a href="javascript:;" class="sign_btn btn btn-right btn-sign"></a></span>
    </div>
    </header>
         
{:R('advert/index', array(10), 'Widget')}

<div id="ct">
<link rel="stylesheet" type="text/css" href="__STATIC__/jwap/css/zhuanti.css?ts=201510111950">
  <div class="index_w">
    <ul class="category">
    <nav type="lists" style="other">
    <volist name="data" id="val">
      <li class="ffxgo_1" data-url="{$val.link}">
        <span>
          <img src="%7B:attach(get_thumb(%24val%5B'icon'%5D,%20'_m'),'m')%7D" alt="{$val.name}">
        </span>
        <strong>{$val.name}</strong>
      </li>
     
    </volist>
    </nav>  
    </ul>
   
    <div class="hot_recommend">
    <nav type="lists" style="foot">
    <volist name="data" id="val">
      <!-- 每日更新 -->
      <if condition="$val['alias'] eq 'new' ">
      
      <dl class="today ffxgo_1" data-url="{$val.link}">
                <dt class="tit t1" style="width: 60px;height: 15px;background:url({:attach(get_thumb($val['icon1'], '_m'),'m')});  background-size: contain;
  background-repeat: no-repeat;">{$val.name}</dt>
                <dd class="txt">{$val.des}</dd>
                <dd class="img">
<img src="%7B:attach(get_thumb(%24val%5B'icon'%5D,%20'_m'),'m')%7D"    style="max-width:90%" alt="{$val.name}"><span></span>
</dd>
                <!-- dl-->
            </dl>
     </if>
     <if condition="$val['alias'] eq 'shijian' ">
        <dl class="rec_item ffxgo_1" data-url="{$val.link}">
          <dt class="tit">{$val.name}</dt>
          <dd class="txt">{$val.des}</dd>
          <dd class="img"><img src="%7B:attach(get_thumb(%24val%5B'icon'%5D,%20'_m'),'m')%7D"    style="max-width:90%" alt="好货早收藏"></dd>                   <!-- dl-->
       </dl>     
      
      </if>
    </volist>
    </nav> 
    </div>
    <script type="text/javascript">   

</script>
    <div class="hot_bottom">
    <nav type="lists" style="foot">
    <volist name="data" id="val">
    <if condition="$val['alias'] eq 'hot' ">
      <dl class="add_item ffxgo_1" data-url="{$val.link}">
                <dt class="img">
                    <img  src="%7B:attach(%24val%5B'icon'%5D,'m')%7D"    style="max-width:90%"  style="max-width:90%" alt="如何识别是否为微信浏览器打开,并弹出图片? " >
                </dt>
                <dd>
                    <p class="tit t6">{$val.name}</p>
                    <p class="txt">{$val.des}</p>
                </dd>
       </dl>
      </if>
    <if condition="$val['alias'] eq 'temai' ">
      <dl class="add_item ffxgo_1" data-url="{$val.link}">
                <dt class="img">
                    <img  src="%7B:attach(%24val%5B'icon'%5D,'m')%7D"    style="max-width:90%"  style="max-width:90%" alt="如何识别是否为微信浏览器打开,并弹出图片? " >
                </dt>
                <dd>
                    <p class="tit">
                        <span class="fc_orange">{$val.name}</span>
                        <if condition="$val['hot'] eq '1'"><span class="icon_saleShop">热卖</span></if><if condition="$val['hot'] eq '2'"><span class="icon_bestBuy">精选</span></if>
                    </p>
                    <p class="txt">{$val.des}</p>
                </dd>
            </dl>
      </if>
    </volist>
    </nav>
    </div>
  </div>
</div>
<script type="text/javascript">   
 $(".ffxgo_1").off("click").on("click",function(){
       window.location.href = $(this).attr("data-url");
  });
</script>
<div id="goods">
<section class="goods" id="goods">
    <ul class="goods-list clear">
<include file="public:itemlist"></include>    
    </ul>
</section>
<div class="paging">
<div class="paging-nav">
{$page}
</div>    
</div>
</div>
<include file="public:footer"></include>
</div>
</div>
<include file="public:footjs"></include>
<script type="text/javascript">document.getElementById("back_top").style.display = "none";
window.onscroll = function () {
    if (document.documentElement.scrollTop + document.body.scrollTop > 100) {
        document.getElementById("back_top").style.display = "block";
    }
    else {
        document.getElementById("back_top").style.display = "none";
    }
}
</script><script type="text/javascript">$(document).ready(function(){  

        var jumpurl=$("#jumpurl").text();
        if(getck("showdiv") == "")
        {
            var data = new Date();
            var timestr = data.getFullYear() + "-" + (Number(data.getMonth())+1) + "-" + data.getDate() + " " + data.getHours() + ":" + data.getMinutes() + ":" + data.getSeconds();
            document.cookie="showdiv=" + timestr;
        }
        else
        {
            var date_ = convertdate(getck("showdiv"));
            var data = new Date();
            var num = Number(data.getTime()) - Number(date_.getTime());
            if(num >= 24*3600000)//已经过期重新设置
            {
               document.cookie="showdiv=";
            }
        }
        $("#closebtn").click(function(){ document.cookie="isshow=true";$("#ffxiabige_scroll").fadeOut("slow");});
        $("#add_fav").click(function(){ 
            window.open(jumpurl); 
            document.cookie="isshow=true";
            $("#ffxiabige_scroll").fadeOut("slow");
        });

        $("#welcome_img").click(function(){
              window.open(jumpurl); 
              document.cookie="isshow=true";
              $("#ffxiabige_scroll").fadeOut("slow");
        });

        setTimeout("showdiv()",1000);  //这里修改打开网页多久之后显示提示
        });

    function showdiv()
    { 
       if(getck("isshow")  == "true")
       {
         return;
       }
       else
       {
         if(getck("showdiv") == "")
         {
            $("#ffxiabige_scroll").width(document.body.clientWidth);
            $("#ffxiabige_scroll").height(document.body.clientHeight);
            $("#ffxiabige_scroll").show(400);
         }
         else
         {
            var date_ = convertdate(getck("showdiv"));
            var data = new Date();
            var num = Number(data.getTime()) - Number(date_.getTime());
            if(num >= 24*3600000)//已经过期重新设置
            {
                document.cookie="showdiv=";
                $("#ffxiabige_scroll").width(document.body.clientWidth);
                $("#ffxiabige_scroll").height(document.body.clientHeight);
                $("#ffxiabige_scroll").show();
            } 
         }
       }
    }

    var acookie=document.cookie.split("; ");
    function getck(sname)
    {
       //获取单个cookies
        for(var i=0;i<acookie.length;i++){
        var arr=acookie[i].split("=");
        if(sname==arr[0]){
        if(arr.length>1)
        return unescape(arr[1]);
        else
        return "";
        }}
        return "";
    }

    function convertdate(datestr)
    {
      var date_hidden = datestr;
      date_hidden = date_hidden.replace(":","-");
      date_hidden = date_hidden.replace(":","-");
      date_hidden = date_hidden.replace(" ","-");
      var date = new Date(Number(date_hidden.split("-")[0]),Number(date_hidden.split("-")[1])-1,Number(date_hidden.split("-")[2]),Number(date_hidden.split("-")[3]),Number(date_hidden.split("-")[4]),Number(date_hidden.split("-")[5]));
      return date;  
    }

    function clearcookie()
    {
        document.cookie="showdiv=";
        document.cookie="isshow=";location.href=location.href;
    }   
</script>

</code>
Copier après la connexion

这个是首页 请问一下需要怎么改动?

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal