chengjie 7 年之前
父节点
当前提交
3557dff4a1

+ 2 - 1
app.json

@@ -12,6 +12,7 @@
12
     "backgroundTextStyle": "light",
12
     "backgroundTextStyle": "light",
13
     "navigationBarBackgroundColor": "#fff",
13
     "navigationBarBackgroundColor": "#fff",
14
     "navigationBarTitleText": "数学计算题",
14
     "navigationBarTitleText": "数学计算题",
15
-    "navigationBarTextStyle": "black"
15
+    "navigationBarTextStyle": "black",
16
+    "backgroundColor":"#000000"
16
   }
17
   }
17
 }
18
 }

二进制
images/formula_division_size02.png


二进制
images/universalpic_attention_light_red_bg.png


二进制
images/universalpic_close_white_size01.png


+ 292 - 98
pages/main/detail.js

@@ -2,29 +2,41 @@ import common from '../../utils/util';
2
 import server from '../../utils/main';
2
 import server from '../../utils/main';
3
 
3
 
4
 const app = getApp();
4
 const app = getApp();
5
-var times=1;
5
+var times = 1;
6
+var pageIndex = 0;
7
+var QuestionList = [];
8
+var isAndroid=false;
9
+const waitTime = ["", "10秒钟", "15秒钟", "20秒钟", "25秒钟", "半分钟", "35秒钟", "40秒钟", "45秒钟"];
6
 
10
 
