账单报表

This commit is contained in:
limqhz
2023-02-10 18:02:59 +08:00
parent 87a1b4ce18
commit 4bb155021c
10 changed files with 165 additions and 253 deletions

View File

@@ -20,16 +20,16 @@ page {
--td-dialog-title-color: none; --td-dialog-title-color: none;
} }
/* 记账类型颜色 */ /* 记账类型颜色 */
.t-color-income { .t-color-INCOME {
color: red; color: red;
} }
.t-color-expend { .t-color-EXPEND {
color: green; color: green;
} }
.t-color-transfer { .t-color-TRANSFER {
color: blue; color: orange;
} }
.t-color-repayment { .t-color-REPAYMENT {
color: yellow; color: yellow;
} }
/* 记账类型颜色 */ /* 记账类型颜色 */
@@ -43,7 +43,7 @@ t-cell {
--td-cell-note-color: green; --td-cell-note-color: green;
} }
.t-cell-TRANSFER { .t-cell-TRANSFER {
--td-cell-note-color: blue; --td-cell-note-color: orange;
} }
.t-cell-REPAYMENT { .t-cell-REPAYMENT {
--td-cell-note-color: yellow; --td-cell-note-color: yellow;
@@ -78,7 +78,7 @@ t-cell {
} }
.center_box { .center_box {
width: 100%; width: 100%;
margin-top: 20rpx; margin-top: 10rpx;
display: flex; display: flex;
justify-content: center; justify-content: center;
} }

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">支出{{expendBalance}}</text> <text class="t-color-EXPEND">支出{{expendBalance}}</text>
<text class="t-color-income">收入{{incomeBalance}}</text> <text class="t-color-INCOME">收入{{incomeBalance}}</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"/>

View File

@@ -3,7 +3,7 @@
<image src="https://tdesign.gtimg.com/site/miniprogram-doc/doc-actionsheet.png"/> <image src="https://tdesign.gtimg.com/site/miniprogram-doc/doc-actionsheet.png"/>
账单金额 账单金额
</view> </view>
<view class="{{money > 0 ? 't-color-income' : 't-color-expend'}} font_large">{{money > 0 ? "+" + money : money}}</view> <view class="{{'t-color-' + billType}} font_large">{{money}}</view>
</view> </view>
<view class="padding_box"> <view class="padding_box">
<t-divider dashed/> <t-divider dashed/>

View File

@@ -1,17 +1,23 @@
const app = getApp()
Page({ Page({
data: { data: {
typeName: '宠物', expendID: -1,
billList: [ rangeDate: app.$utils.formatDateMonth(new Date()),
{"title":"狗粮","type":"expend","dateTime":"01-06","from":"支付宝","money":"35.00"}, sumMoney: 0,
{"title":"狗粮","type":"expend","dateTime":"01-06","from":"支付宝","money":"35.00"}, billList: []
{"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 expendID = options.expendId
let rangeDate = options.rangeDate
this.setData({expendID,rangeDate})
},
onShow() {
app.$api.listBillGroupDetail({expendId:this.data.expendID,rangeDate:this.data.rangeDate}).then(res =>{
if (res.data){
let sumMoney = res.data.sumMoney
let billList = res.data.billList
this.setData({sumMoney,billList})
}
})
} }
}); });

View File

@@ -1,22 +1,22 @@
<view class="main_look"> <view class="main_look">
<view class="look_content"> <view class="look_content">
<view class="pay_look"> <view class="pay_look">
<view class="inline_box font_big">{{typeName}}分类总计</view> <view class="inline_box font_big">分类总计</view>
</view> </view>
<view class="pay_look"> <view class="pay_look">
<text class="center_look font_big">{{ 89310.23 }}</text> <text class="center_look font_big">{{ sumMoney }}</text>
</view> </view>
</view> </view>
</view> </view>
<view wx:if="{{billList != null && billList.length > 0}}"> <view wx:if="{{billList != null && billList.length > 0}}">
<t-cell-group theme="card"> <t-cell-group theme="card">
<t-cell wx:for="{{billList}}" wx:key="index" <t-cell wx:for="{{billList}}" wx:key="index"
title="{{item.title}}" title="{{item.moneyName}}"
description="{{item.dateTime}} • {{item.from}}" description="{{item.date}} • {{item.accountName}}"
align="top" align="top"
image="/image/bill/5.png" 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

@@ -1,5 +1,11 @@
import * as echarts from '../../ec-canvas/echarts'; import * as echarts from '../../ec-canvas/echarts';
let pieData = [];
let line1Data = [];
let line2Data = [];
function initPieChart(canvas, width, height, dpr) { function initPieChart(canvas, width, height, dpr) {
if (pieData.length <= 0){
return;
}
const chart = echarts.init(canvas, null, { const chart = echarts.init(canvas, null, {
width: 400, width: 400,
height: 250, height: 250,
@@ -17,29 +23,14 @@ function initPieChart(canvas, width, height, dpr) {
type: 'pie', type: 'pie',
center: ['50%', '50%'], center: ['50%', '50%'],
radius: ['0%', '70%'], radius: ['0%', '70%'],
data: [{ data: pieData
value: 55,
name: '数码产品',
id: 1
}, {
value: 20,
name: '零食'
}, {
value: 10,
name: '娱乐'
}, {
value: 20,
name: '房贷'
}, {
value: 38,
name: '房租'
}]
}] }]
}; };
chart.setOption(option); chart.setOption(option);
chart.on('click', 'series.pie', function(param) { chart.on('click', 'series.pie', function(param) {
console.log(param);
wx.navigateTo({ wx.navigateTo({
url: "./group/index?type=1" url: "./group/index?expendId=" + param.data.sId + '&rangeDate=' + param.data.sDate
}) })
}); });
return chart; return chart;
@@ -52,12 +43,7 @@ function initLineChart1(canvas, width, height, dpr) {
devicePixelRatio: dpr // new devicePixelRatio: dpr // new
}); });
canvas.setChart(chart); canvas.setChart(chart);
var option = { var option = {
title: {
text: '的撒打',
left: 'center'
},
legend: { legend: {
data: ['支出', '收入', '转账','还款'], data: ['支出', '收入', '转账','还款'],
top: 20, top: 20,
@@ -75,8 +61,7 @@ function initLineChart1(canvas, width, height, dpr) {
xAxis: { xAxis: {
type: 'category', type: 'category',
boundaryGap: false, boundaryGap: false,
data: ['第一周', '第二周', '第三周', '第四周'], show: false
// show: false
}, },
yAxis: { yAxis: {
x: 'center', x: 'center',
@@ -86,13 +71,12 @@ function initLineChart1(canvas, width, height, dpr) {
type: 'dashed' type: 'dashed'
} }
} }
// show: false
}, },
series: [{ series: [{
name: '支出', name: '支出',
type: 'line', type: 'line',
smooth: true, smooth: true,
data: [18, 36, 65, 30, 78, 40, 33] data: [18, 36, 65, 30, 78, 40, 33,123,123,12,23,123,123,123,123,213,23,21,12,31,3,12,32,31,3,31,5,4324,1,74,123,43]
}, { }, {
name: '收入', name: '收入',
type: 'line', type: 'line',
@@ -120,12 +104,7 @@ function initLineChart2(canvas, width, height, dpr) {
devicePixelRatio: dpr // new devicePixelRatio: dpr // new
}); });
canvas.setChart(chart); canvas.setChart(chart);
var option = { var option = {
title: {
text: '的撒打',
left: 'center'
},
legend: { legend: {
data: ['支出', '收入', '转账','还款'], data: ['支出', '收入', '转账','还款'],
top: 20, top: 20,
@@ -143,8 +122,7 @@ function initLineChart2(canvas, width, height, dpr) {
xAxis: { xAxis: {
type: 'category', type: 'category',
boundaryGap: false, boundaryGap: false,
data: ['1月', '2月', '3月', '4月', '5月', '6月'], show: false
// show: false
}, },
yAxis: { yAxis: {
x: 'center', x: 'center',
@@ -194,53 +172,9 @@ Page({
sumIncome: 0, sumIncome: 0,
sumTransfer: 0, sumTransfer: 0,
sumRepayment: 0, sumRepayment: 0,
payTypeList: [ payTypeList: [],
{"title":"数码产品","type":"expend","progress":"80","money":"4500.00"}, incomeList : [],
{"title":"房贷","type":"expend","progress":"20","money":"35.00"}, payList : [],
{"title":"数码产品","type":"expend","progress":"80","money":"4500.00"},
{"title":"房贷","type":"expend","progress":"20","money":"35.00"},
{"title":"数码产品","type":"expend","progress":"80","money":"4500.00"},
{"title":"房贷","type":"expend","progress":"20","money":"35.00"},
{"title":"数码产品","type":"expend","progress":"80","money":"4500.00"},
{"title":"房贷","type":"expend","progress":"20","money":"35.00"},
{"title":"数码产品","type":"expend","progress":"80","money":"4500.00"},
{"title":"房贷","type":"expend","progress":"20","money":"35.00"},
],
incomeList : [
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"},
{"id":1,"title":"电脑","type":"income","dateTime":"01-06","from":"银行卡","money":"4500.00"}
],
payList : [
{"id":1,"title":"狗粮","type":"expend","dateTime":"01-06","from":"支付宝","money":"35.00"},
{"id":2,"title":"狗粮","type":"expend","dateTime":"01-06","from":"支付宝","money":"35.00"},
{"id":2,"title":"狗粮","type":"expend","dateTime":"01-06","from":"支付宝","money":"35.00"},
{"id":2,"title":"狗粮","type":"expend","dateTime":"01-06","from":"支付宝","money":"35.00"},
{"id":2,"title":"狗粮","type":"expend","dateTime":"01-06","from":"支付宝","money":"35.00"},
{"id":2,"title":"狗粮","type":"expend","dateTime":"01-06","from":"支付宝","money":"35.00"},
{"id":2,"title":"狗粮","type":"expend","dateTime":"01-06","from":"支付宝","money":"35.00"},
{"id":2,"title":"狗粮","type":"expend","dateTime":"01-06","from":"支付宝","money":"35.00"},
{"id":3,"title":"狗粮","type":"expend","dateTime":"01-06","from":"支付宝","money":"35.00"},
],
ecPie: { ecPie: {
onInit: initPieChart onInit: initPieChart
}, },
@@ -251,6 +185,12 @@ Page({
onInit: initLineChart2 onInit: initLineChart2
} }
}, },
onLoad: function (options) {
if (options.rangeDate){
let showDate = options.rangeDate
this.setData({showDate})
}
},
onShow: function () { onShow: function () {
this.updateView(); this.updateView();
if (wx.canIUse('hideHomeButton')) { if (wx.canIUse('hideHomeButton')) {
@@ -268,6 +208,35 @@ Page({
this.setData({accountList,sumExpend,sumIncome,sumTransfer,sumRepayment}) this.setData({accountList,sumExpend,sumIncome,sumTransfer,sumRepayment})
} }
}) })
app.$api.listExpendOrderBills({'rangeDate':this.data.showDate}).then(res => {
if (res){
let payList = res.data
this.setData({payList})
}
})
app.$api.listIncomeOrderBills({'rangeDate':this.data.showDate}).then(res => {
if (res){
let incomeList = res.data
this.setData({incomeList})
}
})
app.$api.listBillGroup({'rangeDate':this.data.showDate}).then(res => {
if (res){
let payTypeList = res.data
pieData = [];
if (payTypeList){
payTypeList.forEach(x => {
pieData = pieData.concat({
sId: x.expendId,
sDate: this.data.showDate,
value: x.progress,
name: x.moneyName
});
})
}
this.setData({payTypeList})
}
})
}, },
showPicker(e) { showPicker(e) {
const { mode } = e.currentTarget.dataset; const { mode } = e.currentTarget.dataset;
@@ -289,8 +258,9 @@ Page({
[mode]: value [mode]: value
// [`${mode}Text`]: value, // [`${mode}Text`]: value,
}); });
this.updateView() // this.updateView()
this.hidePicker() this.hidePicker()
wx.redirectTo({url:"./index?rangeDate=" + this.data.showDate})
} }
}); });

View File

@@ -4,10 +4,10 @@
<t-tabs defaultValue="{{0}}" t-class="custom-tabs" theme="card"> <t-tabs defaultValue="{{0}}" t-class="custom-tabs" theme="card">
<t-tab-panel label="总览" value="0" class="tab_content"> <t-tab-panel label="总览" value="0" class="tab_content">
<view class="space_box font_big"> <view class="space_box font_big">
<text class="t-color-expend">支出\n {{sumExpend}}</text> <text class="t-color-EXPEND">支出\n {{sumExpend}}</text>
<text class="t-color-income">收入\n {{sumIncome}}</text> <text class="t-color-INCOME">收入\n {{sumIncome}}</text>
<text class="t-color-transfer">转账\n {{sumTransfer}}</text> <text class="t-color-TRANSFER">转账\n {{sumTransfer}}</text>
<text class="t-color-repayment">还款\n {{sumRepayment}}</text> <text class="t-color-REPAYMENT">还款\n {{sumRepayment}}</text>
</view> </view>
<view class="padding_box"> <view class="padding_box">
<t-divider dashed content="账单明细"/> <t-divider dashed content="账单明细"/>
@@ -35,13 +35,12 @@
<view wx:if="{{payTypeList != null && payTypeList.length > 0}}"> <view wx:if="{{payTypeList != null && payTypeList.length > 0}}">
<t-cell-group theme="card"> <t-cell-group theme="card">
<t-cell wx:for="{{payTypeList}}" wx:key="index" <t-cell wx:for="{{payTypeList}}" wx:key="index"
title="{{item.title}}" title="{{item.moneyName}}"
description="{{item.progress}}%" description="{{item.progress}}%"
align="top" align="top"
image="/image/bill/8.png" image="{{item.moneyIcon}}"
note="{{item.money}}" note="{{item.money}}"
class="t-cell-{{item.type}}" url="{{'/pages/chart/group/index?expendId=' + item.expendId + '&rangeDate=' + showDate}}"
url="{{'/pages/chart/group/index?type=' + item.type}}"
/> />
</t-cell-group> </t-cell-group>
</view> </view>
@@ -50,12 +49,13 @@
</t-tab-panel> </t-tab-panel>
<t-tab-panel label="趋势" value="2"> <t-tab-panel label="趋势" value="2">
<view class="chart-box"> <view class="chart-box">
<view class="center_box">月</view> <view class="chart_title">月</view>
<ec-canvas id="mychart-dom-line1" canvas-id="mychart-line1" ec="{{ ecLine1 }}"></ec-canvas> <ec-canvas id="mychart-dom-line1" canvas-id="mychart-line1" ec="{{ ecLine1 }}"></ec-canvas>
</view> </view>
<view class="chart-box2"> <view class="chart-box2">
<view class="center_box">近6月</view> <view class="chart-title2">近6月</view>
<ec-canvas id="mychart-dom-line2" canvas-id="mychart-line2" ec="{{ ecLine2 }}"></ec-canvas> <ec-canvas id="mychart-dom-line2" canvas-id="mychart-line2" ec="{{ ecLine2 }}"></ec-canvas>
<view class="chart-chart-bottom"></view>
</view> </view>
</t-tab-panel> </t-tab-panel>
<t-tab-panel label="排行" value="3"> <t-tab-panel label="排行" value="3">
@@ -65,12 +65,12 @@
<view wx:if="{{payList != null && payList.length > 0}}"> <view wx:if="{{payList != null && payList.length > 0}}">
<t-cell-group theme="card"> <t-cell-group theme="card">
<t-cell wx:for="{{payList}}" wx:key="index" <t-cell wx:for="{{payList}}" wx:key="index"
title="{{item.title}}" title="{{item.moneyName}}"
description="{{item.dateTime}} • {{item.from}}" description="{{item.date}} • {{item.accountName}}"
align="top" align="top"
image="/image/bill/2.png" 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>
@@ -81,12 +81,12 @@
<view wx:if="{{incomeList != null && incomeList.length > 0}}"> <view wx:if="{{incomeList != null && incomeList.length > 0}}">
<t-cell-group theme="card"> <t-cell-group theme="card">
<t-cell wx:for="{{incomeList}}" wx:key="index" <t-cell wx:for="{{incomeList}}" wx:key="index"
title="{{item.title}}" title="{{item.moneyName}}"
description="{{item.dateTime}} • {{item.from}}" description="{{item.date}} • {{item.accountName}}"
align="top" align="top"
image="/image/bill/4.png" 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

@@ -2,20 +2,29 @@
width:100%; width:100%;
height:500rpx; height:500rpx;
position: absolute; position: absolute;
top: 100rpx; top: 78rpx;
bottom: 0; bottom: 0;
left: 0; left: -20rpx;
right: 0; right: 0;
} }
.chart-box2 { .chart-box2 {
width:100%; width:100%;
height:500rpx; height:500rpx;
position: absolute; position: absolute;
top: 650rpx; top: 498rpx;
bottom: 0; left: -20rpx;
left: 0;
right: 0; right: 0;
} }
.chart_title{
margin-top: 18rpx;
margin-left: 20rpx;
color: orange;
}
.chart-title2{
margin-top: 50rpx;
margin-left: 20rpx;
color: orange;
}
ec-canvas { ec-canvas {
width: 100%; width: 100%;
height: 100%; height: 100%;

View File

@@ -28,8 +28,8 @@ Component({
data: { data: {
list: [ list: [
{ value: 'label_1', icon: 'home', ariaLabel: '首页' }, { value: 'label_1', icon: 'home', ariaLabel: '首页' },
{ value: 'label_2', icon: 'app', ariaLabel: '统计' }, { value: 'label_2', icon: 'chart', ariaLabel: '统计' },
{ value: 'label_3', icon: 'chat', ariaLabel: '资产' }, { value: 'label_3', icon: 'creditcard', ariaLabel: '资产' },
{ value: 'label_4', icon: 'user', ariaLabel: '我的' }, { value: 'label_4', icon: 'user', ariaLabel: '我的' },
], ],
}, },
@@ -60,21 +60,7 @@ Component({
}) })
} }
}, },
checkLogin(){
// let userInfo = wx.getStorageSync('userInfo');
// let token = wx.getStorageSync('userToken');
// if (userInfo && token){
// return true;
// }else {
// return false;
// }
},
onChange(event) { onChange(event) {
// if (!this.checkLogin()){
// wx.redirectTo({url:"/pages/login/index"});
// }
this.setIconData(event.detail.value); this.setIconData(event.detail.value);
}, },
} }

