有房
This commit is contained in:
@@ -1,60 +0,0 @@
|
|||||||
plus.share.getServices(function(s) {
|
|
||||||
shares = ss;
|
|
||||||
for (var i in ss ) {
|
|
||||||
var s = ss[i];
|
|
||||||
var item = document.createElement("li");
|
|
||||||
item.setAttribute("class", "ditem");
|
|
||||||
item.setAttribute("onclick", (s.id == "weixin") ? "shareWeiXin(this.plusShare)" : "shareAction(this.plusShare)");
|
|
||||||
item.innerText = s.description;
|
|
||||||
item.plusShare = s;
|
|
||||||
list.appendChild(item);
|
|
||||||
}
|
|
||||||
}, function(e) {
|
|
||||||
alert("获取分享服务列表失败:" + e.message);
|
|
||||||
});
|
|
||||||
|
|
||||||
function shareAction(s, ex) {
|
|
||||||
outSet("分享操作:");
|
|
||||||
if (!s) {
|
|
||||||
outLine("无效的分享服务!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (s.authenticated) {
|
|
||||||
outLine("---已授权---");
|
|
||||||
shareMessage(s, ex);
|
|
||||||
} else {
|
|
||||||
outLine("---未授权---");
|
|
||||||
s.authorize(function() {
|
|
||||||
shareMessage(s, ex);
|
|
||||||
}, function(e) {
|
|
||||||
outLine("认证授权失败:" + e.code + " - " + e.message);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function shareMessage(s,ex){
|
|
||||||
var msg={content:sharecontent.value,extra:{scene:ex}};
|
|
||||||
if(pic&&pic.realUrl){
|
|
||||||
msg.pictures=[pic.realUrl];
|
|
||||||
}
|
|
||||||
|
|
||||||
s.send( msg, function(){
|
|
||||||
alert( "分享到\""+s.description+"\"成功! " );
|
|
||||||
}, function(e){
|
|
||||||
alert( "分享到\""+s.description+"\"失败: "+e.code+" - "+e.message );
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
function cancelAuth(){try{
|
|
||||||
|
|
||||||
for ( var i in shares ) {
|
|
||||||
var s = shares[i];
|
|
||||||
if ( s.authenticated ) {
|
|
||||||
outLine( "取消\""+s.description+"\"");
|
|
||||||
}
|
|
||||||
s.forbid();
|
|
||||||
}
|
|
||||||
// 取消授权后需要更新服务列表
|
|
||||||
updateServices();
|
|
||||||
outLine( "操作成功!" );}catch(e){alert(e);}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* 更新分享服务
|
||||||
|
*/
|
||||||
|
function updateSerivces(){
|
||||||
|
plus.share.getServices( function(s){
|
||||||
|
shares={};
|
||||||
|
for(var i in s){
|
||||||
|
var t=s[i];
|
||||||
|
shares[t.id]=t;
|
||||||
|
}
|
||||||
|
}, function(e){
|
||||||
|
alert("获取分享服务列表失败:"+e.message );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 分享操作
|
||||||
|
* @param {JSON} sb 分享操作对象s.s为分享通道对象(plus.share.ShareService)
|
||||||
|
* @param {Boolean} bh 是否分享链接
|
||||||
|
*/
|
||||||
|
function shareAction(sb,bh) {
|
||||||
|
if(!sb||!sb.s){
|
||||||
|
alert("无效的分享服务!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var msg={content:sharehrefDes,extra:{scene:sb.x}};
|
||||||
|
if(bh){
|
||||||
|
msg.href=shareUrl;
|
||||||
|
if(sharehrefTitle&&sharehrefTitle!=""){
|
||||||
|
msg.title=sharehrefTitle;
|
||||||
|
}
|
||||||
|
if(sharehrefDes&&sharehrefDes!=""){
|
||||||
|
msg.content=sharehrefDes;
|
||||||
|
}
|
||||||
|
msg.thumbs=["_www/logo.png"];
|
||||||
|
msg.pictures=["_www/logo.png"];
|
||||||
|
}else{
|
||||||
|
if(pic&&pic.realUrl){
|
||||||
|
msg.pictures=[pic.realUrl];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 发送分享
|
||||||
|
if ( sb.s.authenticated ) {
|
||||||
|
shareMessage(msg,sb.s);
|
||||||
|
} else {
|
||||||
|
alert("---未授权---");
|
||||||
|
sb.s.authorize( function(){
|
||||||
|
shareMessage(msg,sb.s);
|
||||||
|
},function(e){
|
||||||
|
alert("认证授权失败:"+e.code+" - "+e.message );
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 发送分享消息
|
||||||
|
* @param {JSON} msg
|
||||||
|
* @param {plus.share.ShareService} s
|
||||||
|
*/
|
||||||
|
function shareMessage(msg,s){
|
||||||
|
s.send( msg, function(){
|
||||||
|
alert("分享到\""+s.description+"\"成功! " );
|
||||||
|
|
||||||
|
}, function(e){
|
||||||
|
alert( "分享到\""+s.description+"\"失败: "+JSON.stringify(e) );
|
||||||
|
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分析链接
|
||||||
|
function shareHref(){
|
||||||
|
var shareBts=[];
|
||||||
|
// 更新分享列表
|
||||||
|
var ss=shares['weixin'];
|
||||||
|
ss&&ss.nativeClient&&(shareBts.push({title:'微信朋友圈',s:ss,x:'WXSceneTimeline'}),
|
||||||
|
shareBts.push({title:'微信好友',s:ss,x:'WXSceneSession'}));
|
||||||
|
ss=shares['qq'];
|
||||||
|
ss&&ss.nativeClient&&shareBts.push({title:'QQ',s:ss});
|
||||||
|
// 弹出分享列表
|
||||||
|
shareBts.length>0?plus.nativeUI.actionSheet({title:'分享链接',cancel:'取消',buttons:shareBts},function(e){
|
||||||
|
(e.index>0)&&shareAction(shareBts[e.index-1],true);
|
||||||
|
}):plus.nativeUI.alert('当前环境无法支持分享链接操作!');
|
||||||
|
}
|
||||||
@@ -271,7 +271,7 @@
|
|||||||
"description": "个推推送"
|
"description": "个推推送"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"share": {"weixin":{"appid":"wx734a9e3085abcd90","appsecret":"47ce59f3c52984c4e193880fb09b12af","description":"可选,微信分享"}},
|
"share": {"weixin":{"description":"可选,微信分享"}},
|
||||||
"payment": {},
|
"payment": {},
|
||||||
"oauth": {
|
"oauth": {
|
||||||
"weixin": {
|
"weixin": {
|
||||||
|
|||||||
@@ -23,7 +23,9 @@
|
|||||||
<button class="button button-link button-nav pull-left" onclick="back(),plus.nativeUI.closeWaiting();">
|
<button class="button button-link button-nav pull-left" onclick="back(),plus.nativeUI.closeWaiting();">
|
||||||
<span class="mui-icon mui-icon mui-icon-arrowleft"></span>
|
<span class="mui-icon mui-icon mui-icon-arrowleft"></span>
|
||||||
</button>
|
</button>
|
||||||
<button onclick="shareShow()">打开分享</button>
|
<button class="button button-link button-nav pull-right open-popover" onclick="shareHref()">
|
||||||
|
<span class="icon icon-path"></span>
|
||||||
|
</button>
|
||||||
<h1 class="title"></h1>
|
<h1 class="title"></h1>
|
||||||
</header>
|
</header>
|
||||||
<div class="content contentText">
|
<div class="content contentText">
|
||||||
@@ -51,12 +53,19 @@ $.config = {router: false}
|
|||||||
<script type="text/javascript" src="../../js/cn.js" charset="utf-8"></script>
|
<script type="text/javascript" src="../../js/cn.js" charset="utf-8"></script>
|
||||||
<script src="../../config.js"></script>
|
<script src="../../config.js"></script>
|
||||||
<script type="text/javascript" src="../../js/common.js" ></script>
|
<script type="text/javascript" src="../../js/common.js" ></script>
|
||||||
<script type="text/javascript" src="../../js/shara/shara.js" ></script>
|
<script type="text/javascript" src="../../js/shara/sharaMine.js" ></script>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('plusready', onPlusReady, false);
|
document.addEventListener('plusready', onPlusReady, false);
|
||||||
|
var shareUrl = BASE_PATH+"/news/newDetail?newsId=";
|
||||||
|
var sharehrefTitle = "我是一个超级无敌大帅哥";
|
||||||
|
var sharehrefDes = "不信你自己来看看啊!";
|
||||||
|
var shareId='';
|
||||||
|
|
||||||
function onPlusReady() {
|
function onPlusReady() {
|
||||||
var self = plus.webview.currentWebview();
|
var self = plus.webview.currentWebview();
|
||||||
var id = self.newsId;
|
var id = self.newsId;
|
||||||
|
shareId = id
|
||||||
|
shareUrl = shareUrl+id
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type : 'get',
|
type : 'get',
|
||||||
url : BASE_PATH + "/rest/news/detail",
|
url : BASE_PATH + "/rest/news/detail",
|
||||||
@@ -79,9 +88,11 @@ function onPlusReady() {
|
|||||||
error:function(){
|
error:function(){
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
updateSerivces();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user