|
楼主 |
发表于 2016-12-7 15:26:56
|
显示全部楼层
我把我的测试页面代码给你看看
第一个方法是分享方法
Model.prototype.weixinClick = function(event) {
// share.shareTo({
// scene : "timeline"
// });
function success(result) {
}
function error(result) {
}
var url = window.location.href;
alert('调用分享到微信朋友圈');
if (!navigator.weixin) {
return;
}
function success(result) {
alert(JSON.stringify(result));
}
function error(result) {
alert(JSON.stringify(result));
}
/*
* Scene: { SESSION: 0, // 聊天界面 TIMELINE: 1, // 朋友圈 FAVORITE: 2 // 收藏 },
* Type: { APP: 1, EMOTION: 2, FILE: 3, IMAGE: 4, MUSIC: 5, VIDEO: 6,
* WEBPAGE: 7 },
*/
alert("分享的路径是 "+url)
var weixin = navigator.weixin;
weixin.share({
message : {
title : "WeX5开发指南", // 标题
description : "分享到微信", // 描述,分享到朋友圈的时候描述不可见,分享给朋友时可见
mediaTagName : "轻松生活",
thumb : 'file:///C:\Users\Administrator\AppData\Roaming\Tencent\QQ\Temp\%W@GJ$ACOF(TYDYECOKVDYB.pnghttp://wex5.com/cn/wp-content/uploads/2015/03/wen-xin-2.png',//location.origin + require.toUrl('./img/weixin.jpg'), // 图标,图标不能大于30KB,
// location.origin
// +
// require.toUrl('./');
media : {
// type : weixin.Type.WEBPAGE, // webpage
// 设置分享类型,webpage为url
webpageUrl : utils.getShareUrl(url)
// Utils.getShareUrl()
// 设置当前页面为分享url,Utils.getShareUrl("[img]file:///C:\Users\ADMINI~1\AppData\Local\Temp\[5UQ[BL(6~BS2JV6W}N6[%S.png[/img]http://www.baidu.com")
// 设置指定url为分享页面
// webpage
}
},
scene : navigator.weixin.Scene.TIMELINE
}, success, error);
};
第二个方法是 model时间里面 回来的方法
Model.prototype.modelLoad = function(event){
alert("modelLoad111");
var self = this;
var url = window.location.href;
alert(url)
base.ready(function() {
// self.ready.set(true);
share.onMenuShareTimeline({
title : 'WeX5开发指南',
link : utils.getShareUrl(url),
imgUrl : 'file:///C:\Users\Administrator\AppData\Roaming\Tencent\QQ\Temp\%W@GJ$ACOF(TYDYECOKVDYB.pnghttp://wex5.com/cn/wp-content/uploads/2015/03/wen-xin-2.png',
trigger : function(res) {
// 不要尝试在trigger中使用ajax异步请求修改本次分享的内容,因为客户端分享操作是一个同步操作,这时候使用ajax的回包会还没有返回
alert('用户点击分享到朋友圈');
},
success : function(res) {
alert('已分享');
},
cancel : function(res) {
alert('已取消');
},
fail : function(res) {
alert(JSON.stringify(res));
}
});
});
};
|
|