7
 Page({
11
 Page({
8
   data: {
12
   data: {
9
     version: app.globalData.version,
13
     version: app.globalData.version,
10
     FileUrl: app.globalData.fileUrl,
14
     FileUrl: app.globalData.fileUrl,
11
-    IsShowMenu:false,
12
-    filter:'horizontal',
13
-    PageNumber:1,
15
+    IsShowMenu: false,
16
+    filter: 'horizontal',
17
+    //filter: 'vertical',
18
+    PageNumber: 1,
19
+    PageCount: 60,
14
     IsFinished: false,
20
     IsFinished: false,
21
+    arrPage:[],
22
+    ShowLoading:false,
15
   },
23
   },
16
   onLoad: function(options) {
24
   onLoad: function(options) {
17
     var id = options.id;
25
     var id = options.id;
18
     this.setData({
26
     this.setData({
19
       Containnerheight: server.getWindowHeight(),
27
       Containnerheight: server.getWindowHeight(),
20
-      ID:id,
28
+      ID: id,
21
     });
29
     });
22
     var systemInfo = wx.getSystemInfoSync();
30
     var systemInfo = wx.getSystemInfoSync();
23
     if (systemInfo.system && systemInfo.system.indexOf("Android") >= 0) {
31
     if (systemInfo.system && systemInfo.system.indexOf("Android") >= 0) {
24
-      times=2;
32
+      times = 2;
25
     }
33
     }
26
     this.getDetail(id);
34
     this.getDetail(id);
27
-    
35
+
36
+    isAndroid = false;
37
+    if (app.globalData.systemInfo.system && app.globalData.systemInfo.system.indexOf("Android") >= 0)
38
+      isAndroid=true;
39
+
28
   },
40
   },
29
   getDetail: function(id) {
41
   getDetail: function(id) {
30
     var item;
42
     var item;
@@ -43,41 +55,235 @@ Page({
43
       QuestionTypeItem: item,
55
       QuestionTypeItem: item,
44
     });
56
     });
45
   },
57
   },
46
-  gotoAnswer: function (e) {
58
+  gotoAnswer: function(e) {
47
     wx.navigateTo({
59
     wx.navigateTo({
48
       url: '../main/answer',
60
       url: '../main/answer',
49
     });
61
     });
50
   },
62
   },
51
-  getFinish:function(){
63
+  getFinish: function() {
52
     this.setData({
64
     this.setData({
53
       IsFinished: true,
65
       IsFinished: true,
54
     });
66
     });
55
     this.getList(this.data.ID);
67
     this.getList(this.data.ID);
56
   },
68
   },
57
 
69
 
58
-  getList: function (id) {
70
+  getList: function(id) {
59
     var that = this;
71
     var that = this;
60
-
61
-    server.getLocalHost(function () {
62
-      server.getData('GetQuestionTypesPrint?ID=' + id, function (data) {
72
+    var pageNum = that.data.PageNumber;
73
+    var QuestionTypeCategory = 3;
74
+    if (that.data.filter == "horizontal")
75
+      QuestionTypeCategory = 2;
76
+    pageIndex = 0;
77
+    server.getLocalHost(function() {
78
+      server.getData('GetQuestionTypesPrint?ID=' + id + '&QuestionTypeCategory=' + QuestionTypeCategory + '&PageNum=' + pageNum, function(data) {
63
         //console.log("UserInfo:" + data);
79
         //console.log("UserInfo:" + data);
64
         if (data) {
80
         if (data) {
65
-          that.saveImage(data);
81
+          that.setData({
82
+            ShowLoading:true,
83
+            arrPage: [],
84
+            WaitTime: waitTime[that.data.PageNumber],
85
+          });
86
+          QuestionList = data;
87
+          
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
+          }
66
         }
108
         }
67
       });
109
       });
68
-
69
     });
110
     });
70
   },
111
   },
71
-  saveImage: function (item) {
112
+  saveImage: function() {
113
+    var item = QuestionList;
114
+
72
     var that = this;
115
     var that = this;
73
     var ctx = wx.createCanvasContext("Canvas", that);
116
     var ctx = wx.createCanvasContext("Canvas", that);
74
     ctx.setFillStyle('white');
117
     ctx.setFillStyle('white');
75
-    ctx.fillRect(0, 0, 1050, 1485);
118
+    ctx.fillRect(0, 0, 2100, 2970);
119
+    ctx.fillStyle = "#000000";
120
+
121
+    //计算数组最大长度
122
+    var maxLength = 0;
123
+    for (var l = 0; l < item.QuestionList.length; l++) {
124
+      var num1 = item.QuestionList[l];
125
+      if (num1.Vertical) {
126
+        for (var n = 0; n < num1.Vertical.length; n++) {
127
+          if (maxLength < num1.Vertical[n].Array.length)
128
+            maxLength = num1.Vertical[n].Array.length;
129
+        }
130
+      }
131
+    }
132
+
133
+    var xStart = 60;
134
+    var yStart = 247;
135
+
136
+    var height = 150;
137
+    if (item.QuestionTypeCategory == 2)
138
+      height = 59;
139
+    if (item.PageCount == 18)
140
+      height = 210;
141
+    else if (item.PageCount == 15)
142
+      height = 250;
143
+    //括号
144
+    var index = 0;
145
+    ctx.setFontSize(12);
146
+    for (var i = 0; i < 3; i++) {
147
+      for (var j = 0; j < item.PageCount / 3; j++) {
148
+        index++;
149
+        ctx.fillText("(", xStart + i * 310, yStart + j * height);
150
+        ctx.fillText(")", xStart + i * 310 + 22, yStart + j * height);
151
+      }
152
+    }
153
+
154
+    //编号
155
+    index = 0;
156
+    ctx.setTextAlign('center');
157
+    var numberLeft = 12;
158
+    if (isAndroid)
159
+      numberLeft = 14;
160
+    for (var i = 0; i < 3; i++) {
161
+      for (var j = 0; j < item.PageCount / 3; j++) {
162
+        index++;
163
+        ctx.fillText(index, xStart + i * 310 + numberLeft, yStart + j * height);
164
+      }
165
+    }
166
+
167
+    //算式
168
+    index = 0;
169
+    ctx.setFontSize(24);
170
+    for (var i = 0; i < 3; i++) {
171
+      for (var j = 0; j < item.PageCount / 3; j++) {
172
+        index++;
173
+
174
+        //横式
175
+        if (item.QuestionTypeCategory == 2) {
176
+
177
+          var A = item.QuestionList[index - 1].A.toString();
178
+          if (item.QuestionList[index - 1].HiddenColumn == "A")
179
+            A = "____";
180
+          var OperateAB = item.QuestionList[index - 1].OperateAB.toString();
181
+          console.log(OperateAB);
182
+          var B = item.QuestionList[index - 1].B.toString();
183
+          if (item.QuestionList[index - 1].HiddenColumn == "B")
184
+            B = "____";
185
+          var equation = A + " " + OperateAB + " " + B;
186
+          if (item.QuestionList[index - 1].C) {
187
+            var OperateBC = item.QuestionList[index - 1].OperateBC.toString();
188
+            var C = item.QuestionList[index - 1].C.toString();
189
+            equation += " " + OperateBC + " " + C;
190
+            if (item.QuestionList[index - 1].D) {
191
+              var OperateCD = item.QuestionList[index - 1].OperateCD.toString();
192
+              var D = item.QuestionList[index - 1].D.toString();
193
+              equation += " " + OperateCD + " " + D;
194
+            }
195
+          }
196
+          equation += " = ";
197
+          var R = item.QuestionList[index - 1].R.toString();
198
+          if (item.QuestionList[index - 1].HiddenColumn == "R")
199
+            R = "";
200
+          equation += R;
201
+
202
+          var num = xStart + i * 310 + 31;
203
+
204
+          for (var n = 0; n < equation.length; n++) {
205
+            var len = getLength(equation[n]);
206
+            num += len;
207
+            if (equation[n] == ".") {
208
+              ctx.fillText(equation[n], num + 3, yStart + j * 59);
209
+            } else {
210
+              var h = 0;
211
+              if (equation[n] == "_")
212
+                h = 8;
213
+              ctx.fillText(equation[n], num, yStart + j * 59 + h);
214
+            }
215
+          }
216
+        }
217
+        //竖式
218
+        else if (item.QuestionTypeCategory == 3) {
219
+
220
+          var num1 = item.QuestionList[index - 1];
221
+          var isAnswer = false;
222
+
223
+          var width = 250;
224
+          if (num1.OperateAB == "÷")
225
+            width = 240;
226
+
227
+          //console.log(num1);
228
+          for (var n = 0; n < num1.Vertical.length; n++) {
229
+            if (maxLength > num1.Vertical[n].Array.length) {
230
+              if (num1.OperateAB != "÷")
231
+                num1.Vertical[n].Array.splice(1, 0, "");
232
+            }
233
+          }
234
+          console.log(num1);
235
+
236
+
237
+          for (var n = 0; n < num1.Vertical.length; n++) {
238
+            var num = xStart + i * 310 + width;
239
+            for (var m = num1.Vertical[n].Array.length - 1; m >= 0; m--) {
240
+              var str = "";
241
+              if (num1.Vertical[n].Type == "line") {
242
+
243
+                var lineLength = num1.Vertical[n].Array.length * 30 + 20;
244
+                if (num1.OperateAB == "÷") {
245
+                  lineLength = num1.A.toString().length * 30;
246
+                }
247
+                ctx.moveTo(num, yStart + j * height + n * 30);
248
+                ctx.lineTo(num - lineLength, yStart + j * height + n * 30);
249
+                ctx.stroke();
250
+
251
+                if (num1.OperateAB != "÷")
252
+                  isAnswer = true;
253
+                break;
254
+              }
255
+              else {
256
+                str = num1.Vertical[n].Array[m];
257
+
258
+                if (num1.OperateAB == "÷" && str == "√") {
259
+                  isAnswer = true;
260
+                  ctx.drawImage("../../images/formula_division_size02.png", num - (num1.Vertical[n].Array.length - m) * 30 - 20, yStart + j * height + n * 30 - 31, 56, 76);
261
+                  //break;
262
+                }
263
+                else if (num1.OperateAB == "÷" && n == 0) {
264
+                }
265
+                else if (num1.OperateAB == "÷" && n == 1) {
266
+                  ctx.fillText(str, num - (num1.Vertical[n].Array.length - m) * 10, yStart + j * height + n * 30);
267
+                }
268
+                else {
269
+                  ctx.fillText(str, num - (num1.Vertical[n].Array.length - m) * 30, yStart + j * height + n * 30);
270
+                }
271
+              }
272
+
273
+            }
274
+            if (isAnswer)
275
+              break;
276
+          }
277
+
278
+        }
279
+      }
280
+    }
281
+
76
     ctx.setTextAlign('left');
282
     ctx.setTextAlign('left');
77
     ctx.setTextBaseline('top');
283
     ctx.setTextBaseline('top');
78
-    ctx.fillStyle = "#000000";
79
     ctx.setFontSize(32);
284
     ctx.setFontSize(32);
80
     ctx.fillText(item.Name, 60, 45);
285
     ctx.fillText(item.Name, 60, 45);
286
+    ctx.fillText("99", 835, 50);
81
 
287
 
82
 
288
 
83
     ctx.setFontSize(12);
289
     ctx.setFontSize(12);
@@ -90,88 +296,54 @@ Page({
90
     ctx.fillText("出题时间 " + item.CreateTime, 875, 94);
296
     ctx.fillText("出题时间 " + item.CreateTime, 875, 94);
91
     ctx.fillText("微信扫一扫 计时看答案", 875, 111);
297
     ctx.fillText("微信扫一扫 计时看答案", 875, 111);
92
     ctx.fillText("《数学计算题》选题 打印 扫码 批改", 875, 137);
298
     ctx.fillText("《数学计算题》选题 打印 扫码 批改", 875, 137);
93
-    ctx.setFontSize(32);
94
-    ctx.fillText("99", 875, 50);
95
     ctx.drawImage("../../images/answer.png", 890, 54, 100, 100);
299
     ctx.drawImage("../../images/answer.png", 890, 54, 100, 100);
96
 
300
 
97
-    ctx.setTextBaseline('middle');
98
-    var xStart = 60;
99
-    var yStart = 247;
100
-    var index = 0;
101
-    for (var i = 0; i < 3; i++) {
102
-      for (var j = 0; j < 20; j++) {
103
-        index++;
104
-        ctx.setTextAlign('left');
105
-        ctx.setFontSize(12);
106
-        ctx.fillText("(", xStart + i * 310, yStart + j * 59);
107
-        ctx.setTextAlign('center');
108
-        ctx.fillText(index, xStart + i * 310 + 13, yStart + j * 59);
109
-        ctx.setTextAlign('left');
110
-        ctx.fillText(")", xStart + i * 310 + 22, yStart + j * 59);
111
-
112
-        ctx.setFontSize(24);
113
-
114
-        var A = item.QuestionList[index - 1].A.toString();
115
-        if (item.QuestionList[index - 1].HiddenColumn == "A")
116
-          A = "____";
117
-        var OperateAB = item.QuestionList[index - 1].OperateAB.toString();
118
-        console.log(OperateAB);
119
-        var B = item.QuestionList[index - 1].B.toString();
120
-        if (item.QuestionList[index - 1].HiddenColumn == "B")
121
-          B = "____";
122
-        var equation = A + " " + OperateAB + " " + B;
123
-        if (item.QuestionList[index - 1].C) {
124
-          var OperateBC = item.QuestionList[index - 1].OperateBC.toString();
125
-          var C = item.QuestionList[index - 1].C.toString();
126
-          equation += " " + OperateBC + " " + C;
127
-          if (item.QuestionList[index - 1].D) {
128
-            var OperateCD = item.QuestionList[index - 1].OperateCD.toString();
129
-            var D = item.QuestionList[index - 1].D.toString();
130
-            equation += " " + OperateCD + " " + D;
131
-          }
132
-        }
133
-        equation += " = ";
134
-        var R = item.QuestionList[index - 1].R.toString();
135
-        if (item.QuestionList[index - 1].HiddenColumn == "R")
136
-          R = "";
137
-        equation += R;
138
-
139
-        var num = xStart + i * 310 + 31;
140
-        ctx.setTextAlign('center');
141
-        for (var n = 0; n < equation.length; n++) {
142
-          var len = getLength(equation[n]);
143
-          num += len;
144
-          if (equation[n] == ".") {
145
-            ctx.fillText(equation[n], num + 3, yStart + j * 59);
146
-          } else {
147
-            var h = 0;
148
-            if (equation[n] == "_")
149
-              h = 8;
150
-            ctx.fillText(equation[n], num, yStart + j * 59 + h);
151
-          }
152
-        }
153
-      }
154
-    }
155
-
301
+    ctx.draw(true, function(n) {
302
+      var w = 1050,
303
+        h = 1485;
156
 
304
 
157
-    ctx.draw(true, function (n) {
158
-      var w=1050,h=1485;
159
-      
160
 
305
 
161
       wx.canvasToTempFilePath({
306
       wx.canvasToTempFilePath({
162
         x: 0,
307
         x: 0,
163
         y: 0,
308
         y: 0,
164
-        width: w*times,
165
-        height: h*times,
309
+        width: w * times,
310
+        height: h * times,
166
         //destWidth: w*times,
311
         //destWidth: w*times,
167
         //destHeight: h*times,
312
         //destHeight: h*times,
168
         canvasId: 'Canvas',
313
         canvasId: 'Canvas',
169
-        success: function (res2) {
314
+        success: function(res2) {
170
           console.log(res2.tempFilePath);
315
           console.log(res2.tempFilePath);
171
-          wx.previewImage({
172
-            current: res2.tempFilePath, // 当前显示图片的http链接
173
-            urls: [res2.tempFilePath] // 需要预览的图片http链接列表
174
-          });
316
+
317
+          wx.saveImageToPhotosAlbum({
318
+            filePath: res2.tempFilePath,
319
+            success(res3) {
320
+              console.log("save:" + res3.savedFilePath);
321
+              that.data.arrPage.push(res2.tempFilePath);
322
+
323
+              that.setData({
324
+                arrPage: that.data.arrPage,
325
+              });
326
+
327
+              if (that.data.arrPage.length < that.data.PageNumber) {
328
+                pageIndex++;
329
+                that.saveImage();
330
+              } else {
331
+                that.setData({
332
+                  ShowLoading: false,
333
+                });
334
+
335
+                wx.previewImage({
336
+                  current: that.data.arrPage[0], // 当前显示图片的http链接
337
+                  urls: that.data.arrPage // 需要预览的图片http链接列表
338
+                });
339
+              }
340
+            },
341
+            fail(err3) {
342
+              console.log(err3);
343
+              
344
+            },
345
+          })
346
+                    
175
         }
347
         }
176
       })
348
       })
177
     });
349
     });
@@ -197,31 +369,53 @@ Page({
197
     }
369
     }
198
 
370
 
199
   },
371
   },
200
-  changePageNumber: function (e) {
372
+  changePageNumber: function(e) {
201
     var id = Number(e.currentTarget.dataset.id);
373
     var id = Number(e.currentTarget.dataset.id);
202
-    this.data.PageNumber+=id;
203
-    if (this.data.PageNumber<1)
204
-      this.data.PageNumber=1;
205
-    else if (this.data.PageNumber > 5)
206
-      this.data.PageNumber = 5;
374
+    this.data.PageNumber += id;
375
+    if (this.data.PageNumber < 1)
376
+      this.data.PageNumber = 1;
377
+    else if (this.data.PageNumber > 8)
378
+      this.data.PageNumber = 8;
207
 
379
 
208
     this.setData({
380
     this.setData({
209
       PageNumber: this.data.PageNumber,
381
       PageNumber: this.data.PageNumber,
210
     });
382
     });
211
   },
383
   },
212
-  menuClick: function (e) {
384
+  showImage:function(e){
385
+    var that = this;
386
+    var id=e.currentTarget.dataset.id;
387
+    wx.previewImage({
388
+      current: that.data.arrPage[id], // 当前显示图片的http链接
389
+      urls: that.data.arrPage // 需要预览的图片http链接列表
390
+    });
391
+  },
392
+  closeLoading:function(){
393
+    var that=this;
394
+    that.setData({
395
+      ShowLoading: false,
396
+      IsFinished:false,
397
+    });
398
+  },
399
+  menuClick: function(e) {
213
     this.data.filter = e.currentTarget.dataset.id;
400
     this.data.filter = e.currentTarget.dataset.id;
401
+    if (this.data.filter == "horizontal") {
402
+      this.data.PageCount = this.data.QuestionTypeItem.QuestionNumber2;
403
+    } else if (this.data.filter == "vertical") {
404
+      this.data.PageCount = this.data.QuestionTypeItem.QuestionNumber3;
405
+    }
406
+
214
     this.setData({
407
     this.setData({
215
       filter: this.data.filter,
408
       filter: this.data.filter,
216
       IsShowMenu: false,
409
       IsShowMenu: false,
410
+      PageCount: this.data.PageCount,
217
     });
411
     });
218
   },
412
   },
219
-  closeMenu: function () {
413
+  closeMenu: function() {
220
     this.setData({
414
     this.setData({
221
       IsShowMenu: false,
415
       IsShowMenu: false,
222
     });
416
     });
223
   },
417
   },
224
-  openMenu: function () {
418
+  openMenu: function() {
225
     this.setData({
419
     this.setData({
226
       IsShowMenu: true,
420
       IsShowMenu: true,
227
     });
421
     });

+ 30 - 11
pages/main/detail.wxml

@@ -42,7 +42,7 @@
42
 
42
 
43
           <block wx:if="{{filter=='horizontal'}}">横式</block>
43
           <block wx:if="{{filter=='horizontal'}}">横式</block>
44
           <block wx:if="{{filter=='vertical'}}">竖式</block>
44
           <block wx:if="{{filter=='vertical'}}">竖式</block>
45
-          <block wx:if="{{filter=='all'}}">横式+竖式</block>
45
+          <!-- <block wx:if="{{filter=='all'}}">横式+竖式</block> -->
46
 
46
 
47
         </view>
47
         </view>
48
         <view class="btnAddSub"></view>
48
         <view class="btnAddSub"></view>
@@ -60,7 +60,7 @@
60
       <view class="btnAddSub" bindtap='changePageNumber' data-id="1"></view>
60
       <view class="btnAddSub" bindtap='changePageNumber' data-id="1"></view>
61
     </view>
61
     </view>
62
 
62
 
63
-    <view class="text5">每份含 9道题目</view>
63
+    <view class="text5">每份含 {{PageCount}} 道题目,至多 8 份</view>
64
 
64
 
65
     <image class="universalpic_line_dashed_size01" src="../../images/universalpic_line_dashed_size01.png" />
65
     <image class="universalpic_line_dashed_size01" src="../../images/universalpic_line_dashed_size01.png" />
66
 
66
 
@@ -78,14 +78,9 @@
78
         <image class="universalpic_right_white_size01" src="../../images/universalpic_right_white_size01.png" />
78
         <image class="universalpic_right_white_size01" src="../../images/universalpic_right_white_size01.png" />
79
       </view>
79
       </view>
80
       <view class="text6">完成了</view>
80
       <view class="text6">完成了</view>
81
-      <view class="text7">题目以图片格式保存到手机相册,共 6张</view>
81
+      <view class="text7">题目以图片格式保存到手机相册,共 {{arrPage.length}} 张</view>
82
       <view class="panel21 FlexRow">
82
       <view class="panel21 FlexRow">
83
-        <view class="panel210"></view>
84
-        <view class="panel210"></view>
85
-        <view class="panel210"></view>
86
-        <view class="panel210"></view>
87
-        <view class="panel210"></view>
88
-        <view class="panel210"></view>
83
+        <image class="panel210" wx:for="{{arrPage}}" wx:key="index" src="{{item}}" data-id='{{index}}' bindtap='showImage' />
89
       </view>
84
       </view>
90
 
85
 
91
       <image class="universalpic_line_dashed_size01" src="../../images/universalpic_line_dashed_size01.png" />
86
       <image class="universalpic_line_dashed_size01" src="../../images/universalpic_line_dashed_size01.png" />
@@ -122,12 +117,12 @@
122
       <image wx:if="{{filter=='vertical'}}" class="universalpic_select_on_black" src="../../images/universalpic_select_on_black.png" />
117
       <image wx:if="{{filter=='vertical'}}" class="universalpic_select_on_black" src="../../images/universalpic_select_on_black.png" />
123
 
118
 
124
     </view>
119
     </view>
125
-    <view class="line"></view>
120
+    <!-- <view class="line"></view>
126
     <view class="panel FlexRow" bindtap='menuClick' data-id="all">
121
     <view class="panel FlexRow" bindtap='menuClick' data-id="all">
127
       <view>横式+竖式</view>
122
       <view>横式+竖式</view>
128
       <image wx:if="{{filter=='all'}}" class="universalpic_select_on_black" src="../../images/universalpic_select_on_black.png" />
123
       <image wx:if="{{filter=='all'}}" class="universalpic_select_on_black" src="../../images/universalpic_select_on_black.png" />
129
 
124
 
130
-    </view>
125
+    </view> -->
131
     <view class="line"></view>
126
     <view class="line"></view>
132
     <view class="line2"></view>
127
     <view class="line2"></view>
133
     <view class="line"></view>
128
     <view class="line"></view>
@@ -137,5 +132,29 @@
137
 
132
 
138
   </view>
133
   </view>
139
 
134
 
135
+</view>
136
+
137
+<view class="loading container FlexColumn" style="min-height:{{Containnerheight}}rpx;" wx:if="{{ShowLoading}}">
138
+  <view class="loading1 FlexColumn">
139
+    <view class="line1"></view>
140
+    <view class="line2 FlexColumn">
141
+      <view class="text">共 {{PageNumber}} 张图片</view>
142
+      <view class="text2">正在保存第 {{arrPage.length}} 张... 可能需要{{WaitTime}}</view>
143
+    </view>
144
+    <view class="line3 FlexColumn">
145
+      <view class="text3">使用建议</view>
146
+      <view class="text4">每张卷子里的题目都是动态生成哒,每次出题都会得到不同的结果。</view>
147
+    </view>
148
+    <view class="line4"></view>
149
+    <image class="universalpic_attention_light_red_bg" src="../../images/universalpic_attention_light_red_bg.png" />
150
+    <image class="universalpic_attention_light_red" src="../../images/universalpic_attention_light_red.gif" />
151
+    
152
+  </view>
153
+  <view class="close FlexRow">
154
+    <view class="close1 FlexRow" bindtap='closeLoading'>
155
+    <image class="universalpic_close_white_size01" src="../../images/universalpic_close_white_size01.png" />
156
+    </view>
157
+  </view>
158
+
140
 </view>
159
 </view>
141
 <canvas class='Canvas' canvas-id="Canvas"></canvas>
160
 <canvas class='Canvas' canvas-id="Canvas"></canvas>

+ 96 - 0
pages/main/detail.wxss

@@ -360,5 +360,101 @@
360
   top:0rpx;
360
   top:0rpx;
361
 }
361
 }
362
 
362
 
363
+.loading {
364
+  position: fixed;
365
+  top:0;
366
+  z-index: 100;
367
+  background-color: rgba(229,167,68,0.8);
368
+}
369
+
370
+.loading .loading1 {
371
+  position: absolute;
372
+  top:317rpx;
373
+  width:100%;
374
+}
375
+
376
+.loading1 .line1 {
377
+  width:100%;
378
+  height:20rpx;
379
+  background-color: #A63917;
380
+}
381
+
382
+
383
+.loading1 .line2 {
384
+  width:100%;
385
+  height:279rpx;
386
+  background-color: #FFE6C2;
387
+  z-index: 100;
388
+}
389
+
390
+.loading1 .text {
391
+  font-size:48rpx;
392
+  margin-top:60rpx;
393
+}
394
+
395
+.loading1 .text2 {
396
+  font-size:24rpx;
397
+  margin-top: 10rpx;
398
+}
399
+
400
+.loading1 .line3 {
401
+  width:100%;
402
+  height:250rpx;
403
+  background-color: #A63917;
404
+  color:#fff;
405
+}
406
+
407
+.loading1 .text3 {
408
+  font-size:28rpx;
409
+}
410
+
411
+.loading1 .text4 {
412
+  font-size:32rpx;
413
+  margin-top: 10rpx;
414
+  font-weight: 400;
415
+  text-align: center;
416
+  width: 690rpx;
417
+}
418
+
419
+.loading1 .line4 {
420
+  width:100%;
421
+  height:20rpx;
422
+  background-color: #7D2B25;
423
+  margin-top: 0rpx;
424
+}
425
+
426
+
427
+.loading1 .universalpic_attention_light_red_bg{
428
+  width:172rpx;
429
+  height:192rpx;
430
+  z-index: 110;
431
+  position: absolute;
432
+  top:-91rpx;
433
+}
434
+.loading1 .universalpic_attention_light_red{
435
+  width:90rpx;
436
+  height:90rpx;
437
+  position: absolute;
438
+  top: -40rpx;
439
+  z-index: 110;
440
+}
441
+
442
+.loading .close {
443
+  position: fixed;
444
+  bottom:126rpx;
445
+  width:100%;
446
+}
447
+.loading .close1 {
448
+  width:120rpx;
449
+  height:120rpx;
450
+  border-radius: 50%;
451
+  background-color: #B3443B;
452
+}
453
+
454
+.universalpic_close_white_size01{
455
+  width:26rpx;
456
+  height:26rpx;
457
+}
458
+
363
 
459
 
364
 
460
 

+ 24 - 0
pages/main/list.js

@@ -54,6 +54,8 @@ Page({
54
     });
54
     });
55
   },
