star-m-share
v0.0.2
Published
IMWeb team unit share for mobile
Downloads
2
Readme
star-m-share
移动端share分享组件,现继承手Q分享和微信内嵌页分享
依赖说明
- jquery
- qqapi
使用说明
初始化
share.init(opt);
MQQ分享消息
// opts: 同init参数
// type: 分享类型,0:QQ好友;1:QQ空间;2:微信好友;3:微信朋友圈
// cb: 4.7.2版本以下不支持此分享,这时会调用cb
share.MQQShareMessage(opts, type, cb);
展示MQQ分享面板
// opts: 同init参数
// onMQQShowShareMenu: function,面板展示之后回调
// cb: 5.2版本以下不支持此分享,这时会调用cb
share.MQQShowShareMenu(opts, cb);
微信分享好友
// opts: 同init参数
share.WeiXinShareToFriend(opts);
微信分享朋友圈
// opts: 同init参数
share.WeiXinShareToTimeline(opts);
静态扩展,永久可用:
- 在OP内添加分享组件的初始化代码,key为位数值,从低到高,如1,2,4,8,value为function(opts)
- 在share内添加flag常量供用户使用
动态扩展,页面内可用,同静态扩展,只是用程序来实现上面两个步骤
- share.OP[4] = function(opts) { ... };
- share.FLAG_XXX = 4;
API
属性、方法、事件、返回值等说明列表
| 属性 | 说明 | 类型 | 默认值 |
| :--- | :--- | :--- | :--- |
| flag | 初始化组件标识位,目前有share.FLAG_MQQ和share.FLAG_WEIXIN两个,可组合 | number
| undefined
|
| title | 分享标题,会被<meta itemprop="name" content="..."/>
覆盖 | string
| '分享' |
| desc | 分享描述,会被<meta itemprop="description" content="..."/>
覆盖 | string
| '点击查看详情' |
| image | 分享图片链接,会被<meta itemprop="image" content="..."/>
覆盖 | string
| undefined
|
| url | 分享链接 | string
| location.href
|
| beforeMQQShare | 在MQQ分享之前调用,可以修改分享内容 | function
| undefined
|
| beforeMQQShareTimeline | 在MQQ分享微信朋友圈之前调用,可以修改分享内容,因为分享朋友圈默认会把desc隐藏 | function
| undefined
|
| onMQQShareBtnClick | 在MQQ分享面板中点击了分享类型之后回调 | function
| undefined
|
| onMQQShare | MQQ分享回调,注:IOS不支持回调,分享微信好友和朋友圈不支持回调 | function
| undefined
|
| beforeWeiXinShareToFriend | 在微信分享好友之前调用,可以修改分享内容 | function
| undefined
|
| beforeWeiXinShareTimeline | 在微信分享朋友圈之前调用,可以修改分享内容,因为分享朋友圈默认会把desc隐藏 | function
| undefined
|
| onShareWeiXinFriend | 微信分享好友回调 | function
| undefined
|
| onShareWeiXinTimeline | 微信分享朋友圈回调 | function
| undefined
|
回调说明
beforeMQQShare: function,在MQQ分享之前调用,可以修改分享内容
- args:
- shareParams: 分享内容对象
- return:
- shareParams: 修改之后的分享内容对象
beforeMQQShareTimeline: function,在MQQ分享微信朋友圈之前调用,可以修改分享内容,因为分享朋友圈默认会把desc隐藏,因此与分享好友分开
- args:
- shareParams: 分享内容对象,title已经替换为desc,原来的title在otitle字段
- return:
- shareParams: 修改之后的分享内容对象
onMQQShareBtnClick: function,在MQQ分享面板中点击了分享类型之后回调
- args:
- type: 用户点击的分享类型,0:QQ好友;1:QQ空间;2:微信好友;3:微信朋友圈
- return: none
onMQQShare: function,MQQ分享回调,注:IOS不支持回调,分享微信好友和朋友圈不支持回调
- args: (注:4.6版本以下无参数)
- result: MQQ分享结果
- retCode: 0:用户点击发送,完成整个分享流程;1:用户点击取消,中断分享流程
- type: 用户点击的分享类型,0:QQ好友;1:QQ空间;2:微信好友;3:微信朋友圈
- return: none
beforeWeiXinShareToFriend: function,在微信分享好友之前调用,可以修改分享内容
- args:
- shareParams: 分享内容对象
- return:
- shareParams: 修改之后的分享内容对象
beforeWeiXinShareTimeline: function,在微信分享朋友圈之前调用,可以修改分享内容,因为分享朋友圈默认会把desc隐藏,因此与分享好友分开
- args:
- shareParams: 分享内容对象,title已经替换为desc,原来的title在otitle字段
- return:
- shareParams: 修改之后的分享内容对象
onShareWeiXinFriend: function,微信分享好友回调
- args:
- res: 分享结果
- err_msg: send_app_msg:cancel 用户取消
send_app_msg:ok 分享成功
fail: 分享失败
- return: none
onShareWeiXinTimeline: function,微信分享朋友圈回调
- args:
- res: 分享结果
- err_msg: share_timeline:cancel 用户取消,注:检测用户取消动作只有IOS支持
share_timeline:ok 分享成功
fail: 分享失败
- return: none