├── README.md
├── app.js
├── app.json
├── app.wxss
├── images
├── 0.jpg
├── 1.jpg
└── 2.jpg
├── pages
├── contest
│ ├── summary.js
│ ├── summary.wxml
│ ├── summary.wxss
│ ├── test.js
│ ├── test.wxml
│ └── test.wxss
├── index
│ ├── index.js
│ ├── index.wxml
│ └── index.wxss
└── logs
│ ├── logs.js
│ ├── logs.json
│ ├── logs.wxml
│ └── logs.wxss
├── project.config.json
└── utils
└── util.js
/README.md:
--------------------------------------------------------------------------------
1 | # WeChart
2 | 微信小程序在线考试,支持多选题和单选题。
3 |
4 | Online Test on WECHAT mini programme aka ``WMP`` with multiple choice and multiple choices.
5 |
6 | `` single selection and multiple selection ``
7 |
--------------------------------------------------------------------------------
/app.js:
--------------------------------------------------------------------------------
1 | const host = "https://page404.top";
2 | //const host = "http://localhost:64028";
3 |
4 | App({
5 | Sync: function (code, userInfo) {
6 | wx.request({
7 | url: host + "/Home/Code/" + code, method: "POST", data: { userInfo: userInfo },
8 | success: sync => {
9 | if (sync.data.success) {
10 | this.globalData.openId = sync.data.openId;
11 | if (this.globalData.openId) {
12 | wx.setStorageSync('openId', this.globalData.openId); console.log("Got openId:" + sync.data.openId);
13 |
14 | if(sync.data.currentID == -1){
15 | wx.reLaunch({ url: "/pages/contest/summary" });
16 | }else{
17 | this.globalData.currentIndex = sync.data.currentID;
18 | wx.reLaunch({ url: "/pages/contest/test" });
19 | }
20 | }
21 | }
22 | },
23 | fail: () => { console.log("Home/Code Fail"); }
24 | })
25 | },
26 | Login: function (callback = true) {
27 | console.log(callback);
28 | wx.login({
29 | success: res => {// 获取用户信息
30 | var code = res.code; console.log(code);
31 | wx.getSetting({
32 | success: res => {
33 | var that = this;
34 | if (res.authSetting['scope.userInfo']) {
35 | // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
36 | wx.getUserInfo({
37 | success: res => {
38 | console.log(res);
39 | // 可以将 res 发送给后台解码出 unionId
40 | this.globalData.userInfo = res.userInfo;
41 | // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
42 | // 所以此处加入 callback 以防止这种情况
43 |
44 | if (this.userInfoReadyCallback && callback) {
45 | this.userInfoReadyCallback(res);
46 | }
47 | console.log("bypass callback");
48 | this.Sync(code, res.userInfo);
49 | }
50 | });
51 | }
52 | }
53 | });
54 | }
55 | });//End of wxLogin
56 | },
57 | onLaunch: function () {
58 | this.globalData.openId = wx.getStorageSync('openId') || [];
59 | console.log("onlaunch : openId ="+this.globalData.openId);
60 | this.Login(true);
61 | },
62 | globalData: {
63 | userInfo: null,
64 | currentIndex: 0,
65 | openId: "小行星"
66 | }
67 | })
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "pages": [
3 | "pages/index/index",
4 | "pages/logs/logs",
5 | "pages/contest/test",
6 | "pages/contest/summary"
7 | ],
8 | "window": {
9 | "backgroundTextStyle": "light",
10 | "navigationBarBackgroundColor": "#fff",
11 | "navigationBarTitleText": "WeChat",
12 | "navigationBarTextStyle": "black"
13 | },
14 | "networkTimeout": {
15 | "request": 20000,
16 | "connectSocket": 20000,
17 | "uploadFile": 20000,
18 | "downloadFile": 20000
19 | }
20 | }
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/images/0.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/charset/WeChart/f313bf3ea87286e18692a8fe5e084a17045b4fcd/images/0.jpg
--------------------------------------------------------------------------------
/images/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/charset/WeChart/f313bf3ea87286e18692a8fe5e084a17045b4fcd/images/1.jpg
--------------------------------------------------------------------------------
/images/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/charset/WeChart/f313bf3ea87286e18692a8fe5e084a17045b4fcd/images/2.jpg
--------------------------------------------------------------------------------
/pages/contest/summary.js:
--------------------------------------------------------------------------------
1 | Page({
2 | data:{
3 | frameHall:[]
4 | },
5 | onShow: function (loadEvent) {
6 | //判断题目是不是都做完了
7 | this.ShowSummary();
8 | },
9 | MainPage: function () {
10 | wx.reLaunch({ url: "/pages/index/index" });
11 | },
12 | ShowSummary: function () {
13 | let that = this; let app = getApp();
14 | wx.request({
15 | url: "https://page404.top/Home/Summary/",
16 | method: "POST",
17 | data: { openId: app.globalData.openId },
18 | success: succ => {
19 | console.log(succ.data);
20 | var UI = {};
21 | if (succ.data.success) {
22 | var rt = succ.data.summary.right, tt = succ.data.summary.total;
23 | if (rt == 0 && tt == 0) { tt = 100; }
24 | that.setData({ 'right': rt });
25 | that.setData({ 'total': tt });
26 |
27 | that.setData({'frameHall' : succ.data.topUsers});
28 | } else {
29 | that.setData({ 'total': 0 });
30 | }
31 | },
32 | fail : ()=>{
33 | that.setData({ 'total': 0 });
34 | }
35 | })
36 | },
37 | data: {
38 | canShowSummary: false,
39 | right: 0,
40 | total: 100
41 | }
42 | })
--------------------------------------------------------------------------------
/pages/contest/summary.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 你的得分
4 |
5 | {{right}}/{{total}}
6 | 你还未完成本次测试
7 |
8 |
9 | 名人堂
10 |
11 |
12 | {{item.nickname}}
13 | {{item.score}}
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/pages/contest/summary.wxss:
--------------------------------------------------------------------------------
1 | /* pages/contest/summary.wxss */
2 |
3 | .yourProcess {
4 | text-align: center;
5 | color: darkslategray;
6 | margin-top: 64px;
7 | font-size: 32pt;
8 | /*background-color: darkkhaki;*/
9 | }
10 |
11 | .yourScore {
12 | text-align: center;
13 | color: red;
14 | margin-top: 10px;
15 | /*background-color: darkkhaki;*/
16 | }
17 |
18 | .floatImage {
19 | position: fixed;
20 | top: 1px;
21 | z-index: -1;
22 | left: 0px;
23 | height: 100%;
24 | width: 100%;
25 | }
26 |
27 | .frameHall {
28 | text-align: center;
29 | margin-top: 32px;
30 | }
31 |
32 | .detail {
33 | margin-top: 10px;
34 | margin-left: 32px;
35 | margin-right:32px;
36 | margin-bottom: 10px;
37 | text-align: left;
38 | height:58px;
39 | }
40 | .userinfo-avatar {
41 | width: 64px;
42 | height: 64px;
43 | margin-left: 32px;
44 | border-radius: 50%;
45 | float: left;
46 | }
47 | .nickName{
48 | width: 128px;
49 | margin-top:16px;
50 | margin-left:8px;
51 | overflow:hidden;
52 | float:left;
53 | }
54 | .score{
55 | /*width:128px;*/
56 | margin-top:16px;
57 | margin-left:8px;
58 | float:left;
59 | clear:right;
60 | }
61 | .fixedButton0 {
62 | position: fixed;
63 | bottom: 0px;
64 | width: 100%;
65 | }
--------------------------------------------------------------------------------
/pages/contest/test.js:
--------------------------------------------------------------------------------
1 | const host = "https://page404.top";
2 | //const host = "http://localhost:64028";
3 |
4 | const app = getApp();
5 |
6 | Page({
7 | data: {
8 | ContestItem: {
9 | branchId: -1,
10 | content: "[题干位置]",
11 | isRichText: false,
12 | branchCount: 4,
13 | radioClass: 'show',
14 | checkboxClass: 'hide',
15 | answerClass: 'hide',
16 | testType: 0,
17 | contentAnswer: ''
18 | },
19 | radioItems: [
20 | { name: "A", value: "选项 A", checked: false }, { name: "B", value: "选项 B", checked: false },
21 | { name: "C", value: "选项 C", checked: false }, { name: "D", value: "选项 D", checked: false }
22 | ],
23 | checkboxItems: [
24 | { name: "A", value: "选项 A", checked: false }, { name: "B", value: "选项 B", checked: false },
25 | { name: "C", value: "选项 C", checked: false }, { name: "D", value: "选项 D", checked: false }
26 | ]
27 | },
28 | Next: function (e) {
29 | switch (this.data.testType) {
30 | case "0"://单选题
31 | for (var i = 0; i < this.data.ContestItem.branchCount; i++) {
32 | if (this.data.radioItems[i].checked) {
33 | this.Submit(i);
34 | return;
35 | }
36 | }
37 | wx.showToast({ title: '什么都没选...', icon: 'loading', duration: 500 });
38 | break;
39 | case "1"://多选题
40 | var selected = 0;
41 | for (var i = 0; i < this.data.ContestItem.branchCount; i++) {
42 | if (this.data.checkboxItems[i].checked) selected += (1 << i);
43 | console.log(selected);
44 | }
45 | console.log("SELECTED: " + selected);
46 | if (selected > 0) {
47 | this.Submit(selected);
48 | return;
49 | }
50 | wx.showToast({ title: '什么都没选...', icon: 'loading', duration: 500 });
51 | break;
52 | }
53 | },
54 | Previous: function (e) {
55 | let app = getApp();
56 | if (app.globalData.currentIndex == 0) return;
57 | app.globalData.currentIndex--;
58 | this.showTestPage();
59 | },
60 | Submit: function (choice) {
61 | let THAT = this; console.log(THAT);
62 | wx.getLocation({
63 | type: "wgs84",
64 | success: loc => {
65 | let p = THAT; console.log(p);
66 | wx.request({
67 | url: "https://page404.top/Contest/Submit/" + app.globalData.currentIndex, method: "POST",
68 | data: { OpenID: app.globalData.openId, Latitude: loc.latitude, Longitude: loc.longitude, Choice: choice },
69 | success: el => {
70 | var res = el.data; console.log(el); let Q = p;
71 | if (res.noMore) {
72 | wx.showModal({
73 | title: '提示',
74 | content: '提交本次测试并查看结果?',
75 | success: function (res) {
76 | if (res.confirm) {
77 | wx.request({
78 | url: host + "/Contest/Deal/",
79 | method: "POST", data: { openId: app.globalData.openId },
80 | success: deal => {
81 | if (deal.data == 1)
82 | wx.reLaunch({ url: '/pages/contest/summary' });
83 | else {
84 | wx.showModal({
85 | title: "DealUnsuccessful", content: "似乎还没法提交呢..",
86 | showCancel: false, confirmText: "好吧"
87 | });
88 | }
89 | },
90 | fail: () => {
91 | wx.showModal({
92 | title: "DealFail", content: "似乎小好又开小差了.",
93 | showCancel: false, confirmText: '朕怎知道'
94 | });
95 | }
96 | });
97 | }
98 | }
99 | });//endof ShowModal
100 |
101 | } else {
102 | if (res.rowsAffected >= 0) {
103 | app.globalData.currentIndex++; Q.showTestPage();
104 | } else {
105 | wx.showModal({
106 | title: "上传选择答案错误", content: "似乎小好又开小差了.",
107 | showCancel: false, confirmText: '朕怎知道'
108 | });
109 | }
110 | }
111 | },//endof getlocation.success.request.success
112 | fail: function () {
113 | wx.showModal({
114 | title: "连接错误", showCancel: false, confirmText: "朕知道了",
115 | content: "似乎无法连接到服务器. 你可以:查看你的网路设置/联系作者是否欠费."
116 | });
117 | }
118 | });//endof getlocation.success.request
119 | },//endof getlocation.success
120 | fail: () => {
121 | wx.reLaunch("/pages/index/index");
122 | }
123 | });
124 | },
125 | BindChangeRadio: function (e) {
126 | var index = e.detail.value.charCodeAt() - 'A'.charCodeAt(), changeUI = {};
127 | for (var i = 0; i < this.data.ContestItem.branchCount; i++) {
128 | changeUI['radioItems[' + i + '].checked'] = (i == index);
129 | }
130 | this.setData(changeUI);
131 | },
132 | BindChangeCheckbox: function (e) {
133 | var UI = {}, status = [0, 1, 2, 3], now = e.detail.value;
134 | console.log(now);
135 | for (var i = 0; i < e.detail.value.length; i++) {
136 | now[i] = e.detail.value[i].charCodeAt() - 'A'.charCodeAt();
137 | UI['checkboxItems[' + now[i] + '].checked'] = true;
138 | }
139 | console.log(now);
140 | var remain = status.filter(el => !now.includes(el));
141 | for (var i = 0; i < remain.length; i++) {
142 | UI['checkboxItems[' + remain[i] + '].checked'] = false;
143 | }
144 | console.log(remain);
145 | console.log(UI);
146 | this.setData(UI);
147 | },
148 | showTestPage: function () {
149 | var that = this;
150 | if (app.globalData.openId == null) return;
151 | console.log("Enter showTestPage request");
152 | wx.request({
153 | url: "https://page404.top/Contest/Test/" + app.globalData.currentIndex,
154 | method: "POST", data: { openId: app.globalData.openId },
155 | success: function (g) {
156 | var res = g.data, UI = {};
157 | console.log(g);
158 | if (res == null) return;
159 | that.setData({ 'ContestItem.content': res.content });
160 | that.setData({ 'ContestItem.branchId': res.branchID });
161 | that.setData({ 'testType': res.testType });
162 | switch (res.testType) {
163 | case '0':
164 | that.setData({ 'radioItems[0].value': 'A: ' + res.a });
165 | that.setData({ 'radioItems[1].value': 'B: ' + res.b });
166 | that.setData({ 'radioItems[2].value': 'C: ' + res.c });
167 | that.setData({ 'radioItems[3].value': 'D: ' + res.d });
168 | that.ensureView(true, false, false);
169 | if (res.chosen == null) {
170 | that.ResetCurrent(true, false, false);
171 | } else {
172 | UI['radioItems[' + res.chosen + '].checked'] = true;
173 | that.setData(UI);
174 | }
175 | break;
176 | case '1':
177 | that.setData({ 'checkboxItems[0].value': 'A: ' + res.a });
178 | that.setData({ 'checkboxItems[1].value': 'B: ' + res.b });
179 | that.setData({ 'checkboxItems[2].value': 'C: ' + res.c });
180 | that.setData({ 'checkboxItems[3].value': 'D: ' + res.d });
181 | that.ensureView(false, true, false);
182 | if (res.chosen == null) {
183 | that.ResetCurrent(false, true, false);
184 | } else {
185 | var array = [
186 | res.chosen & 0x01,
187 | (res.chosen & 0x02) >> 1,
188 | (res.chosen & 0x04) >> 2,
189 | (res.chosen & 0x08) >> 3
190 | ]
191 | for (var i = 0; i < array.length; i++) {
192 | if (array[i] > 0)
193 | UI['checkboxItems[' + i + '].checked'] = true;
194 | that.setData(UI);
195 | }
196 | }
197 | break;
198 | }
199 | },
200 | fail: function (g) {
201 | that.setData({ 'ContestItem.content': "似乎无法找到题目" });
202 | }
203 | })
204 | },
205 | ResetCurrent: function (radio, checkbox, textbox) {
206 | var count = 0, UI = {};
207 | if (radio) count++; if (checkbox) count++; if (textbox) count++;
208 | if (count != 1) {
209 | radio = true; checkbox = false; textbox = false;
210 | }
211 | if (radio) {
212 | UI['radioItems[0].checked'] = false;
213 | UI['radioItems[1].checked'] = false;
214 | UI['radioItems[2].checked'] = false;
215 | UI['radioItems[3].checked'] = false;
216 | }
217 | if (checkbox) {
218 | UI['checkboxItems[0].checked'] = false;
219 | UI['checkboxItems[1].checked'] = false;
220 | UI['checkboxItems[2].checked'] = false;
221 | UI['checkboxItems[3].checked'] = false;
222 | }
223 | if (textbox) {
224 | UI['contentAnswer'] = '';
225 | }
226 | this.setData(UI);
227 | },
228 | ensureView: function (radio, checkbox, textbox) {
229 | var count = 0, UI = {};
230 | if (radio) count++; if (checkbox) count++; if (textbox) count++;
231 | if (count != 1) {
232 | radio = true; checkbox = false; textbox = false;
233 | }
234 | UI["ContestItem.radioClass"] = radio ? "show" : "hide";
235 | UI["ContestItem.checkboxClass"] = checkbox ? "show" : "hide";
236 | UI["ContestItem.textboxClass"] = textbox ? "show" : "hide";
237 | this.setData(UI);
238 | },
239 | onShow: function (e) {
240 | this.showTestPage();
241 | }
242 | })
--------------------------------------------------------------------------------
/pages/contest/test.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{testTypePrompt}}
4 |
5 | 第{{ContestItem.branchId + 1}}题.
6 | {{ContestItem.content}}
7 |
8 |
9 |
10 |
12 |
13 |
14 |
15 |
16 |
17 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/pages/contest/test.wxss:
--------------------------------------------------------------------------------
1 | button {
2 | margin: 5px, 5px, 5px, 5px;
3 | }
4 |
5 | .content {
6 | margin-top: 30px;
7 | margin-left: 10px;
8 | margin-right: 10px;
9 | font-size: 18pt;
10 | line-height: 30pt;
11 | }
12 |
13 | .index {
14 | color: red;
15 | }
16 |
17 | .options {
18 | color: darkslategray;
19 | }
20 |
21 | .buttonGroup {
22 | margin-top: 30px;
23 | margin-bottom: 10px;
24 | }
25 |
26 | .fixedButton0 {
27 | position: fixed;
28 | bottom: 45px;
29 | width: 100%;
30 | }
31 | .fixedButton1 {
32 | position: fixed;
33 | bottom: 56px;
34 | width: 100%;
35 | }
36 | .fixedButton2 {
37 | position: fixed;
38 | bottom: 0;
39 | width: 100%;
40 | }
41 | .show{
42 | display:inherit;
43 | }
44 | .hide{
45 | display:none;
46 | }
47 |
48 | .floatImage {
49 | position: fixed;
50 | top: 1px;
51 | z-index: -1;
52 | left: 0px;
53 | height: 100%;
54 | width: 100%;
55 | }
--------------------------------------------------------------------------------
/pages/index/index.js:
--------------------------------------------------------------------------------
1 | const app = getApp();
2 |
3 | Page({
4 | data: {
5 | motto: '《架构简明测试》',
6 | userInfo: {}, hasUserInfo: false, canIUse: wx.canIUse('button.open-type.getUserInfo'),
7 | cmdStartDisabled: true, cmdSummaryDisabled: true, cmdResetUserDisabled: true
8 | },
9 | //事件处理函
10 | ShowScore: function () { wx.reLaunch({ url: '/pages/contest/summary' }); },
11 | ResetUser: function () {
12 | wx.showModal({
13 | title: '重要提示', content: '点击投诉按钮将会清空你的成绩!',
14 | success: function (res) {
15 | if (res.confirm) {
16 | wx.request({
17 | url: "https://page404.top/Home/Reset/",
18 | method: "POST", data: { openId: app.globalData.openId },
19 | success: deal => {
20 | if (deal.data.userInfoDeleted == 1) {
21 | wx.removeStorageSync('openId');
22 | wx.reLaunch({ url: '/pages/index/index' });
23 | } else {
24 | wx.showModal({
25 | title: "ResetUnsuccessful", content: "似乎还没法提交呢..",
26 | showCancel: false, confirmText: "好吧"
27 | });
28 | }
29 | },
30 | fail: () => {
31 | wx.showModal({
32 | title: "ResetFail", content: "似乎小好又开小差了.",
33 | showCancel: false, confirmText: '朕怎知道'
34 | });
35 | }
36 | });
37 | }
38 | }
39 | });//endof ShowModal
40 | },
41 | onShow: function () {
42 | let that = this;
43 | if (app.globalData.openId.length == 0) return;
44 | wx.request({
45 | url: "https://page404.top/Home/Summary", method: "POST",
46 | data: { openId: app.globalData.openId },
47 | success: summary => {
48 | console.log(summary);
49 | if (summary.data.success) {
50 | that.resetView(summary.data.currentIndex < 0, summary.data.currentIndex >= 0);
51 | } else {
52 | that.resetView();
53 | }
54 | },
55 | fail: () => { that.resetView(); }
56 | });
57 | },
58 | resetView: function (start = true, summary = true) {
59 | this.setData({ 'cmdStartDisabled': start });
60 | this.setData({ 'cmdSummaryDisabled': summary });
61 | },
62 | onLoad: function () {
63 | if (app.globalData.userInfo) {
64 | this.setData({ userInfo: app.globalData.userInfo, hasUserInfo: true }); console.log("Load Type A");
65 | } else if (this.data.canIUse) {
66 | // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
67 | // 所以此处加入 callback 以防止这种情况
68 | app.userInfoReadyCallback = res => {
69 | this.setData({ userInfo: res.userInfo, hasUserInfo: true }); console.log("Load Type B");
70 | }
71 | } else {
72 | // 在没有 open-type=getUserInfo 版本的兼容处理
73 | wx.getUserInfo({
74 | success: res => {
75 | app.globalData.userInfo = res.userInfo;
76 | this.setData({ userInfo: res.userInfo, hasUserInfo: true }); console.log("Load Type C");
77 | }
78 | });
79 | }
80 | },
81 | getUserInfo: function (e) {
82 | app.globalData.userInfo = e.detail.userInfo
83 | this.setData({ userInfo: e.detail.userInfo, hasUserInfo: true });
84 | wx.login({
85 | success: res => {
86 | app.Sync(res.code, e.detail.userInfo);
87 | }
88 | })
89 | },
90 | StartTest: function () {
91 | wx.reLaunch({ url: "/pages/contest/test" });
92 | }
93 | })
94 |
--------------------------------------------------------------------------------
/pages/index/index.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | 欢迎{{userInfo.nickName}}{{userInfo.gender == '1' ? "先生" : "女士"}}
9 |
10 |
11 |
12 | {{motto}}
13 |
14 |
15 | 需要您的实时地理位置、头像信息用于统计成绩,请允许开启
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | https://page404.top/
25 | ICPS:苏ICP备18008020号-1
26 | 架构状元狼
27 |
28 |
29 |
--------------------------------------------------------------------------------
/pages/index/index.wxss:
--------------------------------------------------------------------------------
1 | /**index.wxss**/
2 |
3 | .userinfo {
4 | display: flex;
5 | flex-direction: column;
6 | align-items: center;
7 | }
8 |
9 | .userinfo-avatar {
10 | width: 128rpx;
11 | height: 128rpx;
12 | margin: 20rpx;
13 | border-radius: 50%;
14 | }
15 |
16 | .userinfo-nickname {
17 | color: navy;
18 | }
19 |
20 | .usermotto {
21 | margin-top: 3px;
22 | text-align: center;
23 | }
24 |
25 | .functions {
26 | margin-top: 100px;
27 | margin-bottom: 100px;
28 | }
29 |
30 | .floatImage {
31 | position: fixed;
32 | top: 100px;
33 | z-index: -1;
34 | left: 0px;
35 | height: 100%;
36 | width: 100%;
37 | }
38 |
39 | .bottom {
40 | position: fixed;
41 | bottom: 5px;
42 | }
43 |
44 | .webref {
45 | text-align: center;
46 | color: darkgray;
47 | font-size: 8pt;
48 | font-style: underline;
49 | margin-bottom: 1px;
50 | display: block;
51 | }
52 |
53 | .icps {
54 | text-align: center;
55 | color: gray;
56 | font-size: 9pt;
57 | margin-bottom: 1px;
58 | display: block;
59 | }
60 |
61 | .rm {
62 | text-align: center;
63 | color: black;
64 | font-size: 9pt;
65 | display: block;
66 | }
67 |
--------------------------------------------------------------------------------
/pages/logs/logs.js:
--------------------------------------------------------------------------------
1 | //logs.js
2 | const util = require('../../utils/util.js')
3 |
4 | Page({
5 | data: {
6 | logs: []
7 | },
8 | onLoad: function () {
9 | this.setData({
10 | logs: (wx.getStorageSync('logs') || []).map(log => {
11 | return util.formatTime(new Date(log))
12 | })
13 | })
14 | }
15 | })
16 |
--------------------------------------------------------------------------------
/pages/logs/logs.json:
--------------------------------------------------------------------------------
1 | {
2 | "navigationBarTitleText": "查看启动日志"
3 | }
--------------------------------------------------------------------------------
/pages/logs/logs.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{index + 1}}. {{log}}
5 |
6 |
7 |
--------------------------------------------------------------------------------
/pages/logs/logs.wxss:
--------------------------------------------------------------------------------
1 | .log-list {
2 | display: flex;
3 | flex-direction: column;
4 | padding: 40rpx;
5 | }
6 | .log-item {
7 | margin: 10rpx;
8 | }
9 |
--------------------------------------------------------------------------------
/project.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "项目配置文件。",
3 | "setting": {
4 | "urlCheck": true,
5 | "es6": true,
6 | "postcss": true,
7 | "minified": true,
8 | "newFeature": true
9 | },
10 | "compileType": "miniprogram",
11 | "libVersion": "1.9.90",
12 | "appid": "wx11dfc6c8d337ee1a",
13 | "projectname": "WeChart",
14 | "isGameTourist": false,
15 | "condition": {
16 | "search": {
17 | "current": -1,
18 | "list": []
19 | },
20 | "conversation": {
21 | "current": -1,
22 | "list": []
23 | },
24 | "game": {
25 | "currentL": -1,
26 | "list": []
27 | },
28 | "miniprogram": {
29 | "current": -1,
30 | "list": []
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/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: formatTime
19 | }
20 |
--------------------------------------------------------------------------------