交易规则完成

This commit is contained in:
2020-08-16 17:19:52 +08:00
parent 2fef75a2c9
commit e9c91cc7e4
6 changed files with 486 additions and 0 deletions

93
js/credit.js Normal file
View File

@ -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 = [];
}
}
},
})

173
js/credit_edit.js Normal file
View File

@ -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 = [];
}
}
},
})
})

10
js/trade_rule_detail.js Normal file
View File

@ -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)
}
})