diff --git a/lib/apis.js b/lib/apis.js index 0d3ce943c315446a6d5d17028d91ee36aa63dddf..dfd43bb600d7b1b59993ad1a4a9fcaf3717d56f4 100644 --- a/lib/apis.js +++ b/lib/apis.js @@ -187,6 +187,7 @@ const third = [ 'checkSession', 'getUserInfo', 'share', + 'shareWithSystem', 'showShareMenu', 'hideShareMenu', 'requestPayment', diff --git a/src/platforms/app-plus/service/api/plugin/share.js b/src/platforms/app-plus/service/api/plugin/share.js index b40b6354b980ff9a7e00fcbce7f829ca28faaddb..2960ecad3dad5927d48f9939ceac7a607a65923e 100644 --- a/src/platforms/app-plus/service/api/plugin/share.js +++ b/src/platforms/app-plus/service/api/plugin/share.js @@ -195,3 +195,36 @@ export function share (params, callbackId, method = 'share') { } ) } + +export function shareWithSystem (params, callbackId, method = 'shareWithSystem') { + let { + type, + imageUrl, + summary: content, + href + } = params + type = type || 'text' + const allowedTypes = ['text', 'image'] + if (allowedTypes.indexOf(type) < 0) { + invoke(callbackId, { + errMsg: method + ':fail:分享参数 type 不正确' + }) + } + if (typeof imageUrl === 'string' && imageUrl) { + imageUrl = getRealPath(imageUrl) + } + plus.share.sendWithSystem({ + type, + pictures: imageUrl ? [imageUrl] : [], + content, + href + }, function (res) { + invoke(callbackId, { + errMsg: method + ':ok' + }) + }, function (err) { + invoke(callbackId, { + errMsg: method + ':fail:' + err.message + }) + }) +}