Authored by 郭成尧

'exampleshare'

... ... @@ -7,67 +7,68 @@
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'
]
});
if (/MicroMessenger/i.test(navigator.userAgent)) {
$.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) => {
if (window.wx) {
window.wx.ready(function() {
... ...
... ... @@ -10,7 +10,7 @@
<button class="button" @click='yoho.goNewPage({"url":"http://m.yohoblk.com"})'>新页面</button>
<button class="button" @click="yoho.goPay()">支付</button>
<button class="button" @click="yoho.goBack()">返回</button>
<button class="button" @click='yoho.goShare({"title":"标题","des":"描述","img":"http://7xwj52.com1.z0.glb.clouddn.com/brandbg.jpg","url":"http://m.yohoblk.com/product/shop/share?domain=sctest1"})'>分享</button>
<button class="button" @click='yoho.goShare({"title":"标题","des":"描述","img":"http://7xwj52.com1.z0.glb.clouddn.com/brandbg.jpg","url":"http://m.yohoblk.com/example/app"})'>分享</button>
<button class="button" @click='yoho.goSearch()'>搜索</button>
<button class="button" @click='yoho.goSetting()'>设置</button>
<button class="button" @click='yoho.goSetAvatar()'>设置头像</button>
... ... @@ -27,6 +27,7 @@
<script>
const yoho = require('yoho');
const modal = require('common/modal');
const share = require('common/share');
module.exports = {
data() {
... ... @@ -41,6 +42,12 @@
modal.alert('传递的信息是:' + data);
}
});
share({
title: '标题',
link: location.href,
desc: '我在BLK发现了一个不错的品牌,赶快来看看吧!',
imgUrl: 'http://7xwj52.com1.z0.glb.clouddn.com/brandbg.jpg'
});
}
};
</script>
... ...