From 9f5205c3841e4d93d031417fd8783ae638a5d5bc Mon Sep 17 00:00:00 2001 From: tianya Date: Tue, 29 Nov 2022 21:45:05 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=87=E7=94=A8DedeConfirm=E6=94=B9=E5=86=99?= =?UTF-8?q?window.confirm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/admin/js/key.js | 41 +++-------------------- src/admin/js/main.js | 39 ++++++++++++++++++++++ src/admin/templets/diy_edit.htm | 4 --- src/admin/templets/feedback_main.htm | 44 ++++++++++++++++++++----- src/admin/templets/freelist_main.htm | 41 ++++++++++++----------- src/admin/templets/mychannel_edit.htm | 7 ++-- src/admin/templets/stepselect_main.htm | 23 ++++++++----- src/admin/templets/templets_default.htm | 9 +++-- src/static/web/js/style.js | 40 ++++++++++++++++++++++ src/user/templets/content_list.htm | 6 +++- src/user/templets/content_sg_list.htm | 6 +++- src/user/templets/mypay.htm | 11 +++++-- src/user/templets/operation.htm | 6 ++-- src/user/templets/pm-main.htm | 14 ++++++-- 14 files changed, 200 insertions(+), 91 deletions(-) diff --git a/src/admin/js/key.js b/src/admin/js/key.js index fd72d27f..576c7cab 100644 --- a/src/admin/js/key.js +++ b/src/admin/js/key.js @@ -15,46 +15,13 @@ function noselAll() } } } -function delkey() -{ - if (window.confirm("您确定要删除选定的关键字吗")) { - document.form3.dopost.value = 'del'; - document.form3.submit(); - } -} -function diskey() -{ - if (window.confirm("您确定要禁用选定的关键字吗")) { - document.form3.dopost.value = 'dis'; - document.form3.submit(); - } -} -function enakey() -{ - if (window.confirm("您确定要启用选定的关键字吗")) { - document.form3.dopost.value = 'ena'; - document.form3.submit(); - } -} -function urlkey() -{ - if (window.confirm("您确定要更新选定的关键字的网址吗")) { - document.form3.dopost.value = 'url'; - document.form3.submit(); - } -} -function rankey() -{ - if (window.confirm("您确定要改变选定的关键字的频率吗")) { - document.form3.dopost.value = 'ran'; - document.form3.submit(); - } -} //批量删除搜多关键字 function delall() { - if (window.confirm("您确定要删除选定的关键字吗")) { + DedeConfirm("您确定要删除选定的关键字吗?").then((v)=>{ document.form3.dopost.value = 'delall'; document.form3.submit(); - } + }).catch((e)=>{ + console.log(e) + }); } \ No newline at end of file diff --git a/src/admin/js/main.js b/src/admin/js/main.js index 33ae09f6..38e16f9c 100644 --- a/src/admin/js/main.js +++ b/src/admin/js/main.js @@ -511,6 +511,45 @@ function guid() { } return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4()); } +var _DedeConfirmFuncs = {}; +var _DedeConfirmFuncsClose = {}; +function __DedeConfirmRun(modalID) { + _DedeConfirmFuncs[modalID](); +} +function __DedeConfirmRunClose(modalID) { + _DedeConfirmFuncsClose[modalID](); +} +function DedeConfirm(content="",title="确认提示") { + let modalID = guid(); + return new Promise((resolve, reject) => { + _DedeConfirmFuncs[modalID] = ()=>{ + resolve("success"); + CloseModal(`DedeModal${modalID}`); + } + _DedeConfirmFuncsClose[modalID] = ()=>{ + reject("cancel"); + CloseModal(`DedeModal${modalID}`); + } + + let footer = ` `; + let modal = ``; + $("body").append(modal) + $("#DedeModal" + modalID).modal({ + backdrop: 'static', + show: true + }); + $("#DedeModal" + modalID).on('hidden.bs.modal', function (e) { + $("#DedeModal" + modalID).remove(); + }) + }) +} //函数会返回一个modalID,通过这个id可自已定义一些方法,这里用到了一个展开语法https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/Spread_syntax function ShowMsg(content, ...args) { title = "系统提示"; diff --git a/src/admin/templets/diy_edit.htm b/src/admin/templets/diy_edit.htm index 56418192..ff5b3e50 100644 --- a/src/admin/templets/diy_edit.htm +++ b/src/admin/templets/diy_edit.htm @@ -18,10 +18,6 @@ } return true; } - function DelNote(gourl) { - if (!window.confirm("您确认要删除这条记录吗")) { return false; } - location.href = gourl; - } diff --git a/src/admin/templets/feedback_main.htm b/src/admin/templets/feedback_main.htm index a659543a..0b2ce504 100644 --- a/src/admin/templets/feedback_main.htm +++ b/src/admin/templets/feedback_main.htm @@ -45,23 +45,51 @@ } function delFeedback() { var qstr = getCheckboxItem(); - if (qstr == "") ShowMsg("您没选中任何文档"); - else if (window.confirm('您确定要删除这些评论吗')) location.href = "feedback_main.php?job=del&fid=" + qstr; + if (qstr == "") { + ShowMsg("您没选中任何文档"); + return + }; + DedeConfirm("您确定要删除这些评论吗?").then((v)=>{ + location.href = "feedback_main.php?job=del&fid=" + qstr + }).catch((e)=>{ + console.log(e) + }); } function delFeedbackIP() { var qstr = getCheckboxItem(); - if (qstr == "") ShowMsg("您没选中任何文档"); - else if (window.confirm('您确定要删除这些评论吗')) location.href = "feedback_main.php?job=delall&fid=" + qstr; + if (qstr == "") { + ShowMsg("您没选中任何文档"); + return; + }; + DedeConfirm("您确定要删除这些评论吗?").then((v)=>{ + location.href = "feedback_main.php?job=delall&fid=" + qstr; + }).catch((e)=>{ + console.log(e) + }); } function checkFeedback() { var qstr = getCheckboxItem(); - if (qstr == "") ShowMsg("您没选中任何文档"); - else location.href = "feedback_main.php?job=check&fid=" + qstr; + if (qstr == "") { + ShowMsg("您没选中任何文档"); + return; + }; + DedeConfirm("您确定要删除这些评论吗?").then((v)=>{ + location.href = "feedback_main.php?job=check&fid=" + qstr; + }).catch((e)=>{ + console.log(e) + }); } function editFeedback() { var qstr = getCheckboxItem(); - if (qstr == "") ShowMsg("您没选中任何文档"); - else location.href = "feedback_edit.php?job=edit&fid=" + qstr; + if (qstr == "") { + ShowMsg("您没选中任何文档"); + return; + } + DedeConfirm("您确定要删除这些评论吗?").then((v)=>{ + location.href = "feedback_edit.php?job=edit&fid=" + qstr; + }).catch((e)=>{ + console.log(e) + }); } diff --git a/src/admin/templets/freelist_main.htm b/src/admin/templets/freelist_main.htm index ce0b69e3..c0c3d09c 100644 --- a/src/admin/templets/freelist_main.htm +++ b/src/admin/templets/freelist_main.htm @@ -12,8 +12,8 @@ diff --git a/src/static/web/js/style.js b/src/static/web/js/style.js index 546a49cb..6815cf20 100644 --- a/src/static/web/js/style.js +++ b/src/static/web/js/style.js @@ -29,6 +29,46 @@ function guid() { } return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4()); } + +var _DedeConfirmFuncs = {}; +var _DedeConfirmFuncsClose = {}; +function __DedeConfirmRun(modalID) { + _DedeConfirmFuncs[modalID](); +} +function __DedeConfirmRunClose(modalID) { + _DedeConfirmFuncsClose[modalID](); +} +function DedeConfirm(content="",title="确认提示") { + let modalID = guid(); + return new Promise((resolve, reject) => { + _DedeConfirmFuncs[modalID] = ()=>{ + resolve("success"); + CloseModal(`DedeModal${modalID}`); + } + _DedeConfirmFuncsClose[modalID] = ()=>{ + reject("cancel"); + CloseModal(`DedeModal${modalID}`); + } + + let footer = ` `; + let modal = ``; + $("body").append(modal) + $("#DedeModal" + modalID).modal({ + backdrop: 'static', + show: true + }); + $("#DedeModal" + modalID).on('hidden.bs.modal', function (e) { + $("#DedeModal" + modalID).remove(); + }) + }) +} //函数会返回一个modalID,通过这个id可自已定义一些方法,这里用到了一个展开语法:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/Spread_syntax function ShowMsg(content, ...args) { title = "系统提示"; diff --git a/src/user/templets/content_list.htm b/src/user/templets/content_list.htm index f088d5ab..e0707920 100755 --- a/src/user/templets/content_list.htm +++ b/src/user/templets/content_list.htm @@ -17,7 +17,11 @@ location = "archives_do.php?dopost=edit&channelid=" + channelid + "&aid=" + aid; } function delArc(aid) { - if (window.confirm('您确定要删除这篇文档吗')) location = "archives_do.php?aid=" + aid + "&dopost=delArc"; + DedeConfirm("您确定要删除这篇文档吗?").then((v)=>{ + location = "archives_do.php?aid=" + aid + "&dopost=delArc"; + }).catch((e)=>{ + console.log(e) + }); } diff --git a/src/user/templets/content_sg_list.htm b/src/user/templets/content_sg_list.htm index eb1b74cb..74ffe1ae 100755 --- a/src/user/templets/content_sg_list.htm +++ b/src/user/templets/content_sg_list.htm @@ -17,7 +17,11 @@ location = "archives_do.php?dopost=edit&channelid=" + channelid + "&aid=" + aid; } function delArc(aid) { - if (window.confirm('您确定要删除这篇文档吗')) location = "archives_do.php?aid=" + aid + "&dopost=delArc"; + DedeConfirm("您确定要删除这篇文档吗?").then((v)=>{ + location = "archives_do.php?aid=" + aid + "&dopost=delArc"; + }).catch((e)=>{ + console.log(e) + }); } diff --git a/src/user/templets/mypay.htm b/src/user/templets/mypay.htm index c0d59b30..e24a3101 100755 --- a/src/user/templets/mypay.htm +++ b/src/user/templets/mypay.htm @@ -68,6 +68,9 @@ //获得选中文件的文件名 function GetCheckfolderItem() { var allSel = ''; + if (typeof document.form1.deleteid == "undefined") { + return ''; + } if (document.form1.deleteid.value) return document.form1.deleteid.value; for (i = 0; i < document.form1.deleteid.length; i++) { if (document.form1.deleteid[i].checked) { @@ -82,12 +85,14 @@ function DoSubmit() { var selid = GetCheckfolderItem(); if (selid == '') { - alert("您没选中任何信息"); + ShowMsg("您没选中任何信息"); return false; } - if (window.confirm("您确定要删除这些消息吗")) { + DedeConfirm("您确定要删除这些消息吗?").then((v)=>{ location = "mypay.php?dopost=del&ids=" + selid; - } + }).catch((e)=>{ + console.log(e) + }); } diff --git a/src/user/templets/operation.htm b/src/user/templets/operation.htm index e6dbec93..81dc3ac5 100755 --- a/src/user/templets/operation.htm +++ b/src/user/templets/operation.htm @@ -82,9 +82,11 @@ ShowMsg("您没选中任何信息"); return false; } - if (window.confirm("您确定要删除这些消息吗")) { + DedeConfirm("您确定要删除这些消息吗?").then((v)=>{ location = "operation.php?dopost=del&ids=" + selid; - } + }).catch((e)=>{ + console.log(e) + }); } diff --git a/src/user/templets/pm-main.htm b/src/user/templets/pm-main.htm index 6e12d87b..1017e2ca 100755 --- a/src/user/templets/pm-main.htm +++ b/src/user/templets/pm-main.htm @@ -44,15 +44,23 @@ } return allSel; } + //删除操作 function DoSubmit(myfolder) { var selid = GetCheckfolderItem(); if (selid == '') { ShowMsg("您没选中任何信息"); return false; } - if (window.confirm("您确定要删除这些消息吗")) { - location = "pm.php?dopost=del&ids=" + selid + "&folder=" + myfolder; - } + DedeConfirm("您确定要删除这些消息吗?").then((v)=>{ + $.get("pm.php?dopost=remove&ids=" + selid + "&folder=" + myfolder,function (data) { + let result = JSON.parse(data); + if (result.code === 200) { + location.reload(); + } + }) + }).catch((e)=>{ + console.log(e) + }); }