预算配置
This commit is contained in:
@@ -1,33 +1,50 @@
|
||||
const app = getApp()
|
||||
Page({
|
||||
data: {
|
||||
sumBudget: "0.00",
|
||||
sumUsed: "0.00",
|
||||
sumBalance: "0.00",
|
||||
|
||||
showSetBudget : false,
|
||||
mainMoney: "200.00",
|
||||
changeType: "main",
|
||||
changeItem: 0,
|
||||
currentId: -1,
|
||||
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"}
|
||||
],
|
||||
payTypeList : [],
|
||||
},
|
||||
onLoad: function (options) {
|
||||
|
||||
},
|
||||
onShow() {
|
||||
this.updateBudget();
|
||||
},
|
||||
updateBudget(){
|
||||
app.$api.getBudget().then(res => {
|
||||
if (res.data){
|
||||
let sumBudget = res.data.sumBudget
|
||||
let sumUsed = res.data.sumUsed
|
||||
let sumBalance = res.data.sumBalance
|
||||
let payTypeList = res.data.payTypeList
|
||||
this.setData({sumBudget,sumUsed,sumBalance,payTypeList})
|
||||
}
|
||||
})
|
||||
},
|
||||
changeBudget(e) {
|
||||
let {type,id} = e.currentTarget.dataset
|
||||
let tCurrentMoney = 0.00;
|
||||
if (type == 'count'){
|
||||
tCurrentMoney = this.data.mainMoney
|
||||
tCurrentMoney = this.data.sumBudget
|
||||
}else {
|
||||
tCurrentMoney = this.data.payTypeList[id - 1].money;
|
||||
this.data.payTypeList.forEach(item => {
|
||||
if (item.id == id){
|
||||
tCurrentMoney = item.budget
|
||||
}
|
||||
})
|
||||
}
|
||||
this.setData({
|
||||
showSetBudget: true,
|
||||
changeType: type,
|
||||
changeItem: id,
|
||||
currentId: id,
|
||||
currentMoney: tCurrentMoney
|
||||
})
|
||||
},
|
||||
@@ -51,19 +68,14 @@ Page({
|
||||
})
|
||||
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()
|
||||
app.$api.editBudget({
|
||||
expendId:this.data.currentId,
|
||||
budget:this.data.currentMoney
|
||||
}).then(res=>{
|
||||
if(res){
|
||||
this.closeDialog();
|
||||
}
|
||||
})
|
||||
},
|
||||
closeDialog() {
|
||||
this.setData({
|
||||
|
||||
@@ -4,24 +4,27 @@
|
||||
<view bind:tap="changeBudget" data-type="count" class="inline_box font_big">总预算<t-icon name="tools"/></view>
|
||||
</view>
|
||||
<view class="pay_look">
|
||||
<text class="center_look font_big">{{ mainMoney }}</text>
|
||||
<text class="center_look font_big">{{ sumBudget }}</text>
|
||||
</view>
|
||||
<view class="balance_look">
|
||||
<text>当月使用: {{ 900.00 }}</text>
|
||||
<text>预算剩余: {{ 1200.00 }}</text>
|
||||
<text>当月使用: {{ sumUsed }}</text>
|
||||
<text>预算剩余: {{ sumBalance }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<t-cell wx:for="{{payTypeList}}" wx:key="index"
|
||||
title="{{item.name}}"
|
||||
title="{{item.expendName}}"
|
||||
align="top"
|
||||
image="/image/bill/3.png"
|
||||
note="{{item.money}}"
|
||||
image="{{item.expendIcon}}"
|
||||
note="{{item.budget}}"
|
||||
bind:tap="changeBudget"
|
||||
data-type="item"
|
||||
data-id="{{item.id}}"
|
||||
>
|
||||
<t-progress wx:if="{{item.money}}" slot="description" percentage="{{25}}" />
|
||||
<view wx:if="{{item.money}}" slot="description">
|
||||
<t-progress percentage="{{25}}" />
|
||||
<text>已使用:{{item.used}}</text>
|
||||
</view>
|
||||
<text class="error_msg" wx:else slot="description">未设置预算</text>
|
||||
</t-cell>
|
||||
<t-dialog
|
||||
|
||||
@@ -2,10 +2,7 @@ const app = getApp()
|
||||
Page({
|
||||
data: {
|
||||
progress: 89,
|
||||
todayList: [
|
||||
{"moneyName":"电脑","billType":"INCOME","date":"01-06","accountName":"银行卡","money":"4500.00"},
|
||||
{"moneyName":"狗粮","billType":"EXPEND","date":"01-06","accountName":"支付宝","money":"35.00"},
|
||||
]
|
||||
todayList: []
|
||||
},
|
||||
onLoad: function (options) {
|
||||
},
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
</view>
|
||||
<view class="space_box font_small">
|
||||
<text>当月预算消费情况</text>
|
||||
<view bind:tap="modifyBudget" class="inline_box"><t-icon name="tools" size="28rpx"/>调整</view>
|
||||
<view bind:tap="modifyBudget" class="inline_box"><t-icon name="money-circle" size="28rpx"/>查看</view>
|
||||
</view>
|
||||
<view class="padding_box">
|
||||
<t-progress theme="plump" percentage="{{progress}}" status="{{progress > 80 ? 'error' : 'success' }}" />
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
const app = getApp();
|
||||
Page({
|
||||
data: {
|
||||
payList: [
|
||||
{"name":"薪资","money":"89310.00","icon":"/image/bill/0.png"},
|
||||
{"name":"红包","money":"0.23","icon":"/image/bill/2.png"}
|
||||
]
|
||||
payList: []
|
||||
},
|
||||
onLoad: function (options) {
|
||||
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
const app = getApp();
|
||||
Page({
|
||||
data: {
|
||||
incomeList: [
|
||||
{"name":"薪资","money":"89310.00","icon":"/image/bill/0.png"},
|
||||
{"name":"红包","money":"0.23","icon":"/image/bill/2.png"}
|
||||
]
|
||||
incomeList: []
|
||||
},
|
||||
onShow() {
|
||||
app.$api.getSettings().then(setting => {
|
||||
|
||||
@@ -298,4 +298,13 @@ export default {
|
||||
deleteBill(params) {
|
||||
return fetchPost('/user/bill/del/' + params,null,true,false);
|
||||
},
|
||||
/**
|
||||
* 预算处理
|
||||
*/
|
||||
getBudget(){
|
||||
return fetchPost('/user/budget',null,true,false);
|
||||
},
|
||||
editBudget(params){
|
||||
return fetchPost('/user/budget/edit',params,true,false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user