小程序分享
1、支持分享小程序类型消息至会话,暂不支持分享至朋友圈
2、若客户端版本低于6.5.6或在iPad客户端接收,小程序类型分享将自动转成网页类型分享。开发者必须填写网页链接字段,确保低版本客户端能正常打开网页链接。
import { MWeixin } from "@yl/super-jssdk";
MWeixin.shareMiniProgram(optional);
| 参数 | 类型 | 必填 | 作用 |
|---|---|---|---|
| optional | Object | 是 | 必选参数 |
optional
| 参数 | 类型 | 必填 | 作用 |
|---|---|---|---|
| params | object | 是 |
params结构说明
| 参数 | 类型 | 必填 | 作用 |
|---|---|---|---|
| userName | string | 是 | 小程序的原始id,可通过微信公众平台-->设置-->基本设置-->帐号信息里得到 |
| webpageUrl | string | 是 | 兼容低版本的网页链接,当手机安装微信为低版本时,以网页形式打开 |
| thumbData | string | 是 | 缩略图地址,支持本地、网络地址(分享前将自动下载该图片,打开微信分享速度依网速而定) |
| path | string | 否 | 小程序页面的路径 |
| title | string | 否 | 标题 |
| description | string | 否 | 兼容低版本的描述语 |
| miniProgramType | number | 否 | 0:正式版;1:开发版;2:体验版;默认为0 |
| 参数 | 类型 | 作用 |
|---|---|---|
| resolve(result) | Function | result为json对象,格式如:{"code":"用户换取access_token的code","state":"第三方程序发送时用来标识其请求的唯一性的标志","lang":"微信客户端当前语言","country":"微信用户当前国家信息"} |
| reject(error) | Function | 失败回调,err为详细错误信息,是一个json对象,例如:{"errCode":-1,"errMsg":"出错啦"} |
const params = { "userName":"gh_1c95c11a29e2",
"webpageUrl":"http://www.baidu.com",
"path":"pages/index/index",
"title":"小程序标题",
"description":"小程序desc",
"thumbData":"http://www.xiufa.com/BJUI/plugins/kindeditor_4.1.10/attached/image/20160427/20160427020327_69298.png"};
MWeixin.shareMiniProgram({params}).then(res => {
console.log(res)
}).catch(err => {
console.log(err)
});