• H5登录 分享(未完)


    前提条件:H5静态页面,登录接口

    登录:

    分享:

    先引入 

    <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>

    值得注意的是:这个链接的协议必须和项目页面的协议保持一致(不能一个http 一个https)
    $(function() {
    var url = location.href.split('#')[0];

    alert(url);
    //请求微信分享所需信息
    $.ajax({
    url: 'https://xcx.puhuiwealth.com/index/index/share', //分享接口
    type: 'post',
    dataType: 'json',
    data: {'url': url},
    success: function (res) {
    alert("111111" + res);
    wx.config({

    appId: res.appId, // 必填,公众号的唯一标识
    timestamp: res.timestamp, // 必填,生成签名的时间戳
    nonceStr: res.nonceStr, // 必填,生成签名的随机串
    signature: res.signature,// 必填,签名,见附录1
    jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage'] // 必填,需要使用的JS接口列表
    });

    },
    error(err) {
    alert("2222222222" + err);
    }
    })
    })
    //微信配置
    wx.ready(function(){
    wx.onMenuShareTimeline({//分享到朋友圈
    title: '双十一的背后,真相竟然是......', // 分享标题
    link: 'https://xcx.puhuiwealth.com/double11/index.html', // 分享链接
    imgUrl: 'https://xcx.puhuiwealth.com/double11/resources/share.jpg' // 分享图标
    });
    wx.onMenuShareAppMessage({//分享给朋友
    title: '双十一的背后,真相竟然是......', // 分享标题
    link: 'https://xcx.puhuiwealth.com/double11/index.html', // 分享链接
    imgUrl: 'https://xcx.puhuiwealth.com/double11/resources/share.jpg', // 分享图标
    desc: '查看真相请戳→', // 分享描述

    type: '', // 分享类型,music、video或link,不填默认为link
    dataUrl: '', // 如果type是music或video,则要提供数据链接,默认为空
    success: function () {
    // 用户确认分享后执行的回调函数
    alert('share success');
    },
    cancel: function () {
    // 用户取消分享后执行的回调函数
    alert('share cancle');
    }
    })
    });
  • 相关阅读:
    bzoj3302
    bzoj1264
    听风
    bzoj5073
    bzoj2144
    bzoj1263
    bzoj3653
    Docker 入门 2 镜像基本操作
    Docker 入门 1 准备 Docker 环境
    Docker Hub 镜像加速
  • 原文地址:https://www.cnblogs.com/dongjingya/p/11805907.html
Copyright © 2020-2023  润新知