* para: {id:'sohu',isNeedLoginTip:'xxxxx?',loginedMethod:getJobUserLink}
* 默认调用方式:snsShareFun({id:'tqq',isNeedLoginTip:''})
* 调用该方法的前提条件:
* 1.需要为本页面的内容隐藏域:tips_mask_share_title 赋值
* 2.需要为本页面的URL隐藏域:tips_mask_share_url 赋值
* 3.需要在调用本方法的页面声明变量 var jobID (工作ID) 并为给变量赋值
* 4.用到全局变量变量:isLogin,保证该值的正确性
*/
var goUrl;
function snsShareFun(obj){
//微博类型
var v_type;
//跳转到微博的URL
var url ;
//新开窗口tip
var tip ;
//设定宽度
var temp_width = obj.width;
if(typeof(temp_width)=="undefined"){
temp_width = screen.availWidth-400;
}
//设定高度
var temp_height = obj.height;
if(typeof(temp_height)=="undefined"){
temp_height = screen.availHeight-200;
}
//设定分享内容
var shareTitle = obj.shareTitle;
if(typeof(shareTitle)=="undefined"){
shareTitle = share_title;
}
//设定分享链接
var shareUrl = obj.shareUrl;
if(typeof(shareUrl)=="undefined"){
shareUrl = share_url;
}
if (obj.id=="sohu"){
url="http://t.sohu.com/third/post.jsp?url=?share_url&title=?share_title&content=utf-8";
tip="转播到搜狐微博";
v_type="0";
}else if (obj.id=="tqq"){
url="http://v.t.qq.com/share/share.php?title=?share_title&url=?share_url&site=www.aceona.com&appkey="+encodeURI('7c3450bbecd247758089ee8df5cf546c');
tip="转播到腾讯微博";
v_type="1";
}else if (obj.id=="tsina"){
url="http://v.t.sina.com.cn/share/share.php?title=?share_title&url=?share_url&appkey=" + 2937052444+ "&site=www.aceona.com&content=utf-8";
tip="转播到新浪微博";
v_type="2";
}else if (obj.id=="qzone"){
url="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=?share_url&title=?share_title";
tip="转播到QQ空间";
v_type="3";
}else if (obj.id=="bsh"){
url="http://bai.sohu.com/share/blank/add.do?link=?share_url&title=?share_title";
tip="转播到白社会";
v_type="4";
}else if (obj.id=="douban"){
url="http://www.douban.com/recommend/?url=?share_url&title=?share_title";
tip="转播到豆瓣网";
v_type="5";
}else if (obj.id=="xiaonei"){
url="http://share.renren.com/share/buttonshare.do?link=?share_url&title=?share_title";
tip="转播到人人网";
v_type="6";
}
goUrl = url;
var isNeedLoginTip = obj.isNeedLoginTip;
var loginedMethod = obj.loginedMethod;
//判断是否需要登陆
if(typeof(isNeedLoginTip)!="undefined")
{
getCurrentUser(function(result){
if(result.RESULT=="unauthorized"){//未登陆
if(isNeedLoginTip==''){
isNeedLoginTip='登陆后分享可能会获得推荐奖金,确认吗?';
}
jConfirm(isNeedLoginTip,"温馨提示",
function(flag)
{
if(flag)
{
showLoginDiv();
}
else
{
commonShare(goUrl,tip,temp_width,temp_height,shareUrl,shareTitle);
}
});
}else{//已经登陆
if(typeof(loginedMethod)!="undefined")
{
loginedMethod(v_type,callback);
}else{
getJobUserLink({async:false,post_id:jobID,share_type:v_type},function(data){
if(data!=null)
{
$("#tips_mask_share_url").val(data);
}
commonShare(goUrl,tip,temp_width,temp_height,shareUrl,shareTitle);
});
}
}
});
}else
{
commonShare(goUrl,tip,temp_width,temp_height,shareUrl,shareTitle);
}
} // end snsShareFun
function commonShare(url,tip,temp_width,temp_height,shareUrl,shareTitle)
{
//定义新开窗口样式
var defaultFeatures={
scrollbars:"no",
status:"yes",
resizable:"no",
titlebar:"no",
width:temp_width,
height:temp_height,
top:Math.ceil(100),
left:Math.ceil(200)
};
var content = url.replace("?share_url",encodeURIComponent(shareUrl)).replace("?share_title",encodeURIComponent(shareTitle));
window.open(content,tip,defaultFeatures);
}
//获取url
function getJobUserLink(param, method) {
$.get("/action?UserShareAction=0&action=getShareLink", param,
function(data) {
if (typeof method == "function") {
method(data);
} else {
alert("method param error");
}
});
}