43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const common_js_util = require("../../common/js/util.js");
|
|
const shareToWeixin = (title, imageUrl, content) => {
|
|
common_vendor.index.share({
|
|
provider: "weixin",
|
|
scene: "WXSceneSession",
|
|
shareData,
|
|
success: function(res) {
|
|
common_js_util.util.showToastAndRedirect("分享成功", "success");
|
|
},
|
|
fail: function(err) {
|
|
common_js_util.util.showToastAndRedirect("分享失败", "error");
|
|
}
|
|
});
|
|
};
|
|
const shareToQQ = (title, imageUrl, filePath) => {
|
|
common_vendor.index.share({
|
|
provider: "qq",
|
|
scene: "QZoneScene",
|
|
title,
|
|
imageUrl,
|
|
filePath,
|
|
success: function(res) {
|
|
common_js_util.util.showToastAndRedirect("分享成功", "success");
|
|
},
|
|
fail: function(err) {
|
|
common_js_util.util.showToastAndRedirect("分享失败", "error");
|
|
}
|
|
});
|
|
};
|
|
const shareToPlatform = (platform, title, imageUrl, content, filePath) => {
|
|
switch (platform) {
|
|
case "weixin":
|
|
shareToWeixin();
|
|
break;
|
|
case "qq":
|
|
shareToQQ(title, imageUrl, filePath);
|
|
break;
|
|
}
|
|
};
|
|
exports.shareToPlatform = shareToPlatform;
|