账单查询
This commit is contained in:
@@ -1,28 +1,45 @@
|
||||
const app = getApp();
|
||||
Page({
|
||||
data: {
|
||||
sid: -1,
|
||||
showSetMoney: false,
|
||||
currentMoney: 0.00,
|
||||
currentMoneyText: "8754.09",
|
||||
currentMoneyText: 0,
|
||||
expendBalance: 0,
|
||||
incomeBalance: 0,
|
||||
priceError: false,
|
||||
visible : false,
|
||||
dateRangeText : '请选择日期区间',
|
||||
dateRange : [new Date().getTime()- 24 * 60 * 60 * 1000,new Date().getTime()],
|
||||
dateRangeText : null,
|
||||
dateRange : null,
|
||||
minDate: new Date().getTime() - 365 * 24 * 60 * 60 * 1000,
|
||||
maxDate: new Date().getTime(),
|
||||
incomeList : [
|
||||
{"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"}
|
||||
],
|
||||
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"}
|
||||
]
|
||||
incomeList : [],
|
||||
payList : []
|
||||
},
|
||||
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() {
|
||||
this.setData({ visible: true });
|
||||
@@ -42,24 +59,25 @@ Page({
|
||||
showDialog() {
|
||||
this.setData({
|
||||
showSetMoney: true,
|
||||
currentMoney: this.data.currentMoneyText
|
||||
currentMoneyText: this.data.currentMoneyText
|
||||
})
|
||||
},
|
||||
onPriceInput(e) {
|
||||
this.setData({
|
||||
currentMoney: e.detail.value
|
||||
currentMoneyText: e.detail.value
|
||||
})
|
||||
},
|
||||
onConfirm () {
|
||||
const isNumber = /^\d+(\.\d+)?$/.test(this.data.currentMoney);
|
||||
const isNumber = /^\d+(\.\d+)?$/.test(this.data.currentMoneyText);
|
||||
if (!isNumber) {
|
||||
this.setData({
|
||||
priceError: true
|
||||
})
|
||||
return;
|
||||
}
|
||||
app.$api.editAccount({});
|
||||
this.setData({
|
||||
currentMoneyText: this.data.currentMoney,
|
||||
currentMoneyText: this.data.currentMoneyText,
|
||||
priceError: false
|
||||
})
|
||||
this.closeDialog()
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="space_box_no_padding font_big">
|
||||
<text class="t-color-expend">支出{{1203.00}}</text>
|
||||
<text class="t-color-income">收入{{1203.00}}</text>
|
||||
<text class="t-color-expend">支出{{expendMoney}}</text>
|
||||
<text class="t-color-income">收入{{incomeMoney}}</text>
|
||||
</view>
|
||||
<view class="padding_box">
|
||||
<t-divider content="{{dateRangeText}}" bind:tap="handleCalendar"/>
|
||||
@@ -53,5 +53,5 @@
|
||||
bind:confirm="onConfirm"
|
||||
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>
|
||||
|
||||
@@ -2,6 +2,9 @@ Page({
|
||||
data: {
|
||||
noMoney : "****",
|
||||
hiddenMoney: false,
|
||||
sumBalance: 0,
|
||||
cashBalance: 0,
|
||||
oweBalance: 0,
|
||||
cashAccountList : [
|
||||
{"name":"现金","money":"2000.00"},
|
||||
{"name":"银行卡","money":"30500.03"}
|
||||
@@ -17,6 +20,28 @@ Page({
|
||||
if (wx.canIUse('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 () {
|
||||
let isHidden = this.data.hiddenMoney;
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
<view class="look_content">
|
||||
<view class="pay_look">
|
||||
<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 class="balance_look">
|
||||
<text>总资产: {{ hiddenMoney ? noMoney : 900.00 }}</text>
|
||||
<text>总资产: {{ hiddenMoney ? noMoney : cashBalance }}</text>
|
||||
<text> | </text>
|
||||
<text>总负债: {{ hiddenMoney ? noMoney : -300.00 }}</text>
|
||||
<text>总负债: {{ hiddenMoney ? noMoney : oweBalance }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -18,9 +18,9 @@
|
||||
<t-cell wx:for="{{cashAccountList}}" wx:key="index"
|
||||
title="{{item.name}}"
|
||||
align="top"
|
||||
image="/image/account/5.png"
|
||||
url="/pages/account/detail/index"
|
||||
note="{{hiddenMoney ? noMoney : item.money}}"
|
||||
image="{{item.icon}}"
|
||||
url="/pages/account/detail/index?sid={{item.id}}&balance={{item.balance}}"
|
||||
note="{{hiddenMoney ? noMoney : item.balance}}"
|
||||
/>
|
||||
</t-cell-group>
|
||||
<view class="padding_box">
|
||||
@@ -30,9 +30,9 @@
|
||||
<t-cell wx:for="{{oweAccountList}}" wx:key="index"
|
||||
title="{{item.name}}"
|
||||
align="top"
|
||||
image="/image/account/10.png"
|
||||
url="/pages/account/detail/index"
|
||||
note="{{hiddenMoney ? noMoney : item.money}}"
|
||||
image="{{item.icon}}"
|
||||
url="/pages/account/detail/index?sid={{item.id}}&balance={{item.balance}}"
|
||||
note="{{hiddenMoney ? noMoney : item.balance}}"
|
||||
/>
|
||||
</t-cell-group>
|
||||
<view class="placeholder"/>
|
||||
|
||||
@@ -31,7 +31,6 @@ Component({
|
||||
start: '2000-01-01 00:00:00',
|
||||
end: '2030-09-09 12:12:12',
|
||||
|
||||
name: null,
|
||||
money: null,
|
||||
billType: null,
|
||||
account: null,
|
||||
@@ -93,7 +92,6 @@ Component({
|
||||
if (this.properties.billId != -1){
|
||||
app.$api.getBill(this.properties.billId).then(res => {
|
||||
if (res.data){
|
||||
let name = res.data.name;
|
||||
let money = res.data.money;
|
||||
let billType = res.data.billType;
|
||||
let account = res.data.account;
|
||||
@@ -103,7 +101,7 @@ Component({
|
||||
let remark = res.data.remark;
|
||||
let dateText = res.data.date;
|
||||
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(){
|
||||
handler.close();
|
||||
},
|
||||
onNameInput(e) {
|
||||
this.setData({ name : e.detail.value})
|
||||
},
|
||||
onRemarkInput(e) {
|
||||
this.setData({ remark : e.detail.value})
|
||||
},
|
||||
@@ -209,7 +204,6 @@ Component({
|
||||
saveBill () {
|
||||
let param = {
|
||||
id : this.properties.billId,
|
||||
name:this.data.name,
|
||||
money:this.data.money,
|
||||
billType:this.data.billType,
|
||||
account:this.data.account,
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
<t-input
|
||||
label="名称"
|
||||
placeholder="请输入名称"
|
||||
align="right"
|
||||
bindchange="onNameInput"
|
||||
value="{{name}}"
|
||||
/>
|
||||
<t-input
|
||||
label="金额"
|
||||
placeholder="0.00"
|
||||
|
||||
@@ -30,7 +30,6 @@ Component({
|
||||
start: '2000-01-01 00:00:00',
|
||||
end: '2030-09-09 12:12:12',
|
||||
|
||||
name: null,
|
||||
money: null,
|
||||
billType: null,
|
||||
fromAccount: null,
|
||||
@@ -78,7 +77,6 @@ Component({
|
||||
if (this.properties.billId != -1){
|
||||
app.$api.getBill(this.properties.billId).then(res => {
|
||||
if (res.data){
|
||||
let name = res.data.name;
|
||||
let money = res.data.money;
|
||||
let billType = res.data.billType;
|
||||
let fromAccount = res.data.fromAccount;
|
||||
@@ -89,7 +87,7 @@ Component({
|
||||
let remark = res.data.remark;
|
||||
let dateText = res.data.date;
|
||||
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(){
|
||||
handler.close();
|
||||
},
|
||||
onNameInput(e) {
|
||||
this.setData({ name : e.detail.value})
|
||||
},
|
||||
onRemarkInput(e) {
|
||||
this.setData({ remark : e.detail.value})
|
||||
},
|
||||
@@ -199,7 +194,6 @@ Component({
|
||||
saveBill () {
|
||||
let param = {
|
||||
id : this.properties.billId,
|
||||
name:this.data.name,
|
||||
money:this.data.money,
|
||||
billType:this.data.billType,
|
||||
fromAccount:this.data.fromAccount,
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
<t-input
|
||||
label="名称"
|
||||
placeholder="请输入名称"
|
||||
align="right"
|
||||
bindchange="onNameInput"
|
||||
value="{{name}}"
|
||||
/>
|
||||
<t-input
|
||||
label="金额"
|
||||
placeholder="0.00"
|
||||
|
||||
@@ -3,16 +3,8 @@ Page({
|
||||
data: {
|
||||
progress: 89,
|
||||
todayList: [
|
||||
{"name":"电脑","type":"INCOME","date":"01-06","accountName":"银行卡","money":"4500.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"},
|
||||
{"name":"狗粮","type":"EXPEND","date":"01-06","accountName":"支付宝","money":"35.00"},
|
||||
{"moneyName":"电脑","billType":"INCOME","date":"01-06","accountName":"银行卡","money":"4500.00"},
|
||||
{"moneyName":"狗粮","billType":"EXPEND","date":"01-06","accountName":"支付宝","money":"35.00"},
|
||||
]
|
||||
},
|
||||
onLoad: function (options) {
|
||||
|
||||
@@ -28,12 +28,12 @@
|
||||
<view wx:if="{{todayList != null && todayList.length > 0}}">
|
||||
<t-cell-group theme="card">
|
||||
<t-cell wx:for="{{todayList}}" wx:key="index"
|
||||
title="{{item.name}}"
|
||||
title="{{item.moneyName}}"
|
||||
description="{{item.date}} • {{item.accountName}}"
|
||||
align="top"
|
||||
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>
|
||||
|
||||
@@ -21,24 +21,11 @@ Page({
|
||||
wx.login({
|
||||
success (res) {
|
||||
if (res.code) {
|
||||
let param = {
|
||||
appid:'wxb1f499f0a173865b',
|
||||
secret:'833eefaf9206337d6c2d643f94baef7b',
|
||||
js_code: res.code,
|
||||
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
|
||||
})
|
||||
})
|
||||
}
|
||||
app.$api.loginAccount({"wxCode":res.code}).then(t=>{
|
||||
wx.setStorageSync("userId",t.data)
|
||||
that.setData({
|
||||
noLogin : false
|
||||
})
|
||||
})
|
||||
} else {
|
||||
console.log('登录失败!' + res.errMsg)
|
||||
|
||||
@@ -31,10 +31,13 @@ Page({
|
||||
}
|
||||
})
|
||||
}
|
||||
if (options.isAdd == 1 && options.isAccount == 0){
|
||||
let settingType = 'EXPEND_SETTING';
|
||||
if (options.isIncome == 1){
|
||||
settingType = 'INCOME_SETTING'
|
||||
if (options.isAdd == 1){
|
||||
let settingType = 'CASH_SETTING';
|
||||
if (options.isAccount == 0){
|
||||
settingType = 'EXPEND_SETTING';
|
||||
if (options.isIncome == 1){
|
||||
settingType = 'INCOME_SETTING'
|
||||
}
|
||||
}
|
||||
this.setData({settingType})
|
||||
}
|
||||
|
||||
@@ -278,12 +278,18 @@ export default {
|
||||
getSettingsIncome(){
|
||||
return fetchPost('/user/settings/income',null,true,false);
|
||||
},
|
||||
editAccount(params){
|
||||
return fetchPost('/user/settings/edit/bill',params,true,false);
|
||||
},
|
||||
/**
|
||||
* 账单处理
|
||||
*/
|
||||
listBillsToday() {
|
||||
return fetchPost('/user/bills/today', null,true,false);
|
||||
},
|
||||
listBillByAccount(params){
|
||||
return fetchPost('/user/bills/account' ,params,true,false);
|
||||
},
|
||||
editBill(params) {
|
||||
return fetchPost('/user/bill/edit',params,true,false);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user