03
08月
2015
<script>
$(function(){
//通过config接口注入权限验证配置
wx.config({
debug: false,
appId: 'wx359a54fbc89871ac',
timestamp: '1438586242',
nonceStr: 'RVPtAKKguij7EBhY',
signature: '83d20bed15d13a9641c97ef7392bbb850922a911',
jsApiList: [
'onMenuShareTimeline',
'onMenuShareAppMessage',
'onMenuShareQQ',
'startRecord',
'stopRecord',
'onRecordEnd',
'playVoice',
'pauseVoice',
'stopVoice',
'uploadVoice',
'downloadVoice',
]
});
$(document).ajaxStop(function(){
function getCookie(name){
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr != null) return unescape(arr[2]);
return null;
}
wx.ready(function () {
var action = 'microagent';
var controller = 'site';
if(action=='promote'){
var title = $("#Title").text();
var SpreadId=$("#SpreadId").val();
// var desc = $("#Content").text();
// desc =desc.replace(/\s+/g,"").substring(0,80);
var desc='生菌能平衡肠道菌群,促进肠道蠕动,预防和改善腹泻便秘,刺激肠道免疫机能,增强免疫力。';
// alert(desc);
var imgUrl = 'http://www.yaotouzi.cn/assets/v1/i/public-ico/share.jpg';
var link = 'http://www.yaotouzi.cn/promote/shopopenlink?articleId=&SellerId=';
var dataUrl = 'http://www.yaotouzi.cn/promote/shopopenlink?articleId=&SellerId=';
WxShare(title,desc,imgUrl,link,dataUrl,SpreadId);
}else if(action=='shopopenlink'){
var title = $("#Title").text();
var SpreadId=$("#SpreadId").val();
// var desc = $(".z_olink_content").text();
var desc='生菌能平衡肠道菌群,促进肠道蠕动,预防和改善腹泻便秘,刺激肠道免疫机能,增强免疫力。';
var imgUrl = 'http://www.yaotouzi.cn/assets/v1/i/public-ico/share.jpg';
var link = 'http://www.yaotouzi.cn/promote/shopopenlink?articleId=&SellerId=';
var dataUrl = 'http://www.yaotouzi.cn/promote/shopopenlink?articleId=&SellerId=';
WxShare(title,desc,imgUrl,link,dataUrl,SpreadId);
}else{
var SellerId=$("#SellerIds").val();
var UserId=$("#UserIds").val();
var ParentId=getCookie("ParentId");
var url=window.location.hostname;
var title = '民生益生菌,中国益生菌领先品牌';
var desc = '益生菌能平衡肠道菌群,促进肠道蠕动,预防和改善腹泻便秘,刺激肠道免疫机能,增强免疫力。';
var imgUrl = 'http://www.yaotouzi.cn/assets/v1/i/public-ico/share.jpg';
var link = url+"?ParentId="+ParentId+"&SellerId="+SellerId+"&UserId="+UserId;
var dataUrl = url+"?ParentId="+ParentId+"&SellerId="+UserId+"&UserId="+UserId;
WxShare(title,desc,imgUrl,link,dataUrl);
}
$(document).on("click",".wechat",function(){
$(".am-share").hide();
$(".popbg").hide();
$(".weixin-alert").modal('open');
$("#my-alert").modal('close');
var title = $(".wechat").attr("Name");
var desc = $(".wechat").attr("Content");
var imgUrl = $(".wechat").attr("Src");
var link = $(".wechat").attr("URL");
var dataUrl = $(".wechat").attr("URL");
var SellerId = $(".wechat").attr("SellerId");
WxShare(title,desc,imgUrl,link,dataUrl);
})
});
})
/* wx.error(function (res) {
alert(res.errMsg);
}); */
function WxShare(title,desc,imgUrl,link,dataUrl,SpreadId){
//分享到朋友圈
wx.onMenuShareTimeline({
title: title,
desc: desc,
type: 'link',
imgUrl: imgUrl,
link:link,
dataUrl:dataUrl,
success: function () {
$(".weixin-alert").modal('close');
if(SpreadId!="" && SpreadId!=null && SpreadId!=undefined){
UpdateBroswerCount(SpreadId);
}
},
cancel: function () {
$(".weixin-alert").modal('close');
}
});
//分享给好友
wx.onMenuShareAppMessage({
title: title,
desc: desc,
type: 'link',
imgUrl: imgUrl,
link:link,
dataUrl:dataUrl,
success: function () {
$(".weixin-alert").modal('close');
if(SpreadId!="" && SpreadId!=null && SpreadId!=undefined){
UpdateBroswerCount(SpreadId);
}
},
cancel: function () {
$(".weixin-alert").modal('close');
if(SpreadId!="" && SpreadId!=null && SpreadId!=undefined){
UpdateBroswerCount(SpreadId);
}
}
});
//分享到QQ
wx.onMenuShareQQ({
title: title,
desc: desc,
type: 'link',
imgUrl: imgUrl,
link:link,
dataUrl:dataUrl,
success: function () {
$(".weixin-alert").modal('close');
},
cancel: function () {
$(".weixin-alert").modal('close');
}
});
}
function UpdateBroswerCount(SpreadId){
$.ajax({
type:'post',
url:'/promote/UpdateBroswerCount',
data:{SpreadId:SpreadId},
dataType:'jsonp',
jsonp:'callback',
success:function(ret){
}
});
}
})
</script>
$(function(){
//通过config接口注入权限验证配置
wx.config({
debug: false,
appId: 'wx359a54fbc89871ac',
timestamp: '1438586242',
nonceStr: 'RVPtAKKguij7EBhY',
signature: '83d20bed15d13a9641c97ef7392bbb850922a911',
jsApiList: [
'onMenuShareTimeline',
'onMenuShareAppMessage',
'onMenuShareQQ',
'startRecord',
'stopRecord',
'onRecordEnd',
'playVoice',
'pauseVoice',
'stopVoice',
'uploadVoice',
'downloadVoice',
]
});
$(document).ajaxStop(function(){
function getCookie(name){
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr != null) return unescape(arr[2]);
return null;
}
wx.ready(function () {
var action = 'microagent';
var controller = 'site';
if(action=='promote'){
var title = $("#Title").text();
var SpreadId=$("#SpreadId").val();
// var desc = $("#Content").text();
// desc =desc.replace(/\s+/g,"").substring(0,80);
var desc='生菌能平衡肠道菌群,促进肠道蠕动,预防和改善腹泻便秘,刺激肠道免疫机能,增强免疫力。';
// alert(desc);
var imgUrl = 'http://www.yaotouzi.cn/assets/v1/i/public-ico/share.jpg';
var link = 'http://www.yaotouzi.cn/promote/shopopenlink?articleId=&SellerId=';
var dataUrl = 'http://www.yaotouzi.cn/promote/shopopenlink?articleId=&SellerId=';
WxShare(title,desc,imgUrl,link,dataUrl,SpreadId);
}else if(action=='shopopenlink'){
var title = $("#Title").text();
var SpreadId=$("#SpreadId").val();
// var desc = $(".z_olink_content").text();
var desc='生菌能平衡肠道菌群,促进肠道蠕动,预防和改善腹泻便秘,刺激肠道免疫机能,增强免疫力。';
var imgUrl = 'http://www.yaotouzi.cn/assets/v1/i/public-ico/share.jpg';
var link = 'http://www.yaotouzi.cn/promote/shopopenlink?articleId=&SellerId=';
var dataUrl = 'http://www.yaotouzi.cn/promote/shopopenlink?articleId=&SellerId=';
WxShare(title,desc,imgUrl,link,dataUrl,SpreadId);
}else{
var SellerId=$("#SellerIds").val();
var UserId=$("#UserIds").val();
var ParentId=getCookie("ParentId");
var url=window.location.hostname;
var title = '民生益生菌,中国益生菌领先品牌';
var desc = '益生菌能平衡肠道菌群,促进肠道蠕动,预防和改善腹泻便秘,刺激肠道免疫机能,增强免疫力。';
var imgUrl = 'http://www.yaotouzi.cn/assets/v1/i/public-ico/share.jpg';
var link = url+"?ParentId="+ParentId+"&SellerId="+SellerId+"&UserId="+UserId;
var dataUrl = url+"?ParentId="+ParentId+"&SellerId="+UserId+"&UserId="+UserId;
WxShare(title,desc,imgUrl,link,dataUrl);
}
$(document).on("click",".wechat",function(){
$(".am-share").hide();
$(".popbg").hide();
$(".weixin-alert").modal('open');
$("#my-alert").modal('close');
var title = $(".wechat").attr("Name");
var desc = $(".wechat").attr("Content");
var imgUrl = $(".wechat").attr("Src");
var link = $(".wechat").attr("URL");
var dataUrl = $(".wechat").attr("URL");
var SellerId = $(".wechat").attr("SellerId");
WxShare(title,desc,imgUrl,link,dataUrl);
})
});
})
/* wx.error(function (res) {
alert(res.errMsg);
}); */
function WxShare(title,desc,imgUrl,link,dataUrl,SpreadId){
//分享到朋友圈
wx.onMenuShareTimeline({
title: title,
desc: desc,
type: 'link',
imgUrl: imgUrl,
link:link,
dataUrl:dataUrl,
success: function () {
$(".weixin-alert").modal('close');
if(SpreadId!="" && SpreadId!=null && SpreadId!=undefined){
UpdateBroswerCount(SpreadId);
}
},
cancel: function () {
$(".weixin-alert").modal('close');
}
});
//分享给好友
wx.onMenuShareAppMessage({
title: title,
desc: desc,
type: 'link',
imgUrl: imgUrl,
link:link,
dataUrl:dataUrl,
success: function () {
$(".weixin-alert").modal('close');
if(SpreadId!="" && SpreadId!=null && SpreadId!=undefined){
UpdateBroswerCount(SpreadId);
}
},
cancel: function () {
$(".weixin-alert").modal('close');
if(SpreadId!="" && SpreadId!=null && SpreadId!=undefined){
UpdateBroswerCount(SpreadId);
}
}
});
//分享到QQ
wx.onMenuShareQQ({
title: title,
desc: desc,
type: 'link',
imgUrl: imgUrl,
link:link,
dataUrl:dataUrl,
success: function () {
$(".weixin-alert").modal('close');
},
cancel: function () {
$(".weixin-alert").modal('close');
}
});
}
function UpdateBroswerCount(SpreadId){
$.ajax({
type:'post',
url:'/promote/UpdateBroswerCount',
data:{SpreadId:SpreadId},
dataType:'jsonp',
jsonp:'callback',
success:function(ret){
}
});
}
})
</script>
特殊说明,本文版权归 ning个人博客 所有带原创标签请勿转载,转载请注明出处.
本文标题: 微信公众平台开发分享