project init
This commit is contained in:
73
pages/budget/index.js
Normal file
73
pages/budget/index.js
Normal file
@@ -0,0 +1,73 @@
|
||||
Page({
|
||||
data: {
|
||||
showSetBudget : false,
|
||||
mainMoney: "200.00",
|
||||
changeType: "main",
|
||||
changeItem: 0,
|
||||
currentMoney: "0.00",
|
||||
priceError: false,
|
||||
payTypeList : [
|
||||
{"id":1,"name":"娱乐","money":"2000.00"},
|
||||
{"id":2,"name":"干饭","money":""},
|
||||
{"id":3,"name":"游戏","money":"2000.00"},
|
||||
{"id":4,"name":"其它","money":"400"}
|
||||
],
|
||||
},
|
||||
onLoad: function (options) {
|
||||
|
||||
},
|
||||
changeBudget(e) {
|
||||
let {type,id} = e.currentTarget.dataset
|
||||
let tCurrentMoney = 0.00;
|
||||
if (type == 'count'){
|
||||
tCurrentMoney = this.data.mainMoney
|
||||
}else {
|
||||
tCurrentMoney = this.data.payTypeList[id - 1].money;
|
||||
}
|
||||
this.setData({
|
||||
showSetBudget: true,
|
||||
changeType: type,
|
||||
changeItem: id,
|
||||
currentMoney: tCurrentMoney
|
||||
})
|
||||
},
|
||||
onPriceInput(e) {
|
||||
this.setData({
|
||||
currentMoney: e.detail.value
|
||||
})
|
||||
},
|
||||
onConfirm (e) {
|
||||
const { priceError } = this.data;
|
||||
const isNumber = /^\d+(\.\d+)?$/.test(this.data.currentMoney);
|
||||
if (priceError === isNumber) {
|
||||
this.setData({
|
||||
priceError: !isNumber,
|
||||
});
|
||||
}
|
||||
if (this.data.priceError) {
|
||||
this.setData({
|
||||
currentMoney: "0.00",
|
||||
priceError: false
|
||||
})
|
||||
return;
|
||||
}
|
||||
if (this.data.changeType == 'count') {
|
||||
this.setData({
|
||||
mainMoney: this.data.currentMoney
|
||||
})
|
||||
}else {
|
||||
let cPayTypeList = this.data.payTypeList
|
||||
let cPayType = cPayTypeList[this.data.changeItem - 1]
|
||||
cPayType.money = this.data.currentMoney;
|
||||
this.setData({
|
||||
payTypeList : cPayTypeList
|
||||
})
|
||||
}
|
||||
this.closeDialog()
|
||||
},
|
||||
closeDialog() {
|
||||
this.setData({
|
||||
showSetBudget: false
|
||||
})
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user