index.js
import share from './src/share.js';
export {share}
share.js
export default {
created() {
//#ifdef MP-WEIXIN
wx.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline']
});
//#endif
},
}
/**
* 开启朋友圈分享功能
* @description 监听路由切换/自动执行
* @return void
*/
overShare() {
wx.onAppRoute((res) => {
// console.log('route', res)
let pages = getCurrentPages()
let view = pages[pages.length - 1]
if(view) {
wx.showShareMenu({
menus: ['shareAppMessage', 'shareTimeline'],
success(res) {},
fail(e) {}
})
}
})
},
//引入分享
import {share} from './mixins/index.js'
Vue.mixin(share)