From ff43780f12abdba6460ba806543127a39635ec94 Mon Sep 17 00:00:00 2001 From: JerryYan <792602257@qq.com> Date: Sun, 16 Aug 2020 15:03:45 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=B0=E8=B4=A6OK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- css/notepad.css | 7 ++++--- js/notepad.js | 32 ++++++++++++++++++++++++++------ templete/notepad.html | 35 +++++++++++++++++++++++------------ 3 files changed, 53 insertions(+), 21 deletions(-) diff --git a/css/notepad.css b/css/notepad.css index 6a63b61..add2ffc 100644 --- a/css/notepad.css +++ b/css/notepad.css @@ -18,7 +18,8 @@ } .name { - font-size: 18px; + font-size: 1.4rem; + width: calc(100vw - 5px - 85px); color: black; line-height: 42px; padding-left: 5px; @@ -36,18 +37,18 @@ .right { float: right; + width: 60px; margin-left: 5px; } .small_title, .created_time, .updated_time { - font-size: 0.8rem; color: #BBBBBB; } .operation { - font-size: 1rem; + font-size: 1.2rem; line-height: 42px; padding-right: 10px; padding-left: 10px; diff --git a/js/notepad.js b/js/notepad.js index 8a68caf..dd292bb 100644 --- a/js/notepad.js +++ b/js/notepad.js @@ -20,10 +20,24 @@ const app = new Vue({ this.$set(this.noteData[index], 'currentDelete', false) }, confirmDelete(index){ - console.log("删除", this.noteData[index]) - // some ajax - mui.toast("删除") - window.location.reload() + $.ajax({ + url: qlgUrl("app/note/delete"), + method: "POST", + data: { + id: this.noteData[index].id, + }, + dataType: "json", + success: (res) => { + if(res.status != 1){ + mui.alert(res.msg); + } + this.loadData(); + }, + error: (err) => { + mui.alert("请求失败"); + this.loadData(); + } + }) }, edit(index){ mui.openWindow({ @@ -49,7 +63,7 @@ const app = new Vue({ url: qlgUrl("app/note/index"), method: "GET", dataType: 'json', - success: function(res){ + success: (res) => { if(res.status == 1){ this.noteData = res.data; localStorage.setItem("LOCAL_NOTE", JSON.stringify(res.data)); @@ -68,7 +82,13 @@ const app = new Vue({ var localData = localStorage.getItem("LOCAL_NOTE"); this.loadData(); if(localData){ - this.noteData = JSON.parse(localData); + try{ + JSON.parse(localData); + this.noteData = JSON.parse(localData); + } catch(e) { + console.log(e); + this.noteData = []; + } } }, }) \ No newline at end of file diff --git a/templete/notepad.html b/templete/notepad.html index 0d11853..42e7ee9 100644 --- a/templete/notepad.html +++ b/templete/notepad.html @@ -40,13 +40,13 @@ }