mtl-js-sdk
Version:
ynf-fw-mtl-api
74 lines (73 loc) • 2.49 kB
JavaScript
import {invokeSuccess, invokeFail} from '../callback'
import {execUpesnBridgeify,canExecUpesnBridge} from '../bridge/index'
export function doShare(param = {}) {
let {type, title, desc, imgUrl, link} = param;
if (typeof type == 'number') {
if (type == 2 || type == 3) {
let obj = api.require('wxPlus');
if (!obj) {
if (canExecUpesnBridge()) {
execUpesnBridgeify('shareWithType', {
...param,
imageUrl: imgUrl,
pageUrl: param.link
});
return;
}
invokeFail(param, {msg:'module wxPlus not added'});
return;
}
obj.shareWebpage({
scene: type == 2 ? 'session' : 'timeline',
title: title,
description: desc,
thumb: imgUrl,
contentUrl: link
}, function(ret, err){
if (ret.status){
invokeSuccess(param, {});
} else {
invokeFail(param, err);
}
});
} else if (type == 4 || type == 5) {
let obj = api.require('QQPlus');
if (!obj) {
if (canExecUpesnBridge()) {
execUpesnBridgeify('shareWithType', {
...param,
imageUrl: imgUrl,
pageUrl: param.link
});
return;
}
invokeFail(param, {msg:'module QQPlus not added'});
return;
}
obj.shareNews({
type: type == 4 ? 'QFriend' : 'QZone',
title: title,
description: desc,
imgUrl: imgUrl,
url: link
}, function(ret, err){
if (ret.status){
invokeSuccess(param, {});
} else {
invokeFail(param, err);
}
});
} else {
if (canExecUpesnBridge()) {
execUpesnBridgeify('shareWithType', {
...param,
imageUrl: imgUrl,
pageUrl: param.link
});
return;
}
}
} else {
invokeFail(param, {'message':'not support'});
}
}