Giter Site home page Giter Site logo

gzhiyi / dandan-account Goto Github PK

View Code? Open in Web Editor NEW
169.0 8.0 45.0 1.59 MB

【此版本不是线上版本】🐷 不记录任何用户身份信息;专注记账的目的;账单清晰自然,报表易懂易分析;助你理财之路轻松有意义,小程序【单单记账】。

License: MIT License

JavaScript 100.00%
cloud-functions miniprogram accounting

dandan-account's Introduction

dandan-account's People

Contributors

dependabot[bot] avatar guozf2018 avatar gzhiyi avatar hequanb avatar lemonicestuff avatar yunnet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dandan-account's Issues

v5.0.2需求规划

  1. 首页增加最近分类的快捷操作。
  2. 优化图表页的样式。
  3. 分类可以添加父类。
  4. 一起记账需求。

单单账单记录_账单表结构

初拟表结构, 欢迎修改
Create Collection DANDAN_NOTE_ACCOUNT {
_id : 系统生成,
accountDate String (账单日期 yyyy-MM-dd)
income Double (收入),
Expenditure Double (支出),
netIncome Double (净收入),
createTime Date (创建时间),
updateTime Date (修改时间),
openId String (用户ID)
}
/**
以下可支持修改当天的数据
可以通过聚合函数addField().match()匹配到对应的日期
year String(年 yyyy)
month String (月 MM)
day String (日 dd)
*/

共享账单的设计。

目前一个账单绑定一个openId。
如果需要实现多人共享账单(包括创建、删除、修改、查询共享账单),则需要一个集合去储存共享关系。
该集合包含如下字段:

createdBy: 创建人的openId,String;
relateUsers: 关联账单的用户列表,Array;
startDate: 关联账单的开始时间,Date;
endDate: 关联账单的结束时间,Date;
name: 组名,String;
createDate: 创建时间,Date;

用户请求所有相关账单列表之前,需要匹配relateUsers的所有用户的账单并集合起来。

权限

relateUsers内的所有用户都可以随时解除关联,解除需要将移除relateUsers对应的用户的openId。

初始小程序时分类数据集合

对于克隆下来发现没有分类,我这里有一份默认的分类集合提供导入。在云开发控制台导入到分类表即可。

云开发控制台-数据库-DANDAN_NOTE_CATEGORY(如无需新建)-导入-选择json文件即可。

对于json内的数据可以根据需要进行修改。

因为json就这么一段,所以就直接贴上来,保存为json后在导入时选择。

