qlg.frontend/js/notepad.js
2020-05-25 22:03:54 +08:00

74 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mui.plusReady(function(){
$(".footer").click(function(){
app.create();
})
})
const app = new Vue({
el: '#app',
data() {
return {
noteData: [
],
}
},
methods: {
triggerDelete(index) {
this.$set(this.noteData[index], 'currentDelete', true)
},
cancelDelete(index){
this.$set(this.noteData[index], 'currentDelete', false)
},
confirmDelete(index){
console.log("删除", this.noteData[index])
// some ajax
mui.toast("删除")
window.location.reload()
},
edit(index){
mui.openWindow({
url: "notepad_edit.html",
id: "notepad_edit"+index,
extras: {
noteId: index
},
createNew: false, //是否重复创建同样id的webview默认为false:不重复创建,直接显示
waiting: {
autoShow: true, //自动显示等待框默认为true
title: '正在加载...', //等待对话框上显示的提示内容
}
})
},
create(){
// some jump
this.edit(0);
// JZL.openWindow('trade_rule.html', 'trade_rule.html')
},
loadData() {
$.ajax({
url: qlgUrl("app/note/index"),
method: "GET",
dataType: 'json',
success: function(res){
if(res.status == 1){
this.noteData = res.data;
localStorage.setItem("LOCAL_NOTE", JSON.stringify(res.data));
}else{
mui.alert(res.msg);
}
},
error: function(err){
mui.alert("请求失败");
self.back();
}
});
},
},
created() {
var localData = localStorage.getItem("LOCAL_NOTE");
this.loadData();
if(localData){
this.noteData = JSON.parse(localData);
}
},
})