uniapp微信分享功能

/* //#ifdef H5
            const url = encodeURIComponent(window.location.href.split('#')[0]);
            let params = 'url='+url
            getWeixinShareParams(params).then(res => {
                let {data,status,msg} = res;
                if(status === 10000){
                    let s = data;
                    that.$wx.config({
                        debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
                        appId: s.appid, // 必填,公众号的唯一标识
                        timestamp: s.timestamp, // 必填,生成签名的时间戳
                        nonceStr: s.noncestr, // 必填,生成签名的随机串
                        signature: s.signature,// 必填,签名
                        jsApiList: ['onMenuShareAppMessage', 'onMenuShareTimeline'] // 必填,需要使用的JS接口列表
                    });
                    that.$wx.ready(function () {
                        //分享到朋友
                        that.$wx.onMenuShareAppMessage({
                            title: "快戳我啊!让您享受白菜价网购的快感", // 分享标题
                            desc: "先领优惠券再下单享受折上折,各种大额优惠券让你领到手软呦!快戳我!快戳我!", // 分享描述
                            link: window.location.href, // 分享链接
                            imgUrl: "https://himg.bdimg.com/sys/portrait/item/wise.1.ce97d70.5dsprhrSJv7ZbQlgHusPsg.jpg?time=4105", // 分享图标
                            type: 'link', // 分享类型,music、video或link,不填默认为link
                            success: function () {
                                //alert("分享成功");
                                that.$message.success('分享成功');
                            },
                            cancel: function () {
                                //alert("未分享!");
                                that.$message.success('分享取消');
                            }
                        });
                        that.$wx.onMenuShareTimeline({
                            title: "快戳我!让您享受白菜价网购的快感", // 分享标题
                            desc: "先领优惠券再下单享受折上折,各种大额优惠券让你领到手软呦!快戳我!快戳我!", // 分享描述
                            link: window.location.href, // 分享链接
                            imgUrl: "https://himg.bdimg.com/sys/portrait/item/wise.1.ce97d70.5dsprhrSJv7ZbQlgHusPsg.jpg?time=4105", // 分享图标
                            trigger: function (res) {
                            },
                            success: function (res) {
                                that.$message.success('分享成功');
                            },
                            cancel: function (res) {
                                that.$message.success('分享取消');
                            },
                            fail: function (res) {
                            }
                        });
                    });
                }
            });
            //#endif */

 

posted @ 2021-10-21 17:20  春风得意之时  阅读(1285)  评论(0编辑  收藏  举报