修改活动详情分享功能接入原生方法

This commit is contained in:
chenruiye
2025-05-28 11:48:11 +08:00
parent 3a5bb21704
commit fb6d58c59c

View File

@@ -253,23 +253,35 @@ function genLink(){
hideLoading(layerIndex);
if (res.code == 200) {
let text = res.data;
if (navigator.clipboard) {
// 使用 navigator.clipboard API
navigator.clipboard.writeText(text)
.then(function () {
toastMsg(langReplace(localLang.demoModule.Copy_Successfully))
})
.catch(function (error) {
});
} else {
// 使用 document.execCommand("copy") 作为备用方案
var $temp = $("<textarea>");
$("body").append($temp);
$temp.val(text).select();
document.execCommand("copy");
$temp.remove();
toastMsg(langReplace(localLang.demoModule.Copy_Successfully))
}
if (browser.ios) {
window.webkit.messageHandlers.showShareAction.postMessage(text);
} else if (browser.android) {
if (androidJsObj && typeof androidJsObj === 'object') {
window.androidJsObj.showShareAction(text);
}
}
// copyText(text);
// if (navigator.clipboard) {
// console.log('使用 navigator.clipboard API')
// // 使用 navigator.clipboard API
// navigator.clipboard.writeText(text)
// .then(function () {
// console.log('复制成功')
// toastMsg(langReplace(localLang.demoModule.Copy_Successfully))
// })
// .catch(function (error) {
// console.log(error)
// });
// } else {
// console.log('----没诗意')
// // 使用 document.execCommand("copy") 作为备用方案
// var $temp = $("<textarea>");
// $("body").append($temp);
// $temp.val(text).select();
// document.execCommand("copy");
// $temp.remove();
// toastMsg(langReplace(localLang.demoModule.Copy_Successfully))
// }
} else {
toastMsg(res.message)
}