149 lines
6.0 KiB
HTML
149 lines
6.0 KiB
HTML
![]() |
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
|
|||
|
<script type="text/javascript">
|
|||
|
//如果微信分销配置正常, 商品详情分享内容中的"图标"不显示, 则检查域名否配置了https, 如果配置了https,分享图片地址也要https开头
|
|||
|
var httpPrefix = "http://{$Think.server.SERVER_NAME}";
|
|||
|
<if condition="ACTION_NAME eq 'goodsInfo'">
|
|||
|
var ShareLink = httpPrefix+"/index.php?m=Mobile&c=Goods&a=goodsInfo&id={$goods[goods_id]}"; //默认分享链接
|
|||
|
var ShareImgUrl = httpPrefix+"{$goods[goods_id]|goods_thum_images=100,100}"; // 分享图标
|
|||
|
var ShareTitle = "{$goods.goods_name|default=$tpshop_config['shop_info_store_title']}"; // 分享标题
|
|||
|
var ShareDesc = "{$goods.goods_remark|default=$tpshop_config['shop_info_store_desc']}"; // 分享描述
|
|||
|
<elseif condition="ACTION_NAME eq 'info'"/>
|
|||
|
var ShareLink = "{$team['bd_url']}"; //默认分享链接
|
|||
|
var ShareImgUrl = "{$team['bd_pic']}"; //分享图标
|
|||
|
var ShareTitle = "{$team[share_title]}"; //分享标题
|
|||
|
var ShareDesc = "{$team[share_desc]}"; //分享描述
|
|||
|
<elseif condition="ACTION_NAME eq 'found'"/>
|
|||
|
var ShareLink = httpPrefix+"/index.php?m=Mobile&c=Team&a=found&id={$teamFound[found_id]}"; //默认分享链接
|
|||
|
var ShareImgUrl = "{$team[bd_pic]}"; //分享图标
|
|||
|
var ShareTitle = "{$team[share_title]}"; //分享标题
|
|||
|
var ShareDesc = "{$team[share_desc]}"; //分享描述
|
|||
|
<elseif condition="ACTION_NAME eq 'my_store'"/>
|
|||
|
var ShareLink = httpPrefix+"/index.php?m=Mobile&c=Distribut&a=my_store";
|
|||
|
var ShareImgUrl = httpPrefix+"{$tpshop_config['shop_info_store_logo']}";
|
|||
|
var ShareTitle = "{$share_title}";
|
|||
|
var ShareDesc = httpPrefix+"/index.php?m=Mobile&c=Distribut&a=my_store}";
|
|||
|
<else />
|
|||
|
var ShareLink = httpPrefix+"/index.php?m=Mobile&c=Index&a=index"; //默认分享链接
|
|||
|
var ShareImgUrl = httpPrefix+"{$tpshop_config['shop_info_wap_home_logo']}"; //分享图标
|
|||
|
var ShareTitle = "{$tpshop_config['shop_info_store_title']}"; //分享标题
|
|||
|
var ShareDesc = "{$tpshop_config['shop_info_store_desc']}"; //分享描述
|
|||
|
</if>
|
|||
|
|
|||
|
var is_distribut = getCookie('is_distribut'); // 是否分销代理
|
|||
|
var user_id = getCookie('user_id'); // 当前用户id
|
|||
|
// 如果已经登录了, 并且是分销商
|
|||
|
if(parseInt(is_distribut) == 1 && parseInt(user_id) > 0)
|
|||
|
{
|
|||
|
ShareLink = ShareLink + "&first_leader="+user_id;
|
|||
|
}
|
|||
|
|
|||
|
$(function() {
|
|||
|
if(isWeiXin() && parseInt(user_id)>0){
|
|||
|
$.ajax({
|
|||
|
type : "POST",
|
|||
|
url:"/index.php?m=Mobile&c=Index&a=ajaxGetWxConfig&t="+Math.random(),
|
|||
|
data:{'askUrl':encodeURIComponent(location.href.split('#')[0])},
|
|||
|
dataType:'JSON',
|
|||
|
success: function(res)
|
|||
|
{
|
|||
|
//微信配置
|
|||
|
wx.config({
|
|||
|
debug: false,
|
|||
|
appId: res.appId,
|
|||
|
timestamp: res.timestamp,
|
|||
|
nonceStr: res.nonceStr,
|
|||
|
signature: res.signature,
|
|||
|
jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage','onMenuShareQQ','onMenuShareQZone','hideOptionMenu'] // 功能列表,我们要使用JS-SDK的什么功能
|
|||
|
});
|
|||
|
},
|
|||
|
error:function(res){
|
|||
|
console.log("wx.config error:");
|
|||
|
console.log(res);
|
|||
|
return false;
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
// config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在 页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready 函数中。
|
|||
|
wx.ready(function(){
|
|||
|
// 获取"分享到朋友圈"按钮点击状态及自定义分享内容接口
|
|||
|
wx.onMenuShareTimeline({
|
|||
|
title: ShareTitle, // 分享标题
|
|||
|
link:ShareLink,
|
|||
|
desc: ShareDesc,
|
|||
|
imgUrl:ShareImgUrl // 分享图标
|
|||
|
});
|
|||
|
|
|||
|
// 获取"分享给朋友"按钮点击状态及自定义分享内容接口
|
|||
|
wx.onMenuShareAppMessage({
|
|||
|
title: ShareTitle, // 分享标题
|
|||
|
desc: ShareDesc, // 分享描述
|
|||
|
link:ShareLink,
|
|||
|
imgUrl:ShareImgUrl // 分享图标
|
|||
|
});
|
|||
|
// 分享到QQ
|
|||
|
wx.onMenuShareQQ({
|
|||
|
title: ShareTitle, // 分享标题
|
|||
|
desc: ShareDesc, // 分享描述
|
|||
|
link:ShareLink,
|
|||
|
imgUrl:ShareImgUrl // 分享图标
|
|||
|
});
|
|||
|
// 分享到QQ空间
|
|||
|
wx.onMenuShareQZone({
|
|||
|
title: ShareTitle, // 分享标题
|
|||
|
desc: ShareDesc, // 分享描述
|
|||
|
link:ShareLink,
|
|||
|
imgUrl:ShareImgUrl // 分享图标
|
|||
|
});
|
|||
|
|
|||
|
<if condition="CONTROLLER_NAME eq 'User'">
|
|||
|
wx.hideOptionMenu(); // 用户中心 隐藏微信菜单
|
|||
|
</if>
|
|||
|
});
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
function isWeiXin(){
|
|||
|
var ua = window.navigator.userAgent.toLowerCase();
|
|||
|
if(ua.match(/MicroMessenger/i) == 'micromessenger'){
|
|||
|
return true;
|
|||
|
}else{
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
</script>
|
|||
|
<!--微信关注提醒 start-->
|
|||
|
<if condition="$Think.session.subscribe eq 0">
|
|||
|
<button class="guide" style="display:none;" onclick="follow_wx()">关注公众号</button>
|
|||
|
<style type="text/css">
|
|||
|
.guide{width:0.627rem;height:2.83rem;text-align: center;border-radius: 8px ;font-size:0.512rem;padding:8px 0;border:1px solid #adadab;color:#000000;background-color: #fff;position: fixed;right: 6px;bottom: 200px;z-index: 99;}
|
|||
|
#cover{display:none;position:absolute;left:0;top:0;z-index:18888;background-color:#000000;opacity:0.7;}
|
|||
|
#guide{display:none;position:absolute;top:5px;z-index:19999;}
|
|||
|
#guide img{width: 70%;height: auto;display: block;margin: 0 auto;margin-top: 10px;}
|
|||
|
div.layui-m-layerchild h3{font-size:0.64rem;height:1.24rem;line-height:1.24rem;}
|
|||
|
.layui-m-layercont img{height:8.96rem;width:8.96rem;}
|
|||
|
</style>
|
|||
|
<script type="text/javascript">
|
|||
|
//关注微信公众号二维码
|
|||
|
function follow_wx()
|
|||
|
{
|
|||
|
layer.open({
|
|||
|
type : 1,
|
|||
|
title: '关注公众号',
|
|||
|
content: '<img src="{$wechat_config.qr}">',
|
|||
|
style: ''
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
$(function(){
|
|||
|
if(isWeiXin()){
|
|||
|
var subscribe = getCookie('subscribe'); // 是否已经关注了微信公众号
|
|||
|
if(subscribe == 0)
|
|||
|
$('.guide').show();
|
|||
|
}else{
|
|||
|
$('.guide').hide();
|
|||
|
}
|
|||
|
})
|
|||
|
|
|||
|
</script>
|
|||
|
</if>
|
|||
|
<!--微信关注提醒 end-->
|