小程序分享给好友列表
效果图
<button class="menu"open-type='share'><image class="big_img"style="height:240rpx;"src="{{'/tuike/big_register2.png'}}"></image></button>
js部分
onShareAppMessage () {return {title: '快来注册成为分销客,推荐客户拿佣金吧!',path: '/pages/entry?parentId=' + this.userinfo.distributorId + '&storeId=' + this.storeId + '&isShare=' + 1}}
小程序分享到朋友圈
Page({//页面的初始数据data:{},//自定义函数// 用户点击右上角分享给好友,要先在分享好友这里设置menus的两个参数,才可以分享朋友圈onShareAppMessage: function() {wx.showShareMenu({withShareTicket: true,menus: ['shareAppMessage', 'shareTimeline']})},// 分享到朋友圈onShareTimeline () {return {title: this.current_viewing.name,query: '/pages/home/view/artdetail?storeId=' + this.storeId + '&id=' + this.current_viewing.id + '&customerId=' + this.customerId + '&genre=' + this.current_viewing.genre,}}//用户点击右上角分享朋友圈示例// onShareTimeline: function () {// return {// title: '',// query: {// key: value// },// imageUrl: ''// }// },//生命周期函数--监听页面加载onLoad: function(options) {},})
写了这段代码后,刚加载页面时分享朋友圈是灰色的,我点击了分享好友后,才可以分享朋友圈?
把这段代码放到onLoad或者onReady中就可以了
wx.showShareMenu({withShareTicket: true,menus: ['shareAppMessage', 'shareTimeline']})