View File

@@ -51,42 +51,23 @@ export function fetchPost(url, params, needToken, multiple) {
console.log(res); console.log(res);
if (response.statusCode == 200) { if (response.statusCode == 200) {
if (res.err_code == 0) { if (res.err_code == 0) {
// wx.hideLoading(); wx.hideLoading();
resolve(res); resolve(res);
} else { } else {
if (res.err_code == 10003 || res.err_code == 10006 || res.err_code == 20006) {
// wx.removeStorageSync('accessToken');
// wx.redirectTo({
// url: '/pages/login/index',
// })
isUnLogin();
reject(res);
return;
} else if (res.err_code == 20005) {
wx.removeStorageSync('accessToken');
wx.removeStorageSync('history');
wx.hideLoading(); wx.hideLoading();
wx.showToast({ wx.showToast({
title: res.err_msg, title: res.data.err_msg,
icon: 'none',
duration: 2000
})
reject(res);
} else {
wx.hideLoading();
wx.showToast({
title: res.err_msg,
icon: 'none', icon: 'none',
duration: 2000 duration: 2000
}) })
reject(res); reject(res);
} }
}
} else { } else {
wx.hideLoading(); wx.hideLoading();
wx.showToast({ wx.showToast({
title: '网络错误', title: '服务器异常',
icon: 'none', icon: 'none',
duration: 4000
}) })
reject(response); reject(response);
} }
@@ -97,6 +78,7 @@ export function fetchPost(url, params, needToken, multiple) {
wx.showToast({ wx.showToast({
title: '网络错误', title: '网络错误',
icon: 'none', icon: 'none',
duration: 4000
}) })
reject(response); reject(response);
}, },
@@ -119,35 +101,13 @@ export function fetchPost(url, params, needToken, multiple) {
wx.hideLoading(); wx.hideLoading();
resolve(res.data); resolve(res.data);
} else { } else {
if (res.data.err_code == 10003 || res.data.err_code == 10006 || res.data.err_code == 20006) {
// wx.removeStorageSync('accessToken');
// wx.redirectTo({
// url: '/pages/login/index',
// })
reject(res);
return;
} else if (res.data.err_code == 30022) {
reject(res);
} else if (res.data.err_code == 20005) {
wx.removeStorageSync('accessToken');
wx.removeStorageSync('history');
wx.hideLoading(); wx.hideLoading();
wx.showToast({ wx.showToast({
title: res.data.err_msg, title: res.data.err_msg,
icon: 'none', icon: 'none',
duration: 2000 duration: 4000
}) })
reject(res); reject(res);
} else {
wx.hideLoading();
wx.showToast({
title: res.data.err_msg,
icon: 'none',
duration: 2000
})
reject(res);
}
} }
}, },
fail: function(res) { fail: function(res) {
@@ -155,7 +115,7 @@ export function fetchPost(url, params, needToken, multiple) {
wx.showToast({ wx.showToast({
title: '网络错误', title: '网络错误',
icon: 'none', icon: 'none',
duration: 2000 duration: 4000
}) })
reject(res); reject(res);
@@ -187,37 +147,15 @@ export function fetchGet(url, params, needToken) {
wx.hideLoading(); wx.hideLoading();
resolve(res.data); resolve(res.data);
} else { } else {
if (res.data.err_code == 10003 || res.data.err_code == 10006 || res.data.err_code == 20006) {
// isUnLogin();
reject(res); reject(res);
return;
} else if (res.data.err_code == 20005) {
wx.removeStorageSync('accessToken');
wx.removeStorageSync('history');
wx.hideLoading();
wx.showToast({
title: res.data.err_msg,
icon: 'none',
duration: 2000
})
reject(res);
} else {
wx.hideLoading();
wx.showToast({
title: res.data.err_msg,
icon: 'none',
duration: 2000
})
reject(res);
}
} }
} else { } else {
wx.hideLoading(); wx.hideLoading();
reject(res) reject(res)
wx.showToast({ wx.showToast({
title: '网络错误', title: '服务器异常',
icon: 'none', icon: 'none',
duration: 2000 duration: 4000
}) })
} }
}, },
@@ -227,7 +165,7 @@ export function fetchGet(url, params, needToken) {
wx.showToast({ wx.showToast({
title: '网络错误', title: '网络错误',
icon: 'none', icon: 'none',
duration: 2000 duration: 4000
}) })
}, },
}) })
@@ -255,19 +193,6 @@ export default {
return fetchPost('/user/settings/del/' + params,null,true,false); return fetchPost('/user/settings/del/' + params,null,true,false);
}, },
getSettings() { getSettings() {
// let result;
// if (type == 'INCOME_SETTING'){
// result = wx.getStorageSync('INCOME_SETTING');
// }
// if (type == 'EXPEND_SETTING'){
// result = wx.getStorageSync('INCOME_SETTING');
// }
// if (type == 'ACCOUNT_SETTING'){
// result = wx.getStorageSync('INCOME_SETTING');
// }
// if (result){
// return result;
// }
return fetchPost('/user/settings', null, true, false); return fetchPost('/user/settings', null, true, false);
}, },
@@ -286,12 +211,6 @@ export default {
listBillsToday() { listBillsToday() {
return fetchPost('/user/bills/today', null,true,false); return fetchPost('/user/bills/today', null,true,false);
}, },
listBillByAMonth(params){
return fetchPost('/user/bills/month' ,params,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);
}, },
@@ -312,5 +231,27 @@ export default {
}, },
editBudget(params){ editBudget(params){
return fetchPost('/user/budget/edit',params,true,false); return fetchPost('/user/budget/edit',params,true,false);
} },
/**
* 账单统计
*/
listBillByAMonth(params){
return fetchPost('/user/bills/month' ,params,true,false);
},
listExpendOrderBills(params){
return fetchPost('/user/bills/expend/order' ,params,true,false);
},
listIncomeOrderBills(params){
return fetchPost('/user/bills/income/order' ,params,true,false);
},
listBillByAccount(params){
return fetchPost('/user/bills/account' ,params,true,false);
},
listBillGroup(params){
return fetchPost('/user/bills/group/list' ,params,true,false);
},
listBillGroupDetail(params){
return fetchPost('/user/bills/group/detail' ,params,true,false);
},
} }