55
   },
56
   buildList:function(){
56
   buildList:function(){
57
+    var that=this;
58
+
57
     var arrID = categoryID.split(",");
59
     var arrID = categoryID.split(",");
58
     var list = [];
60
     var list = [];
59
 
61
 
@@ -93,6 +95,28 @@ Page({
93
     this.setData({
95
     this.setData({
94
       QuestionTypeList: list,
96
       QuestionTypeList: list,
95
     });
97
     });
98
+
99
+    setTimeout(function(){
100
+      var query = wx.createSelectorQuery();
101
+      query.select('.line4').boundingClientRect();
102
+      query.exec(function (res) {
103
+        //console.log("top2:" + (res[0].top));
104
+        var LineLongHeight = Number(res[0].top) * 2;
105
+        if (that.data.CategoryNum == 1 )
106
+          LineLongHeight+=430;
107
+        else if (that.data.CategoryNum == 2)
108
+          LineLongHeight += 320;
109
+        else if (that.data.CategoryNum == 3)
110
+          LineLongHeight += 280;
111
+        else if (that.data.CategoryNum == 4)
112
+          LineLongHeight += 30;
113
+        console.log("LineLongHeight:" + LineLongHeight);
114
+        that.setData({
115
+          LineLongHeight: LineLongHeight,
116
+        });
117
+      });
118
+    },200);
119
+    
96
   },
120
   },
97
   menuClick:function(e){
121
   menuClick:function(e){
98
     this.data.filter = e.currentTarget.dataset.id;
122
     this.data.filter = e.currentTarget.dataset.id;

+ 3 - 2
pages/main/list.wxml

@@ -66,12 +66,13 @@
66
   <view class="line4"></view>
66
   <view class="line4"></view>
67
 
67
 
68
   <view class="line5"></view>
68
   <view class="line5"></view>
69
+  <view class="line6" hidden="{{QuestionTypeList.length>0}}"></view>
69
 
70
 
70
-  <view class="lineLeft lineLong FlexRow" style="height:{{ (540+QuestionTypeList.length*190) }}rpx;">
71
+  <view class="lineLeft lineLong FlexRow" style="height:{{ LineLongHeight }}rpx;">
71
     <view class="lineLong1">
72
     <view class="lineLong1">
72
     </view>
73
     </view>
73
   </view>
74
   </view>
74
-  <view class="lineRight lineLong FlexRow" style="height:{{ (540+QuestionTypeList.length*190) }}rpx;">
75
+  <view class="lineRight lineLong FlexRow" style="height:{{ LineLongHeight }}rpx;">
75
     <view class="lineLong2">
76
     <view class="lineLong2">
76
     </view>
77
     </view>
77
   </view>
78
   </view>

+ 5 - 0
pages/main/list.wxss

@@ -191,6 +191,11 @@
191
   height: 50rpx;
191
   height: 50rpx;
192
   background-color: #514a47;
192
   background-color: #514a47;
193
 }
193
 }
194
+.line6 {
195
+  width: 100%;
196
+  height: 550rpx;
197
+  background-color: #514a47;
198
+}
194
 
199
 
195
 .lineLong {
200
 .lineLong {
196
   width: 30rpx;
201
   width: 30rpx;

+ 211 - 77
pages/main/print.js

@@ -1,39 +1,236 @@
1
 import common from '../../utils/util';
1
 import common from '../../utils/util';
2
 import server from '../../utils/main';
2
 import server from '../../utils/main';
3
 
3
 
4
-const app = getApp()
4
+const app = getApp();
5
+var QuestionList = [];
6
+var isAndroid = false;
7
+
5
 Page({
8
 Page({
6
   data: {
9
   data: {
7
     Left: 0,
10
     Left: 0,
8
   },
11
   },
9
-  onLoad: function(options) {
12
+  onLoad: function (options) {
10
     var id = options.id;
13
     var id = options.id;
11
-    id = 179;
12
-    this.getList(id);
14
+    id = 183;
15
+    var QuestionTypeCategory=3;
16
+    this.getList(id, QuestionTypeCategory);
17
+
18
+    isAndroid = false;
19
+    if (app.globalData.systemInfo.system && app.globalData.systemInfo.system.indexOf("Android") >= 0)
20
+      isAndroid = true;
21
+
13
   },
22
   },
14
-  getList: function(id) {
23
+  getList: function (id, QuestionTypeCategory) {
15
     var that = this;
24
     var that = this;
16
 
25
 
17
-    server.getLocalHost(function() {
18
-      server.getData('GetQuestionTypesPrint?ID=' + id, function(data) {
26
+    server.getLocalHost(function () {
27
+      server.getData('GetQuestionTypesPrint?QuestionTypeCategory=' + QuestionTypeCategory+'&ID=' + id, function (data) {
19
         //console.log("UserInfo:" + data);
28
         //console.log("UserInfo:" + data);
20
         if (data) {
29
         if (data) {
21
-          that.saveImage(data);
30
+          //var data=wx.getStorageSync("TestPrint");
31
+          QuestionList = data;
32
+          var ctx = wx.createCanvasContext("Canvas", that);
33
+          ctx.setFillStyle('white');
34
+          ctx.fillRect(0, 0, 1050, 1485);
35
+          ctx.draw(true, function (n) {
36
+            wx.canvasToTempFilePath({
37
+              x: 0,
38
+              y: 0,
39
+              width: 2100,
40
+              height: 2970,
41
+              destWidth: 2100,
42
+              destHeight: 2970,
43
+              canvasId: 'Canvas',
44
+              success: function (res2) {
45
+                console.log(res2.tempFilePath);
46
+                that.saveImage();
47
+              }
48
+            })
49
+          });
22
         }
50
         }
23
       });
51
       });
24
 
52
 
25
     });
53
     });
26
   },
54
   },
27
-  saveImage: function(item) {
55
+  saveImage: function () {
56
+    var item = QuestionList;
57
+
28
     var that = this;
58
     var that = this;
29
     var ctx = wx.createCanvasContext("Canvas", that);
59
     var ctx = wx.createCanvasContext("Canvas", that);
30
     ctx.setFillStyle('white');
60
     ctx.setFillStyle('white');
61
+    //ctx.fillRect(0, 0, 1050, 1485);
31
     ctx.fillRect(0, 0, 1050, 1485);
62
     ctx.fillRect(0, 0, 1050, 1485);
63
+    ctx.fillStyle = "#000000";
64
+
65
+    //计算数组最大长度
66
+    var maxLength = 0;
67
+    for (var l = 0; l < item.QuestionList.length; l++) {
68
+      var num1 = item.QuestionList[l];
69
+      if (num1.Vertical) {
70
+        for (var n = 0; n < num1.Vertical.length; n++) {
71
+          if (maxLength < num1.Vertical[n].Array.length)
72
+            maxLength = num1.Vertical[n].Array.length;
73
+        }
74
+      }
75
+    }
76
+
77
+    var xStart = 60;
78
+    var yStart = 247;
79
+
80
+    var height = 150;
81
+    if (item.QuestionTypeCategory == 2)
82
+      height = 59;
83
+    if (item.PageCount == 18)
84
+      height = 210;
85
+    else if (item.PageCount == 15)
86
+      height = 250;
87
+    //括号
88
+    var index = 0;
89
+    ctx.setFontSize(12);
90
+    for (var i = 0; i < 3; i++) {
91
+      for (var j = 0; j < item.PageCount / 3; j++) {
92
+        index++;
93
+        ctx.fillText("(", xStart + i * 310, yStart + j * height);
94
+        ctx.fillText(")", xStart + i * 310 + 22, yStart + j * height);
95
+      }
96
+    }
97
+
98
+    //编号
99
+    index = 0;
100
+    ctx.setTextAlign('center');
101
+    var numberLeft = 12;
102
+    if (isAndroid)
103
+      numberLeft = 14;
104
+    for (var i = 0; i < 3; i++) {
105
+      for (var j = 0; j < item.PageCount / 3; j++) {
106
+        index++;
107
+        ctx.fillText(index, xStart + i * 310 + numberLeft, yStart + j * height);
108
+      }
109
+    }
110
+
111
+    //算式
112
+    index = 0;
113
+    ctx.setFontSize(24);
114
+    for (var i = 0; i < 3; i++) {
115
+      for (var j = 0; j < item.PageCount / 3; j++) {
116
+        index++;
117
+
118
+        //横式
119
+        if (item.QuestionTypeCategory == 2) {
120
+
121
+          var A = item.QuestionList[index - 1].A.toString();
122
+          if (item.QuestionList[index - 1].HiddenColumn == "A")
123
+            A = "____";
124
+          var OperateAB = item.QuestionList[index - 1].OperateAB.toString();
125
+          console.log(OperateAB);
126
+          var B = item.QuestionList[index - 1].B.toString();
127
+          if (item.QuestionList[index - 1].HiddenColumn == "B")
128
+            B = "____";
129
+          var equation = A + " " + OperateAB + " " + B;
130
+          if (item.QuestionList[index - 1].C) {
131
+            var OperateBC = item.QuestionList[index - 1].OperateBC.toString();
132
+            var C = item.QuestionList[index - 1].C.toString();
133
+            equation += " " + OperateBC + " " + C;
134
+            if (item.QuestionList[index - 1].D) {
135
+              var OperateCD = item.QuestionList[index - 1].OperateCD.toString();
136
+              var D = item.QuestionList[index - 1].D.toString();
137
+              equation += " " + OperateCD + " " + D;
138
+            }
139
+          }
140
+          equation += " = ";
141
+          var R = item.QuestionList[index - 1].R.toString();
142
+          if (item.QuestionList[index - 1].HiddenColumn == "R")
143
+            R = "";
144
+          equation += R;
145
+
146
+          var num = xStart + i * 310 + 31;
147
+          
148
+          for (var n = 0; n < equation.length; n++) {
149
+            var len = getLength(equation[n]);
150
+            num += len;
151
+            if (equation[n] == ".") {
152
+              ctx.fillText(equation[n], num + 3, yStart + j * 59);
153
+            } else {
154
+              var h = 0;
155
+              if (equation[n] == "_")
156
+                h = 8;
157
+              ctx.fillText(equation[n], num, yStart + j * 59 + h);
158
+            }
159
+          }
160
+        }
161
+        //竖式
162
+        else if (item.QuestionTypeCategory == 3) {
163
+
164
+          var num1 = item.QuestionList[index - 1];
165
+          var isAnswer = false;
166
+
167
+          var width = 250;
168
+          if (num1.OperateAB == "÷")
169
+            width=240;
170
+
171
+          //console.log(num1);
172
+          for (var n = 0; n < num1.Vertical.length; n++) {
173
+            if (maxLength > num1.Vertical[n].Array.length) {
174
+              if (num1.OperateAB != "÷")
175
+                num1.Vertical[n].Array.splice(1, 0, "");
176
+            }
177
+          }
178
+          console.log(num1);
179
+
180
+
181
+          for (var n = 0; n < num1.Vertical.length; n++) {
182
+            var num = xStart + i * 310 + width;
183
+            for (var m = num1.Vertical[n].Array.length - 1; m >= 0; m--) {
184
+              var str = "";
185
+              if (num1.Vertical[n].Type == "line") {
186
+
187
+                var lineLength = num1.Vertical[n].Array.length * 30+20;
188
+                var lineTop=-15;
189
+                if (num1.OperateAB == "÷") {
190
+                  lineLength = num1.A.toString().length * 30;
191
+                  lineTop=0;
192
+                }
193
+                
194
+                ctx.moveTo(num, yStart + j * height + n * 30 + lineTop);
195
+                ctx.lineTo(num - lineLength, yStart + j * height + n * 30 + lineTop);
196
+                ctx.stroke();
197
+
198
+                if (num1.OperateAB != "÷")
199
+                  isAnswer = true;
200
+                break;
201
+              }
202
+              else {
203
+                str = num1.Vertical[n].Array[m];
204
+
205
+                if (num1.OperateAB == "÷" && str == "√") {
206
+                  isAnswer = true;
207
+                  ctx.drawImage("../../images/formula_division_size02.png", num - (num1.Vertical[n].Array.length - m) * 30 - 20, yStart + j * height + n * 30 - 31, 56, 76);
208
+                  //break;
209
+                }
210
+                else if (num1.OperateAB == "÷" && n == 0) {
211
+                }
212
+                else if (num1.OperateAB == "÷" && n == 1) {
213
+                  ctx.fillText(str, num - (num1.Vertical[n].Array.length - m) * 10, yStart + j * height + n * 30);
214
+                }
215
+                else {
216
+                  ctx.fillText(str, num - (num1.Vertical[n].Array.length - m) * 30, yStart + j * height + n * 30);
217
+                }
218
+              }
219
+
220
+            }
221
+            if (isAnswer)
222
+              break;
223
+          }
224
+
225
+        }
226
+      }
227
+    }
228
+
32
     ctx.setTextAlign('left');
229
     ctx.setTextAlign('left');
33
     ctx.setTextBaseline('top');
230
     ctx.setTextBaseline('top');
34
-    ctx.fillStyle = "#000000";
35
     ctx.setFontSize(32);
231
     ctx.setFontSize(32);
36
     ctx.fillText(item.Name, 60, 45);
232
     ctx.fillText(item.Name, 60, 45);
233
+    ctx.fillText("99", 835, 50);
37
 
234
 
38
 
235
 
39
     ctx.setFontSize(12);
236
     ctx.setFontSize(12);
@@ -46,71 +243,10 @@ Page({
46
     ctx.fillText("出题时间 " + item.CreateTime, 875, 94);
243
     ctx.fillText("出题时间 " + item.CreateTime, 875, 94);
47
     ctx.fillText("微信扫一扫 计时看答案", 875, 111);
244
     ctx.fillText("微信扫一扫 计时看答案", 875, 111);
48
     ctx.fillText("《数学计算题》选题 打印 扫码 批改", 875, 137);
245
     ctx.fillText("《数学计算题》选题 打印 扫码 批改", 875, 137);
49
-    ctx.setFontSize(32);
50
-    ctx.fillText("99", 875, 50);
51
     ctx.drawImage("../../images/answer.png", 890, 54, 100, 100);
246
     ctx.drawImage("../../images/answer.png", 890, 54, 100, 100);
52
 
247
 
53
-    ctx.setTextBaseline('middle');
54
-    var xStart = 60;
55
-    var yStart = 247;
56
-    var index = 0;
57
-    for (var i = 0; i < 3; i++) {
58
-      for (var j = 0; j < 20; j++) {
59
-        index++;
60
-        ctx.setTextAlign('left');
61
-        ctx.setFontSize(12);
62
-        ctx.fillText("(", xStart + i * 310, yStart + j * 59);
63
-        ctx.setTextAlign('center');
64
-        ctx.fillText(index, xStart + i * 310 + 13, yStart + j * 59);
65
-        ctx.setTextAlign('left');
66
-        ctx.fillText(")", xStart + i * 310 + 22, yStart + j * 59);
67
-
68
-        ctx.setFontSize(24);
69
-
70
-        var A = item.QuestionList[index - 1].A.toString();
71
-        if (item.QuestionList[index - 1].HiddenColumn == "A")
72
-          A = "____";
73
-        var OperateAB = item.QuestionList[index - 1].OperateAB.toString();
74
-        console.log(OperateAB);
75
-        var B = item.QuestionList[index - 1].B.toString();
76
-        if (item.QuestionList[index - 1].HiddenColumn == "B")
77
-          B = "____";
78
-        var equation = A + " " + OperateAB + " " + B;
79
-        if (item.QuestionList[index - 1].C) {
80
-          var OperateBC = item.QuestionList[index - 1].OperateBC.toString();
81
-          var C = item.QuestionList[index - 1].C.toString();
82
-          equation += " " + OperateBC + " " + C;
83
-          if (item.QuestionList[index - 1].D) {
84
-            var OperateCD = item.QuestionList[index - 1].OperateCD.toString();
85
-            var D = item.QuestionList[index - 1].D.toString();
86
-            equation += " " + OperateCD + " " + D;
87
-          }
88
-        }
89
-        equation += " = ";
90
-        var R = item.QuestionList[index - 1].R.toString();
91
-        if (item.QuestionList[index - 1].HiddenColumn == "R")
92
-          R = "";
93
-        equation += R;
94
-
95
-        var num = xStart + i * 310 + 31;
96
-        ctx.setTextAlign('center');
97
-        for (var n = 0; n < equation.length; n++) {
98
-          var len = getLength(equation[n]);
99
-          num += len;
100
-          if (equation[n] == ".") {
101
-            ctx.fillText(equation[n], num + 3, yStart + j * 59);
102
-          } else {
103
-            var h=0;
104
-            if (equation[n]=="_")
105
-              h=8;
106
-            ctx.fillText(equation[n], num, yStart + j * 59+h);
107
-          }
108
-        }
109
-      }
110
-    }
111
-
112
 
248
 
113
-    ctx.draw(true, function(n) {
249
+    ctx.draw(true, function (n) {
114
       wx.canvasToTempFilePath({
250
       wx.canvasToTempFilePath({
115
         x: 0,
251
         x: 0,
116
         y: 0,
252
         y: 0,
@@ -148,17 +284,15 @@ Page({
148
           return 12;
284
           return 12;
149
       }
285
       }
150
     }
286
     }
151
-
152
   },
287
   },
153
-  moveLeft: function() {
288
+  moveLeft: function () {
154
     this.setData({
289
     this.setData({
155
       Left: this.data.Left + 375,
290
       Left: this.data.Left + 375,
156
     });
291
     });
157
   },
292
   },
158
-  moveRight: function() {
293
+  moveRight: function () {
159
     this.setData({
294
     this.setData({
160
       Left: this.data.Left - 375,
295
       Left: this.data.Left - 375,
161
     });
296
     });
162
   }
297
   }
163
-});
164
-
298
+});

+ 0 - 2
pages/main/print.wxss

@@ -5,8 +5,6 @@
5
 .Canvas{
5
 .Canvas{
6
   width: 2100rpx; 
6
   width: 2100rpx; 
7
   height: 2970rpx;
7
   height: 2970rpx;
8
-  background-color:#f2f2f2;
9
-  /* z-index: 50; */
10
   position: absolute;
8
   position: absolute;
11
   left:0rpx;
9
   left:0rpx;
12
   top:0rpx;
10
   top:0rpx;