{
  "_id": "food_and_drink_breakfast",
  "categoryName": "早餐",
  "categoryIcon": "icon",
  "description": "早餐",
  "flow": 0,
  "type": 0,
  "parentId": "food_and_drink_total",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "food_and_drink_dinner",
  "categoryName": "晚餐",
  "categoryIcon": "icon",
  "description": "晚餐",
  "flow": 0,
  "type": 0,
  "parentId": "food_and_drink_total",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "food_and_drink_lunch",
  "categoryName": "午餐",
  "categoryIcon": "icon",
  "description": "午餐",
  "flow": 0,
  "type": 0,
  "parentId": "food_and_drink_total",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "food_and_drink_night_snack",
  "categoryName": "宵夜",
  "categoryIcon": "icon",
  "description": "宵夜",
  "flow": 0,
  "type": 0,
  "parentId": "food_and_drink_total",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "food_and_drink_snack",
  "categoryName": "零食",
  "categoryIcon": "icon",
  "description": "零食",
  "flow": 0,
  "type": 0,
  "parentId": "food_and_drink_total",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "food_and_drink_total",
  "categoryName": "餐饮",
  "categoryIcon": "icon",
  "description": "餐饮",
  "flow": 0,
  "type": 0,
  "parentId": "",
  "isSelectable": false,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "income",
  "categoryName": "收入",
  "categoryIcon": "icon",
  "description": "收入",
  "flow": 1,
  "type": 0,
  "parentId": "",
  "isSelectable": false,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "income_ETFs",
  "categoryName": "基金",
  "categoryIcon": "icon",
  "description": "基金",
  "flow": 1,
  "type": 0,
  "parentId": "income",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "income_bonus",
  "categoryName": "奖金",
  "categoryIcon": "icon",
  "description": "奖金",
  "flow": 1,
  "type": 0,
  "parentId": "income",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "income_debt_collect",
  "categoryName": "收债",
  "categoryIcon": "icon",
  "description": "收债",
  "flow": 1,
  "type": 0,
  "parentId": "income",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "income_gifts",
  "categoryName": "礼金",
  "categoryIcon": "icon",
  "description": "礼金",
  "flow": 1,
  "type": 0,
  "parentId": "income",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "income_living",
  "categoryName": "生活费",
  "categoryIcon": "icon",
  "description": "生活费",
  "flow": 1,
  "type": 0,
  "parentId": "income",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "income_red_packet",
  "categoryName": "红包",
  "categoryIcon": "icon",
  "description": "红包",
  "flow": 1,
  "type": 0,
  "parentId": "income",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "income_refund",
  "categoryName": "退款",
  "categoryIcon": "icon",
  "description": "退款",
  "flow": 1,
  "type": 0,
  "parentId": "income",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "income_salary",
  "categoryName": "工资",
  "categoryIcon": "icon",
  "description": "工资",
  "flow": 1,
  "type": 0,
  "parentId": "income",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "income_stocks",
  "categoryName": "股票",
  "categoryIcon": "icon",
  "description": "股票",
  "flow": 1,
  "type": 0,
  "parentId": "income",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "medicine",
  "categoryName": "医疗",
  "categoryIcon": "icon",
  "description": "医疗",
  "flow": 0,
  "type": 0,
  "parentId": "",
  "isSelectable": false,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "medicine_doctor",
  "categoryName": "看病",
  "categoryIcon": "icon",
  "description": "看病",
  "flow": 0,
  "type": 0,
  "parentId": "medicine",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "medicine_medicine",
  "categoryName": "药物",
  "categoryIcon": "icon",
  "description": "药物",
  "flow": 0,
  "type": 0,
  "parentId": "medicine",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "money_management",
  "categoryName": "理财",
  "categoryIcon": "icon",
  "description": "理财",
  "flow": 0,
  "type": 0,
  "parentId": "",
  "isSelectable": false,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "money_management_ETFs",
  "categoryName": "基金",
  "categoryIcon": "icon",
  "description": "基金",
  "flow": 0,
  "type": 0,
  "parentId": "money_management",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "money_management_stocks",
  "categoryName": "股票",
  "categoryIcon": "icon",
  "description": "股票",
  "flow": 0,
  "type": 0,
  "parentId": "money_management",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "others",
  "categoryName": "杂项",
  "categoryIcon": "icon",
  "description": "杂项",
  "flow": 0,
  "type": 0,
  "parentId": "",
  "isSelectable": false,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "others_sub",
  "categoryName": "杂项",
  "categoryIcon": "icon",
  "description": "杂项",
  "flow": 0,
  "type": 0,
  "parentId": "others",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "skin_care",
  "categoryName": "护理",
  "categoryIcon": "icon",
  "description": "护理",
  "flow": 0,
  "type": 0,
  "parentId": "",
  "isSelectable": false,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "skin_care_makeup",
  "categoryName": "化妆品",
  "categoryIcon": "icon",
  "description": "化妆品",
  "flow": 0,
  "type": 0,
  "parentId": "skin_care",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "stored_value",
  "categoryName": "储值",
  "categoryIcon": "icon",
  "description": "储值",
  "flow": 0,
  "type": 0,
  "parentId": "",
  "isSelectable": false,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "stored_value_bus_card",
  "categoryName": "公交卡",
  "categoryIcon": "icon",
  "description": "公交卡",
  "flow": 0,
  "type": 0,
  "parentId": "stored_value",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "stored_value_call_credit",
  "categoryName": "话费",
  "categoryIcon": "icon",
  "description": "话费",
  "flow": 0,
  "type": 0,
  "parentId": "stored_value",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "stored_value_membership_card",
  "categoryName": "会员卡",
  "categoryIcon": "icon",
  "description": "会员卡",
  "flow": 0,
  "type": 0,
  "parentId": "stored_value",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "stored_value_virtual",
  "categoryName": "虚拟物品",
  "categoryIcon": "icon",
  "description": "虚拟物品",
  "flow": 0,
  "type": 0,
  "parentId": "stored_value",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "transportation",
  "categoryName": "出行",
  "categoryIcon": "icon",
  "description": "出行",
  "flow": 0,
  "type": 0,
  "parentId": "",
  "isSelectable": false,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "transportation_airplane",
  "categoryName": "飞机",
  "categoryIcon": "icon",
  "description": "飞机",
  "flow": 0,
  "type": 0,
  "parentId": "transportation",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "transportation_high_speed_rail",
  "categoryName": "高铁",
  "categoryIcon": "icon",
  "description": "高铁",
  "flow": 0,
  "type": 0,
  "parentId": "transportation",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
} {
  "_id": "transportation_online_car",
  "categoryName": "网约车",
  "categoryIcon": "icon",
  "description": "网约车",
  "flow": 0,
  "type": 0,
  "parentId": "transportation",
  "isSelectable": true,
  "createTime": {
    "$date": "2019-08-21T08:02:30.448Z"
  },
  "openId": "SYSTEM",
  "isDel": false
}

