uniapp分享到微信好友和朋友圈
首先目前的微信小程序只支持页面中右上角三个点触发分享功能,页面按钮只能触发分享至微信好友的功能
<template><view class="share"><button open-type="share"> <image :src="item.icon" mode='heightFix' @click="share_action"></image> <text>分享</text></button></view>
</template>
<script>export default {data(){return {}},onShow(){wx.showShareMenu({withShareTicket:true,menus:["shareAppMessage","shareTimeline"]})},methods:{onShareTimeline(options) {let that = thislet data = {title:'', imageUrl: '', success: res => {if (res.errMsg == 'shareAppMessage:ok') {}},fail: res => {if (res.errMsg == 'shareAppMessage:fail cancel') {}if (res.errMsg == 'shareAppMessage:fail') {}},complete: res => {}}return data},onShareAppMessage(options){var that = this;var shareObj = {title:'', desc:'',path: '/pages/share/index', imageUrl: '', success: function(res){if(res.errMsg == 'shareAppMessage:ok'){console.log(res)}},fail: function(){if(res.errMsg == 'shareAppMessage:fail cancel'){console.log(res)}else if(res.errMsg == 'shareAppMessage:fail'){console.log(res)}},complete: fucntion(){}}if( options.from == 'button' ){var eData = options.target.dataset;console.log( eData.id); shareObj.path = '/pages/share/index'}return shareObj;},}}
</script>