Authored by 郭成尧

'weicharshare'

/**
* Created by PhpStorm.
* User: Targaryen
* Date: 2016/7/29
* Time: 16:55
*/
const $ = require('yoho-jquery');
$.ajax({
url: '//res.wx.qq.com/open/js/jweixin-1.1.0.js',
dataType: "script",
cache: true,
success: function() {
$.ajax({
url: '/api/wechat/share/token',
data: {
url: location.href
},
success: function(res) {
if (window.wx) {
window.wx.config({
debug: false,
appId: res.appId,
timestamp: res.timestamp,
nonceStr: res.nonceStr,
signature: res.signature,
jsApiList: [
'checkJsApi',
'onMenuShareTimeline',
'onMenuShareAppMessage',
'onMenuShareQQ',
'onMenuShareWeibo',
'hideMenuItems',
'showMenuItems',
'hideAllNonBaseMenuItem',
'showAllNonBaseMenuItem',
'translateVoice',
'startRecord',
'stopRecord',
'onRecordEnd',
'playVoice',
'pauseVoice',
'stopVoice',
'uploadVoice',
'downloadVoice',
'chooseImage',
'previewImage',
'uploadImage',
'downloadImage',
'getNetworkType',
'openLocation',
'getLocation',
'hideOptionMenu',
'showOptionMenu',
'closeWindow',
'scanQRCode',
'chooseWXPay',
'openProductSpecificView',
'addCard',
'chooseCard',
'openCard'
]
});
}
}
});
}
});
module.exports = (shareData) => {
window.wx.ready(function() {
window.wx.onMenuShareAppMessage(shareData);
window.wx.onMenuShareTimeline(shareData);
window.wx.onMenuShareQQ(shareData);
window.wx.onMenuShareWeibo(shareData);
});
};
... ...
... ... @@ -52,6 +52,7 @@
const shareBottom = require('component/tool/share-bottom.vue');
const qs = require('yoho-qs');
const tip = require('common/tip');
const share = require('common/share');
module.exports = {
... ... @@ -60,6 +61,16 @@
shopInfo: {}
};
},
watch: {
shopInfo() {
share({
title: this.shopInfo.brandName,
link: location.href,
desc: this.shopInfo.shareSubTitle,
imgUrl: this.shopInfo.brandBg
});
}
},
methods: {
/* 获取店铺简介相关数据 */
... ...