Skip to content

Commit

Permalink
fix: 修复版本问题
Browse files Browse the repository at this point in the history
  • Loading branch information
GzhiYi committed Dec 24, 2021
1 parent a74b5c6 commit 77f618e
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 52 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = crlf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module.exports = {
'import/no-extraneous-dependencies': 0,
'no-plusplus': 0,
'comma-dangle': ["error", "never"],
eqeqeq: 0
eqeqeq: 0,
'linebreak-style': ["error", "windows"]
},
};
30 changes: 13 additions & 17 deletions miniprogram/pages/components/list/list.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable prefer-destructuring */
import dayjs from 'dayjs'

const { importStore } = getApp()
const { create, store } = importStore
let dateRange = null
Expand Down Expand Up @@ -48,26 +49,22 @@ create.Component(store, {
name: 'getAccountList',
data,
success(res) {
console.log('查看账单', res)
if (res.result && res.result.code === 1) {
const response = res.result.data
self.setData({
billResult: response.page
})
// 存在dateRange则表明选择了区间,需要将结果传到日历组件
if (dateRange) {
const flowOutList = response.page.filter(item => item.flow == 0)
const flowInList = response.page.filter(item => item.flow == 1)
let outMonty = 0
let inMoney = 0
flowOutList.forEach(item => {
outMonty += item.money
})
flowInList.forEach(item => {
inMoney += item.money
})
store.data.pickDateListSumResult = [outMonty, inMoney]
}
const flowOutList = response.page.filter((item) => item.flow == 0)
const flowInList = response.page.filter((item) => item.flow == 1)
let outMonty = 0
let inMoney = 0
flowOutList.forEach((item) => {
outMonty += item.money
})
flowInList.forEach((item) => {
inMoney += item.money
})
store.data.pickDateListSumResult = [outMonty, inMoney]
} else {
wx.showToast({
title: '获取账单失败,稍后再试',
Expand Down Expand Up @@ -153,15 +150,14 @@ create.Component(store, {
this.getBillList(event.detail[0], event.detail[1], 'list')
},
onControl(event) {
const now = new Date()
const self = this
const { mode } = event.detail
if (mode === 'reset') {
dateRange = null
self.getBillList(this.data.today, this.data.today, 'list')
}
},
reFetchBillList(event) {
reFetchBillList() {
this.triggerEvent('reFetchBillList')
}
}
Expand Down
65 changes: 31 additions & 34 deletions miniprogram/pages/morechart/morechart.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
const dayjs = require('dayjs')

const baseConfig = (chart, type = 'month') => {
chart.scale('date', {
type: 'timeCat',
tickCount: 10
});
})
chart.scale('value', {
tickCount: 5
});
})
chart.tooltip({
showCrosshairs: true,
showTitle: type == 'month',
offsetY: 20
});
})
chart.legend({
position: 'bottom'
})
chart.line().position('date*value').shape('smooth').color('type', function(val) {
chart.line().position('date*value').shape('smooth').color('type', (val) => {
if (val === '收入') {
return '#4fd69c';
} else if (val === '支出') {
return '#f75676';
} else if (val === '净收入') {
return '#ffdd57';
return '#4fd69c'
} if (val === '支出') {
return '#f75676'
} if (val === '净收入') {
return '#ffdd57'
}
});
})
}
Page({
data: {
Expand Down Expand Up @@ -60,12 +61,12 @@ Page({
const { categories, series } = res.result.data
if (res.result.code === 1 && categories) {
const data = []
categories.forEach((date, index) => {
series.forEach(line => {
categories.forEach((inDate, index) => {
series.forEach((line) => {
data.push({
"date": date,
"type": line.name,
"value": line.data[index]
date: inDate,
type: line.name,
value: line.data[index]
})
})
})
Expand All @@ -85,13 +86,11 @@ Page({
chart.source(data)
baseConfig(chart)
chart.axis('date', {
label: (text) => {
return {
text: text.slice(8) + '日'
}
}
label: (text) => ({
text: `${text.slice(8)}日`
})
})
chart.render();
chart.render()
// 注意:需要把chart return 出来
return chart
}
Expand All @@ -117,12 +116,12 @@ Page({
const { categories, series } = res.result.data
if (res.result.code === 1 && categories) {
const data = []
categories.forEach((date, index) => {
series.forEach(line => {
categories.forEach((inDate, index) => {
series.forEach((line) => {
data.push({
"date": date,
"type": line.name,
"value": line.data[index]
date: inDate,
type: line.name,
value: line.data[index]
})
})
})
Expand All @@ -139,13 +138,11 @@ Page({
chart.source(data)
baseConfig(chart, 'year')
chart.axis('date', {
label: (text) => {
return {
text: text.slice(5, 7) + '月'
}
}
label: (text) => ({
text: `${text.slice(5, 7)}月`
})
})
chart.render();
chart.render()
// 注意:需要把chart return 出来
return chart
}
Expand All @@ -158,8 +155,8 @@ Page({
bindDateChange(event) {
const oldMonth = this.data.month
const oldYear = this.data.year
const newMonth = dayjs(event.detail.value).format("MM")
const newYear = dayjs(event.detail.value).format("YYYY")
const newMonth = dayjs(event.detail.value).format('MM')
const newYear = dayjs(event.detail.value).format('YYYY')
this.setData({
date: event.detail.value,
month: newMonth,
Expand Down

0 comments on commit 77f618e

Please sign in to comment.