diff --git a/pages/account/detail/index.js b/pages/account/detail/index.js
index 3145968..3f821e8 100644
--- a/pages/account/detail/index.js
+++ b/pages/account/detail/index.js
@@ -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()
diff --git a/pages/account/detail/index.wxml b/pages/account/detail/index.wxml
index 7f4b54b..cec8526 100644
--- a/pages/account/detail/index.wxml
+++ b/pages/account/detail/index.wxml
@@ -11,8 +11,8 @@
- 支出{{1203.00}}
- 收入{{1203.00}}
+ 支出{{expendMoney}}
+ 收入{{incomeMoney}}
@@ -53,5 +53,5 @@
bind:confirm="onConfirm"
bind:cancel="closeDialog"
>
-
+
diff --git a/pages/account/index.js b/pages/account/index.js
index 07d8ef4..fafb5d1 100644
--- a/pages/account/index.js
+++ b/pages/account/index.js
@@ -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;
diff --git a/pages/account/index.wxml b/pages/account/index.wxml
index ea81a60..5325e33 100644
--- a/pages/account/index.wxml
+++ b/pages/account/index.wxml
@@ -2,12 +2,12 @@
净资产
- {{ hiddenMoney ? noMoney : 1200.00 }}
+ {{ hiddenMoney ? noMoney : sumBalance }}
- 总资产: {{ hiddenMoney ? noMoney : 900.00 }}
+ 总资产: {{ hiddenMoney ? noMoney : cashBalance }}
|
- 总负债: {{ hiddenMoney ? noMoney : -300.00 }}
+ 总负债: {{ hiddenMoney ? noMoney : oweBalance }}
@@ -18,9 +18,9 @@
@@ -30,9 +30,9 @@
diff --git a/pages/bill/types/expenses.js b/pages/bill/types/expenses.js
index 2fe2ac4..bf96682 100644
--- a/pages/bill/types/expenses.js
+++ b/pages/bill/types/expenses.js
@@ -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,
diff --git a/pages/bill/types/expenses.wxml b/pages/bill/types/expenses.wxml
index 7ad2b90..264bfba 100644
--- a/pages/bill/types/expenses.wxml
+++ b/pages/bill/types/expenses.wxml
@@ -1,10 +1,3 @@
-
{
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,
diff --git a/pages/bill/types/transfer.wxml b/pages/bill/types/transfer.wxml
index 9e5f372..9a7688a 100644
--- a/pages/bill/types/transfer.wxml
+++ b/pages/bill/types/transfer.wxml
@@ -1,10 +1,3 @@
-
diff --git a/pages/myself/index.js b/pages/myself/index.js
index c969b9c..5da4036 100644
--- a/pages/myself/index.js
+++ b/pages/myself/index.js
@@ -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)
diff --git a/pages/settings/edit/index.js b/pages/settings/edit/index.js
index c627bcc..c652e0e 100644
--- a/pages/settings/edit/index.js
+++ b/pages/settings/edit/index.js
@@ -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})
}
diff --git a/utils/api.js b/utils/api.js
index b5d8a14..400e98d 100644
--- a/utils/api.js
+++ b/utils/api.js
@@ -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);
},