zoukankan      html  css  js  c++  java
  • 分享微信链接自定义标题前端(基于asp测试版)

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport"  content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
    <script src="./js/jquery-2.1.1.min.js"></script>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
        <title>TEST</title>
    </head>
        <body><p>每一件事都行!</p>
            <button onclick="ajaxConfig()">测试结果</button>     
        </body>
    <script  type="text/javascript">
        function ajaxConfig(){
            let url1 = "https://api.douban.com/v2/book/isbn/"+ 9787040332612
            var url=window.location.href.split('#')[0];  
            url = url.replace(/&/g, '%26');
            let url_config = "http://118.25.3.240:8060/getUrl?url="+url
            $.ajax({
                type: "GET",
                url: url_config,
                dataType: "JSON",
                processData: false,
                success: function (obj) {
                    console.log(obj)
                    wx.config({
                        debug: true,
                        appId: obj.appId,
                        timestamp: obj.timestamp,
                        nonceStr: obj.nonceStr,
                        signature: obj.signature,
                        jsApiList: [
                            'onMenuShareAppMessage'
                        ]
                    });
                    wx.checkJsApi({

                           jsApiList: ['onMenuShareTimeline','onMenuShareAppMessage'], // 需要检测的JS接口列表,所有JS接口列表见附录2,

                           success: function(res) {

                            }

                           });
                    wx.ready(function () {
                        wx.onMenuShareAppMessage({
                            title: '你好', // 分享标题
                            desc: "每一件事,你好", // 分享描述
                            link: url, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                            imgUrl: '', // 分享图标
                            trigger: function (res) {
                                alert('用户点击发送给朋友');
                            },
                            success: function (res) {
                                alert('已分享');
                            },
                            cancel: function (res) {
                                alert('已取消');
                            },
                            fail: function (res) {
                                alert(JSON.stringify(res));
                            }
                            
                        });
                                  
                });     
               
                  },
                   error: function(e){
                    console.log("error")
                 }
                   
                     });
            }
        
    </script>



  • 相关阅读:
    16.什么是面向对象编程?
    15.运动
    14.this指向和ES6常用内容
    13.正则表达式
    12.事件模型
    11.event事件对象
    10.BOM
    9.DOM
    拓扑排序学习(复习)笔记
    [Luogu] P1987 摇钱树
  • 原文地址:https://www.cnblogs.com/setname/p/10404145.html
Copyright © 2011-2022 走看看