• 微信小程序实现分享至朋友圈的功能来啦


    参考: https://www.jianshu.com/p/64f73586e63a 

    https://developers.weixin.qq.com/miniprogram/dev/reference/api/Page.html#onShareTimeline

    https://www.jianshu.com/p/41990bc2167c

    https://www.jb51.net/article/187128.htm

     onLoad: function(options) {
            wx.showShareMenu({
                withShareTicket: true,
                menus: ['shareAppMessage', 'shareTimeline'],
                success(res) {
                    console.log(res)
                },
                fail(e) {
                    console.log(e)
                }
            })
        },
    
    
       onShareAppMessage: function() {
            return {
                title: "名巢未来酒店",
                desc: 'Minnest',
                path: '/pages/order/index/index'
            }
        },
        onShareTimeline: function() {
            return {
                title: '测试小程序分享至朋友圈',
                path: '../test/test',
                imageUrl: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1594374964481&di=3ceba827e91e126012c43de3887a58c7&imgtype=0&src=http%3A%2F%2Fdmimg.5054399.com%2Fallimg%2Fpkm%2Fpk%2F13.jpg'
            }
        },
    

      

      /**
         * 分享
         */
        onShareAppMessage: function() {
            var openId = wx.getStorageSync('openId');
            var queryPath = '/pages/home/index/index' + (openId ? '?shareOpenId=' + openId : '');
            console.log(queryPath);
            return {
                title: "名巢未来酒店",
                desc: 'Minnest',
                path: queryPath
            }
        },
    
        /**
         * 分享到朋友圈
         */
        onShareTimeline: function() {
            var openId = wx.getStorageSync('openId');
            var queryPath = '/pages/home/index/index' + (openId ? '?shareOpenId=' + openId : '');
            return {
                title: '名巢未来酒店',
                query: queryPath
            }
        },
    

      

      onLoad: function(options) {
            this.getLocation();
            this.getAds();
            this.initTimeList();
            this.getCouponCards(() => {
                this.setData({
                    showCouponsModal: true
                })
            });
            // 进入首页进行加载判断
            this.getnologinpic();
            wx.showShareMenu({
                withShareTicket:true,
                menus:['shareAppMessage', 'shareTimeline']
            })
            // 获取分享人
            if (options && options.shareOpenId) {
                var params = {
                    url: '/api/system/users',
                    body: {
                        openid: options.shareOpenId,
                    }
                }
                request.doRequest(
                    params,
                    function(data) {
                        if (data.data.length != 0) {
                            wx.setStorage({
                              data: data.data[0].id,
                              key: 'shareUser',
                            })
                        } else {
                            wx.setStorage({
                                data: 0,
                                key: 'shareUser',
                            })
                        }
                    },
                )
            } else {
                wx.setStorage({
                    data: 0,
                    key: 'shareUser',
                })
            }
        },
    

      

    苦心人,天不负
  • 相关阅读:
    ios 属性的特性
    ios 线程锁 与 线程交互
    iOS 变量名前为什么要加_下划线
    ios 常见问题
    ios 沙盒
    ios 去掉屏幕键盘的方法
    UITableView方法详解
    Image View、Text Field、Keyboard 隐藏键盘
    用php 进行对文件的操作 (上)
    文件上传-------头像上传预览
  • 原文地址:https://www.cnblogs.com/taxun/p/13857475.html
Copyright © 2020-2023  润新知