分类规划

按目前的规划,分类应该设置一个大类,一个小类的形式。

大类 --- 小类

大类用于统计数据、关联小类以及好排列分类等。小类提供用户选择。

默认分类(支出)

食品

早餐、午餐、晚餐、零食

出行

高铁、飞机、网约车

储值

公交卡、会员卡、话费、虚拟商品

生活用品

生活用品

服饰

衣服、裤子、鞋子

护理

化妆品

文娱

书、电影

医药

生病、药品

资金流动

红包、借钱

理财

基金、股票

杂项

杂项

小程序环境分离

分离小程序环境

官方文档很模糊,搜索到了几条关于小程序环境分离的问题,大部分吐槽官方怎么没有一个好的办法分离开发和生产环境。

分离方式

  1. 云函数在调用的时候指定环境,依据云函数所在的环境进行动态设置。
const wxContext = cloud.getWXContext()
  cloud.updateConfig({
    env: wxContext.ENV
  })
  // 初始化数据库
  const db = cloud.database({
    env: wxContext.ENV
  })
  1. 小程序端起到起立环境的主要作用。在appjs中。
     wx.cloud.init({
        traceUser: true,
        env: 'release-wifo3', // 测试环境
        // env: 'dandan-zdm86' // 正式环境
      })

预览小程序的时候开启测试环境的env,在部署上线发布的时候再切换为正式环境。

折线图数据格式

数据格式

为便于函数数据对接,这里约束下前后端关于数据折线图的格式:

chartData: {
	categories: ['横坐标1', '横坐标2', '横坐标3', '横坐标4', '横坐标5', '横坐标6'], 
	series: [{
		name: '线1名称',
		data: [35, 20, 25, 37, 4, 20]
	}, {
		name: '线2名称',
		data: [70, 40, 65, 100, 44, 68]
	}, {
		name: '线3名称',
		data: [100, 80, 95, 150, 112, 132]
	}]
}

以上表示折线图有五个坐标,实际可以按需求进行坐标个数调整,只要数据个数对的上就可以了。

对于折线图的需求,可以看实际情况下需要展示多少数据。

按需求描述

  1. 获取当月每天数据趋势图。包含每天的收入、支出、净收入。
    入参为(例):month: “2019-11”
  2. 获取当年每月数据趋势图。包含每月的收入、支出、净收入。这一块的数据每个月返回的数据应在上一月数据上累加。
    入参为(例):year: “2019”

// TODO

