<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>new title</title>
</head>
<body>
<nav title="测试分享"/>
<div width="100%" >
<input type="label" value="分享到" />
<select id="select" value="session" width="100%" >
<option text="会话" value="session" ></option>
<option text="朋友圈" value="timeline" ></option>
<option text="收藏" value="favorite" ></option>
</select>
</div>
<input type="button" value="分享文本" onClick="shareText" width="100%"/>
<input type="button" value="分享图片" onClick="shareImg" width="100%"/>
<input type="button" value="分享新闻" onClick="shareNews" width="100%"/>
</body>
<script>
function shareText(){
var data = {};
data.content="我是要分享的文本信息";
testShare(0,data);
}
function shareImg(){
var data ={};
data.image= "/images/app.png";//(单纯去分享图片的时候,没有太大限制)
testShare(1,data);
}
function shareNews(){
/**
* content 分享内容
* title 标题
* image 图片路径(和新闻在一起分享的时候,图片的大小不能超过32k,微信有限制)
* url 点击后跳转到的页面
* desc 描述信息
* type 分享类型 text:0 image:1 news:2
*/
var data = {};
data.content = "我是要分享的信息";
data.title = "分享标题";
data.image = "/images/app.png";
data.url = "http://www.primeton.com";
testShare(2,data);
}
function testShare(type,param){
Utils.shareWebchat(type,select.getValue(),param,function(retCode,retMsg){
toast(retCode+','+retMsg);
});
}
</script>
</html>