para-bridge-demo
Version:
a bridge api for js-ios/andriod rest
59 lines (52 loc) • 1.67 kB
text/typescript
import { BridgePlugin } from '../bridge';
interface IShareWeixinMsg {
// 分享场景
// timeline (默认)发送到朋友圈
// session 发送到聊天界面
// favorite 添加到微信收藏
scene?: 'timeline' | 'session' | 'favorite';
// 分享标题
title: string;
// 分享描述
desc: string;
// 分享图标
imgUrl?: string;
// 分享的base64格式图片,优先级高于imgUrl
imgBase64?: string;
// 分享链接
link: string; // "http://m.fc.com/",
// 分享类型
// video-视频, music-音乐, img-图片, text-文字, webpage-网页 (不填默认), 微信小程序另调bridge实现
type?: 'video' | 'music' | 'img' | 'text' | 'webpage';
// 分享的数据内容。如果type是video,则要提供数据链接,默认为空
dataUrl?: string;
}
interface IShareWeixinMsgResult {
// 0分享成功, 1取消分享, 2操作被拒绝, 3 其他
status: '0' | '1' | '2' | '3';
// 分享结果描述
desc: string;
}
export class ShareWeixinMsg<K> extends BridgePlugin<IShareWeixinMsg, K>{
protected get ntvPluginName() {
return '_ntv_navbar_share_to_weixin';
}
protected get availableMinVersion() {
return '1.0.0';
}
protected bridgeExecChrome(pluginName: string | undefined): void {
throw new Error('ShareWeixinMsg() 未针对当前环境实现');
}
}
/**
* 分享到微信的朋友圈和朋友。
* Tips:可分享文字,图片,音乐和视频
*/
export const shareToWeixin = (param: IShareWeixinMsg) => {
return new ShareWeixinMsg<IShareWeixinMsgResult>(param).invokeOnce().then(result => {
return result.cbData;
})
}
/**
* todo: 分享到微信小程序
*/