预算配置
This commit is contained in:
@@ -31,12 +31,14 @@ Page({
|
||||
},
|
||||
changeBudget(e) {
|
||||
let {type,id} = e.currentTarget.dataset
|
||||
console.log(id);
|
||||
console.log(type);
|
||||
let tCurrentMoney = 0.00;
|
||||
if (type == 'count'){
|
||||
tCurrentMoney = this.data.sumBudget
|
||||
}else {
|
||||
this.data.payTypeList.forEach(item => {
|
||||
if (item.id == id){
|
||||
if (item.expendId == id){
|
||||
tCurrentMoney = item.budget
|
||||
}
|
||||
})
|
||||
@@ -68,11 +70,16 @@ Page({
|
||||
})
|
||||
return;
|
||||
}
|
||||
let expendId = this.data.currentId
|
||||
if (this.data.changeType == 'count'){
|
||||
expendId = -1
|
||||
}
|
||||
app.$api.editBudget({
|
||||
expendId:this.data.currentId,
|
||||
expendId:expendId,
|
||||
budget:this.data.currentMoney
|
||||
}).then(res=>{
|
||||
if(res){
|
||||
this.updateBudget();
|
||||
this.closeDialog();
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<view class="main_look">
|
||||
<view class="look_content">
|
||||
<view class="pay_look">
|
||||
<view bind:tap="changeBudget" data-type="count" class="inline_box font_big">总预算<t-icon name="tools"/></view>
|
||||
<view bind:tap="changeBudget" data-id="-1" data-type="count" class="inline_box font_big">总预算<t-icon name="tools"/></view>
|
||||
</view>
|
||||
<view class="pay_look">
|
||||
<text class="center_look font_big">{{ sumBudget }}</text>
|
||||
@@ -19,10 +19,10 @@
|
||||
note="{{item.budget}}"
|
||||
bind:tap="changeBudget"
|
||||
data-type="item"
|
||||
data-id="{{item.id}}"
|
||||
data-id="{{item.expendId}}"
|
||||
>
|
||||
<view wx:if="{{item.money}}" slot="description">
|
||||
<t-progress percentage="{{25}}" />
|
||||
<view wx:if="{{item.id}}" slot="description">
|
||||
<t-progress percentage="{{item.progress}}" />
|
||||
<text>已使用:{{item.used}}</text>
|
||||
</view>
|
||||
<text class="error_msg" wx:else slot="description">未设置预算</text>
|
||||
|
||||
@@ -181,27 +181,19 @@ function initLineChart2(canvas, width, height, dpr) {
|
||||
chart.setOption(option);
|
||||
return chart;
|
||||
}
|
||||
const app = getApp();
|
||||
Page({
|
||||
data: {
|
||||
// 指定选择区间起始值
|
||||
start: '2000-01-01 00:00:00',
|
||||
end: '2030-09-09 12:12:12',
|
||||
showDateVisible:false,
|
||||
showDate:'2022-01',
|
||||
accountList: [
|
||||
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
|
||||
{"id":2,"title":"狗粮","type":"expend","dateTime":"01-06","from":"支付宝","money":"35.00"},
|
||||
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
|
||||
{"id":2,"title":"狗粮","type":"expend","dateTime":"01-06","from":"支付宝","money":"35.00"},
|
||||
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
|
||||
{"id":2,"title":"狗粮","type":"expend","dateTime":"01-06","from":"支付宝","money":"35.00"},
|
||||
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
|
||||
{"id":2,"title":"狗粮","type":"expend","dateTime":"01-06","from":"支付宝","money":"35.00"},
|
||||
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
|
||||
{"id":2,"title":"狗粮","type":"expend","dateTime":"01-06","from":"支付宝","money":"35.00"},
|
||||
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
|
||||
{"id":2,"title":"狗粮","type":"expend","dateTime":"01-06","from":"支付宝","money":"35.00"},
|
||||
],
|
||||
showDate:app.$utils.formatDateMonth(new Date()),
|
||||
accountList: [],
|
||||
sumExpend: 0,
|
||||
sumIncome: 0,
|
||||
sumTransfer: 0,
|
||||
sumRepayment: 0,
|
||||
payTypeList: [
|
||||
{"title":"数码产品","type":"expend","progress":"80","money":"4500.00"},
|
||||
{"title":"房贷","type":"expend","progress":"20","money":"35.00"},
|
||||
@@ -258,15 +250,25 @@ Page({
|
||||
ecLine2: {
|
||||
onInit: initLineChart2
|
||||
}
|
||||
},
|
||||
onLoad: function (options) {
|
||||
|
||||
},
|
||||
onShow: function () {
|
||||
this.updateView();
|
||||
if (wx.canIUse('hideHomeButton')) {
|
||||
wx.hideHomeButton()
|
||||
}
|
||||
},
|
||||
updateView(){
|
||||
app.$api.listBillByAMonth({'rangeDate':this.data.showDate}).then(res => {
|
||||
if (res.data){
|
||||
let accountList = res.data.accountList
|
||||
let sumExpend = res.data.sumExpend
|
||||
let sumIncome = res.data.sumIncome
|
||||
let sumTransfer = res.data.sumTransfer
|
||||
let sumRepayment = res.data.sumRepayment
|
||||
this.setData({accountList,sumExpend,sumIncome,sumTransfer,sumRepayment})
|
||||
}
|
||||
})
|
||||
},
|
||||
showPicker(e) {
|
||||
const { mode } = e.currentTarget.dataset;
|
||||
this.setData({
|
||||
@@ -283,12 +285,12 @@ Page({
|
||||
onConfirm(e) {
|
||||
const { value } = e.detail;
|
||||
const { mode } = this.data;
|
||||
console.log('confim', value);
|
||||
this.setData({
|
||||
[mode]: value
|
||||
// [`${mode}Text`]: value,
|
||||
});
|
||||
this.hidePicker();
|
||||
this.updateView()
|
||||
this.hidePicker()
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
<t-tabs defaultValue="{{0}}" t-class="custom-tabs" theme="card">
|
||||
<t-tab-panel label="总览" value="0" class="tab_content">
|
||||
<view class="space_box font_big">
|
||||
<text class="t-color-expend">支出\n {{1203.00}}</text>
|
||||
<text class="t-color-income">收入\n {{1203.00}}</text>
|
||||
<text class="t-color-transfer">转账\n {{1203.00}}</text>
|
||||
<text class="t-color-repayment">还款\n {{1203.00}}</text>
|
||||
<text class="t-color-expend">支出\n {{sumExpend}}</text>
|
||||
<text class="t-color-income">收入\n {{sumIncome}}</text>
|
||||
<text class="t-color-transfer">转账\n {{sumTransfer}}</text>
|
||||
<text class="t-color-repayment">还款\n {{sumRepayment}}</text>
|
||||
</view>
|
||||
<view class="padding_box">
|
||||
<t-divider dashed content="账单明细"/>
|
||||
@@ -15,18 +15,18 @@
|
||||
<view wx:if="{{accountList != null && accountList.length > 0}}">
|
||||
<t-cell-group theme="card">
|
||||
<t-cell wx:for="{{accountList}}" wx:key="index"
|
||||
title="{{item.title}}"
|
||||
description="{{item.dateTime}} • {{item.from}}"
|
||||
title="{{item.moneyName}}"
|
||||
description="{{item.date}} • {{item.accountName}}"
|
||||
align="top"
|
||||
image="/image/bill/4.png"
|
||||
image="{{item.moneyIcon}}"
|
||||
note="{{item.money}}"
|
||||
class="t-cell-{{item.type}}"
|
||||
class="t-cell-{{item.billType}}"
|
||||
url="{{'/pages/bill/index?id=' + item.id}}"
|
||||
/>
|
||||
</t-cell-group>
|
||||
</view>
|
||||
<view wx:else class="empty-view" >
|
||||
<t-empty icon="chart-bubble" description="今日还未记账" />
|
||||
<t-empty icon="chart-bubble" description="本月无账单记录" />
|
||||
</view>
|
||||
</t-tab-panel>
|
||||
<t-tab-panel label="支出分类" value="1">
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
const app = getApp()
|
||||
Page({
|
||||
data: {
|
||||
progress: 89,
|
||||
sumToday:0,
|
||||
sumBalance:0,
|
||||
sumBudget:0,
|
||||
sumUsed:0,
|
||||
progress:0,
|
||||
todayList: []
|
||||
},
|
||||
onLoad: function (options) {
|
||||
@@ -13,6 +17,16 @@ Page({
|
||||
this.setData({todayList})
|
||||
}
|
||||
})
|
||||
app.$api.getBudgetIndex().then(res => {
|
||||
if (res.data){
|
||||
let sumToday = res.data.sumToday
|
||||
let sumBalance = res.data.sumBalance
|
||||
let sumBudget = res.data.sumBudget
|
||||
let sumUsed = res.data.sumUsed
|
||||
let progress = Math.floor(res.data.sumUsed / res.data.sumBudget * 10000) / 100
|
||||
this.setData({sumToday,sumBalance,sumBudget,sumUsed,progress})
|
||||
}
|
||||
})
|
||||
if (wx.canIUse('hideHomeButton')) {
|
||||
wx.hideHomeButton()
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<view class="main_look">
|
||||
<view class="look_content">
|
||||
<view class="look_content font_big">
|
||||
<view class="pay_look">
|
||||
<text>今日支出\n</text>
|
||||
<text class="font_big">200.00</text>
|
||||
<text class="font_big">{{sumToday}}</text>
|
||||
</view>
|
||||
<view class="balance_look">
|
||||
<text>账户余额:2235.20</text>
|
||||
<text>预算余额:300.00</text>
|
||||
<text>账户余额:{{sumBalance}}</text>
|
||||
<text>预算余额:{{sumBudget - sumUsed}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -15,11 +15,11 @@
|
||||
<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' }}" />
|
||||
<t-progress theme="plump" percentage="{{progress}}" status="{{ progress > 80 ? 'error' : 'success' }}" />
|
||||
</view>
|
||||
<view class="space_box font_small">
|
||||
<text>当月预算:54602.00</text>
|
||||
<text>已消费:777.80</text>
|
||||
<text>当月预算:{{sumBudget}}</text>
|
||||
<text>已消费:{{sumUsed}}</text>
|
||||
</view>
|
||||
<view class="padding_box">
|
||||
<t-button theme="primary" size="medium" block bind:tap="addBill">记一笔</t-button>
|
||||
|
||||
Reference in New Issue
Block a user