$(function() {
var share = {
title: '放手放脚体验高速急刹车 9位科技大咖亲测沃尔沃自动驾驶',
desc: '全球首个自动驾驶路试项目 Drive Me Truest Me 自动驾到 谁敢来约',
link: 'http://geekpark.net/zhuanti/volvo/mobile.html',
icon: 'http://geekpark-img.qiniudn.com/volvo-guestshare.jpg'
};
(function() {
var videoSwiper = new Swiper('#video-slider', {
autoplay: 6000,
nextButton: '#video-slider .swiper-button-next',
prevButton: '#video-slider .swiper-button-prev'
});
})();
$.ajax({
url: location.origin + '/wechat_js',
type: 'post',
data: {url: location.href.split('#')[0]}
}).done(function(data) {
if(typeof data.msg == 'undefined') {
if(isWechat()) {
wechatJS(data);
}
} else {
console.log(data.msg);
}
});
function wechatJS (data) {
// 微信JS图片预览
wx.config({
debug: false,
appId: 'your app id',
timestamp: data.timestamp,
nonceStr: data.noncestr,
signature: data.signature,
jsApiList: ['previewImage', 'onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ']
});
// 现场图片
$('#select-img').on('click', function() {
wx.previewImage({
current: 'http://geekpark-img.qiniudn.com/volvomobile-video-preview.jpg?imageView/2/w/720',
urls: [
'http://geekpark-img.qiniudn.com/volvohezhao.jpg?imageView/2/w/1000',
'http://geekpark-img.qiniudn.com/volvoP1250200.jpg?imageView/2/w/1000',
'http://geekpark-img.qiniudn.com/volvoP1250040.jpg?imageView/2/w/1000',
'http://geekpark-img.qiniudn.com/volvoP1250322.jpg?imageView/2/w/1000',
'http://geekpark-img.qiniudn.com/volvoP1250370.jpg?imageView/2/w/1000',
'http://geekpark-img.qiniudn.com/volvoP1250381.jpg?imageView/2/w/1000',
'http://geekpark-img.qiniudn.com/volvoP1250399.jpg?imageView/2/w/1000',
'http://geekpark-img.qiniudn.com/volvoP1250424.jpg?imageView/2/w/1000',
'http://geekpark-img.qiniudn.com/volvoP1250453.jpg?imageView/2/w/1000',
'http://geekpark-img.qiniudn.com/volvo15409.jpg?imageView/2/w/1000',
'http://geekpark-img.qiniudn.com/volvo98655.jpg?imageView/2/w/1000',
'http://geekpark-img.qiniudn.com/volvoP1250275.jpg?imageView/2/w/1000'
]
});
});
wx.ready(function(){
wx.onMenuShareAppMessage({
title: share.title,
desc: share.desc,
link: share.link,
imgUrl: share.icon
});
wx.onMenuShareQQ({
title: share.title,
desc: share.desc,
link: share.link,
imgUrl: share.icon
});
// 分享
wx.onMenuShareTimeline({
title: share.title,
link: share.link,
imgUrl: share.icon
});
});
} // wechatJS end
function isWechat() {
var ua = navigator.userAgent.toLowerCase();
return (/micromessenger/.test(ua)) ? true : false;
}
});