账单查询

This commit is contained in:
limqhz
2023-02-08 16:59:00 +08:00
parent 1f5580c0f3
commit 668a387554
13 changed files with 98 additions and 93 deletions

View File

@@ -1,28 +1,45 @@
const app = getApp(); const app = getApp();
Page({ Page({
data: { data: {
sid: -1,
showSetMoney: false, showSetMoney: false,
currentMoney: 0.00, currentMoneyText: 0,
currentMoneyText: "8754.09", expendBalance: 0,
incomeBalance: 0,
priceError: false, priceError: false,
visible : false, visible : false,
dateRangeText : '请选择日期区间', dateRangeText : null,
dateRange : [new Date().getTime()- 24 * 60 * 60 * 1000,new Date().getTime()], dateRange : null,
minDate: new Date().getTime() - 365 * 24 * 60 * 60 * 1000, minDate: new Date().getTime() - 365 * 24 * 60 * 60 * 1000,
maxDate: new Date().getTime(), maxDate: new Date().getTime(),
incomeList : [ incomeList : [],
{"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"} payList : []
],
payList : [
{"title":"狗粮","type":"expend","dateTime":"01-06","from":"支付宝","money":"35.00"},
{"title":"狗粮","type":"expend","dateTime":"01-06","from":"支付宝","money":"35.00"},
{"title":"狗粮","type":"expend","dateTime":"01-06","from":"支付宝","money":"35.00"},
{"title":"狗粮","type":"expend","dateTime":"01-06","from":"支付宝","money":"35.00"},
{"title":"狗粮","type":"expend","dateTime":"01-06","from":"支付宝","money":"35.00"},
{"title":"狗粮","type":"expend","dateTime":"01-06","from":"支付宝","money":"35.00"}
]
}, },
onLoad: function (options) { onLoad: function (options) {
let sid = options.sid
let currentMoneyText = options.balance
this.setData({sid,currentMoneyText})
let dateRange = [new Date().getTime()- 24 * 60 * 60 * 1000,new Date().getTime()]
let dateRangeText = app.$utils.formatDate(new Date(dateRange[0])) + '至' +
(dateRange[1] ? app.$utils.formatDate(new Date(dateRange[1])) : app.$utils.formatDate(new Date()));
this.setData({dateRange,dateRangeText})
},
onShow() {
app.$api.listBillByAccount({
id:this.data.sid,
dateRangeText:this.data.dateRangeText,
}).then(res => {
if (res.data){
let incomeList = res.data.incomeList;
let payList = res.data.incomeList;
let expendBalance = res.data.expendBalance;
let incomeBalance = res.data.incomeBalance;
this.setData({
incomeList,payList,expendBalance,incomeBalance
})
}
})
}, },
handleCalendar() { handleCalendar() {
this.setData({ visible: true }); this.setData({ visible: true });
@@ -42,24 +59,25 @@ Page({
showDialog() { showDialog() {
this.setData({ this.setData({
showSetMoney: true, showSetMoney: true,
currentMoney: this.data.currentMoneyText currentMoneyText: this.data.currentMoneyText
}) })
}, },
onPriceInput(e) { onPriceInput(e) {
this.setData({ this.setData({
currentMoney: e.detail.value currentMoneyText: e.detail.value
}) })
}, },
onConfirm () { onConfirm () {
const isNumber = /^\d+(\.\d+)?$/.test(this.data.currentMoney); const isNumber = /^\d+(\.\d+)?$/.test(this.data.currentMoneyText);
if (!isNumber) { if (!isNumber) {
this.setData({ this.setData({
priceError: true priceError: true
}) })
return; return;
} }
app.$api.editAccount({});
this.setData({ this.setData({
currentMoneyText: this.data.currentMoney, currentMoneyText: this.data.currentMoneyText,
priceError: false priceError: false
}) })
this.closeDialog() this.closeDialog()

View File

@@ -11,8 +11,8 @@
</view> </view>
</view> </view>
<view class="space_box_no_padding font_big"> <view class="space_box_no_padding font_big">
<text class="t-color-expend">支出{{1203.00}}</text> <text class="t-color-expend">支出{{expendMoney}}</text>
<text class="t-color-income">收入{{1203.00}}</text> <text class="t-color-income">收入{{incomeMoney}}</text>
</view> </view>
<view class="padding_box"> <view class="padding_box">
<t-divider content="{{dateRangeText}}" bind:tap="handleCalendar"/> <t-divider content="{{dateRangeText}}" bind:tap="handleCalendar"/>
@@ -53,5 +53,5 @@
bind:confirm="onConfirm" bind:confirm="onConfirm"
bind:cancel="closeDialog" bind:cancel="closeDialog"
> >
<t-input bindchange="onPriceInput" value="{{currentMoney}}" tips="{{priceError ? '请输入正确金额' : ''}}" slot="content" type="number" placeholder="0.00"/> <t-input bindchange="onPriceInput" value="{{currentMoneyText}}" tips="{{priceError ? '请输入正确金额' : ''}}" slot="content" type="number" placeholder="0.00"/>
</t-dialog> </t-dialog>

View File

@@ -2,6 +2,9 @@ Page({
data: { data: {
noMoney : "****", noMoney : "****",
hiddenMoney: false, hiddenMoney: false,
sumBalance: 0,
cashBalance: 0,
oweBalance: 0,
cashAccountList : [ cashAccountList : [
{"name":"现金","money":"2000.00"}, {"name":"现金","money":"2000.00"},
{"name":"银行卡","money":"30500.03"} {"name":"银行卡","money":"30500.03"}
@@ -17,6 +20,28 @@ Page({
if (wx.canIUse('hideHomeButton')) { if (wx.canIUse('hideHomeButton')) {
wx.hideHomeButton() wx.hideHomeButton()
} }
app.$api.getSettings().then(setting => {
if (setting.data){
let cashAccountList = setting.data.CASH_SETTING
let sumBalance = 0;
let cashBalance = 0;
cashAccountList.forEach(item => {
if (item.balance){
cashBalance = cashBalance + item.balance
sumBalance = sumBalance + item.balance
}
})
let oweAccountList = setting.data.OWE_SETTING
let oweBalance = 0;
oweAccountList.forEach(item => {
if (item.balance){
oweBalance = oweBalance + item.balance
sumBalance = sumBalance + item.balance
}
})
this.setData({cashAccountList,oweAccountList,cashBalance,oweBalance,sumBalance})
}
})
}, },
changeHidden () { changeHidden () {
let isHidden = this.data.hiddenMoney; let isHidden = this.data.hiddenMoney;

View File

@@ -2,12 +2,12 @@
<view class="look_content"> <view class="look_content">
<view class="pay_look"> <view class="pay_look">
<view class="inline_box font_big">净资产<t-icon bind:tap="changeHidden" name="{{ hiddenMoney ? 'browse' : 'browse-off'}}"/></view> <view class="inline_box font_big">净资产<t-icon bind:tap="changeHidden" name="{{ hiddenMoney ? 'browse' : 'browse-off'}}"/></view>
<text class="font_big">{{ hiddenMoney ? noMoney : 1200.00 }}</text> <text class="font_big">{{ hiddenMoney ? noMoney : sumBalance }}</text>
</view> </view>
<view class="balance_look"> <view class="balance_look">
<text>总资产: {{ hiddenMoney ? noMoney : 900.00 }}</text> <text>总资产: {{ hiddenMoney ? noMoney : cashBalance }}</text>
<text> | </text> <text> | </text>
<text>总负债: {{ hiddenMoney ? noMoney : -300.00 }}</text> <text>总负债: {{ hiddenMoney ? noMoney : oweBalance }}</text>
</view> </view>
</view> </view>
</view> </view>
@@ -18,9 +18,9 @@
<t-cell wx:for="{{cashAccountList}}" wx:key="index" <t-cell wx:for="{{cashAccountList}}" wx:key="index"
title="{{item.name}}" title="{{item.name}}"
align="top" align="top"
image="/image/account/5.png" image="{{item.icon}}"
url="/pages/account/detail/index" url="/pages/account/detail/index?sid={{item.id}}&balance={{item.balance}}"
note="{{hiddenMoney ? noMoney : item.money}}" note="{{hiddenMoney ? noMoney : item.balance}}"
/> />
</t-cell-group> </t-cell-group>
<view class="padding_box"> <view class="padding_box">
@@ -30,9 +30,9 @@
<t-cell wx:for="{{oweAccountList}}" wx:key="index" <t-cell wx:for="{{oweAccountList}}" wx:key="index"
title="{{item.name}}" title="{{item.name}}"
align="top" align="top"
image="/image/account/10.png" image="{{item.icon}}"
url="/pages/account/detail/index" url="/pages/account/detail/index?sid={{item.id}}&balance={{item.balance}}"
note="{{hiddenMoney ? noMoney : item.money}}" note="{{hiddenMoney ? noMoney : item.balance}}"
/> />
</t-cell-group> </t-cell-group>
<view class="placeholder"/> <view class="placeholder"/>

View File

@@ -31,7 +31,6 @@ Component({
start: '2000-01-01 00:00:00', start: '2000-01-01 00:00:00',
end: '2030-09-09 12:12:12', end: '2030-09-09 12:12:12',
name: null,
money: null, money: null,
billType: null, billType: null,
account: null, account: null,
@@ -93,7 +92,6 @@ Component({
if (this.properties.billId != -1){ if (this.properties.billId != -1){
app.$api.getBill(this.properties.billId).then(res => { app.$api.getBill(this.properties.billId).then(res => {
if (res.data){ if (res.data){
let name = res.data.name;
let money = res.data.money; let money = res.data.money;
let billType = res.data.billType; let billType = res.data.billType;
let account = res.data.account; let account = res.data.account;
@@ -103,7 +101,7 @@ Component({
let remark = res.data.remark; let remark = res.data.remark;
let dateText = res.data.date; let dateText = res.data.date;
this.setData({ this.setData({
name,money,billType,account,moneyType,typeText,accountText,remark,dateText money,billType,account,moneyType,typeText,accountText,remark,dateText
}) })
} }
}) })
@@ -149,9 +147,6 @@ Component({
onCancel(){ onCancel(){
handler.close(); handler.close();
}, },
onNameInput(e) {
this.setData({ name : e.detail.value})
},
onRemarkInput(e) { onRemarkInput(e) {
this.setData({ remark : e.detail.value}) this.setData({ remark : e.detail.value})
}, },
@@ -209,7 +204,6 @@ Component({
saveBill () { saveBill () {
let param = { let param = {
id : this.properties.billId, id : this.properties.billId,
name:this.data.name,
money:this.data.money, money:this.data.money,
billType:this.data.billType, billType:this.data.billType,
account:this.data.account, account:this.data.account,

View File

@@ -1,10 +1,3 @@
<t-input
label="名称"
placeholder="请输入名称"
align="right"
bindchange="onNameInput"
value="{{name}}"
/>
<t-input <t-input
label="金额" label="金额"
placeholder="0.00" placeholder="0.00"

View File

@@ -30,7 +30,6 @@ Component({
start: '2000-01-01 00:00:00', start: '2000-01-01 00:00:00',
end: '2030-09-09 12:12:12', end: '2030-09-09 12:12:12',
name: null,
money: null, money: null,
billType: null, billType: null,
fromAccount: null, fromAccount: null,
@@ -78,7 +77,6 @@ Component({
if (this.properties.billId != -1){ if (this.properties.billId != -1){
app.$api.getBill(this.properties.billId).then(res => { app.$api.getBill(this.properties.billId).then(res => {
if (res.data){ if (res.data){
let name = res.data.name;
let money = res.data.money; let money = res.data.money;
let billType = res.data.billType; let billType = res.data.billType;
let fromAccount = res.data.fromAccount; let fromAccount = res.data.fromAccount;
@@ -89,7 +87,7 @@ Component({
let remark = res.data.remark; let remark = res.data.remark;
let dateText = res.data.date; let dateText = res.data.date;
this.setData({ this.setData({
name,money,billType,fromAccount,account,outText,inText,moneyType,remark,dateText money,billType,fromAccount,account,outText,inText,moneyType,remark,dateText
}) })
} }
}) })
@@ -139,9 +137,6 @@ Component({
onCancel(){ onCancel(){
handler.close(); handler.close();
}, },
onNameInput(e) {
this.setData({ name : e.detail.value})
},
onRemarkInput(e) { onRemarkInput(e) {
this.setData({ remark : e.detail.value}) this.setData({ remark : e.detail.value})
}, },
@@ -199,7 +194,6 @@ Component({
saveBill () { saveBill () {
let param = { let param = {
id : this.properties.billId, id : this.properties.billId,
name:this.data.name,
money:this.data.money, money:this.data.money,
billType:this.data.billType, billType:this.data.billType,
fromAccount:this.data.fromAccount, fromAccount:this.data.fromAccount,

View File

@@ -1,10 +1,3 @@
<t-input
label="名称"
placeholder="请输入名称"
align="right"
bindchange="onNameInput"
value="{{name}}"
/>
<t-input <t-input
label="金额" label="金额"
placeholder="0.00" placeholder="0.00"

View File

@@ -3,16 +3,8 @@ Page({
data: { data: {
progress: 89, progress: 89,
todayList: [ todayList: [
{"name":"电脑","type":"INCOME","date":"01-06","accountName":"银行卡","money":"4500.00"}, {"moneyName":"电脑","billType":"INCOME","date":"01-06","accountName":"银行卡","money":"4500.00"},
{"name":"狗粮","type":"EXPEND","date":"01-06","accountName":"支付宝","money":"35.00"}, {"moneyName":"狗粮","billType":"EXPEND","date":"01-06","accountName":"支付宝","money":"35.00"},
{"name":"狗粮","type":"EXPEND","date":"01-06","accountName":"支付宝","money":"35.00"},
{"name":"狗粮","type":"EXPEND","date":"01-06","accountName":"支付宝","money":"35.00"},
{"name":"狗粮","type":"EXPEND","date":"01-06","accountName":"支付宝","money":"35.00"},
{"name":"狗粮","type":"EXPEND","date":"01-06","accountName":"支付宝","money":"35.00"},
{"name":"狗粮","type":"EXPEND","date":"01-06","accountName":"支付宝","money":"35.00"},
{"name":"狗粮","type":"EXPEND","date":"01-06","accountName":"支付宝","money":"35.00"},
{"name":"狗粮","type":"EXPEND","date":"01-06","accountName":"支付宝","money":"35.00"},
{"name":"狗粮","type":"EXPEND","date":"01-06","accountName":"支付宝","money":"35.00"},
] ]
}, },
onLoad: function (options) { onLoad: function (options) {

View File

@@ -28,12 +28,12 @@
<view wx:if="{{todayList != null && todayList.length > 0}}"> <view wx:if="{{todayList != null && todayList.length > 0}}">
<t-cell-group theme="card"> <t-cell-group theme="card">
<t-cell wx:for="{{todayList}}" wx:key="index" <t-cell wx:for="{{todayList}}" wx:key="index"
title="{{item.name}}" title="{{item.moneyName}}"
description="{{item.date}} • {{item.accountName}}" description="{{item.date}} • {{item.accountName}}"
align="top" align="top"
image="{{item.moneyIcon}}" image="{{item.moneyIcon}}"
note="{{item.money}}" note="{{item.money}}"
class="t-cell-{{item.type}}" class="t-cell-{{item.billType}}"
url="{{'/pages/bill/index?id=' + item.id}}" url="{{'/pages/bill/index?id=' + item.id}}"
/> />
</t-cell-group> </t-cell-group>

View File

@@ -21,24 +21,11 @@ Page({
wx.login({ wx.login({
success (res) { success (res) {
if (res.code) { if (res.code) {
let param = { app.$api.loginAccount({"wxCode":res.code}).then(t=>{
appid:'wxb1f499f0a173865b', wx.setStorageSync("userId",t.data)
secret:'833eefaf9206337d6c2d643f94baef7b', that.setData({
js_code: res.code, noLogin : false
grant_type: 'authorization_code' })
};
//发起网络请求
wx.request({
url: 'https://api.weixin.qq.com/sns/jscode2session',
data: param,
success: function(x) {
app.$api.loginAccount({"openId":x.data.openid}).then(t=>{
wx.setStorageSync("userId",t.data)
that.setData({
noLogin : false
})
})
}
}) })
} else { } else {
console.log('登录失败!' + res.errMsg) console.log('登录失败!' + res.errMsg)

View File

@@ -31,10 +31,13 @@ Page({
} }
}) })
} }
if (options.isAdd == 1 && options.isAccount == 0){ if (options.isAdd == 1){
let settingType = 'EXPEND_SETTING'; let settingType = 'CASH_SETTING';
if (options.isIncome == 1){ if (options.isAccount == 0){
settingType = 'INCOME_SETTING' settingType = 'EXPEND_SETTING';
if (options.isIncome == 1){
settingType = 'INCOME_SETTING'
}
} }
this.setData({settingType}) this.setData({settingType})
} }

View File

@@ -278,12 +278,18 @@ export default {
getSettingsIncome(){ getSettingsIncome(){
return fetchPost('/user/settings/income',null,true,false); return fetchPost('/user/settings/income',null,true,false);
}, },
editAccount(params){
return fetchPost('/user/settings/edit/bill',params,true,false);
},
/** /**
* 账单处理 * 账单处理
*/ */
listBillsToday() { listBillsToday() {
return fetchPost('/user/bills/today', null,true,false); return fetchPost('/user/bills/today', null,true,false);
}, },
listBillByAccount(params){
return fetchPost('/user/bills/account' ,params,true,false);
},
editBill(params) { editBill(params) {
return fetchPost('/user/bill/edit',params,true,false); return fetchPost('/user/bill/edit',params,true,false);
}, },