|
|
@@ -5,7 +5,7 @@ const app = getApp();
|
|
5
|
5
|
var times = 1;
|
|
6
|
6
|
var pageIndex = 0;
|
|
7
|
7
|
var QuestionItem = [];
|
|
8
|
|
-var isAndroid=false;
|
|
|
8
|
+var isAndroid = false;
|
|
9
|
9
|
const waitTime = ["", "10秒钟", "15秒钟", "20秒钟", "25秒钟", "半分钟", "35秒钟", "40秒钟", "45秒钟"];
|
|
10
|
10
|
|
|
11
|
11
|
Page({
|
|
|
@@ -18,10 +18,10 @@ Page({
|
|
18
|
18
|
PageNumber: 1,
|
|
19
|
19
|
PageCount: 60,
|
|
20
|
20
|
IsFinished: false,
|
|
21
|
|
- arrPage:[],
|
|
22
|
|
- ShowLoading:false,
|
|
|
21
|
+ arrPage: [],
|
|
|
22
|
+ ShowLoading: false,
|
|
23
|
23
|
},
|
|
24
|
|
- onLoad: function(options) {
|
|
|
24
|
+ onLoad: function (options) {
|
|
25
|
25
|
var id = options.id;
|
|
26
|
26
|
this.setData({
|
|
27
|
27
|
Containnerheight: server.getWindowHeight(),
|
|
|
@@ -35,10 +35,10 @@ Page({
|
|
35
|
35
|
|
|
36
|
36
|
isAndroid = false;
|
|
37
|
37
|
if (app.globalData.systemInfo.system && app.globalData.systemInfo.system.indexOf("Android") >= 0)
|
|
38
|
|
- isAndroid=true;
|
|
|
38
|
+ isAndroid = true;
|
|
39
|
39
|
|
|
40
|
40
|
},
|
|
41
|
|
- getDetail: function(id) {
|
|
|
41
|
+ getDetail: function (id) {
|
|
42
|
42
|
var item;
|
|
43
|
43
|
var data = wx.getStorageSync('QuestionTypeList');
|
|
44
|
44
|
for (var i = 0; i < data.length; i++) {
|
|
|
@@ -55,66 +55,73 @@ Page({
|
|
55
|
55
|
QuestionTypeItem: item,
|
|
56
|
56
|
});
|
|
57
|
57
|
},
|
|
58
|
|
- gotoAnswer: function(e) {
|
|
|
58
|
+ gotoAnswer: function (e) {
|
|
59
|
59
|
wx.navigateTo({
|
|
60
|
60
|
url: '../main/answer',
|
|
61
|
61
|
});
|
|
62
|
62
|
},
|
|
63
|
|
- getFinish: function() {
|
|
|
63
|
+ getFinish: function () {
|
|
64
|
64
|
this.setData({
|
|
65
|
65
|
IsFinished: true,
|
|
66
|
66
|
});
|
|
67
|
67
|
this.getList(this.data.ID);
|
|
68
|
68
|
},
|
|
69
|
69
|
|
|
70
|
|
- getList: function(id) {
|
|
|
70
|
+ getList: function (id) {
|
|
71
|
71
|
var that = this;
|
|
72
|
72
|
var pageNum = that.data.PageNumber;
|
|
73
|
73
|
var QuestionTypeCategory = 3;
|
|
74
|
74
|
if (that.data.filter == "horizontal")
|
|
75
|
75
|
QuestionTypeCategory = 2;
|
|
76
|
76
|
pageIndex = 0;
|
|
77
|
|
- server.getLocalHost(function() {
|
|
78
|
|
- server.getData('GetQuestionTypesPrint?ID=' + id + '&QuestionTypeCategory=' + QuestionTypeCategory + '&PageNum=' + pageNum, function(data) {
|
|
79
|
|
- //console.log("UserInfo:" + data);
|
|
80
|
|
- if (data) {
|
|
81
|
|
- that.setData({
|
|
82
|
|
- ShowLoading:true,
|
|
83
|
|
- arrPage: [],
|
|
84
|
|
- WaitTime: waitTime[that.data.PageNumber],
|
|
85
|
|
- });
|
|
86
|
77
|
|
|
87
|
|
- QuestionItem = data;
|
|
88
|
|
-
|
|
89
|
|
- if (isAndroid) {
|
|
90
|
|
- var ctx = wx.createCanvasContext("Canvas", that);
|
|
91
|
|
- ctx.fillRect(0, 0, 1050, 1485);
|
|
92
|
|
- ctx.draw(true, function (n) {
|
|
93
|
|
- wx.canvasToTempFilePath({
|
|
94
|
|
- x: 0,
|
|
95
|
|
- y: 0,
|
|
96
|
|
- width: 2100,
|
|
97
|
|
- height: 2970,
|
|
98
|
|
- canvasId: 'Canvas',
|
|
99
|
|
- success: function (res2) {
|
|
100
|
|
- that.saveImage();
|
|
101
|
|
- }
|
|
102
|
|
- })
|
|
103
|
|
- });
|
|
104
|
|
- }
|
|
105
|
|
- else{
|
|
106
|
|
- that.saveImage();
|
|
107
|
|
- }
|
|
|
78
|
+ server.getData('GetQuestionTypesPrint?ID=' + id + '&QuestionTypeCategory=' + QuestionTypeCategory + '&PageNum=' + pageNum, function (data) {
|
|
|
79
|
+ //console.log("UserInfo:" + data);
|
|
|
80
|
+ if (data) {
|
|
|
81
|
+ that.setData({
|
|
|
82
|
+ ShowLoading: true,
|
|
|
83
|
+ arrPage: [],
|
|
|
84
|
+ WaitTime: waitTime[that.data.PageNumber],
|
|
|
85
|
+ });
|
|
|
86
|
+
|
|
|
87
|
+ QuestionItem = data;
|
|
|
88
|
+
|
|
|
89
|
+ if (isAndroid) {
|
|
|
90
|
+ var ctx = wx.createCanvasContext("Canvas", that);
|
|
|
91
|
+ ctx.fillRect(0, 0, 1050, 1485);
|
|
|
92
|
+ ctx.draw(true, function (n) {
|
|
|
93
|
+ wx.canvasToTempFilePath({
|
|
|
94
|
+ x: 0,
|
|
|
95
|
+ y: 0,
|
|
|
96
|
+ width: 2100,
|
|
|
97
|
+ height: 2970,
|
|
|
98
|
+ canvasId: 'Canvas',
|
|
|
99
|
+ success: function (res2) {
|
|
|
100
|
+ that.saveImage();
|
|
|
101
|
+ }
|
|
|
102
|
+ })
|
|
|
103
|
+ });
|
|
108
|
104
|
}
|
|
109
|
|
- });
|
|
|
105
|
+ else {
|
|
|
106
|
+ that.saveImage();
|
|
|
107
|
+ }
|
|
|
108
|
+ }
|
|
110
|
109
|
});
|
|
|
110
|
+
|
|
111
|
111
|
},
|
|
112
|
|
- saveLocalData:function(data){
|
|
113
|
|
- var list = wx.getStorageSync("QuestionList");
|
|
|
112
|
+ saveLocalData: function (data) {
|
|
|
113
|
+ var list = wx.getStorageSync("AnswerList");
|
|
114
|
114
|
if (list && list.length > 0) {
|
|
115
|
|
- var id = list[list.length - 1].AnswerID + 1;
|
|
116
|
|
- if (id >= 100) {
|
|
117
|
|
- id = 1;
|
|
|
115
|
+ list.sort(function (a, b) {
|
|
|
116
|
+ if (a.CreateTime == b.CreateTime) {
|
|
|
117
|
+ return b.AnswerID - b.AnswerID;
|
|
|
118
|
+ } else {
|
|
|
119
|
+ return b.CreateTime > a.CreateTime;
|
|
|
120
|
+ }
|
|
|
121
|
+ });
|
|
|
122
|
+ var id = list[0].AnswerID + 1;
|
|
|
123
|
+ if (list.length >= 100) {
|
|
|
124
|
+ id = list[list.length-1].AnswerID;
|
|
118
|
125
|
}
|
|
119
|
126
|
for (var i = 0; i < list.length; i++) {
|
|
120
|
127
|
if (list[i].AnswerID == id) {
|
|
|
@@ -122,17 +129,18 @@ Page({
|
|
122
|
129
|
}
|
|
123
|
130
|
}
|
|
124
|
131
|
data.AnswerID = id;
|
|
125
|
|
- list.push(data);
|
|
|
132
|
+ list.unshift(data);
|
|
126
|
133
|
}
|
|
127
|
134
|
else {
|
|
128
|
135
|
data.AnswerID = 1;
|
|
129
|
136
|
list = [];
|
|
130
|
137
|
list.push(data);
|
|
131
|
138
|
}
|
|
132
|
|
- wx.setStorageSync("QuestionList", list);
|
|
|
139
|
+
|
|
|
140
|
+ wx.setStorageSync("AnswerList", list);
|
|
133
|
141
|
return data;
|
|
134
|
142
|
},
|
|
135
|
|
- saveImage: function() {
|
|
|
143
|
+ saveImage: function () {
|
|
136
|
144
|
var that = this;
|
|
137
|
145
|
var item = QuestionItem;
|
|
138
|
146
|
item = that.saveLocalData(item);
|
|
|
@@ -189,7 +197,7 @@ Page({
|
|
189
|
197
|
}
|
|
190
|
198
|
|
|
191
|
199
|
//算式
|
|
192
|
|
- index = 0;
|
|
|
200
|
+ index = that.data.arrPage.length*item.PageCount;
|
|
193
|
201
|
ctx.setFontSize(24);
|
|
194
|
202
|
for (var i = 0; i < 3; i++) {
|
|
195
|
203
|
for (var j = 0; j < item.PageCount / 3; j++) {
|
|
|
@@ -202,7 +210,7 @@ Page({
|
|
202
|
210
|
if (item.QuestionList[index - 1].HiddenColumn == "A")
|
|
203
|
211
|
A = "____";
|
|
204
|
212
|
var OperateAB = item.QuestionList[index - 1].OperateAB.toString();
|
|
205
|
|
- console.log(OperateAB);
|
|
|
213
|
+ //console.log(OperateAB);
|
|
206
|
214
|
var B = item.QuestionList[index - 1].B.toString();
|
|
207
|
215
|
if (item.QuestionList[index - 1].HiddenColumn == "B")
|
|
208
|
216
|
B = "____";
|
|
|
@@ -307,7 +315,7 @@ Page({
|
|
307
|
315
|
ctx.setTextBaseline('top');
|
|
308
|
316
|
ctx.setFontSize(32);
|
|
309
|
317
|
ctx.fillText(item.Name, 60, 45);
|
|
310
|
|
-
|
|
|
318
|
+
|
|
311
|
319
|
|
|
312
|
320
|
ctx.setFontSize(12);
|
|
313
|
321
|
ctx.fillText(item.CagegoryName, 60, 90);
|
|
|
@@ -324,7 +332,7 @@ Page({
|
|
324
|
332
|
|
|
325
|
333
|
ctx.drawImage("../../images/answer.png", 890, 54, 100, 100);
|
|
326
|
334
|
|
|
327
|
|
- ctx.draw(true, function(n) {
|
|
|
335
|
+ ctx.draw(true, function (n) {
|
|
328
|
336
|
var w = 1050,
|
|
329
|
337
|
h = 1485;
|
|
330
|
338
|
|
|
|
@@ -337,7 +345,7 @@ Page({
|
|
337
|
345
|
//destWidth: w*times,
|
|
338
|
346
|
//destHeight: h*times,
|
|
339
|
347
|
canvasId: 'Canvas',
|
|
340
|
|
- success: function(res2) {
|
|
|
348
|
+ success: function (res2) {
|
|
341
|
349
|
console.log(res2.tempFilePath);
|
|
342
|
350
|
|
|
343
|
351
|
wx.saveImageToPhotosAlbum({
|
|
|
@@ -366,10 +374,10 @@ Page({
|
|
366
|
374
|
},
|
|
367
|
375
|
fail(err3) {
|
|
368
|
376
|
console.log(err3);
|
|
369
|
|
-
|
|
|
377
|
+
|
|
370
|
378
|
},
|
|
371
|
379
|
})
|
|
372
|
|
-
|
|
|
380
|
+
|
|
373
|
381
|
}
|
|
374
|
382
|
})
|
|
375
|
383
|
});
|
|
|
@@ -395,7 +403,7 @@ Page({
|
|
395
|
403
|
}
|
|
396
|
404
|
|
|
397
|
405
|
},
|
|
398
|
|
- changePageNumber: function(e) {
|
|
|
406
|
+ changePageNumber: function (e) {
|
|
399
|
407
|
var id = Number(e.currentTarget.dataset.id);
|
|
400
|
408
|
this.data.PageNumber += id;
|
|
401
|
409
|
if (this.data.PageNumber < 1)
|
|
|
@@ -407,22 +415,22 @@ Page({
|
|
407
|
415
|
PageNumber: this.data.PageNumber,
|
|
408
|
416
|
});
|
|
409
|
417
|
},
|
|
410
|
|
- showImage:function(e){
|
|
|
418
|
+ showImage: function (e) {
|
|
411
|
419
|
var that = this;
|
|
412
|
|
- var id=e.currentTarget.dataset.id;
|
|
|
420
|
+ var id = e.currentTarget.dataset.id;
|
|
413
|
421
|
wx.previewImage({
|
|
414
|
422
|
current: that.data.arrPage[id], // 当前显示图片的http链接
|
|
415
|
423
|
urls: that.data.arrPage // 需要预览的图片http链接列表
|
|
416
|
424
|
});
|
|
417
|
425
|
},
|
|
418
|
|
- closeLoading:function(){
|
|
419
|
|
- var that=this;
|
|
|
426
|
+ closeLoading: function () {
|
|
|
427
|
+ var that = this;
|
|
420
|
428
|
that.setData({
|
|
421
|
429
|
ShowLoading: false,
|
|
422
|
|
- IsFinished:false,
|
|
|
430
|
+ IsFinished: false,
|
|
423
|
431
|
});
|
|
424
|
432
|
},
|
|
425
|
|
- menuClick: function(e) {
|
|
|
433
|
+ menuClick: function (e) {
|
|
426
|
434
|
this.data.filter = e.currentTarget.dataset.id;
|
|
427
|
435
|
if (this.data.filter == "horizontal") {
|
|
428
|
436
|
this.data.PageCount = this.data.QuestionTypeItem.QuestionNumber2;
|
|
|
@@ -436,25 +444,25 @@ Page({
|
|
436
|
444
|
PageCount: this.data.PageCount,
|
|
437
|
445
|
});
|
|
438
|
446
|
},
|
|
439
|
|
- closeMenu: function() {
|
|
|
447
|
+ closeMenu: function () {
|
|
440
|
448
|
this.setData({
|
|
441
|
449
|
IsShowMenu: false,
|
|
442
|
450
|
});
|
|
443
|
451
|
},
|
|
444
|
|
- openMenu: function() {
|
|
|
452
|
+ openMenu: function () {
|
|
445
|
453
|
this.setData({
|
|
446
|
454
|
IsShowMenu: true,
|
|
447
|
455
|
});
|
|
448
|
456
|
},
|
|
449
|
|
- onShareAppMessage: function() {
|
|
|
457
|
+ onShareAppMessage: function () {
|
|
450
|
458
|
return {
|
|
451
|
459
|
title: '',
|
|
452
|
460
|
path: 'pages/index/index',
|
|
453
|
|
- success: function(res) {},
|
|
454
|
|
- fail: function(err) {
|
|
|
461
|
+ success: function (res) { },
|
|
|
462
|
+ fail: function (err) {
|
|
455
|
463
|
console.log(err);
|
|
456
|
464
|
},
|
|
457
|
|
- complete: function(res) {
|
|
|
465
|
+ complete: function (res) {
|
|
458
|
466
|
console.log(res);
|
|
459
|
467
|
},
|
|
460
|
468
|
}
|