1. 程式人生 > >分享微信鏈接自定義標題前端(基於asp測試版)

分享微信鏈接自定義標題前端(基於asp測試版)

tex als des line () ppm https head weixin

<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>



分享微信鏈接自定義標題前端(基於asp測試版)