├── .gitignore
├── frontend
├── README.md
├── image
│ ├── 1.png
│ ├── 2.png
│ ├── 3.png
│ ├── 4.png
│ ├── 5.png
│ ├── 6.png
│ ├── 7.png
│ ├── banner.png
│ └── wxcode.jpg
├── sitemap.json
├── pages
│ ├── book
│ │ ├── book.wxss
│ │ ├── book-wxa-auto-dark.wxss
│ │ ├── book.json
│ │ ├── book.wxml
│ │ └── book.js
│ ├── index
│ │ ├── index.json
│ │ ├── index-wxa-auto-dark.wxss
│ │ ├── index.wxml
│ │ ├── index.wxss
│ │ └── index.js
│ ├── mybooks
│ │ ├── mybooks-wxa-auto-dark.wxss
│ │ ├── mybooks.json
│ │ ├── mybooks.wxss
│ │ ├── mybooks.wxml
│ │ └── mybooks.js
│ ├── admin
│ │ ├── admin-wxa-auto-dark.wxss
│ │ ├── admin.json
│ │ ├── admin.wxss
│ │ ├── admin.wxml
│ │ └── admin.js
│ └── admin_verify
│ │ ├── admin_verify-wxa-auto-dark.wxss
│ │ ├── admin_verify.wxss
│ │ ├── admin_verify.wxml
│ │ ├── admin_verify.json
│ │ ├── admin_verify.js
│ │ └── md5.js
├── app-wxa-auto-dark.wxss
├── app.wxss
├── package-lock.json
├── utils
│ └── util.js
├── app.json
├── project.config.json
└── app.js
├── backend
├── data
│ ├── tickets_open.json
│ ├── tickets_closed.json
│ ├── dynamic.json
│ └── settings.json
├── README.md
├── new.py
└── server.py
├── .github
├── trigger.json
└── workflows
│ └── python-app.yml
├── .gitattributes
├── README.md
├── checkpoint.py
└── LICENSE
/.gitignore:
--------------------------------------------------------------------------------
1 | secrets.*
--------------------------------------------------------------------------------
/frontend/README.md:
--------------------------------------------------------------------------------
1 | ### 微信小程序
--------------------------------------------------------------------------------
/backend/data/tickets_open.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/backend/data/tickets_closed.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/.github/trigger.json:
--------------------------------------------------------------------------------
1 | {
2 | "trigger": 0
3 | }
4 |
--------------------------------------------------------------------------------
/backend/README.md:
--------------------------------------------------------------------------------
1 | ### 后端服务器
2 |
3 | **Python** Flask
--------------------------------------------------------------------------------
/backend/data/dynamic.json:
--------------------------------------------------------------------------------
1 | {"off_days": [], "blocked": []}
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.wxml linguist-language=html
2 | *.wxss linguist-language=css
3 |
--------------------------------------------------------------------------------
/frontend/image/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muhac/hitsz-appointment-scheduling/HEAD/frontend/image/1.png
--------------------------------------------------------------------------------
/frontend/image/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muhac/hitsz-appointment-scheduling/HEAD/frontend/image/2.png
--------------------------------------------------------------------------------
/frontend/image/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muhac/hitsz-appointment-scheduling/HEAD/frontend/image/3.png
--------------------------------------------------------------------------------
/frontend/image/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muhac/hitsz-appointment-scheduling/HEAD/frontend/image/4.png
--------------------------------------------------------------------------------
/frontend/image/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muhac/hitsz-appointment-scheduling/HEAD/frontend/image/5.png
--------------------------------------------------------------------------------
/frontend/image/6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muhac/hitsz-appointment-scheduling/HEAD/frontend/image/6.png
--------------------------------------------------------------------------------
/frontend/image/7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muhac/hitsz-appointment-scheduling/HEAD/frontend/image/7.png
--------------------------------------------------------------------------------
/frontend/image/banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muhac/hitsz-appointment-scheduling/HEAD/frontend/image/banner.png
--------------------------------------------------------------------------------
/frontend/image/wxcode.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/muhac/hitsz-appointment-scheduling/HEAD/frontend/image/wxcode.jpg
--------------------------------------------------------------------------------
/frontend/sitemap.json:
--------------------------------------------------------------------------------
1 | {
2 | "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
3 | "rules": [{
4 | "action": "allow",
5 | "page": "*"
6 | }]
7 | }
--------------------------------------------------------------------------------
/frontend/pages/book/book.wxss:
--------------------------------------------------------------------------------
1 | /* pages/book/book.wxss */
2 |
3 | .weui-agree .weui-agree__text {
4 | display: inline;
5 | }
6 |
7 | .weui-form__opr-area {
8 | margin-bottom: 0;
9 | }
10 |
11 | @import 'book-wxa-auto-dark.wxss'
--------------------------------------------------------------------------------
/frontend/pages/index/index.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarBackgroundColor": "#ffffff",
3 | "navigationBarTextStyle": "black",
4 | "navigationBarTitleText": "心理咨询预约",
5 | "backgroundColor": "#eeeeee",
6 | "backgroundTextStyle": "light"
7 | }
--------------------------------------------------------------------------------
/frontend/app-wxa-auto-dark.wxss:
--------------------------------------------------------------------------------
1 | /*
2 | 此文件为开发者工具生成,生成时间: 2021/3/6 下午2:08:58
3 | 使用方法:
4 | 在 app.wxss 文件末尾引入样式
5 | ```
6 | @import "./app-wxa-auto-dark.wxss";
7 | ```
8 | */
9 |
10 | @media (prefers-color-scheme: dark) {
11 | :root {}
12 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## 哈尔滨工业大学(深圳)
心理咨询预约系统
2 |
3 | #### 已接入学院
4 |
5 | - [电子与信息工程学院](http://eie.hitsz.edu.cn/)
6 | - [土木与环境工程学院](http://sce.hitsz.edu.cn/)
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/frontend/pages/book/book-wxa-auto-dark.wxss:
--------------------------------------------------------------------------------
1 | /*
2 | 此文件为开发者工具生成,生成时间: 2021/3/6 上午12:18:25
3 | 使用方法:
4 | 在 book.wxss 文件末尾引入样式
5 | ```
6 | @import "./book-wxa-auto-dark.wxss";
7 | ```
8 | */
9 |
10 | @media (prefers-color-scheme: dark) {
11 | :root {}
12 | }
--------------------------------------------------------------------------------
/frontend/pages/mybooks/mybooks-wxa-auto-dark.wxss:
--------------------------------------------------------------------------------
1 | /*
2 | 此文件为开发者工具生成,生成时间: 2021/3/6 下午2:08:58
3 | 使用方法:
4 | 在 mybooks.wxss 文件末尾引入样式
5 | ```
6 | @import "./mybooks-wxa-auto-dark.wxss";
7 | ```
8 | */
9 |
10 | @media (prefers-color-scheme: dark) {
11 | :root {}
12 | }
--------------------------------------------------------------------------------
/frontend/pages/admin/admin-wxa-auto-dark.wxss:
--------------------------------------------------------------------------------
1 | /*
2 | 此文件为开发者工具生成,生成时间: 2021/3/6 上午12:19:08
3 | 使用方法:
4 | 在 admin.wxss 文件末尾引入样式
5 | ```
6 | @import "./admin-wxa-auto-dark.wxss";
7 | ```
8 | */
9 |
10 | @media (prefers-color-scheme: dark) {
11 | :root {
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/frontend/app.wxss:
--------------------------------------------------------------------------------
1 | /**app.wxss**/
2 | .container {
3 | height: 100%;
4 | display: flex;
5 | flex-direction: column;
6 | align-items: center;
7 | justify-content: space-between;
8 | padding: 200rpx 0;
9 | box-sizing: border-box;
10 | }
11 |
12 | @import 'app-wxa-auto-dark.wxss'
--------------------------------------------------------------------------------
/frontend/pages/admin_verify/admin_verify-wxa-auto-dark.wxss:
--------------------------------------------------------------------------------
1 | /*
2 | 此文件为开发者工具生成,生成时间: 2021/3/6 上午12:19:12
3 | 使用方法:
4 | 在 admin_verify.wxss 文件末尾引入样式
5 | ```
6 | @import "./admin_verify-wxa-auto-dark.wxss";
7 | ```
8 | */
9 |
10 | @media (prefers-color-scheme: dark) {
11 | .password-input {
12 | border-color: rgb(83, 83, 83);
13 | }
14 | }
--------------------------------------------------------------------------------
/frontend/pages/admin/admin.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarBackgroundColor": "#ffffff",
3 | "navigationBarTextStyle": "black",
4 | "navigationBarTitleText": "管理后台",
5 | "backgroundColor": "#eeeeee",
6 | "backgroundTextStyle": "light",
7 | "component": true,
8 | "usingComponents": {
9 | "mp-dialog": "weui-miniprogram/dialog/dialog"
10 | }
11 | }
--------------------------------------------------------------------------------
/frontend/pages/admin_verify/admin_verify.wxss:
--------------------------------------------------------------------------------
1 | /* pages/admin_verify/admin_verify.wxss */
2 |
3 | .password-input {
4 | margin-top: 50%;
5 | margin: 50rpx;
6 | padding: 20rpx 50rpx;
7 | border-style: solid;
8 | border-width: 1rpx;
9 | border-color: #aaa;
10 | border-radius: 20rpx;
11 | }
12 |
13 | @import 'admin_verify-wxa-auto-dark.wxss'
--------------------------------------------------------------------------------
/frontend/pages/mybooks/mybooks.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarBackgroundColor": "#ffffff",
3 | "navigationBarTextStyle": "black",
4 | "navigationBarTitleText": "我的预约",
5 | "backgroundColor": "#eeeeee",
6 | "backgroundTextStyle": "light",
7 | "component": true,
8 | "usingComponents": {
9 | "mp-dialog": "weui-miniprogram/dialog/dialog"
10 | }
11 | }
--------------------------------------------------------------------------------
/checkpoint.py:
--------------------------------------------------------------------------------
1 | import requests
2 |
3 | sess = requests.session()
4 | sess.headers.update({'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 '
5 | '(KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36'})
6 | response = sess.get('https://www.bugstop.site/checkpoint/')
7 |
8 | print(response.json())
9 | print('data force save')
10 |
--------------------------------------------------------------------------------
/frontend/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "requires": true,
3 | "lockfileVersion": 1,
4 | "dependencies": {
5 | "weui-miniprogram": {
6 | "version": "1.0.7",
7 | "resolved": "https://registry.npmjs.org/weui-miniprogram/-/weui-miniprogram-1.0.7.tgz",
8 | "integrity": "sha512-tXpLnUyaN1jEZHlYAWid3q+Rbov6a90t7QX4uunEa9E2+IUrVLqxo1Q1CfT1uTtjE5hqg6ABGU0NA819Ga1D3g=="
9 | }
10 | }
11 | }
--------------------------------------------------------------------------------
/frontend/pages/index/index-wxa-auto-dark.wxss:
--------------------------------------------------------------------------------
1 | /*
2 | 此文件为开发者工具生成,生成时间: 2021/3/6 上午12:18:57
3 | 使用方法:
4 | 在 index.wxss 文件末尾引入样式
5 | ```
6 | @import "./index-wxa-auto-dark.wxss";
7 | ```
8 | */
9 |
10 | @media (prefers-color-scheme: dark) {
11 | .userinfo-nickname {
12 | color: rgb(83, 83, 83);
13 | }
14 |
15 | .button {
16 | border-color: rgb(83, 83, 83);
17 | }
18 |
19 | .buttonHover {
20 | border-color: rgb(83, 83, 83);
21 | background: rgb(11, 57, 68);
22 | color: rgb(17, 17, 17);
23 | }
24 | }
--------------------------------------------------------------------------------
/frontend/utils/util.js:
--------------------------------------------------------------------------------
1 | const formatTime = date => {
2 | const year = date.getFullYear()
3 | const month = date.getMonth() + 1
4 | const day = date.getDate()
5 | const hour = date.getHours()
6 | const minute = date.getMinutes()
7 | const second = date.getSeconds()
8 |
9 | return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
10 | }
11 |
12 | const formatNumber = n => {
13 | n = n.toString()
14 | return n[1] ? n : `0${n}`
15 | }
16 |
17 | module.exports = {
18 | formatTime
19 | }
20 |
--------------------------------------------------------------------------------
/frontend/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages": [
3 | "pages/index/index",
4 | "pages/mybooks/mybooks",
5 | "pages/admin_verify/admin_verify",
6 | "pages/book/book",
7 | "pages/admin/admin"
8 | ],
9 | "window": {
10 | "backgroundTextStyle": "light",
11 | "navigationBarBackgroundColor": "#fff",
12 | "navigationBarTitleText": "心理咨询预约",
13 | "navigationBarTextStyle": "black",
14 | "enablePullDownRefresh": false
15 | },
16 | "style": "v2",
17 | "sitemapLocation": "sitemap.json",
18 | "useExtendedLib": {
19 | "weui": true
20 | }
21 | }
--------------------------------------------------------------------------------
/backend/new.py:
--------------------------------------------------------------------------------
1 | import os
2 | import json
3 |
4 | if not os.path.isdir('data'):
5 | os.mkdir('data')
6 |
7 | with open('data/tickets_open.json', 'w') as f:
8 | json.dump({}, f)
9 |
10 | with open('data/tickets_closed.json', 'w') as f:
11 | json.dump({}, f)
12 |
13 | dynamic = {
14 | 'off_days': [], # 特殊休息日
15 | 'blocked': [] # 封禁用户名单
16 | }
17 |
18 | with open('data/dynamic.json', 'w') as f:
19 | json.dump(dynamic, f)
20 |
21 | # written in secrets.py
22 | with open('data/settings.json', 'w') as f:
23 | json.dump({}, f)
24 |
25 | # written in secrets.py
26 | with open('data/secrets.json', 'w') as f:
27 | json.dump({}, f)
28 |
--------------------------------------------------------------------------------
/frontend/pages/admin_verify/admin_verify.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/frontend/pages/book/book.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarBackgroundColor": "#ffffff",
3 | "navigationBarTextStyle": "black",
4 | "navigationBarTitleText": "信息填写",
5 | "backgroundColor": "#eeeeee",
6 | "backgroundTextStyle": "light",
7 | "component": true,
8 | "usingComponents": {
9 | "mp-cells": "weui-miniprogram/cells/cells",
10 | "mp-cell": "weui-miniprogram/cell/cell",
11 | "mp-checkbox": "weui-miniprogram/checkbox/checkbox",
12 | "mp-checkbox-group": "weui-miniprogram/checkbox-group/checkbox-group",
13 | "mp-form": "weui-miniprogram/form/form",
14 | "mp-form-page": "weui-miniprogram/form-page/form-page",
15 | "mp-toptips": "weui-miniprogram/toptips/toptips"
16 | }
17 | }
--------------------------------------------------------------------------------
/.github/workflows/python-app.yml:
--------------------------------------------------------------------------------
1 | name: Automatic Checkpoint
2 |
3 | on:
4 | workflow_dispatch:
5 | schedule:
6 | - cron: "30 10 * * *"
7 | - cron: "30 22 * * *"
8 |
9 | jobs:
10 | Checkpoint:
11 | runs-on: ubuntu-latest
12 |
13 | steps:
14 | - uses: actions/checkout@v2
15 | - name: Set up Python environment
16 | uses: actions/setup-python@v2
17 | with:
18 | python-version: 3.9
19 |
20 | - name: Install Python dependencies
21 | run: |
22 | python -m pip install --upgrade pip
23 | pip install urllib3==1.25.11
24 | pip install requests
25 |
26 | - name: Checkpoint Save
27 | shell: bash
28 | run: python checkpoint.py
29 |
--------------------------------------------------------------------------------
/frontend/pages/admin_verify/admin_verify.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarBackgroundColor": "#ffffff",
3 | "navigationBarTextStyle": "black",
4 | "navigationBarTitleText": "管理中心",
5 | "backgroundColor": "#eeeeee",
6 | "backgroundTextStyle": "light",
7 | "component": true,
8 | "usingComponents": {
9 | "mp-cells": "weui-miniprogram/cells/cells",
10 | "mp-cell": "weui-miniprogram/cell/cell",
11 | "mp-checkbox": "weui-miniprogram/checkbox/checkbox",
12 | "mp-checkbox-group": "weui-miniprogram/checkbox-group/checkbox-group",
13 | "mp-form": "weui-miniprogram/form/form",
14 | "mp-form-page": "weui-miniprogram/form-page/form-page",
15 | "mp-toptips": "weui-miniprogram/toptips/toptips"
16 | }
17 | }
--------------------------------------------------------------------------------
/frontend/pages/index/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Have a Great Day!
6 |
7 |
8 |
9 |
10 | 管理后台
11 |
12 |
13 |
17 |
--------------------------------------------------------------------------------
/frontend/pages/index/index.wxss:
--------------------------------------------------------------------------------
1 | /**index.wxss**/
2 | .userinfo {
3 | display: flex;
4 | flex-direction: column;
5 | align-items: center;
6 | }
7 |
8 | .userinfo-avatar {
9 | width: 128rpx;
10 | height: 128rpx;
11 | margin: 20rpx;
12 | border-radius: 50%;
13 | }
14 |
15 | .userinfo-nickname {
16 | color: #aaa;
17 | }
18 |
19 | .welcome {
20 | margin: 15rpx;
21 | color: #666;
22 | font-size: 28rpx;
23 | }
24 |
25 | .banner {
26 | margin-top: 20rpx;
27 | width: 256rpx;
28 | height: 256rpx;
29 | }
30 |
31 | .usermotto {
32 | position: absolute;
33 | bottom: 10rpx;
34 | text-align: center;
35 | color: #666666;
36 | font-size: 24rpx;
37 | }
38 |
39 | .adminbutton {
40 | margin: 70rpx;
41 | text-align: center;
42 | font-size: 28rpx;
43 | /* text-decoration-line: underline; */
44 | color: rgb(59, 151, 182);
45 | }
46 |
47 | .adminbuttonHover {
48 | text-decoration-line: underline;
49 | color: rgb(38, 95, 114);
50 | }
51 |
52 | .options {
53 | margin-top: 80rpx;
54 | }
55 |
56 | .footer {
57 | position: absolute;
58 | bottom: 30rpx;
59 | }
60 |
61 | .sep {
62 | padding: 2rpx;
63 | }
64 |
65 | @import 'index-wxa-auto-dark.wxss'
--------------------------------------------------------------------------------
/frontend/pages/admin/admin.wxss:
--------------------------------------------------------------------------------
1 | /* pages/admin/admin.wxss */
2 |
3 | .weui-form-preview {
4 | margin-bottom: 50rpx;
5 | }
6 |
7 | .empty {
8 | display: flex;
9 | flex-direction: column;
10 | align-items: center;
11 | margin-top: 100rpx;
12 | margin: 20rpx;
13 | font-size: 30rpx;
14 | color: #666666;
15 | position: relative;
16 | /*脱离文档流*/
17 | margin-top: 45%;
18 | /*偏移*/
19 | }
20 |
21 | .weui-tab__content {
22 | padding-top: 120rpx;
23 | text-align: center;
24 | }
25 |
26 | #top {
27 | height: 15rpx;
28 | background: linear-gradient(180deg, #ffffff, #fcfcfc);
29 | }
30 |
31 | .weui-navbar {
32 | background: linear-gradient(180deg, #fcfcfc, #f9f9f9);
33 | }
34 |
35 | .weui-navbar__item {
36 | margin: 0rpx 50rpx 15rpx 50rpx;
37 | padding: 20rpx !important;
38 | }
39 |
40 | .weui-navbar__title {
41 | padding: 0;
42 | color: dimgray;
43 | }
44 |
45 | .weui-bar__item_on {
46 | border-radius: 15rpx;
47 | background: linear-gradient(145deg, #ffffff, #fafafa);
48 | box-shadow: 3rpx 3rpx 6rpx #d9d9d9,
49 | -3rpx -3rpx 6rpx #ffffff;
50 | }
51 |
52 | .weui-navbar__item::after {
53 | width: 0 !important;
54 | border-right-width: 0 !important;
55 | }
56 |
57 | @import 'admin-wxa-auto-dark.wxss'
--------------------------------------------------------------------------------
/frontend/pages/mybooks/mybooks.wxss:
--------------------------------------------------------------------------------
1 | /* pages/mybooks/mybooks.wxss */
2 |
3 | .weui-form-preview {
4 | margin-bottom: 50rpx;
5 | }
6 |
7 | .empty {
8 | display: flex;
9 | flex-direction: column;
10 | align-items: center;
11 | margin-top: 100rpx;
12 | margin: 20rpx;
13 | font-size: 30rpx;
14 | color: #666666;
15 | position: relative;
16 | /*脱离文档流*/
17 | margin-top: 45%;
18 | /*偏移*/
19 | }
20 |
21 | .weui-tab__content {
22 | padding-top: 120rpx;
23 | text-align: center;
24 | }
25 |
26 | #top {
27 | height: 15rpx;
28 | background: linear-gradient(180deg, #ffffff, #fcfcfc);
29 | }
30 |
31 | .weui-navbar {
32 | background: linear-gradient(180deg, #fcfcfc, #f9f9f9);
33 | }
34 |
35 | .weui-navbar__item {
36 | margin: 0rpx 50rpx 15rpx 50rpx;
37 | padding: 20rpx !important;
38 | }
39 |
40 | .weui-navbar__title {
41 | padding: 0;
42 | color: dimgray;
43 | }
44 |
45 | .weui-bar__item_on {
46 | border-radius: 15rpx;
47 | background: linear-gradient(145deg, #ffffff, #fafafa);
48 | box-shadow: 3rpx 3rpx 6rpx #d9d9d9,
49 | -3rpx -3rpx 6rpx #ffffff;
50 | }
51 |
52 | .weui-navbar__item::after {
53 | width: 0 !important;
54 | border-right-width: 0 !important;
55 | }
56 |
57 | @import 'mybooks-wxa-auto-dark.wxss'
--------------------------------------------------------------------------------
/frontend/pages/index/index.js:
--------------------------------------------------------------------------------
1 | // index.js
2 | // 获取应用实例
3 | const app = getApp()
4 |
5 | Page({
6 | data: {
7 | mask_show: true,
8 | motto: 'Hello World',
9 | userInfo: {},
10 | hasUserInfo: false,
11 | canIUse: wx.canIUse('button.open-type.getUserInfo'),
12 | code: [],
13 | banner: 1,
14 | },
15 | // 事件处理函数
16 | onLoad() {
17 | var i = Math.ceil(Math.random() * 7)
18 | this.setData({
19 | banner: i
20 | })
21 | },
22 | changebanner() {
23 | var i = this.data.banner;
24 | i = i + 1;
25 | if (i > 7) {
26 | i = 1;
27 | }
28 | this.setData({
29 | banner: i
30 | })
31 | },
32 | bindViewTap() {
33 | wx.navigateTo({
34 | url: '../logs/logs'
35 | })
36 | },
37 | gotoAdmin() {
38 | wx.navigateTo({
39 | url: '../admin_verify/admin_verify'
40 | })
41 | },
42 | gotoBook() {
43 | wx.navigateTo({
44 | url: '../book/book'
45 | })
46 | },
47 | gotomyBooks() {
48 | wx.navigateTo({
49 | url: '../mybooks/mybooks'
50 | })
51 | },
52 | /**
53 | * 用户点击右上角分享
54 | */
55 | onShareAppMessage: function () {
56 |
57 | },
58 | })
--------------------------------------------------------------------------------
/frontend/project.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "项目配置文件",
3 | "packOptions": {
4 | "ignore": []
5 | },
6 | "setting": {
7 | "urlCheck": false,
8 | "es6": true,
9 | "enhance": false,
10 | "postcss": true,
11 | "preloadBackgroundData": false,
12 | "minified": true,
13 | "newFeature": false,
14 | "coverView": true,
15 | "nodeModules": false,
16 | "autoAudits": false,
17 | "showShadowRootInWxmlPanel": true,
18 | "scopeDataCheck": false,
19 | "uglifyFileName": false,
20 | "checkInvalidKey": true,
21 | "checkSiteMap": true,
22 | "uploadWithSourceMap": true,
23 | "compileHotReLoad": false,
24 | "useMultiFrameRuntime": true,
25 | "useApiHook": true,
26 | "useApiHostProcess": false,
27 | "babelSetting": {
28 | "ignore": [],
29 | "disablePlugins": [],
30 | "outputPath": ""
31 | },
32 | "enableEngineNative": false,
33 | "bundle": false,
34 | "useIsolateContext": true,
35 | "useCompilerModule": true,
36 | "userConfirmedUseCompilerModuleSwitch": false,
37 | "userConfirmedBundleSwitch": false,
38 | "packNpmManually": false,
39 | "packNpmRelationList": [],
40 | "minifyWXSS": true
41 | },
42 | "compileType": "miniprogram",
43 | "libVersion": "2.15.0",
44 | "appid": "wxdefe17992df5e3fb",
45 | "projectname": "miniprogram-2",
46 | "debugOptions": {
47 | "hidedInDevtools": []
48 | },
49 | "scripts": {},
50 | "staticServerOptions": {
51 | "baseURL": "",
52 | "servePath": ""
53 | },
54 | "isGameTourist": false,
55 | "simulatorType": "wechat",
56 | "simulatorPluginLibVersion": {},
57 | "condition": {
58 | "search": {
59 | "list": []
60 | },
61 | "conversation": {
62 | "list": []
63 | },
64 | "game": {
65 | "list": []
66 | },
67 | "plugin": {
68 | "list": []
69 | },
70 | "gamePlugin": {
71 | "list": []
72 | },
73 | "miniprogram": {
74 | "list": []
75 | }
76 | }
77 | }
--------------------------------------------------------------------------------
/frontend/app.js:
--------------------------------------------------------------------------------
1 | // app.js
2 | App({
3 | onLaunch() {
4 | var that = this
5 | wx.showLoading({
6 | title: "登陆中",
7 | mask: true,
8 | });
9 | // 登录
10 | wx.login({
11 |
12 | success: res => {
13 | // 发送 res.code 到后台换取 openId, sessionKey, unionId
14 |
15 | wx.request({
16 | url: 'https://www.bugstop.site/user/id/',
17 | headers: {
18 | 'Content-Type': 'application/json'
19 | },
20 | data: res,
21 | method: "POST",
22 | timeout: 10000,
23 | success(res) {
24 | console.log(res.data)
25 | if (res.statusCode == 200) {
26 | wx.hideLoading();
27 | that.globalData.wx = res.data.wx
28 | } else {
29 | wx.hideLoading();
30 | wx.showToast({
31 | title: "登录失败",
32 | icon: 'error', //如果要纯文本,不要icon,将值设为'none'
33 | mask: true,
34 | duration: 3000
35 | })
36 | }
37 | },
38 | fail() {
39 | wx.hideLoading();
40 | wx.showToast({
41 | title: "连接超时",
42 | icon: 'error', //如果要纯文本,不要icon,将值设为'none'
43 | mask: true,
44 | duration: 3000
45 | })
46 | }
47 | })
48 | }
49 | })
50 | // 获取用户信息
51 | wx.getSetting({
52 | success: res => {
53 | if (res.authSetting['scope.userInfo']) {
54 | // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
55 | wx.getUserInfo({
56 | success: res => {
57 | // 可以将 res 发送给后台解码出 unionId
58 | this.globalData.userInfo = res.userInfo
59 |
60 | // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
61 | // 所以此处加入 callback 以防止这种情况
62 | if (this.userInfoReadyCallback) {
63 | this.userInfoReadyCallback(res)
64 | }
65 | }
66 | })
67 | }
68 | }
69 | })
70 | },
71 | globalData: {
72 | userInfo: null,
73 | wx: null,
74 | admin_password: null
75 | }
76 | })
--------------------------------------------------------------------------------
/frontend/pages/admin_verify/admin_verify.js:
--------------------------------------------------------------------------------
1 | // pages/admin_verify/admin_verify.js
2 |
3 | var md5 = require("md5.js")
4 | const app = getApp()
5 | Page({
6 |
7 | /**
8 | * 页面的初始数据
9 | */
10 | data: {
11 | password: [],
12 | },
13 |
14 | /**
15 | * 生命周期函数--监听页面加载
16 | */
17 | onLoad: function (options) {
18 | var that = this
19 | wx.getStorage({
20 | key: 'password',
21 | success(res) {
22 | that.setData({
23 | password: res.data
24 | });
25 | if (that.password != "") {
26 | that.login();
27 | }
28 | }
29 | })
30 |
31 | },
32 |
33 | /**
34 | * 生命周期函数--监听页面初次渲染完成
35 | */
36 | onReady: function () {
37 |
38 | },
39 |
40 | /**
41 | * 生命周期函数--监听页面显示
42 | */
43 | onShow: function () {
44 |
45 | },
46 |
47 | /**
48 | * 生命周期函数--监听页面隐藏
49 | */
50 | onHide: function () {
51 |
52 | },
53 |
54 | /**
55 | * 生命周期函数--监听页面卸载
56 | */
57 | onUnload: function () {
58 |
59 | },
60 |
61 | /**
62 | * 页面相关事件处理函数--监听用户下拉动作
63 | */
64 | onPullDownRefresh: function () {
65 |
66 | },
67 |
68 | /**
69 | * 页面上拉触底事件的处理函数
70 | */
71 | onReachBottom: function () {
72 |
73 | },
74 |
75 | formInputChange(e) {
76 | wx.setStorage({
77 | key: "password",
78 | data: e.detail.value,
79 | });
80 | this.setData({
81 | password: e.detail.value,
82 | });
83 | },
84 |
85 | login() {
86 | var that = this
87 | if (this.data.password == "") {
88 | this.setData({
89 | error: "请输入密码"
90 | })
91 | } else {
92 | wx.showLoading({
93 | title: "登陆中",
94 | mask: true,
95 | });
96 | wx.request({
97 | url: 'https://www.bugstop.site/user/verify/',
98 | headers: {
99 | 'Content-Type': 'application/json'
100 | },
101 | data: {
102 | password: md5.md5(this.data.password)
103 | },
104 | method: "POST",
105 | success(res) {
106 | if (res.data.statusCode == 200) {
107 | wx.hideLoading();
108 | app.globalData.admin_password = md5.md5(that.data.password);
109 | wx.redirectTo({
110 | url: '../admin/admin'
111 | })
112 | } else {
113 | wx.hideLoading();
114 | that.setData({
115 | error: "管理密码错误,请联系开发者",
116 | password: ""
117 | })
118 | }
119 | },
120 | fail() {
121 | wx.hideLoading();
122 | that.setData({
123 | error: "登录超时,请稍候重试",
124 | })
125 | }
126 | })
127 | }
128 | }
129 | })
--------------------------------------------------------------------------------
/backend/data/settings.json:
--------------------------------------------------------------------------------
1 | {"checkpoint_frequency": 600, "school": {"\u7535\u5b50\u4e0e\u4fe1\u606f\u5de5\u7a0b\u5b66\u9662": {"\u5730\u70b9": "L1103", "\u8f85\u5bfc\u5458": ["\u718a\u6676\u73b2", "\u5e94\u68a6\u5a34", "\u7530\u8587", "\u6881\u7fa1\u98de", "\u674e\u5a1c"], "\u6700\u8fdc\u53ef\u9884\u7ea6\u5929\u6570": 15, "\u63d0\u524d\u9884\u7ea6\u5c0f\u65f6\u6570": 1}, "\u571f\u6728\u4e0e\u73af\u5883\u5de5\u7a0b\u5b66\u9662": {"\u5730\u70b9": "E425", "\u8f85\u5bfc\u5458": ["\u8d75\u7af9\u9752", "\u6768\u78ca", "\u66f2\u4e30\u6210", "\u5415\u4fca\u5b8f", "\u5218\u6587\u4e9a", "\u674e\u70e8", "\u66f9\u7f61"], "\u6700\u8fdc\u53ef\u9884\u7ea6\u5929\u6570": 30, "\u63d0\u524d\u9884\u7ea6\u5c0f\u65f6\u6570": 1}}, "teacher": {"\u7535\u5b50\u4e0e\u4fe1\u606f\u5de5\u7a0b\u5b66\u9662": {"\u718a\u6676\u73b2": {"\u90ae\u7bb1": "821300030@qq.com", "\u65f6\u95f4": [[9, 10, 11, 14, 15, 16], [9, 10, 11, 14, 15, 16], [9, 10, 11, 14, 15, 16], [9, 10, 11, 14, 15, 16], [9, 10, 11, 14, 15, 16], [], []]}, "\u5e94\u68a6\u5a34": {"\u90ae\u7bb1": "916720619@qq.com", "\u65f6\u95f4": [[9, 10, 11, 14, 15, 16], [9, 10, 11, 14, 15, 16], [9, 10, 11, 14, 15, 16], [9, 10, 11, 14, 15, 16], [9, 10, 11, 14, 15, 16], [], []]}, "\u7530\u8587": {"\u90ae\u7bb1": "635661409@qq.com", "\u65f6\u95f4": [[9, 10, 11, 14, 15, 16], [9, 10, 11, 14, 15, 16], [9, 10, 11, 14, 15, 16], [9, 10, 11, 14, 15, 16], [9, 10, 11, 14, 15, 16], [], []]}, "\u6881\u7fa1\u98de": {"\u90ae\u7bb1": "2695998275@qq.com", "\u65f6\u95f4": [[9, 10, 11, 14, 15, 16], [9, 10, 11, 14, 15, 16], [9, 10, 11, 14, 15, 16], [9, 10, 11, 14, 15, 16], [9, 10, 11, 14, 15, 16], [], []]}, "\u674e\u5a1c": {"\u90ae\u7bb1": "2076505738@qq.com", "\u65f6\u95f4": [[9, 10, 11, 14, 15, 16], [9, 10, 11, 14, 15, 16], [9, 10, 11, 14, 15, 16], [9, 10, 11, 14, 15, 16], [9, 10, 11, 14, 15, 16], [], []]}}, "\u571f\u6728\u4e0e\u73af\u5883\u5de5\u7a0b\u5b66\u9662": {"\u8d75\u7af9\u9752": {"\u90ae\u7bb1": "zhaozhuqing@hit.edu.cn", "\u65f6\u95f4": [[], [], [], [], [15, 16], [], []]}, "\u6768\u78ca": {"\u90ae\u7bb1": "yanglei2020@hit.edu.cn", "\u65f6\u95f4": [[], [], [], [], [10], [], []]}, "\u66f2\u4e30\u6210": {"\u90ae\u7bb1": "694591705@qq.com", "\u65f6\u95f4": [[], [], [], [15], [], [], []]}, "\u5415\u4fca\u5b8f": {"\u90ae\u7bb1": "lvjunhong@hit.edu.cn", "\u65f6\u95f4": [[], [], [], [], [9], [], []]}, "\u5218\u6587\u4e9a": {"\u90ae\u7bb1": "liuwenya@hit.edu.cn", "\u65f6\u95f4": [[], [], [], [10], [], [], []]}, "\u674e\u70e8": {"\u90ae\u7bb1": "liye@hit.edu.cn", "\u65f6\u95f4": [[16], [], [], [], [], [], []]}, "\u66f9\u7f61": {"\u90ae\u7bb1": "caogang@hit.edu.cn", "\u65f6\u95f4": [[10], [], [], [], [], [], []]}}}, "date_format": "%Y \u5e74 %m \u6708 %d \u65e5 \u00b7 %A", "hour_format": ["{:02d}:00 \u00b7 \u5927\u7ea6 30 \u5206\u949f", "{:02d}:30 \u00b7 \u5927\u7ea6 30 \u5206\u949f"], "time_format": "%Y \u5e74 %m \u6708 %d \u65e5 \u00b7 %A%H:%M \u00b7 \u5927\u7ea6 30 \u5206\u949f", "ticket_format": "{:05d}@{}", "timestamp": "%Y-%m-%d %H:%M:%S", "must_fill": ["wx", "id", "name", "sex", "mobile", "school", "teacher", "date", "hour"], "languages": {"en": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"], "zh": ["\u5468\u4e00", "\u5468\u4e8c", "\u5468\u4e09", "\u5468\u56db", "\u5468\u4e94", "\u5468\u516d", "\u5468\u65e5"], "zh_cn": ["\u661f\u671f\u4e00", "\u661f\u671f\u4e8c", "\u661f\u671f\u4e09", "\u661f\u671f\u56db", "\u661f\u671f\u4e94", "\u661f\u671f\u516d", "\u661f\u671f\u65e5"]}}
--------------------------------------------------------------------------------
/frontend/pages/book/book.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | {{sex[sexIndex]}}
13 | 请选择性别
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | {{dataSchool.schools[schoolIndex]}}
25 | 请选择所在学院
26 |
27 |
28 |
29 |
30 | {{teacher_available[teacherIndex]}}
31 | 请选择辅导员
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | {{dataSchedule.dates[dateIndex]}}
40 | 请选择日期
41 |
42 |
43 |
44 |
45 | {{hour_available[hourIndex]}}
46 | 请选择时间
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | {{length}}/140
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/frontend/pages/mybooks/mybooks.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 确定要{{activeIndex==0?"取消预约":"删除"}}吗?
4 |
5 |
6 |
7 |
8 |
9 |
11 | {{item}}
12 |
13 |
14 |
15 |
16 |
17 | 空空如也
18 |
19 |
20 |
21 |
22 | 预约人
23 | {{reservations[tickets[index]].name}}
24 |
25 |
26 |
27 |
28 | 提交时间
29 | {{reservations[tickets[index]].timestamp}}
30 |
31 |
32 | 学院
33 | {{reservations[tickets[index]].school}}
34 |
35 |
36 | 辅导员
37 | {{reservations[tickets[index]].teacher}}
38 |
39 |
40 | 性别
41 | {{reservations[tickets[index]].sex}}
42 |
43 |
44 | 学号
45 | {{reservations[tickets[index]].id}}
46 |
47 |
48 | 手机
49 | {{reservations[tickets[index]].mobile}}
50 |
51 |
52 | 预约日期
53 | {{reservations[tickets[index]].date}}
54 |
55 |
56 | 预约时间
57 | {{reservations[tickets[index]].hour}}
58 |
59 |
60 | 困惑与帮助
61 | {{reservations[tickets[index]].detail}}
62 |
63 |
64 |
65 | 取消预约
68 |
69 |
70 |
71 |
75 |
--------------------------------------------------------------------------------
/frontend/pages/admin/admin.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 确定要关闭此条预约吗?\n(关闭后预约时间仍然被占用)
4 |
5 |
6 | 确定要删除此条预约吗?\n(删除后预约时间不会被占用)
7 |
8 |
9 |
10 |
11 |
12 |
14 | {{item}}
15 |
16 |
17 |
18 |
19 |
20 |
21 | 空空如也
22 |
23 |
24 |
25 |
26 | 预约人
27 | {{reservations[tickets[index]].name}}
28 |
29 |
30 |
31 |
32 | 提交时间
33 | {{reservations[tickets[index]].timestamp}}
34 |
35 |
36 | 学院
37 | {{reservations[tickets[index]].school}}
38 |
39 |
40 | 辅导员
41 | {{reservations[tickets[index]].teacher}}
42 |
43 |
44 | 性别
45 | {{reservations[tickets[index]].sex}}
46 |
47 |
48 | 学号
49 | {{reservations[tickets[index]].id}}
50 |
51 |
52 | 手机
53 | {{reservations[tickets[index]].mobile}}
54 |
55 |
56 | 预约日期
57 | {{reservations[tickets[index]].date}}
58 |
59 |
60 | 预约时间
61 | {{reservations[tickets[index]].hour}}
62 |
63 |
64 | 困惑与帮助
65 | {{reservations[tickets[index]].detail}}
66 |
67 |
68 |
69 | 删除
71 |
72 | 关闭
75 |
76 |
77 |
78 |
84 |
--------------------------------------------------------------------------------
/frontend/pages/mybooks/mybooks.js:
--------------------------------------------------------------------------------
1 | // pages/mybooks/mybooks.js
2 | const app = getApp()
3 | var sliderWidth = 96;
4 | Page({
5 |
6 | /**
7 | * 页面的初始数据
8 | */
9 | data: {
10 | tabs: ["进行中", "已完成"],
11 | activeIndex: 0,
12 | sliderOffset: 0,
13 | sliderLeft: 0,
14 | reservations: [],
15 | tickets: [],
16 | dialogShow: false,
17 | dialogContent: [],
18 | buttons_del: [{
19 | text: '取消'
20 | }, {
21 | text: '确定'
22 | }],
23 | ticket_chosen: [],
24 | },
25 |
26 | /**
27 | * 生命周期函数--监听页面加载
28 | */
29 | onLoad: function (options) {
30 | var that = this;
31 | var tag = this.data.activeIndex == 0 ? "open" : "closed";
32 | wx.getSystemInfo({
33 | success: function (res) {
34 | that.setData({
35 | sliderLeft: (res.windowWidth / that.data.tabs.length - sliderWidth) / 2,
36 | sliderOffset: res.windowWidth / that.data.tabs.length * that.data.activeIndex
37 | });
38 | }
39 | });
40 |
41 | wx.showLoading({
42 | title: "获取数据中",
43 | mask: true
44 | })
45 | wx.request({
46 | url: 'https://www.bugstop.site/plan/list/',
47 | headers: {
48 | 'Content-Type': 'application/json'
49 | },
50 | data: {
51 | user: app.globalData.wx,
52 | tag: tag
53 | },
54 | method: "POST",
55 | success(res) {
56 | console.log(res.data)
57 | wx.hideLoading();
58 | //将获取到的json数据,存在名字叫list的这个数组中
59 | if (res.data.statusCode == 200) {
60 | that.setData({
61 | reservations: res.data.reservations,
62 | tickets: res.data.tickets,
63 | //res代表success函数的事件对,data是固定的,list是数组
64 | })
65 | } else {
66 | wx.showToast({
67 | title: "获取数据失败",
68 | icon: 'error', //如果要纯文本,不要icon,将值设为'none'
69 | mask: true,
70 | duration: 3000
71 | })
72 |
73 | setTimeout(function () {
74 | wx.reLaunch({
75 | url: '/pages/index/index'
76 | })
77 | }, 2000)
78 | };
79 | },
80 | fail() {
81 | wx.hideLoading();
82 | wx.showToast({
83 | title: "获取数据超时",
84 | icon: 'error', //如果要纯文本,不要icon,将值设为'none'
85 | mask: true,
86 | duration: 3000
87 | })
88 | setTimeout(function () {
89 | wx.reLaunch({
90 | url: '/pages/index/index'
91 | })
92 | }, 2000)
93 | }
94 | })
95 | },
96 |
97 | tabClick: function (e) {
98 | var activeIndex = e.currentTarget.id;
99 | var that = this;
100 |
101 | var tag = activeIndex == 0 ? "open" : "closed";
102 |
103 | console.log(activeIndex)
104 | console.log(tag)
105 |
106 | wx.showLoading({
107 | title: "获取数据中",
108 | mask: true
109 | })
110 | wx.request({
111 | url: 'https://www.bugstop.site/plan/list/',
112 | headers: {
113 | 'Content-Type': 'application/json'
114 | },
115 | data: {
116 | user: app.globalData.wx,
117 | tag: tag
118 | },
119 | method: "POST",
120 | success(res) {
121 | console.log(res.data)
122 | wx.hideLoading();
123 | //将获取到的json数据,存在名字叫list的这个数组中
124 | if (res.data.statusCode == 200) {
125 | that.setData({
126 | reservations: res.data.reservations,
127 | tickets: res.data.tickets,
128 | //res代表success函数的事件对,data是固定的,list是数组
129 | })
130 | } else {
131 | wx.showToast({
132 | title: "获取数据失败",
133 | icon: 'error', //如果要纯文本,不要icon,将值设为'none'
134 | mask: true,
135 | duration: 3000
136 | })
137 |
138 | setTimeout(function () {
139 | wx.reLaunch({
140 | url: '/pages/index/index'
141 | })
142 | }, 2000)
143 | };
144 | },
145 | fail() {
146 | wx.hideLoading();
147 | wx.showToast({
148 | title: "获取数据超时",
149 | icon: 'error', //如果要纯文本,不要icon,将值设为'none'
150 | mask: true,
151 | duration: 3000
152 | })
153 | setTimeout(function () {
154 | wx.reLaunch({
155 | url: '/pages/index/index'
156 | })
157 | }, 2000)
158 | },
159 | complete() {
160 | that.setData({
161 | sliderOffset: e.currentTarget.offsetLeft,
162 | activeIndex: activeIndex
163 | });
164 | }
165 | })
166 | },
167 |
168 | /**
169 | * 生命周期函数--监听页面初次渲染完成
170 | */
171 | onReady: function () {
172 |
173 | },
174 |
175 | /**
176 | * 生命周期函数--监听页面显示
177 | */
178 | onShow: function () {
179 |
180 | },
181 |
182 | /**
183 | * 生命周期函数--监听页面隐藏
184 | */
185 | onHide: function () {
186 |
187 | },
188 |
189 | /**
190 | * 生命周期函数--监听页面卸载
191 | */
192 | onUnload: function () {
193 |
194 | },
195 |
196 | /**
197 | * 页面相关事件处理函数--监听用户下拉动作
198 | */
199 | onPullDownRefresh: function () {
200 |
201 | },
202 |
203 | /**
204 | * 页面上拉触底事件的处理函数
205 | */
206 | onReachBottom: function () {
207 |
208 | },
209 |
210 | delonclick: function (e) {
211 | console.log(e)
212 | this.setData({
213 | dialogShow_del: true,
214 | ticket_chosen: e.currentTarget.dataset.value
215 | })
216 |
217 | },
218 |
219 | tapDialogButton_del: function (e) {
220 | var that = this
221 | console.log(e)
222 | this.setData({
223 | dialogShow_del: false,
224 | })
225 | if (e.detail.index == 1) {
226 | wx.showLoading({
227 | title: "删除中",
228 | mask: true
229 | })
230 | wx.request({
231 | url: 'https://www.bugstop.site/plan/edit/',
232 | headers: {
233 | 'Content-Type': 'application/json'
234 | },
235 | method: "POST",
236 | data: {
237 | user: app.globalData.wx,
238 | tid: that.data.ticket_chosen,
239 | op: "cancel"
240 | },
241 | complete() {
242 | wx.showLoading();
243 | },
244 | success(res) {
245 | console.log(res.data)
246 | if (res.data.statusCode == 200) {
247 | wx.showToast({
248 | title: "取消成功",
249 | icon: 'success', //如果要纯文本,不要icon,将值设为'none'
250 | mask: true,
251 | duration: 2000
252 | })
253 | that.onLoad();
254 |
255 | } else {
256 | wx.showToast({
257 | title: "取消失败",
258 | icon: 'error', //如果要纯文本,不要icon,将值设为'none'
259 | mask: true,
260 | duration: 2000
261 | })
262 | }
263 | },
264 | fail() {
265 | wx.showToast({
266 | title: "请求超时",
267 | icon: 'error', //如果要纯文本,不要icon,将值设为'none'
268 | mask: true,
269 | duration: 2000
270 | })
271 | }
272 | })
273 | }
274 | }
275 | })
--------------------------------------------------------------------------------
/frontend/pages/admin_verify/md5.js:
--------------------------------------------------------------------------------
1 | var rotateLeft = function (lValue, iShiftBits) {
2 | return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
3 | }
4 |
5 | var addUnsigned = function (lX, lY) {
6 | var lX4, lY4, lX8, lY8, lResult;
7 | lX8 = (lX & 0x80000000);
8 | lY8 = (lY & 0x80000000);
9 | lX4 = (lX & 0x40000000);
10 | lY4 = (lY & 0x40000000);
11 | lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF);
12 | if (lX4 & lY4) return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
13 | if (lX4 | lY4) {
14 | if (lResult & 0x40000000) return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
15 | else return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
16 | } else {
17 | return (lResult ^ lX8 ^ lY8);
18 | }
19 | }
20 |
21 | var F = function (x, y, z) {
22 | return (x & y) | ((~x) & z);
23 | }
24 |
25 | var G = function (x, y, z) {
26 | return (x & z) | (y & (~z));
27 | }
28 |
29 | var H = function (x, y, z) {
30 | return (x ^ y ^ z);
31 | }
32 |
33 | var I = function (x, y, z) {
34 | return (y ^ (x | (~z)));
35 | }
36 |
37 | var FF = function (a, b, c, d, x, s, ac) {
38 | a = addUnsigned(a, addUnsigned(addUnsigned(F(b, c, d), x), ac));
39 | return addUnsigned(rotateLeft(a, s), b);
40 | };
41 |
42 | var GG = function (a, b, c, d, x, s, ac) {
43 | a = addUnsigned(a, addUnsigned(addUnsigned(G(b, c, d), x), ac));
44 | return addUnsigned(rotateLeft(a, s), b);
45 | };
46 |
47 | var HH = function (a, b, c, d, x, s, ac) {
48 | a = addUnsigned(a, addUnsigned(addUnsigned(H(b, c, d), x), ac));
49 | return addUnsigned(rotateLeft(a, s), b);
50 | };
51 |
52 | var II = function (a, b, c, d, x, s, ac) {
53 | a = addUnsigned(a, addUnsigned(addUnsigned(I(b, c, d), x), ac));
54 | return addUnsigned(rotateLeft(a, s), b);
55 | };
56 |
57 | var convertToWordArray = function (string) {
58 | var lWordCount;
59 | var lMessageLength = string.length;
60 | var lNumberOfWordsTempOne = lMessageLength + 8;
61 | var lNumberOfWordsTempTwo = (lNumberOfWordsTempOne - (lNumberOfWordsTempOne % 64)) / 64;
62 | var lNumberOfWords = (lNumberOfWordsTempTwo + 1) * 16;
63 | var lWordArray = Array(lNumberOfWords - 1);
64 | var lBytePosition = 0;
65 | var lByteCount = 0;
66 | while (lByteCount < lMessageLength) {
67 | lWordCount = (lByteCount - (lByteCount % 4)) / 4;
68 | lBytePosition = (lByteCount % 4) * 8;
69 | lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount) << lBytePosition));
70 | lByteCount++;
71 | }
72 | lWordCount = (lByteCount - (lByteCount % 4)) / 4;
73 | lBytePosition = (lByteCount % 4) * 8;
74 | lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition);
75 | lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
76 | lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
77 | return lWordArray;
78 | };
79 |
80 | var wordToHex = function (lValue) {
81 | var WordToHexValue = "",
82 | WordToHexValueTemp = "",
83 | lByte, lCount;
84 | for (lCount = 0; lCount <= 3; lCount++) {
85 | lByte = (lValue >>> (lCount * 8)) & 255;
86 | WordToHexValueTemp = "0" + lByte.toString(16);
87 | WordToHexValue = WordToHexValue + WordToHexValueTemp.substr(WordToHexValueTemp.length - 2, 2);
88 | }
89 | return WordToHexValue;
90 | };
91 |
92 | var uTF8Encode = function (string) {
93 | string = string.replace(/\x0d\x0a/g, "\x0a");
94 | var output = "";
95 | for (var n = 0; n < string.length; n++) {
96 | var c = string.charCodeAt(n);
97 | if (c < 128) {
98 | output += String.fromCharCode(c);
99 | } else if ((c > 127) && (c < 2048)) {
100 | output += String.fromCharCode((c >> 6) | 192);
101 | output += String.fromCharCode((c & 63) | 128);
102 | } else {
103 | output += String.fromCharCode((c >> 12) | 224);
104 | output += String.fromCharCode(((c >> 6) & 63) | 128);
105 | output += String.fromCharCode((c & 63) | 128);
106 | }
107 | }
108 | return output;
109 | };
110 |
111 | function md5(string) {
112 | var x = Array();
113 | var k, AA, BB, CC, DD, a, b, c, d;
114 | var S11 = 7,
115 | S12 = 12,
116 | S13 = 17,
117 | S14 = 22;
118 | var S21 = 5,
119 | S22 = 9,
120 | S23 = 14,
121 | S24 = 20;
122 | var S31 = 4,
123 | S32 = 11,
124 | S33 = 16,
125 | S34 = 23;
126 | var S41 = 6,
127 | S42 = 10,
128 | S43 = 15,
129 | S44 = 21;
130 | string = uTF8Encode(string);
131 | x = convertToWordArray(string);
132 | a = 0x67452301;
133 | b = 0xEFCDAB89;
134 | c = 0x98BADCFE;
135 | d = 0x10325476;
136 | for (k = 0; k < x.length; k += 16) {
137 | AA = a;
138 | BB = b;
139 | CC = c;
140 | DD = d;
141 | a = FF(a, b, c, d, x[k + 0], S11, 0xD76AA478);
142 | d = FF(d, a, b, c, x[k + 1], S12, 0xE8C7B756);
143 | c = FF(c, d, a, b, x[k + 2], S13, 0x242070DB);
144 | b = FF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE);
145 | a = FF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF);
146 | d = FF(d, a, b, c, x[k + 5], S12, 0x4787C62A);
147 | c = FF(c, d, a, b, x[k + 6], S13, 0xA8304613);
148 | b = FF(b, c, d, a, x[k + 7], S14, 0xFD469501);
149 | a = FF(a, b, c, d, x[k + 8], S11, 0x698098D8);
150 | d = FF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF);
151 | c = FF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1);
152 | b = FF(b, c, d, a, x[k + 11], S14, 0x895CD7BE);
153 | a = FF(a, b, c, d, x[k + 12], S11, 0x6B901122);
154 | d = FF(d, a, b, c, x[k + 13], S12, 0xFD987193);
155 | c = FF(c, d, a, b, x[k + 14], S13, 0xA679438E);
156 | b = FF(b, c, d, a, x[k + 15], S14, 0x49B40821);
157 | a = GG(a, b, c, d, x[k + 1], S21, 0xF61E2562);
158 | d = GG(d, a, b, c, x[k + 6], S22, 0xC040B340);
159 | c = GG(c, d, a, b, x[k + 11], S23, 0x265E5A51);
160 | b = GG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA);
161 | a = GG(a, b, c, d, x[k + 5], S21, 0xD62F105D);
162 | d = GG(d, a, b, c, x[k + 10], S22, 0x2441453);
163 | c = GG(c, d, a, b, x[k + 15], S23, 0xD8A1E681);
164 | b = GG(b, c, d, a, x[k + 4], S24, 0xE7D3FBC8);
165 | a = GG(a, b, c, d, x[k + 9], S21, 0x21E1CDE6);
166 | d = GG(d, a, b, c, x[k + 14], S22, 0xC33707D6);
167 | c = GG(c, d, a, b, x[k + 3], S23, 0xF4D50D87);
168 | b = GG(b, c, d, a, x[k + 8], S24, 0x455A14ED);
169 | a = GG(a, b, c, d, x[k + 13], S21, 0xA9E3E905);
170 | d = GG(d, a, b, c, x[k + 2], S22, 0xFCEFA3F8);
171 | c = GG(c, d, a, b, x[k + 7], S23, 0x676F02D9);
172 | b = GG(b, c, d, a, x[k + 12], S24, 0x8D2A4C8A);
173 | a = HH(a, b, c, d, x[k + 5], S31, 0xFFFA3942);
174 | d = HH(d, a, b, c, x[k + 8], S32, 0x8771F681);
175 | c = HH(c, d, a, b, x[k + 11], S33, 0x6D9D6122);
176 | b = HH(b, c, d, a, x[k + 14], S34, 0xFDE5380C);
177 | a = HH(a, b, c, d, x[k + 1], S31, 0xA4BEEA44);
178 | d = HH(d, a, b, c, x[k + 4], S32, 0x4BDECFA9);
179 | c = HH(c, d, a, b, x[k + 7], S33, 0xF6BB4B60);
180 | b = HH(b, c, d, a, x[k + 10], S34, 0xBEBFBC70);
181 | a = HH(a, b, c, d, x[k + 13], S31, 0x289B7EC6);
182 | d = HH(d, a, b, c, x[k + 0], S32, 0xEAA127FA);
183 | c = HH(c, d, a, b, x[k + 3], S33, 0xD4EF3085);
184 | b = HH(b, c, d, a, x[k + 6], S34, 0x4881D05);
185 | a = HH(a, b, c, d, x[k + 9], S31, 0xD9D4D039);
186 | d = HH(d, a, b, c, x[k + 12], S32, 0xE6DB99E5);
187 | c = HH(c, d, a, b, x[k + 15], S33, 0x1FA27CF8);
188 | b = HH(b, c, d, a, x[k + 2], S34, 0xC4AC5665);
189 | a = II(a, b, c, d, x[k + 0], S41, 0xF4292244);
190 | d = II(d, a, b, c, x[k + 7], S42, 0x432AFF97);
191 | c = II(c, d, a, b, x[k + 14], S43, 0xAB9423A7);
192 | b = II(b, c, d, a, x[k + 5], S44, 0xFC93A039);
193 | a = II(a, b, c, d, x[k + 12], S41, 0x655B59C3);
194 | d = II(d, a, b, c, x[k + 3], S42, 0x8F0CCC92);
195 | c = II(c, d, a, b, x[k + 10], S43, 0xFFEFF47D);
196 | b = II(b, c, d, a, x[k + 1], S44, 0x85845DD1);
197 | a = II(a, b, c, d, x[k + 8], S41, 0x6FA87E4F);
198 | d = II(d, a, b, c, x[k + 15], S42, 0xFE2CE6E0);
199 | c = II(c, d, a, b, x[k + 6], S43, 0xA3014314);
200 | b = II(b, c, d, a, x[k + 13], S44, 0x4E0811A1);
201 | a = II(a, b, c, d, x[k + 4], S41, 0xF7537E82);
202 | d = II(d, a, b, c, x[k + 11], S42, 0xBD3AF235);
203 | c = II(c, d, a, b, x[k + 2], S43, 0x2AD7D2BB);
204 | b = II(b, c, d, a, x[k + 9], S44, 0xEB86D391);
205 | a = addUnsigned(a, AA);
206 | b = addUnsigned(b, BB);
207 | c = addUnsigned(c, CC);
208 | d = addUnsigned(d, DD);
209 | }
210 | var tempValue = wordToHex(a) + wordToHex(b) + wordToHex(c) + wordToHex(d);
211 | return tempValue.toLowerCase();
212 | }
213 |
214 | module.exports.md5 = md5
--------------------------------------------------------------------------------
/frontend/pages/admin/admin.js:
--------------------------------------------------------------------------------
1 | // pages/mybooks/mybooks.js
2 | const app = getApp()
3 | var sliderWidth = 96;
4 | Page({
5 |
6 | /**
7 | * 页面的初始数据
8 | */
9 | data: {
10 | tabs: ["进行中", "已完成"],
11 | activeIndex: 0,
12 | sliderOffset: 0,
13 | sliderLeft: 0,
14 | reservations: [],
15 | tickets: [],
16 | dialogShow: false,
17 | dialogContent: [],
18 | buttons: [{
19 | text: '取消'
20 | }, {
21 | text: '关闭 '
22 | }],
23 | buttons_del: [{
24 | text: '取消'
25 | }, {
26 | text: '确定'
27 | }],
28 | ticket_chosen: [],
29 | },
30 |
31 | /**
32 | * 生命周期函数--监听页面加载
33 | */
34 | onLoad: function (options) {
35 | var that = this;
36 | var tag = this.data.activeIndex == 0 ? "open" : "closed";
37 | wx.showLoading({
38 | title: "获取数据中",
39 | mask: true
40 | })
41 | console.log(app.globalData.admin_password)
42 | wx.request({
43 | url: 'https://www.bugstop.site/plan/list/',
44 | headers: {
45 | 'Content-Type': 'application/json'
46 | },
47 | data: {
48 | user: app.globalData.admin_password,
49 | tag: tag
50 | },
51 | method: "POST",
52 | success(res) {
53 | console.log(res.data)
54 | wx.hideLoading();
55 | //将获取到的json数据,存在名字叫list的这个数组中
56 | if (res.data.statusCode == 200) {
57 | that.setData({
58 | reservations: res.data.reservations,
59 | tickets: res.data.tickets,
60 | //res代表success函数的事件对,data是固定的,list是数组
61 | })
62 | } else {
63 | wx.showToast({
64 | title: "获取数据失败",
65 | icon: 'error', //如果要纯文本,不要icon,将值设为'none'
66 | mask: true,
67 | duration: 3000
68 | })
69 |
70 | setTimeout(function () {
71 | wx.reLaunch({
72 | url: '/pages/index/index'
73 | })
74 | }, 2000)
75 | };
76 | },
77 | fail() {
78 | wx.hideLoading();
79 | wx.showToast({
80 | title: "获取数据超时",
81 | icon: 'error', //如果要纯文本,不要icon,将值设为'none'
82 | mask: true,
83 | duration: 3000
84 | })
85 | setTimeout(function () {
86 | wx.reLaunch({
87 | url: '/pages/index/index'
88 | })
89 | }, 2000)
90 | }
91 | })
92 | },
93 |
94 | /**
95 | * 生命周期函数--监听页面初次渲染完成
96 | */
97 | onReady: function () {
98 |
99 | },
100 |
101 | /**
102 | * 生命周期函数--监听页面显示
103 | */
104 | onShow: function () {
105 |
106 | },
107 |
108 | /**
109 | * 生命周期函数--监听页面隐藏
110 | */
111 | onHide: function () {
112 |
113 | },
114 |
115 | /**
116 | * 生命周期函数--监听页面卸载
117 | */
118 | onUnload: function () {
119 |
120 | },
121 |
122 | /**
123 | * 页面相关事件处理函数--监听用户下拉动作
124 | */
125 | onPullDownRefresh: function () {
126 |
127 | },
128 |
129 | /**
130 | * 页面上拉触底事件的处理函数
131 | */
132 | onReachBottom: function () {
133 |
134 | },
135 |
136 | closeonclick: function (e) {
137 | console.log(e)
138 | this.setData({
139 | dialogShow: true,
140 | ticket_chosen: e.currentTarget.dataset.value
141 | })
142 | },
143 |
144 | delonclick: function (e) {
145 | console.log(e)
146 | this.setData({
147 | dialogShow_del: true,
148 | ticket_chosen: e.currentTarget.dataset.value
149 | })
150 | },
151 |
152 | tapDialogButton: function (e) {
153 | var that = this
154 | console.log(e)
155 | this.setData({
156 | dialogShow: false,
157 | })
158 | if (e.detail.index == 1) {
159 | wx.showLoading({
160 | title: "关闭中",
161 | mask: true
162 | })
163 | wx.request({
164 | url: 'https://www.bugstop.site/plan/edit/',
165 | headers: {
166 | 'Content-Type': 'application/json'
167 | },
168 | method: "POST",
169 |
170 | data: {
171 | user: app.globalData.admin_password,
172 | tid: that.data.ticket_chosen,
173 | op: "closed"
174 | },
175 | complete() {
176 | wx.showLoading();
177 | },
178 | success(res) {
179 | console.log(res.data)
180 | if (res.data.statusCode == 200) {
181 | wx.showToast({
182 | title: "关闭成功",
183 | icon: 'success', //如果要纯文本,不要icon,将值设为'none'
184 | mask: true,
185 | duration: 2000
186 | })
187 | that.onLoad();
188 | } else {
189 | wx.showToast({
190 | title: "关闭失败",
191 | icon: 'error', //如果要纯文本,不要icon,将值设为'none'
192 | mask: true,
193 | duration: 2000
194 | })
195 | }
196 | },
197 | fail() {
198 | wx.showToast({
199 | title: "请求超时",
200 | icon: 'error', //如果要纯文本,不要icon,将值设为'none'
201 | mask: true,
202 | duration: 2000
203 | })
204 | }
205 | })
206 | }
207 | },
208 |
209 | tabClick: function (e) {
210 | var activeIndex = e.currentTarget.id;
211 | var that = this;
212 | var tag = activeIndex == 0 ? "open" : "closed";
213 |
214 | console.log(activeIndex)
215 | console.log(tag)
216 |
217 | wx.showLoading({
218 | title: "获取数据中",
219 | mask: true
220 | })
221 | wx.request({
222 | url: 'https://www.bugstop.site/plan/list/',
223 | headers: {
224 | 'Content-Type': 'application/json'
225 | },
226 | data: {
227 | user: app.globalData.admin_password,
228 | tag: tag
229 | },
230 | method: "POST",
231 | success(res) {
232 | console.log(res.data)
233 | wx.hideLoading();
234 | //将获取到的json数据,存在名字叫list的这个数组中
235 | if (res.data.statusCode == 200) {
236 | that.setData({
237 | reservations: res.data.reservations,
238 | tickets: res.data.tickets,
239 | //res代表success函数的事件对,data是固定的,list是数组
240 | })
241 | } else {
242 | wx.showToast({
243 | title: "获取数据失败",
244 | icon: 'error', //如果要纯文本,不要icon,将值设为'none'
245 | mask: true,
246 | duration: 3000
247 | })
248 |
249 | setTimeout(function () {
250 | wx.reLaunch({
251 | url: '/pages/index/index'
252 | })
253 | }, 2000)
254 | };
255 | },
256 | fail() {
257 | wx.hideLoading();
258 | wx.showToast({
259 | title: "获取数据超时",
260 | icon: 'error', //如果要纯文本,不要icon,将值设为'none'
261 | mask: true,
262 | duration: 3000
263 | })
264 | setTimeout(function () {
265 | wx.reLaunch({
266 | url: '/pages/index/index'
267 | })
268 | }, 2000)
269 | },
270 | complete() {
271 | that.setData({
272 | sliderOffset: e.currentTarget.offsetLeft,
273 | activeIndex: activeIndex
274 | });
275 | }
276 | })
277 | },
278 |
279 | tapDialogButton_del: function (e) {
280 | var that = this
281 | console.log(e)
282 | this.setData({
283 | dialogShow_del: false,
284 | })
285 | if (e.detail.index == 1) {
286 | wx.showLoading({
287 | title: "删除中",
288 | mask: true
289 | })
290 | wx.request({
291 | url: 'https://www.bugstop.site/plan/edit/',
292 | headers: {
293 | 'Content-Type': 'application/json'
294 | },
295 | method: "POST",
296 | data: {
297 | user: app.globalData.admin_password,
298 | tid: that.data.ticket_chosen,
299 | op: "cancel"
300 | },
301 | complete() {
302 | wx.showLoading();
303 | },
304 | success(res) {
305 | console.log(res.data)
306 | if (res.data.statusCode == 200) {
307 | wx.showToast({
308 | title: "取消成功",
309 | icon: 'success', //如果要纯文本,不要icon,将值设为'none'
310 | mask: true,
311 | duration: 2000
312 | })
313 | that.onLoad();
314 |
315 | } else {
316 | wx.showToast({
317 | title: "取消失败",
318 | icon: 'error', //如果要纯文本,不要icon,将值设为'none'
319 | mask: true,
320 | duration: 2000
321 | })
322 | }
323 | },
324 | fail() {
325 | wx.showToast({
326 | title: "请求超时",
327 | icon: 'error', //如果要纯文本,不要icon,将值设为'none'
328 | mask: true,
329 | duration: 2000
330 | })
331 | }
332 | })
333 | }
334 | }
335 | })
--------------------------------------------------------------------------------
/frontend/pages/book/book.js:
--------------------------------------------------------------------------------
1 | const app = getApp()
2 |
3 | Page({
4 | data: {
5 | showTopTips: false,
6 | userInfo: [],
7 |
8 | sex: ["男", "女"],
9 | sexIndex: -1,
10 |
11 | dateIndex: -1,
12 | hourIndex: -1,
13 | teacherIndex: -1,
14 | schoolIndex: -1,
15 | hourItem: {},
16 | dataSchool: {},
17 | dataSchedule: {},
18 | date_available: [],
19 | hour_available: [],
20 |
21 | length: 0,
22 | formData: {},
23 | rules: [{
24 | name: "wx",
25 | rules: {
26 | required: true,
27 | message: "连接服务器失败,请稍候重试",
28 | },
29 | },
30 | {
31 | name: "name",
32 | rules: {
33 | required: true,
34 | message: "请输入姓名",
35 | },
36 | },
37 | {
38 | name: "sex",
39 | rules: {
40 | required: true,
41 | message: "请选择性别",
42 | },
43 | },
44 | {
45 | name: "id",
46 | rules: {
47 | required: true,
48 | message: "学号为必填项",
49 | },
50 | },
51 | {
52 | name: "mobile",
53 | rules: [{
54 | required: true,
55 | message: "手机号码为必填项",
56 | },
57 | {
58 | mobile: true,
59 | message: "手机号码格式不正确",
60 | },
61 | ],
62 | },
63 | {
64 | name: "teacher",
65 | rules: [{
66 | required: true,
67 | message: "请选择一名辅导员",
68 | }, ],
69 | },
70 | {
71 | name: "date",
72 | rules: [{
73 | required: true,
74 | message: "请选择日期",
75 | }, ],
76 | },
77 | {
78 | name: "hour",
79 | rules: [{
80 | required: true,
81 | message: "请选择时间",
82 | }, ],
83 | }
84 | ],
85 | },
86 |
87 | onLoad: function (options) {
88 | var that = this;
89 | this.setData({
90 | userInfo: undefined, // app.globalData.userInfo,
91 | [`formData.wx`]: app.globalData.wx
92 | });
93 | wx.getStorage({
94 | key: "name",
95 | success(res) {
96 | that.setData({
97 | [`formData.name`]: res.data,
98 | });
99 | },
100 | });
101 | wx.getStorage({
102 | key: "sex",
103 | success(res) {
104 | that.setData({
105 | [`formData.sex`]: res.data,
106 | });
107 | },
108 | });
109 | wx.getStorage({
110 | key: "sexIndex",
111 | success(res) {
112 | that.setData({
113 | sexIndex: res.data,
114 | });
115 | },
116 | });
117 |
118 | wx.getStorage({
119 | key: "id",
120 | success(res) {
121 | that.setData({
122 | [`formData.id`]: res.data,
123 | });
124 | },
125 | });
126 | wx.getStorage({
127 | key: "mobile",
128 | success(res) {
129 | that.setData({
130 | [`formData.mobile`]: res.data,
131 | });
132 | },
133 | });
134 | wx.request({
135 | url: "https://www.bugstop.site/plan/open/school",
136 | headers: {
137 | "Content-Type": "application/json",
138 | },
139 |
140 | success(res) {
141 | that.setData({
142 | dataSchool: res.data,
143 | dataSchedule: {
144 | 'statusCode': 400,
145 | 'dates': ["请先选择学院和辅导员"],
146 | 'hours': {
147 | "请先选择学院和辅导员": ["请先选择学院和辅导员"],
148 | }
149 | },
150 | });
151 |
152 | },
153 | fail() {
154 | wx.showToast({
155 | title: "连接超时,请稍候重试",
156 | icon: "error", //如果要纯文本,不要icon,将值设为'none'
157 | mask: true,
158 | });
159 | },
160 | });
161 | },
162 |
163 | textareaInput: function (e) {
164 | this.setData({
165 | length: e.detail.value.length,
166 | [`formData.detail`]: e.detail.value,
167 | });
168 | },
169 |
170 | bindSchoolChange: function (e) {
171 | var dataSchool = this.data.dataSchool;
172 |
173 | this.setData({
174 | schoolIndex: e.detail.value,
175 | teacherIndex: -1,
176 | dateIndex: -1,
177 | hourIndex: -1,
178 | teacher_available: dataSchool.teachers[dataSchool.schools[e.detail.value]].辅导员,
179 | [`formData.school`]: dataSchool.schools[e.detail.value],
180 | });
181 | },
182 |
183 | bindTeacherChange: function (e) {
184 | var that = this;
185 | var teacher = this.data.teacher_available;
186 |
187 | this.setData({
188 | teacherIndex: e.detail.value,
189 | dateIndex: -1,
190 | hourIndex: -1,
191 | [`formData.teacher`]: teacher[e.detail.value],
192 | });
193 |
194 | wx.request({
195 | url: "https://www.bugstop.site/plan/open/schedule?school=" + that.data.formData.school + "&teacher=" + that.data.formData.teacher,
196 | headers: {
197 | "Content-Type": "application/json",
198 | },
199 | success(res) {
200 | that.setData({
201 | dataSchedule: res.data,
202 | });
203 | },
204 | fail() {
205 | wx.showToast({
206 | title: "连接超时,请稍候重试",
207 | icon: "error", //如果要纯文本,不要icon,将值设为'none'
208 | mask: true,
209 | });
210 | },
211 | });
212 | },
213 |
214 | bindDateChange: function (e) {
215 | var dataSchedule = this.data.dataSchedule;
216 |
217 | this.setData({
218 | dateIndex: e.detail.value,
219 | hourIndex: -1,
220 | hour_available: dataSchedule.hours[dataSchedule.dates[e.detail.value]],
221 | [`formData.date`]: dataSchedule.dates[e.detail.value],
222 | });
223 | },
224 |
225 | bindHourChange: function (e) {
226 | var hour_available = this.data.hour_available;
227 |
228 | this.setData({
229 | hourIndex: e.detail.value,
230 | [`formData.hour`]: hour_available[e.detail.value],
231 | });
232 | },
233 |
234 | formInputChange(e) {
235 | const {
236 | field
237 | } = e.currentTarget.dataset;
238 | wx.setStorage({
239 | key: field,
240 | data: e.detail.value,
241 | });
242 | this.setData({
243 | [`formData.${field}`]: e.detail.value,
244 | });
245 | },
246 |
247 | bindSexChange: function (e) {
248 | var sex = this.data.sex;
249 | wx.setStorage({
250 | key: "sexIndex",
251 | data: e.detail.value,
252 | });
253 | wx.setStorage({
254 | key: "sex",
255 | data: sex[e.detail.value],
256 | });
257 | this.setData({
258 | sexIndex: e.detail.value,
259 | [`formData.sex`]: sex[e.detail.value],
260 | });
261 | },
262 |
263 | submitForm() {
264 | var formdata = this.data.formData;
265 | var that = this;
266 | this.selectComponent("#form").validate((valid, errors) => {
267 | if (!valid) {
268 | const firstError = Object.keys(errors);
269 | if (firstError.length) {
270 | this.setData({
271 | error: errors[firstError[0]].message,
272 | });
273 | }
274 | } else {
275 | if (that.data.formData.detail == "" || that.data.formData.detail == null) {
276 | that.data.formData.detail = "未填写";
277 | }
278 | wx.showLoading({
279 | title: "提交中",
280 | mask: true,
281 | });
282 | console.log("submit:", formdata);
283 | wx.request({
284 | url: "https://www.bugstop.site/plan/open/",
285 | data: formdata,
286 | headers: {
287 | "Content-Type": "application/json",
288 | },
289 | timeout: 10000,
290 | method: "POST",
291 | success(res) {
292 | wx.hideLoading();
293 | switch (res.data.statusCode) {
294 | case 200:
295 | wx.showToast({
296 | title: "预约成功",
297 | icon: "success", //如果要纯文本,不要icon,将值设为'none'
298 | mask: true,
299 | duration: 3000,
300 | });
301 |
302 | setTimeout(function () {
303 | wx.redirectTo({
304 | url: "/pages/mybooks/mybooks",
305 | });
306 | }, 2000);
307 | break;
308 |
309 | case 500:
310 | wx.showToast({
311 | title: "预约失败,请重试",
312 | icon: "error", //如果要纯文本,不要icon,将值设为'none'
313 | mask: true,
314 | duration: 3000,
315 | });
316 | break;
317 | }
318 | },
319 | fail() {
320 | wx.hideLoading();
321 | wx.showToast({
322 | title: "提交超时,请稍候重试",
323 | icon: "error", //如果要纯文本,不要icon,将值设为'none'
324 | mask: true,
325 | });
326 | },
327 | });
328 | }
329 | });
330 | },
331 | /**
332 | * 用户点击右上角分享
333 | */
334 | onShareAppMessage: function () {
335 |
336 | },
337 | });
--------------------------------------------------------------------------------
/backend/server.py:
--------------------------------------------------------------------------------
1 | # Author: limuhan
2 | # GitHub: bugstop
3 | # March 7, 2021
4 |
5 | # TODO: statusCode
6 |
7 | import os
8 | import json
9 | import time
10 | import signal
11 | import inspect
12 | import logging
13 | import requests
14 | from typing import Any, Callable
15 | from multiprocessing import Process
16 | from datetime import datetime, timedelta
17 |
18 | from smtplib import SMTP_SSL
19 | from email.header import Header
20 | from email.mime.text import MIMEText
21 |
22 | from flask import Flask, request, jsonify, make_response
23 | from flask_cors import CORS
24 |
25 | DEBUG = False
26 | path = os.path.dirname(inspect.getfile(inspect.currentframe()))
27 |
28 | log_file = path + '/server.log'
29 | log_format = "%(asctime)s - %(levelname)s - %(message)s"
30 | logging.basicConfig(filename=log_file, level=logging.INFO, format=log_format)
31 |
32 | database = [
33 | 'secrets.json', # 储存敏感信息
34 | 'settings.json', # 储存基本设置
35 | 'tickets_open.json', # 储存进行中预约
36 | 'tickets_closed.json', # 储存已完成预约
37 | 'dynamic.json', # 储存动态规则
38 | ]
39 |
40 | with open(path + '/data/secrets.json') as f_obj:
41 | secrets: dict = json.load(f_obj)
42 | with open(path + '/data/settings.json') as f_obj:
43 | settings: dict = json.load(f_obj)
44 | with open(path + '/data/tickets_open.json') as f_obj:
45 | tickets: dict = json.load(f_obj)
46 | with open(path + '/data/tickets_closed.json') as f_obj:
47 | tickets_closed: dict = json.load(f_obj)
48 | with open(path + '/data/dynamic.json') as f_obj:
49 | dynamic: dict = json.load(f_obj)
50 |
51 | # 记录各项数据最近备份时间
52 | database_modified = {data_file: time.time() for data_file in database}
53 | logging.info(('Loaded data', settings, tickets, tickets_closed, dynamic))
54 |
55 |
56 | class DataCheckException(Exception):
57 | """数据校验错误信息"""
58 |
59 |
60 | def send_mail(receiver: str, title: str, content: str) -> None:
61 | """当有新预约时,向对应老师发送邮件"""
62 | try:
63 | server: str = secrets['mailSettings']['server']
64 | username: str = secrets['mailSettings']['username']
65 | password: str = secrets['mailSettings']['password']
66 |
67 | smtp = SMTP_SSL(server)
68 | smtp.set_debuglevel(0)
69 | smtp.ehlo(server)
70 | smtp.login(username, password)
71 |
72 | msg = MIMEText(content, 'plain', 'utf-8')
73 | msg['Subject'] = Header(title, 'utf-8')
74 | msg['From'] = username
75 | msg['To'] = receiver
76 |
77 | smtp.sendmail(username, receiver, msg.as_string())
78 | smtp.quit()
79 | except Exception as e:
80 | logging.error(('send mail error:', e))
81 |
82 |
83 | def time_shift(*args: Any, **kwargs: Any) -> datetime:
84 | """获取(经过偏移量后的)时间"""
85 | return datetime.now() + timedelta(*args, **kwargs)
86 |
87 |
88 | def date_lang(date: str, lang: (str, str) = ('en', 'zh')) -> str:
89 | """时间戳中英互译"""
90 | languages: dict = settings['languages']
91 | source_words, target_words = languages[lang[0]], languages[lang[1]]
92 | for source_word, target_word in zip(source_words, target_words):
93 | date = date.replace(source_word, target_word)
94 | return date
95 |
96 |
97 | def date_convert(date_format: str, lang: (str, str) = ('en', 'zh')) -> Callable:
98 | """辅助时间戳转换函数"""
99 | return lambda z: datetime.strptime(date_lang(z, lang), date_format)
100 |
101 |
102 | def save_data(data: Any, filename: str, detail: str = ':)', force: bool = False) -> None:
103 | """备份数据"""
104 | if not force and time.time() - database_modified[filename] < settings['checkpoint_frequency']:
105 | logging.info(('update skipped:', filename, detail))
106 | else:
107 | logging.warning(('update DATABASE:', filename, detail))
108 | try:
109 | with open(path + '/data/' + filename, 'w') as f:
110 | json.dump(data, f)
111 | except Exception as e:
112 | # 仅作为备份,实时数据全在内存
113 | logging.error(('save data error:', filename, e))
114 | else:
115 | database_modified[filename] = time.time()
116 |
117 |
118 | def checkpoint(msg='force save'):
119 | """强制保存所有数据"""
120 | Process(target=save_data, args=(dynamic, 'dynamic.json', msg, True)).start()
121 | Process(target=save_data, args=(secrets, 'secrets.json', msg, True)).start()
122 | Process(target=save_data, args=(settings, 'settings.json', msg, True)).start()
123 | Process(target=save_data, args=(tickets, 'tickets_open.json', msg, True)).start()
124 | Process(target=save_data, args=(tickets_closed, 'tickets_closed.json', msg, True)).start()
125 |
126 |
127 | def construct_response(msg: dict) -> Any:
128 | """完成请求响应的构造"""
129 | response = make_response(jsonify(msg))
130 | response.headers['Access-Control-Allow-Origin'] = '*'
131 | response.headers['Access-Control-Allow-Methods'] = 'OPTIONS,HEAD,GET,POST'
132 | response.headers['Access-Control-Allow-Headers'] = 'x-requested-with'
133 | return response
134 |
135 |
136 | def get_schedule_available(teacher_name, school_name):
137 | unavailable = list()
138 | for ticket in list(tickets.values()) + list(tickets_closed.values()):
139 | if ticket['teacher'] == teacher_name:
140 | unavailable.append((ticket['date'], ticket['hour']))
141 |
142 | max_days = settings['school'][school_name]['最远可预约天数']
143 | hrs_prep = settings['school'][school_name]['提前预约小时数']
144 | working = settings['teacher'][school_name][teacher_name]['时间']
145 |
146 | dates, hours = list(), dict()
147 | for day in range(max_days):
148 | date = date_lang(time_shift(days=day).strftime(settings['date_format']))
149 | hours_available = working[datetime.weekday(datetime.today() + timedelta(days=day))]
150 |
151 | if date in dynamic['off_days'] or not hours_available:
152 | continue
153 |
154 | hours[date] = list()
155 | for hour_available in hours_available:
156 | hour_start = [s.format(hour_available) for s in settings['hour_format']]
157 |
158 | for hour in hour_start:
159 | if (day == 0 and hour_available <= datetime.now().hour + hrs_prep) \
160 | or (date, hour) in unavailable: # 不可预约当日早些时候或该时段已有预约
161 | continue
162 | hours[date].append(hour)
163 |
164 | if hours[date]:
165 | dates.append(date)
166 |
167 | return dates, {date: hours[date] for date in dates}
168 |
169 |
170 | app = Flask(__name__, )
171 | CORS(app, resources=r'/*') # 允许跨域请求
172 |
173 |
174 | @app.route('/', methods=['GET'])
175 | def index():
176 | """https://github.com/bugstop/hitsz-appointment-scheduling"""
177 | messages = {'statusCode': 200, 'GitHub': 'bugstop', 'copyright': 2021}
178 | return construct_response(messages)
179 |
180 |
181 | @app.route('/checkpoint/', methods=['GET'])
182 | def checkpoint_save():
183 | checkpoint('checkpoint')
184 | messages = {'statusCode': 200, 'GitHub': 'bugstop', 'copyright': 2021}
185 | return construct_response(messages)
186 |
187 |
188 | @app.route('/user/id/', methods=['POST'])
189 | def get_uid():
190 | """获得用户唯一微信ID"""
191 | code = request.json.get('code')
192 | url = 'https://api.weixin.qq.com/sns/jscode2session?' \
193 | 'appid={}&secret={}&js_code={}&grant_type=authorization_code'. \
194 | format(secrets['AppID'], secrets['AppSecret'], code)
195 |
196 | for _ in range(3):
197 | try:
198 | user_id = requests.get(url, timeout=2).json()['openid']
199 | except Exception as e:
200 | logging.critical(('get uid error:', e))
201 | else:
202 | break # 已取得用户ID
203 | else:
204 | user_id = None # 超时
205 |
206 | messages = {'statusCode': 200 if user_id else 500, 'wx': user_id}
207 | logging.info(('user id:', messages))
208 | return construct_response(messages)
209 |
210 |
211 | @app.route('/user/verify/', methods=['POST'])
212 | def admin_verification():
213 | """验证管理员密码"""
214 | admin = request.json.get('password') in secrets['password']
215 | messages = {'statusCode': 200 if admin else 500}
216 | return construct_response(messages)
217 |
218 |
219 | @app.route('/plan/open/school', methods=['GET'])
220 | def open_ticket_school():
221 | """展示可供预约的时间段"""
222 |
223 | try:
224 | messages = {
225 | 'statusCode': 200,
226 | 'schools': list(settings['school']),
227 | 'teachers': settings['school']
228 | }
229 | except Exception as e:
230 | logging.error(('open ticket school error:', e))
231 | messages = {'statusCode': 500}
232 |
233 | return construct_response(messages)
234 |
235 |
236 | @app.route('/plan/open/schedule', methods=['GET'])
237 | def open_ticket_schedule():
238 | """展示可供预约的时间段"""
239 |
240 | try:
241 | school_name = request.args.get('school')
242 | teacher_name = request.args.get('teacher')
243 | if not school_name or not teacher_name:
244 | raise DataCheckException('school or teacher must be filled')
245 |
246 | dates, hours = get_schedule_available(teacher_name, school_name)
247 |
248 | messages = {
249 | 'statusCode': 200,
250 | 'dates': dates,
251 | 'hours': hours,
252 | }
253 |
254 | except Exception as e:
255 | logging.error(('open ticket schedule error:', e))
256 | messages = {'statusCode': 500}
257 |
258 | return construct_response(messages)
259 |
260 |
261 | @app.route('/plan/open/', methods=['POST'])
262 | def open_ticket():
263 | """预约心理咨询"""
264 |
265 | def write_data(ticket):
266 | """新增预约数据"""
267 | global tickets, dynamic
268 |
269 | # 验证数据完整性:是否有留空、是否在黑名单
270 | if not all([ticket.get(item) for item in settings['must_fill']]) \
271 | or ticket['wx'] in dynamic['blocked']:
272 | raise DataCheckException('data check failed')
273 |
274 | # 工单唯一ID形式为:流水号@时间戳
275 | ticket_id = 0 if not tickets and not tickets_closed else max(map(
276 | int, (tid.split('@')[0] for tid in list(tickets) + list(tickets_closed))))
277 | new_ticket_id = settings['ticket_format'].format(ticket_id + 1, time_shift().strftime('%Y%m%d'))
278 |
279 | dates, hours = get_schedule_available(ticket['teacher'], ticket['school'])
280 | if not hours.get(ticket['date']) or ticket['hour'] not in hours.get(ticket['date']):
281 | logging.error((ticket['date'], ticket['hour'], hours))
282 | raise DataCheckException('invalid time')
283 |
284 | ticket['status'] = 'open' # 工单状态:open进行中,close已完成
285 | ticket['timestamp'] = time_shift().strftime(settings['timestamp'])
286 | tickets[new_ticket_id] = ticket
287 |
288 | logging.info(('reserve:', 'write data'))
289 | Process(target=save_data, args=(tickets, 'tickets_open.json', '{} {} {} {}'.format(
290 | new_ticket_id, ticket['name'], ticket['date'].split('·')[0], ticket['hour'][:5]))).start()
291 |
292 | mail_receiver = settings['teacher'][ticket['school']][ticket['teacher']]['邮箱'] \
293 | if ticket['name'] != '张三' else secrets['mailSettings']['maintainer'] # 测试账号
294 | mail_content = '{}{}老师,{}预约了 {}{} 的心理咨询。详细信息请在微信小程序查看。'.format(
295 | ticket['school'], ticket['teacher'], '有同学', ticket['date'].split('·')[0], ticket['hour'][:5])
296 | Process(target=send_mail, args=(mail_receiver, '新的心理咨询预约', mail_content)).start()
297 |
298 | try:
299 | write_data(request.json)
300 | messages = {'statusCode': 200}
301 | except Exception as e:
302 | logging.error(('make reservation error:', e))
303 | messages = {'statusCode': 500}
304 |
305 | return construct_response(messages)
306 |
307 |
308 | @app.route('/plan/list/', methods=['POST'])
309 | def show_reservations():
310 | """展示预约工单列表"""
311 |
312 | def list_data(user_filter: str, tag: str):
313 | """筛选展示的工单并排序"""
314 | global tickets, tickets_closed
315 |
316 | if tag not in ['open', 'closed']:
317 | raise DataCheckException('key check failed')
318 |
319 | # 工单展示按预约时间顺序由近及远。工单ID仅作为唯一标识符,并不参与排序
320 | tickets_selected = tickets if tag != 'closed' else tickets_closed
321 | time_format = date_convert(settings['time_format'], ('zh', 'en'))
322 | tickets_show = sorted(list(tickets_selected.keys()), key=lambda z: time_format(
323 | tickets_selected[z]['date'] + tickets_selected[z]['hour']), reverse=(tag == 'closed'))
324 |
325 | # 自动关闭今天之前的工单
326 | expired_tickets = list()
327 | time_format = date_convert(settings['date_format'], ('zh', 'en'))
328 | while tickets_show and tag == 'open' and time_format(tickets[tickets_show[0]]['date']) < time_shift(days=-1):
329 | ticket_id = tickets_show.pop(0)
330 | tickets[ticket_id]['status'] = 'closed' # TODO: expired
331 | tickets_closed[ticket_id] = tickets[ticket_id]
332 | del tickets[ticket_id]
333 | expired_tickets.append(ticket_id)
334 | if expired_tickets:
335 | logging.info(('list:', 'close expired'))
336 | Process(target=save_data, args=(tickets, 'tickets_open.json', 'close expired')).start()
337 | Process(target=save_data, args=(tickets_closed, 'tickets_closed.json', expired_tickets)).start()
338 |
339 | # 对于普通用户筛选出本人的预约,管理员可以查看本专业所有预约
340 | if user_filter not in secrets['password']:
341 | tickets_show = [ticket for ticket in tickets_show
342 | if tickets_selected[ticket].get('wx') == user_filter]
343 | else:
344 | tickets_show = [ticket for ticket in tickets_show
345 | if tickets_selected[ticket].get('school') == secrets['password'][user_filter]]
346 | tickets_filtered = {ticket: tickets_selected[ticket] for ticket in tickets_show}
347 |
348 | return tickets_filtered, tickets_show
349 |
350 | try:
351 | username = request.json.get('user')
352 | ticket_status = request.json.get('tag')
353 | reservations = list_data(username, ticket_status)
354 | messages = {
355 | 'statusCode': 200,
356 | 'tickets': reservations[1],
357 | 'reservations': reservations[0]
358 | }
359 | except Exception as e:
360 | logging.error(('list reservation error:', e))
361 | messages = {'statusCode': 500}
362 |
363 | return construct_response(messages)
364 |
365 |
366 | @app.route('/plan/edit/', methods=['POST'])
367 | def edit_reservations():
368 | """更改心理咨询预约工单的状态"""
369 |
370 | def edit_data(username, ticket_id, operation):
371 | """修改预约数据"""
372 | global tickets, tickets_closed
373 |
374 | # closed标注工单为已完成,cancel直接删除工单记录
375 | if operation not in ['closed', 'cancel']:
376 | raise DataCheckException('key check failed')
377 |
378 | # 对进行中的工单,本人和管理员有权限进行关闭或删除记录
379 | if tickets.get(ticket_id) and (username == tickets[ticket_id]['wx'] or username in secrets['password']):
380 | ticket, date, hour = tickets[ticket_id], tickets[ticket_id]['date'], tickets[ticket_id]['hour']
381 | tickets[ticket_id]['status'] = operation
382 |
383 | if operation == 'closed':
384 | tickets_closed[ticket_id] = tickets[ticket_id]
385 | Process(target=save_data, args=(tickets_closed, 'tickets_closed.json',
386 | 'close {}'.format(ticket_id))).start()
387 | if operation == 'cancel':
388 | mail_receiver = settings['teacher'][ticket['school']][ticket['teacher']]['邮箱'] \
389 | if tickets[ticket_id]['name'] != '张三' else secrets['mailSettings']['maintainer'] # 测试账号
390 | mail_content = '{}老师,{}取消了原定于 {}{} 的心理咨询。此记录已从系统抹除。'.format(
391 | tickets[ticket_id]['teacher'], '学生', date.split('·')[0], hour[:5])
392 | Process(target=send_mail, args=(mail_receiver, '心理咨询预约取消', mail_content)).start()
393 |
394 | logging.info(('edit:', 'write data'))
395 | del tickets[ticket_id]
396 | Process(target=save_data, args=(tickets, 'tickets_open.json',
397 | 'delete {}'.format(ticket_id))).start()
398 |
399 | # 对已完成的工单,只有管理员有权限删除
400 | elif operation == 'cancel' and tickets_closed.get(ticket_id) and username in secrets['password']:
401 | logging.info(('edit:', 'write data'))
402 | del tickets_closed[ticket_id]
403 | Process(target=save_data, args=(tickets_closed, 'tickets_closed.json',
404 | 'delete {}'.format(ticket_id))).start()
405 |
406 | else:
407 | raise DataCheckException('permission denied')
408 |
409 | try:
410 | uid = request.json.get('user') # 用户的唯一ID,管理员传密码
411 | tid = request.json.get('tid') # 操作的工单ID
412 | op = request.json.get('op') # 操作选项(closed,cancel)
413 | edit_data(uid, tid, op)
414 | messages = {'statusCode': 200}
415 | except Exception as e:
416 | logging.error(('edit reservation error:', e))
417 | messages = {'statusCode': 500}
418 |
419 | return construct_response(messages)
420 |
421 |
422 | if __name__ == '__main__':
423 | logging.info(('working directory:', path))
424 | # 由于Process.start没有join,需要处理僵尸进程
425 | signal.signal(signal.SIGCHLD, signal.SIG_IGN)
426 | app.run(port=2333 if not DEBUG else 6666)
427 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Mozilla Public License Version 2.0
2 | ==================================
3 |
4 | 1. Definitions
5 | --------------
6 |
7 | 1.1. "Contributor"
8 | means each individual or legal entity that creates, contributes to
9 | the creation of, or owns Covered Software.
10 |
11 | 1.2. "Contributor Version"
12 | means the combination of the Contributions of others (if any) used
13 | by a Contributor and that particular Contributor's Contribution.
14 |
15 | 1.3. "Contribution"
16 | means Covered Software of a particular Contributor.
17 |
18 | 1.4. "Covered Software"
19 | means Source Code Form to which the initial Contributor has attached
20 | the notice in Exhibit A, the Executable Form of such Source Code
21 | Form, and Modifications of such Source Code Form, in each case
22 | including portions thereof.
23 |
24 | 1.5. "Incompatible With Secondary Licenses"
25 | means
26 |
27 | (a) that the initial Contributor has attached the notice described
28 | in Exhibit B to the Covered Software; or
29 |
30 | (b) that the Covered Software was made available under the terms of
31 | version 1.1 or earlier of the License, but not also under the
32 | terms of a Secondary License.
33 |
34 | 1.6. "Executable Form"
35 | means any form of the work other than Source Code Form.
36 |
37 | 1.7. "Larger Work"
38 | means a work that combines Covered Software with other material, in
39 | a separate file or files, that is not Covered Software.
40 |
41 | 1.8. "License"
42 | means this document.
43 |
44 | 1.9. "Licensable"
45 | means having the right to grant, to the maximum extent possible,
46 | whether at the time of the initial grant or subsequently, any and
47 | all of the rights conveyed by this License.
48 |
49 | 1.10. "Modifications"
50 | means any of the following:
51 |
52 | (a) any file in Source Code Form that results from an addition to,
53 | deletion from, or modification of the contents of Covered
54 | Software; or
55 |
56 | (b) any new file in Source Code Form that contains any Covered
57 | Software.
58 |
59 | 1.11. "Patent Claims" of a Contributor
60 | means any patent claim(s), including without limitation, method,
61 | process, and apparatus claims, in any patent Licensable by such
62 | Contributor that would be infringed, but for the grant of the
63 | License, by the making, using, selling, offering for sale, having
64 | made, import, or transfer of either its Contributions or its
65 | Contributor Version.
66 |
67 | 1.12. "Secondary License"
68 | means either the GNU General Public License, Version 2.0, the GNU
69 | Lesser General Public License, Version 2.1, the GNU Affero General
70 | Public License, Version 3.0, or any later versions of those
71 | licenses.
72 |
73 | 1.13. "Source Code Form"
74 | means the form of the work preferred for making modifications.
75 |
76 | 1.14. "You" (or "Your")
77 | means an individual or a legal entity exercising rights under this
78 | License. For legal entities, "You" includes any entity that
79 | controls, is controlled by, or is under common control with You. For
80 | purposes of this definition, "control" means (a) the power, direct
81 | or indirect, to cause the direction or management of such entity,
82 | whether by contract or otherwise, or (b) ownership of more than
83 | fifty percent (50%) of the outstanding shares or beneficial
84 | ownership of such entity.
85 |
86 | 2. License Grants and Conditions
87 | --------------------------------
88 |
89 | 2.1. Grants
90 |
91 | Each Contributor hereby grants You a world-wide, royalty-free,
92 | non-exclusive license:
93 |
94 | (a) under intellectual property rights (other than patent or trademark)
95 | Licensable by such Contributor to use, reproduce, make available,
96 | modify, display, perform, distribute, and otherwise exploit its
97 | Contributions, either on an unmodified basis, with Modifications, or
98 | as part of a Larger Work; and
99 |
100 | (b) under Patent Claims of such Contributor to make, use, sell, offer
101 | for sale, have made, import, and otherwise transfer either its
102 | Contributions or its Contributor Version.
103 |
104 | 2.2. Effective Date
105 |
106 | The licenses granted in Section 2.1 with respect to any Contribution
107 | become effective for each Contribution on the date the Contributor first
108 | distributes such Contribution.
109 |
110 | 2.3. Limitations on Grant Scope
111 |
112 | The licenses granted in this Section 2 are the only rights granted under
113 | this License. No additional rights or licenses will be implied from the
114 | distribution or licensing of Covered Software under this License.
115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a
116 | Contributor:
117 |
118 | (a) for any code that a Contributor has removed from Covered Software;
119 | or
120 |
121 | (b) for infringements caused by: (i) Your and any other third party's
122 | modifications of Covered Software, or (ii) the combination of its
123 | Contributions with other software (except as part of its Contributor
124 | Version); or
125 |
126 | (c) under Patent Claims infringed by Covered Software in the absence of
127 | its Contributions.
128 |
129 | This License does not grant any rights in the trademarks, service marks,
130 | or logos of any Contributor (except as may be necessary to comply with
131 | the notice requirements in Section 3.4).
132 |
133 | 2.4. Subsequent Licenses
134 |
135 | No Contributor makes additional grants as a result of Your choice to
136 | distribute the Covered Software under a subsequent version of this
137 | License (see Section 10.2) or under the terms of a Secondary License (if
138 | permitted under the terms of Section 3.3).
139 |
140 | 2.5. Representation
141 |
142 | Each Contributor represents that the Contributor believes its
143 | Contributions are its original creation(s) or it has sufficient rights
144 | to grant the rights to its Contributions conveyed by this License.
145 |
146 | 2.6. Fair Use
147 |
148 | This License is not intended to limit any rights You have under
149 | applicable copyright doctrines of fair use, fair dealing, or other
150 | equivalents.
151 |
152 | 2.7. Conditions
153 |
154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
155 | in Section 2.1.
156 |
157 | 3. Responsibilities
158 | -------------------
159 |
160 | 3.1. Distribution of Source Form
161 |
162 | All distribution of Covered Software in Source Code Form, including any
163 | Modifications that You create or to which You contribute, must be under
164 | the terms of this License. You must inform recipients that the Source
165 | Code Form of the Covered Software is governed by the terms of this
166 | License, and how they can obtain a copy of this License. You may not
167 | attempt to alter or restrict the recipients' rights in the Source Code
168 | Form.
169 |
170 | 3.2. Distribution of Executable Form
171 |
172 | If You distribute Covered Software in Executable Form then:
173 |
174 | (a) such Covered Software must also be made available in Source Code
175 | Form, as described in Section 3.1, and You must inform recipients of
176 | the Executable Form how they can obtain a copy of such Source Code
177 | Form by reasonable means in a timely manner, at a charge no more
178 | than the cost of distribution to the recipient; and
179 |
180 | (b) You may distribute such Executable Form under the terms of this
181 | License, or sublicense it under different terms, provided that the
182 | license for the Executable Form does not attempt to limit or alter
183 | the recipients' rights in the Source Code Form under this License.
184 |
185 | 3.3. Distribution of a Larger Work
186 |
187 | You may create and distribute a Larger Work under terms of Your choice,
188 | provided that You also comply with the requirements of this License for
189 | the Covered Software. If the Larger Work is a combination of Covered
190 | Software with a work governed by one or more Secondary Licenses, and the
191 | Covered Software is not Incompatible With Secondary Licenses, this
192 | License permits You to additionally distribute such Covered Software
193 | under the terms of such Secondary License(s), so that the recipient of
194 | the Larger Work may, at their option, further distribute the Covered
195 | Software under the terms of either this License or such Secondary
196 | License(s).
197 |
198 | 3.4. Notices
199 |
200 | You may not remove or alter the substance of any license notices
201 | (including copyright notices, patent notices, disclaimers of warranty,
202 | or limitations of liability) contained within the Source Code Form of
203 | the Covered Software, except that You may alter any license notices to
204 | the extent required to remedy known factual inaccuracies.
205 |
206 | 3.5. Application of Additional Terms
207 |
208 | You may choose to offer, and to charge a fee for, warranty, support,
209 | indemnity or liability obligations to one or more recipients of Covered
210 | Software. However, You may do so only on Your own behalf, and not on
211 | behalf of any Contributor. You must make it absolutely clear that any
212 | such warranty, support, indemnity, or liability obligation is offered by
213 | You alone, and You hereby agree to indemnify every Contributor for any
214 | liability incurred by such Contributor as a result of warranty, support,
215 | indemnity or liability terms You offer. You may include additional
216 | disclaimers of warranty and limitations of liability specific to any
217 | jurisdiction.
218 |
219 | 4. Inability to Comply Due to Statute or Regulation
220 | ---------------------------------------------------
221 |
222 | If it is impossible for You to comply with any of the terms of this
223 | License with respect to some or all of the Covered Software due to
224 | statute, judicial order, or regulation then You must: (a) comply with
225 | the terms of this License to the maximum extent possible; and (b)
226 | describe the limitations and the code they affect. Such description must
227 | be placed in a text file included with all distributions of the Covered
228 | Software under this License. Except to the extent prohibited by statute
229 | or regulation, such description must be sufficiently detailed for a
230 | recipient of ordinary skill to be able to understand it.
231 |
232 | 5. Termination
233 | --------------
234 |
235 | 5.1. The rights granted under this License will terminate automatically
236 | if You fail to comply with any of its terms. However, if You become
237 | compliant, then the rights granted under this License from a particular
238 | Contributor are reinstated (a) provisionally, unless and until such
239 | Contributor explicitly and finally terminates Your grants, and (b) on an
240 | ongoing basis, if such Contributor fails to notify You of the
241 | non-compliance by some reasonable means prior to 60 days after You have
242 | come back into compliance. Moreover, Your grants from a particular
243 | Contributor are reinstated on an ongoing basis if such Contributor
244 | notifies You of the non-compliance by some reasonable means, this is the
245 | first time You have received notice of non-compliance with this License
246 | from such Contributor, and You become compliant prior to 30 days after
247 | Your receipt of the notice.
248 |
249 | 5.2. If You initiate litigation against any entity by asserting a patent
250 | infringement claim (excluding declaratory judgment actions,
251 | counter-claims, and cross-claims) alleging that a Contributor Version
252 | directly or indirectly infringes any patent, then the rights granted to
253 | You by any and all Contributors for the Covered Software under Section
254 | 2.1 of this License shall terminate.
255 |
256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all
257 | end user license agreements (excluding distributors and resellers) which
258 | have been validly granted by You or Your distributors under this License
259 | prior to termination shall survive termination.
260 |
261 | ************************************************************************
262 | * *
263 | * 6. Disclaimer of Warranty *
264 | * ------------------------- *
265 | * *
266 | * Covered Software is provided under this License on an "as is" *
267 | * basis, without warranty of any kind, either expressed, implied, or *
268 | * statutory, including, without limitation, warranties that the *
269 | * Covered Software is free of defects, merchantable, fit for a *
270 | * particular purpose or non-infringing. The entire risk as to the *
271 | * quality and performance of the Covered Software is with You. *
272 | * Should any Covered Software prove defective in any respect, You *
273 | * (not any Contributor) assume the cost of any necessary servicing, *
274 | * repair, or correction. This disclaimer of warranty constitutes an *
275 | * essential part of this License. No use of any Covered Software is *
276 | * authorized under this License except under this disclaimer. *
277 | * *
278 | ************************************************************************
279 |
280 | ************************************************************************
281 | * *
282 | * 7. Limitation of Liability *
283 | * -------------------------- *
284 | * *
285 | * Under no circumstances and under no legal theory, whether tort *
286 | * (including negligence), contract, or otherwise, shall any *
287 | * Contributor, or anyone who distributes Covered Software as *
288 | * permitted above, be liable to You for any direct, indirect, *
289 | * special, incidental, or consequential damages of any character *
290 | * including, without limitation, damages for lost profits, loss of *
291 | * goodwill, work stoppage, computer failure or malfunction, or any *
292 | * and all other commercial damages or losses, even if such party *
293 | * shall have been informed of the possibility of such damages. This *
294 | * limitation of liability shall not apply to liability for death or *
295 | * personal injury resulting from such party's negligence to the *
296 | * extent applicable law prohibits such limitation. Some *
297 | * jurisdictions do not allow the exclusion or limitation of *
298 | * incidental or consequential damages, so this exclusion and *
299 | * limitation may not apply to You. *
300 | * *
301 | ************************************************************************
302 |
303 | 8. Litigation
304 | -------------
305 |
306 | Any litigation relating to this License may be brought only in the
307 | courts of a jurisdiction where the defendant maintains its principal
308 | place of business and such litigation shall be governed by laws of that
309 | jurisdiction, without reference to its conflict-of-law provisions.
310 | Nothing in this Section shall prevent a party's ability to bring
311 | cross-claims or counter-claims.
312 |
313 | 9. Miscellaneous
314 | ----------------
315 |
316 | This License represents the complete agreement concerning the subject
317 | matter hereof. If any provision of this License is held to be
318 | unenforceable, such provision shall be reformed only to the extent
319 | necessary to make it enforceable. Any law or regulation which provides
320 | that the language of a contract shall be construed against the drafter
321 | shall not be used to construe this License against a Contributor.
322 |
323 | 10. Versions of the License
324 | ---------------------------
325 |
326 | 10.1. New Versions
327 |
328 | Mozilla Foundation is the license steward. Except as provided in Section
329 | 10.3, no one other than the license steward has the right to modify or
330 | publish new versions of this License. Each version will be given a
331 | distinguishing version number.
332 |
333 | 10.2. Effect of New Versions
334 |
335 | You may distribute the Covered Software under the terms of the version
336 | of the License under which You originally received the Covered Software,
337 | or under the terms of any subsequent version published by the license
338 | steward.
339 |
340 | 10.3. Modified Versions
341 |
342 | If you create software not governed by this License, and you want to
343 | create a new license for such software, you may create and use a
344 | modified version of this License if you rename the license and remove
345 | any references to the name of the license steward (except to note that
346 | such modified license differs from this License).
347 |
348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary
349 | Licenses
350 |
351 | If You choose to distribute Source Code Form that is Incompatible With
352 | Secondary Licenses under the terms of this version of the License, the
353 | notice described in Exhibit B of this License must be attached.
354 |
355 | Exhibit A - Source Code Form License Notice
356 | -------------------------------------------
357 |
358 | This Source Code Form is subject to the terms of the Mozilla Public
359 | License, v. 2.0. If a copy of the MPL was not distributed with this
360 | file, You can obtain one at http://mozilla.org/MPL/2.0/.
361 |
362 | If it is not possible or desirable to put the notice in a particular
363 | file, then You may include the notice in a location (such as a LICENSE
364 | file in a relevant directory) where a recipient would be likely to look
365 | for such a notice.
366 |
367 | You may add additional accurate notices of copyright ownership.
368 |
369 | Exhibit B - "Incompatible With Secondary Licenses" Notice
370 | ---------------------------------------------------------
371 |
372 | This Source Code Form is "Incompatible With Secondary Licenses", as
373 | defined by the Mozilla Public License, v. 2.0.
374 |
--------------------------------------------------------------------------------