Skip to content

Instantly share code, notes, and snippets.

@alanerzhao
Created July 23, 2014 07:20
Show Gist options
  • Save alanerzhao/0771f1cd69a10a24f3e1 to your computer and use it in GitHub Desktop.
Save alanerzhao/0771f1cd69a10a24f3e1 to your computer and use it in GitHub Desktop.
<div id="weixin_tip" style="display:none;" class="share-ad">
<img src="../statics/img/tips.png" alt="">
</div>
<script>
var randomTitle = ['头发甩起来!我参加了“疯狂世界杯,加加乐翻天”活动,躺在床上等奖品砸过来吧!','我参加了“疯狂世界杯,加加乐翻天”活动,快来跟我一起领大奖啦!已经有很多兄弟姐妹参加了,你!还!不!赶!紧!的!','各种大奖白送!不参与,不撸起来,简直对不起自己!','我马上要中大奖了,还是辣句话,我要红了,你们要对我好点!','人家发个贴子就中一台iPhone6,我们凭什么只看热闹!速来!','感觉马上就要中奖!不用多久,迎取百富美,走上人生巅峰,']
function is_weixin(){
var ua = navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i)=="micromessenger") {
return true;
} else {
return false;
}
}
if(is_weixin()){
document.getElementById("weixin_tip").style.display="";
}
document.addEventListener('WeixinJSBridgeReady', function() {
onBridgeReady();
// _uparrw.querySelector(".cur").innerHTML = "滑动进入";
if (os_vs >= "7_1_1") {
debugcode += "os_vs>=7_1_1,";
// _uparrw.style.display = 'block';
_uparrw.style.display = 'none';
_bg.style.display = 'none';
document.getElementById("scene").style.display = "block";
if (!domeInitEnd) {
initTabDomo();
}
}
});
function onBridgeReady() {
//转发朋友圈
WeixinJSBridge.on("menu:share:timeline", function(e) {
var url = 'http://www.mofang.com';
var data = {
img_url: "http://sts0.mofang.com/statics/v4/content/img/logo_b9250a9.png",
img_width: "120",
img_height: "120",
link: url,
//desc这个属性要加上,虽然不会显示,但是不加暂时会导致无法转发至朋友圈,
desc: "魔方网",
title: "魔方网"
};
WeixinJSBridge.invoke("shareTimeline", data, function(res) {
WeixinJSBridge.log(res.err_msg);
});
});
//同步到微博
WeixinJSBridge.on("menu:share:weibo", function() {
var url = 'http://www.mofang.com';
WeixinJSBridge.invoke("shareWeibo", {
"content": "魔方网",
"url": url
}, function(res) {
WeixinJSBridge.log(res.err_msg);
});
});
//分享给朋友
WeixinJSBridge.on('menu:share:appmessage', function(argv) {
var url = 'http://www.mofang.com';
WeixinJSBridge.invoke("sendAppMessage", {
img_url: "http://sts0.mofang.com/statics/v4/content/img/logo_b9250a9.png",
img_width: "120",
img_height: "120",
link: url,
desc: "魔方网",
title: "魔方网"
}, function(res) {
WeixinJSBridge.log(res.err_msg);
});
});
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment