wx.ready(function () {
// 在这里调用 API
// 获取“分享到朋友圈”按钮点击状态及自定义分享内容接口
wx.onMenuShareTimeline({
title: '宝爸宝妈看过来-测一测你的育婴等级', // 分享标题
link: 'http://www.chiaus.cn/activity', // 分享链接
imgUrl: 'http://www.chiaus.cn/activity/images/logo.jpg', // 分享图标
success: function () {
// 用户确认分享后执行的回调函数
},
cancel: function () {
// 用户取消分享后执行的回调函数
}
});
// 获取“分享给朋友”按钮点击状态及自定义分享内容接口
wx.onMenuShareAppMessage({
title: '宝爸宝妈看过来-测一测你的育婴等级', // 分享标题
desc: '快来测一测吧', // 分享描述
link: 'http://www.chiaus.cn/activity', // 分享链接
imgUrl: 'http://www.chiaus.cn/activity/images/logo.jpg', // 分享图标
type: '', // 分享类型,music、video或link,不填默认为link
dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空
success: function () {
// 用户确认分享后执行的回调函数
},
cancel: function () {
// 用户取消分享后执行的回调函数
}
});
});
// 对浏览器的UserAgent进行正则匹配,不含有微信独有标识的则为其他浏览器
var useragent = navigator.userAgent;
if (useragent.match(/MicroMessenger/i) != 'MicroMessenger') {
// 这里警告框会阻塞当前页面继续加载
alert('请使用微信打开!');
// 以下代码是用javascript强行关闭当前页面
var opened = window.open('about:blank', '_self');
opened.opener = null;
opened.close();
}

var _system={
$:function(id){return document.getElementById(id);},
_client:function(){
return {w:document.documentElement.scrollWidth,h:document.documentElement.scrollHeight,bw:document.documentElement.clientWidth,bh:document.documentElement.clientHeight};
},
_scroll:function(){
return {x:document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft,y:document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop};
},
_cover:function(show){
if(show){
this.$("cover").style.display="block";
this.$("cover").style.width=(this._client().bw>this._client().w?this._client().bw:this._client().w)+"px";
this.$("cover").style.height=(this._client().bh>this._client().h?this._client().bh:this._client().h)+"px";
}else{
this.$("cover").style.display="none";
}
},
_guide:function(click){
this._cover(true);
this.$("guide").style.display="block";
this.$("guide").style.top=(_system._scroll().y+5)+"px";
window.onresize=function(){_system._cover(true);_system.$("guide").style.top=(_system._scroll().y+5)+"px";};
if(click){_system.$("cover").onclick=function(){
_system._cover();
_system.$("guide").style.display="none";
_system.$("cover").onclick=null;
window.onresize=null;
};}
},
_zero:function(n){
return n<0?0:n;
}
}