主页 > 前端 > javascript >
来源:未知 时间:2016-08-23 16:49 作者:xxadmin 阅读:次
[导读] 今天在做微信分享时候,特意去看了下官方的sdk文档,虽然都介绍了,但是不是很全,所以特意把流程记录下来供大家学习。 第一: 在需要调用JS接口的页面引入如下JS文件,(支持...
|
今天在做微信分享时候,特意去看了下官方的sdk文档,虽然都介绍了,但是不是很全,所以特意把流程记录下来供大家学习。 第一:在需要调用JS接口的页面引入如下JS文件,(支持https):http://res.wx.qq.com/open/js/jweixin-1.0.0.js 第二:备注:前端部分 //微信分享接口
function wxShares_func () {
var shareUrl = "/book/h5/weixin/share"; //微信接口用
var _this = this;
//var myLink = encodeURIComponent(encodeURIComponent(window.location.href));
var myLink = window.location.href;
console.log(myLink);
$.ajax({
type: "POST",
url: shareUrl,
//crossDomain: true,
dataType: "json",
data: "url="+myLink,
success: function (rst) {
console.log(rst);
if (!rst.result) { //请求的数据返回错误的时候
//alert(rst['error']);
} else {
share_api(rst);
};
}
});
function share_api(data) {
data.url = window.location.href;
if(/read/.test(window.location.href)){ //表示阅读页
data.url = method.route()["detail"]+"?id="+method.request("id");
}else if(/detail/.test(window.location.href)){
data.url = method.route()["detail"]+"?id
|
自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习
京ICP备14009008号-1@版权所有www.zixuephp.com
网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com