share

Share模块管理客户端的社交分享功能,提供调用终端社交软件的分享能力。通过plus.share可获取社交分享管理对象。

方法:

对象:

回调方法:

权限:

permissions

{
// ...
"permissions":{
	// ...
	"Share": {
		"description": "分享"
	}
}
}
			

AuthOptions

JSON对象,分享授权认证参数选项

interface plus.share.AuthOptions {
	attribute String appid;
	attribute String appkey;
	attribute String appsecret;
	attribute String redirect_uri;
}
				

说明:

此对象支持的属性值由分享服务的授权认证模块定义。

属性:

Authorize

分享授权控件对象

interface plus.share.Authorize{
	// Methods
	function void load(id);
	function void setVisible(visible);

	// Events
	function void onloaded();
	function void onauthenticated();
	function void onerror();
}
				

说明:

Authorize对象表示分享控件对象,用于在窗口中显示分享控件,使用此对象可自定义分享授权界面。

构造:

方法:

事件:

GeoPosition

JSON对象,用户位置信息

interface plus.share.GeoPosition {
	attribute Number latitude;
	attribute Number longitude;
}
				

说明:

GeoPosition对象用于表示用户分享消息时的位置信息。用于标识分享操作时用户的位置信息。

属性:

ShareService

分享服务对象

interface plus.share.ShareService {
	// Attributes
	attribute DOMString id;
	attribute DOMString description;
	attribute Boolean authenticated;
	attribute DOMString accessToken;
	attribute Boolean nativeClient;
	
	// Methods
	function void authorize(successCallback, errorCallback, options);
	function void forbid();
	function void send(message);
	function void launchMiniProgram(options);
}
				

说明:

ShareService对象用于表示分享服务,在JS中为对象,用于向系统请求分享操作。

属性:

方法:

ShareServerIdentity

分享服务标识

常量:

ShareMessage

JSON对象,分享消息对象

interface plus.share.ShareMessage {
	attribute String type;
	attribute String content;
	attribute String[] thumbs;
	attribute String[] pictures;
	attribute String media;
	attribute String href;
	attribute String title;
	attribute JSON extra;
	attribute GEOPosition geo;
	attribute ShareMessageExtra extra;
	attribute WeixinMiniProgramOptions miniProgram;
	attribute String interface;
}
				

说明:

ShareMessage对象用于表示分享消息内容,在JS中为JSON对象,用于向系统发送分享信息操作。

属性:

ShareMessageExtra

JSON对象,保存分享消息扩展信息

interface plus.share.ShareMessageExtra {
	attribute String scene;
}
				

说明:

ShareMessageExtra对象用于保存各分享平台扩展的参数,用于自定义分享功能。

属性:

WeixinMiniProgramOptions

JSON对象,微信小程序信息

interface plus.share.WeixinMiniProgramOptions {
	attribute String id;
	attribute String path;
	attribute Nnumber type;
	attribute webUrl;
}
				

说明:

用于配置分享小程序的参数,如小程序标识、页面路径等。 注意:分享的小程序需要在微信开放平台关联的开发者账号下,否则会分享失败。

属性:

ServicesSuccessCallback

获取分享服务成功回调

void ServicesSuccessCallback(services){
	// Get share services success code
}
				

说明:

当获取分享服务列表成功时的回调函数,用于返回终端支持的分享服务列表。

参数:

返回值:

void : 无

AuthorizeSuccessCallback

分享授权认证成功回调

void AuthorizeSuccessCallback(services){
	  // Authorize success code
}
				

说明:

分享服务授权认证操作成功时调用。

参数:

返回值:

void : 无

ShareSuccessCallback

分享操作成功回调

void ShareSuccessCallback(){
	// Share success code
}
				

说明:

分享操作成功回调函数,当分享操作成功时调用。

参数:

返回值:

void : 无

ShareErrorCallback

分享操作失败回调

void ShareErrorCallback(error){
	// Error 
	var code = error.code; 			// 错误编码
	var message = error.message;	// 错误描述信息
}
				

说明:

当分享操作失败时的回调函数,用于返回分享相关操作失败的错误信息。

参数:

返回值:

void : 无