From 7cc546afe3ab778af3086f9654cc396ff0aecbb9 Mon Sep 17 00:00:00 2001 From: "catpeter.panda@gmail.com" Date: Fri, 31 Jan 2020 00:51:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=98=E7=BA=BF=E5=9B=BE=EF=BC=8C=E5=88=86?= =?UTF-8?q?=E7=BB=84=E6=9F=A5=E8=AF=A2=E4=BA=BA=E5=91=98=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart-member-list/index.js | 24 ++++ common/util.js | 14 +- package.json | 20 +++ pages.json | 123 +++++++++--------- pages/chart/chart.vue | 81 ++++++++++-- 5 files changed, 189 insertions(+), 73 deletions(-) create mode 100644 cloudfunctions-aliyun/chart-member-list/index.js create mode 100644 package.json diff --git a/cloudfunctions-aliyun/chart-member-list/index.js b/cloudfunctions-aliyun/chart-member-list/index.js new file mode 100644 index 0000000..47fcf91 --- /dev/null +++ b/cloudfunctions-aliyun/chart-member-list/index.js @@ -0,0 +1,24 @@ +// 我在做这个文件,群昵称: 躺希腊额阿毛 QQ:786997741 +// TODO 条件 body_statu.status > 0 +'use strict'; +const db = uniCloud.database() +exports.main = async (event, context) => { + const collection = db.collection('member_list') + const $ = db.command.aggregate + const res = await collection.aggregate().group({ + _id: { + month: { + $month: "$body_status.time" + }, + day: { + $dayOfMonth: "$body_status.time" + }, + year: { + $year: "$body_status.time" + }, + status: "$body_status.status" + }, + count: $.sum(1) + }).end(); + return res +}; diff --git a/common/util.js b/common/util.js index b6db6d4..a126024 100644 --- a/common/util.js +++ b/common/util.js @@ -66,8 +66,20 @@ var dateUtils = { } }; +function formatDate(year, month, day) { + return year + '-' + getTwo(month) + '-' + getTwo(day) +} + +function getTwo(num) { + if (Number(num) < 10) { + return '0' + num; + } else { + return num + } +} module.exports = { formatTime: formatTime, formatLocation: formatLocation, - dateUtils: dateUtils + dateUtils: dateUtils, + formatDate: formatDate } diff --git a/package.json b/package.json new file mode 100644 index 0000000..8ba5c0e --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "xinguan2020-alien-registration", + "version": "1.0.0", + "description": "新型冠状病毒疫情期间针对外来人员的登记系统", + "main": "main.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "https://gitee.com/catpeter/xinguan2020-alien-registration.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "dependencies": { + "lodash": "^4.17.15", + "moment": "^2.24.0" + } +} diff --git a/pages.json b/pages.json index 45ab2e8..633e81c 100644 --- a/pages.json +++ b/pages.json @@ -1,61 +1,66 @@ { - "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages - { - "path": "pages/tabbar/member", - "style": {} - }, { - "path": "pages/tabbar/add", - "style": {} - }, { - "path": "pages/tabbar/search", - "style": {} - }, { - "path": "pages/tabbar/my", - "style": {} - }, { - "path": "pages/login/login", - "style": {} - }, { - "path": "pages/add-member/add-member", - "style": {} - }, { - "path": "pages/member-detail/member-detail", - "style": {} - } - ], - "globalStyle": { - "navigationBarTextStyle": "black", - "navigationBarTitleText": "外来人员登记系统", - "navigationBarBackgroundColor": "#F8F8F8", - "backgroundColor": "#F8F8F8" - }, - "tabBar": { - "color": "#7A7E83", - "selectedColor": "#007AFF", - "borderStyle": "black", - "backgroundColor": "#F8F8F8", - "list": [{ - "pagePath": "pages/tabbar/member", - "iconPath": "static/tab_list.png", - "selectedIconPath": "static/tab_list_hl.png", - "text": "列表" - }, - { - "pagePath": "pages/tabbar/add", - "iconPath": "static/tab_add.png", - "selectedIconPath": "static/tab_add_hl.png", - "text": "新增" - }, { - "pagePath": "pages/tabbar/search", - "iconPath": "static/tab_search.png", - "selectedIconPath": "static/tab_search_hl.png", - "text": "搜索" - }, { - "pagePath": "pages/tabbar/my", - "iconPath": "static/tab_my.png", - "selectedIconPath": "static/tab_my_hl.png", - "text": "我的" - } - ] - } + "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages + { + "path": "pages/tabbar/member", + "style": {} + }, { + "path": "pages/tabbar/add", + "style": {} + }, { + "path": "pages/tabbar/search", + "style": {} + }, { + "path": "pages/tabbar/my", + "style": {} + }, { + "path": "pages/login/login", + "style": {} + }, { + "path": "pages/add-member/add-member", + "style": {} + }, + { + "path": "pages/member-detail/member-detail", + "style": {} + }, + { + "path": "pages/chart/chart", + "style": {} + } + ], + "globalStyle": { + "navigationBarTextStyle": "black", + "navigationBarTitleText": "外来人员登记系统", + "navigationBarBackgroundColor": "#F8F8F8", + "backgroundColor": "#F8F8F8" + }, + "tabBar": { + "color": "#7A7E83", + "selectedColor": "#007AFF", + "borderStyle": "black", + "backgroundColor": "#F8F8F8", + "list": [{ + "pagePath": "pages/tabbar/member", + "iconPath": "static/tab_list.png", + "selectedIconPath": "static/tab_list_hl.png", + "text": "列表" + }, + { + "pagePath": "pages/tabbar/add", + "iconPath": "static/tab_add.png", + "selectedIconPath": "static/tab_add_hl.png", + "text": "新增" + }, { + "pagePath": "pages/tabbar/search", + "iconPath": "static/tab_search.png", + "selectedIconPath": "static/tab_search_hl.png", + "text": "搜索" + }, { + "pagePath": "pages/tabbar/my", + "iconPath": "static/tab_my.png", + "selectedIconPath": "static/tab_my_hl.png", + "text": "我的" + } + ] + } } diff --git a/pages/chart/chart.vue b/pages/chart/chart.vue index 81298c2..16d49ac 100644 --- a/pages/chart/chart.vue +++ b/pages/chart/chart.vue @@ -1,3 +1,4 @@ +// 我在做这个文件,群昵称: 躺希腊额阿毛 QQ:786997741