zoukankan      html  css  js  c++  java
  • 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 */

    作者:freddyhuang
    出处:https://www.cnblogs.com/freddyhuang
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    关于分布式事务、两阶段提交协议、三阶提交协议
    关于分布式一致性的探究
    初始分布式系统
    移动端禁止video在ios系统中自动全屏播放
    ios对new Date() 的兼容问题
    VUE路由懒加载的方式
    记录 好看的阴影
    创建码云仓库,并将本地代码上传至仓库
    v-cloak遇到的问题及解决方法
    CSS 定义一条渐变优雅的分割线
  • 原文地址:https://www.cnblogs.com/freddyhuang/p/15434290.html
Copyright © 2011-2022 走看看