v1.0.1修改需求合集

  1. 底部按钮在tab切换的时候不明显。he说点哪个哪个就变大。
  2. 菜单放在最右边不合适,有些用户不知道。

v6.0.3

这个版本主要增加功能:

带账本的一起记账。

V2.5.6 bugs

  • chart组件内的年份不要从第一年开始。

  • 日历样式数字不居中

  • 月份下划线样式调整

  • 图表处,“余”改为“月余”

  • 弹窗动画

  • 饼图浮点优化

  • 账单分页处理

  • 节流账单获取失败时的再次请求

  • chart组件内账单列表出现无账单的提示信息

  • 发现将未绑定在 WXML 的变量传入 setData 调用

  • 点击分类栏即可跳转到分类页面

  • 限制选择日期间隔,减少性能损耗

  • IOS13升级后,图表那居然透明了

  • 列表难以点击最后一个的问题

  • 切换饼图增加节流

  • 饼图默认颜色扩展

chart页数据接口情况

线上情况

目前线上的饼图数据均是通过账单列表进行处理后渲染的,大致的逻辑是:

  1. 计算每个月的起始和结尾日期,格式均为:2019-09-29。
  2. 通过起始日期startDate和EndDate获取一个月的所有账单数据。
  3. 根据用户的已有的分类进行遍历处理,筛选出每一个父分类的数据情况以及月支出、月收入。
  4. 根据匹配好的数据对页面进行饼图、列表数据渲染。

现在由于没法完整列出一个月所有账单数据的问题(假设账单数据多,需要分页处理),需要重新规划接口数据模式。

新版数据需求

为节省时间和以后维护方便,统一下数据需求。
chart页需要两个接口进行数据呈现

接口一:获取月支出数值、月收入数值、月余数值(月收入 - 月支出)、饼图数据

饼图需要的数据接口如下数组所示,字段名也需要依照下面返回:

[{
    name: 父分类名字,
    data: 该父分类下子分类支出/收入的数值和,
    category: 父分类的数据结构【数据库的数据,id之类的】
}, {
   // ...
}]

接口二:获取某个父分类下的账单了列表

默认情况下进入页面时将不再主动触发查询账单数据,只有在点击饼图的某块,或者在已选分类上作出选择后,我再请求列表数据回来。列表数据必须支持分页,分页建议50每页。

请求数据的参数可以如下:

  1. flow。支出或者收入。
  2. 父分类Id。用于查询该父分类下子分类的数据情况。
  3. 页面值,默认1。

要清楚知道,该接口查询的是某个父分类下的数据

@hequanb

v3.5.0 bugs

  • 支付方式增加招商银行、空值。【一个人的需求】。

  • 常用分类删除按钮默认显示问题。

  • 搜索增加重置按钮。

  • 折线图高度调整下。

  • 在当前的搜索结果中简单计算一些参数,在猪上显示。

  • 日历栏本月支出会有溢出的情况。

首页数据汇集规划

首页banner

首页需要一个展示数据的banner,这里商量需要展示什么数据。

规划

  • 经过考虑,认为首页(记账页面)不应该展示具体的支出收益信息,这会让随处记账的人感到一丝尴尬。
  • 经过考虑,首页只需要展示一个参考值。金钱剩余占比,称为结余占比,计算方式为:支出 / 收入 * 100%。
  • (补充)通过结余率,相应给出一些建议性的话语,比如结余小于10%。就提示他快要吃土、存不上钱等等。

v3.6.0 bugs

  • chart页面点击饼图出现加载账单不够的问题。

V3.0.0 bugs

  • 饼图数值存在浮点溢出。

  • 切换收入和支出后,选择分类的栏未切换。

  • 安卓机存在输入金额那在弹出键盘的时候偏移的问题。

  • 个别时候出现饼图无法点击的问题。

  • 单日首笔账单是收入在左边统计页面会显示为支出的问题。

  • 账单项右侧有多余空白。

  • 记账后提示时间过短。

  • 在分类选择页面不选择分类没有默认选择默认分类的问题。

  • 饼图点击限流。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.