const app = getApp({ allowDefault: true }) // pages/share/share.js Page({ /** * 页面的初始数据 */ data: { posterPath: "", s: app.system.statusBarHeight, // 状态栏高度 n: (app.menu.top - app.system.statusBarHeight) * 2 + app.menu.height, // 导航栏高度 t: app.menu.top, // 胶囊局顶部距离 h: app.menu.height, // 胶囊高度 }, share() { wx.showModal({ title: '提示', content: '请点击右上角“···”,选择“分享到朋友圈”', showCancel: false }); }, onShareAppMessage(){ return { title: '人人爱净水', // 分享卡片标题(必填) path: '/pages/water_filter/water_filter', // 用户点击后跳转的路径(可选,默认当前页) imageUrl: 'https://wechat-img-file.oss-cn-beijing.aliyuncs.com/share.png' // 自定义图片(可选,比例建议 5:4) } }, onShareTimeline() { return { title: '人人爱净水', // 自定义标题 query: '', // 自定义页面路径中的参数 imageUrl: 'https://wechat-img-file.oss-cn-beijing.aliyuncs.com/share.png' // 自定义分享图片路径 } }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { wx.showShareMenu({ withShareTicket: true, menus: ['shareAppMessage', 'shareTimeline'] }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, })