diff --git a/css/credit_edit.css b/css/credit_edit.css new file mode 100644 index 0000000..bc1bb08 --- /dev/null +++ b/css/credit_edit.css @@ -0,0 +1,68 @@ +.row { + background: white; + width: 100%; + position: relative; + margin-top: 5px; + margin-bottom: 5px; +} + +.block{ + margin-top: 36px; + padding: 0 2%; +} + +.z{ + width: 100%; + height: 70px; +} + +.name { + font-size: 18px; + color: black; + line-height: 42px; + padding-left: 5px; +} + +.small_title, +.created_time, +.updated_time { + font-size: 0.8rem; + color: #BBBBBB; +} + +.footer{ + position: fixed; + bottom: 0; + width: 100%; + background: white; + height: 50px; + line-height: 50px; + text-align: center; + border-top: 1px solid #e6e6e6; +} +#content { + width: 100%; +} + +#content .w-e-toolbar { + flex-wrap: wrap; +} + +.s1 { + /* float: left; */ + /* min-width: 60px; */ + line-height: 42px; + color: #525252; + font-size: 17px; + white-space: nowrap; + /* flex: 1.2; */ +} + +.con .row input { + /* float: left; */ + margin: 0; + width:auto ; + border: none; + font-size: 17px; +} + diff --git a/js/credit.js b/js/credit.js new file mode 100644 index 0000000..0b86a92 --- /dev/null +++ b/js/credit.js @@ -0,0 +1,93 @@ +mui.plusReady(function(){ + $('body').on('click', ".footer[data-app='app2']", function(){ + app2.create(); + }) +}) + +const app2 = new Vue({ + el: '#app2', + data() { + return { + creditData: [ + ], + } + }, + methods: { + triggerDelete(index) { + this.$set(this.creditData[index], 'currentDelete', true) + }, + cancelDelete(index){ + this.$set(this.creditData[index], 'currentDelete', false) + }, + confirmDelete(index){ + $.ajax({ + url: qlgUrl("app/note/creditDelete"), + method: "POST", + data: { + id: this.creditData[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({ + url: "credit_edit.html", + id: "credit_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/creditIndex"), + method: "GET", + dataType: 'json', + success: (res) => { + if(res.status == 1){ + this.creditData = res.data; + localStorage.setItem("LOCAL_CREDIT", JSON.stringify(res.data)); + }else{ + mui.alert(res.msg); + } + }, + error: function(err){ + mui.alert("请求失败"); + self.back(); + } + }); + }, + }, + created() { + var localData = localStorage.getItem("LOCAL_CREDIT"); + this.loadData(); + if(localData){ + try{ + JSON.parse(localData); + this.noteData = JSON.parse(localData); + } catch(e) { + this.noteData = []; + } + } + }, +}) \ No newline at end of file diff --git a/js/credit_edit.js b/js/credit_edit.js new file mode 100644 index 0000000..1cc47ea --- /dev/null +++ b/js/credit_edit.js @@ -0,0 +1,173 @@ +mui.init({ + beforeback: function() { + //获得父页面的webview + var list = plus.webview.currentWebview().opener(); //触发父页面的自定义事件(refresh),从而进行刷新 + list.reload(); + //返回true,继续页面关闭逻辑 + return true; + } +}); + +mui.plusReady(function(){ + window.self = plus.webview.currentWebview(); + window.Id = self.noteId; + var $createTime = $("#createTime"); + var $name = $("#name"); + var $cc = $("#cur_cash"); + var $cdc = $("#credit_cash"); + if(Id <= 0) { + $createTime.text("现在"); + $(".footer .add").attr('disabled', true); + } + $(".footer").on("tap", '.save',function(){ + $.ajax({ + url: qlgUrl("app/note/creditSave"), + method: "POST", + data: { + id: Id, + name: $name.val(), + cur_cash: $cc.val(), + credit_cash: $cdc.val(), + }, + dataType: "json", + success: function(res){ + if(res.status != 1){ + mui.alert(res.msg); + }else{ + mui.back(); + } + }, + error: function(err){ + mui.alert("请求失败"); + self.back(); + } + }) + }) + $(".footer").on("tap", '.add',function(){ + app.triggerShowAdd(); + }) + const app = new Vue({ + el: '#content', + data() { + return { + listData: [ + ], + newData: { + type: 1, + amount: 0, + }, + showAdd: false, + } + }, + methods: { + delete2(index) { + if(!confirm('确定要删除么?'))return ; + $.ajax({ + url: qlgUrl("app/note/creditDeleteInfo"), + method: "POST", + data: { + id: this.listData[index].id, + credit_id: this.listData[index].credit_id, + }, + dataType: "json", + success: (res) => { + if(res.status != 1){ + mui.alert(res.msg); + } + this.loadData(); + }, + error: (err) => { + mui.alert("请求失败"); + this.loadData(); + } + }) + }, + loadData() { + $.ajax({ + url: qlgUrl("app/note/creditDetail"), + method: "GET", + data: { + id: window.Id, + }, + dataType: "json", + success: function(res){ + if(res.status == 1){ + $createTime.text(res.data.create_time); + $name.val(res.data.name); + $cdc.val(res.data.credit_cash); + $cc.val(res.data.cur_cash); + $cc.data('val',res.data.cur_cash); + }else{ + alert(res.msg); + } + }, + error: function(err){ + alert("请求失败"); + }, + }); + $.ajax({ + url: qlgUrl("app/note/creditDetailInfo"), + method: "GET", + data: { + id: Id + }, + dataType: 'json', + success: (res) => { + if(res.status == 1){ + this.listData = res.data; + localStorage.setItem("LOCAL_CREDIT_"+Id, JSON.stringify(res.data)); + }else{ + mui.alert(res.msg); + } + }, + error: function(err){ + mui.alert("请求失败"); + self.back(); + } + }); + }, + addNewData() { + $.ajax({ + url: qlgUrl("app/note/creditAdd"), + method: "POST", + data: { + id: Id, + ...this.newData, + }, + dataType: "json", + success: (res) => { + this.newData = { + type: 1, + amount: 0, + } + this.showAdd = false; + if(res.status != 1){ + mui.alert(res.msg); + } + this.loadData(); + }, + error: function(err){ + this.loadData(); + } + }) + }, + triggerShowAdd() { + this.showAdd = !this.showAdd; + }, + }, + created() { + if (Id <= 0) return; + var localData = localStorage.getItem("LOCAL_CREDIT_"+Id); + this.loadData(); + if(localData){ + try{ + JSON.parse(localData); + this.listData = JSON.parse(localData); + } catch(e) { + console.log(e); + this.listData = []; + } + } + }, + }) +}) diff --git a/js/trade_rule_detail.js b/js/trade_rule_detail.js new file mode 100644 index 0000000..d6fa359 --- /dev/null +++ b/js/trade_rule_detail.js @@ -0,0 +1,10 @@ +mui.plusReady(function(){ + // some ajax + window.self = plus.webview.currentWebview(); + window.Id = self.ruleId; + const parentData = self.parentData; + var block = $('.block'); + if (parentData) { + block.html(parentData.content) + } +}) diff --git a/templete/credit_edit.html b/templete/credit_edit.html new file mode 100644 index 0000000..435e20f --- /dev/null +++ b/templete/credit_edit.html @@ -0,0 +1,97 @@ + + + + + + + 内容编辑 + + + + +
+
+ + +

内容编辑

+
+
+
+
+
+ 卡名称: + +
+
+ 卡余额: + + +
+
+ 卡额度: + + +
+
+ 创建时间: +
+
+
+ + + + + 元 + + 新增 + 取消 +
+
+ {{each.create_date}} + {{each.type==0?'初始值':(each.type==1?'购物':(each.type==2?'还款': + (each.type==9?'手动修正':'其他')))}} + {{each.amount}}元 +
删除
+
+
+
+ + + + + + + + + + + + + diff --git a/templete/trade_rule_detail.html b/templete/trade_rule_detail.html new file mode 100644 index 0000000..c187c97 --- /dev/null +++ b/templete/trade_rule_detail.html @@ -0,0 +1,45 @@ + + + + + + + 交易规则详情 + + + + +
+
+ + +

交易规则详情

+
+
+
+
+ +
+ + + + + +