修改活动详情分享功能接入原生方法
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user