chengjie 7 years ago
parent
commit
21bb348838
6 changed files with 268 additions and 140 deletions
  1. 47 12
      pages/main/answer.js
  2. 5 5
      pages/main/answer.wxml
  3. 3 3
      pages/main/default.js
  4. 76 68
      pages/main/detail.js
  5. 59 42
      pages/main/item.js
  6. 78 10
      pages/main/item.wxml

+ 47 - 12
pages/main/answer.js

@@ -8,6 +8,7 @@ Page({
8
     FileUrl: app.globalData.fileUrl,
8
     FileUrl: app.globalData.fileUrl,
9
     IsEdit: false,
9
     IsEdit: false,
10
     ListHeight: 1320,
10
     ListHeight: 1320,
11
+    SelectedCount: 0,
11
   },
12
   },
12
   onLoad: function () {
13
   onLoad: function () {
13
     this.setData({
14
     this.setData({
@@ -17,17 +18,17 @@ Page({
17
   },
18
   },
18
   getList: function () {
19
   getList: function () {
19
     var that = this;
20
     var that = this;
20
-    var list = wx.getStorageSync("QuestionList");
21
+    var list = wx.getStorageSync("AnswerList");
21
     if (list && list.length > 0) {
22
     if (list && list.length > 0) {
22
       var arr = [];
23
       var arr = [];
23
-      for (var i = list.length - 1; i >= 0; i--) {
24
+      for (var i = 0; i < list.length; i++) {
24
         list[i].Selected = false;
25
         list[i].Selected = false;
25
         arr.push(list[i]);
26
         arr.push(list[i]);
26
       }
27
       }
27
 
28
 
28
       var ListHeight = 1320;
29
       var ListHeight = 1320;
29
       var ListHeight2 = 1490;
30
       var ListHeight2 = 1490;
30
-      var ListHeight3 = arr.length * 130+20;
31
+      var ListHeight3 = arr.length * 130 + 20;
31
       if (arr.length > 10) {
32
       if (arr.length > 10) {
32
         ListHeight = 1320 + (arr.length - 10) * 130;
33
         ListHeight = 1320 + (arr.length - 10) * 130;
33
         ListHeight2 = 1490 + (arr.length - 10) * 130;
34
         ListHeight2 = 1490 + (arr.length - 10) * 130;
@@ -44,23 +45,57 @@ Page({
44
   selectItem: function (e) {
45
   selectItem: function (e) {
45
     if (e.currentTarget.dataset.id) {
46
     if (e.currentTarget.dataset.id) {
46
       var id = e.currentTarget.dataset.id;
47
       var id = e.currentTarget.dataset.id;
47
-      var list = this.data.AnswerList;
48
-      for (var i = list.length - 1; i >= 0; i--) {
49
-        if (id == list[i].AnswerID)
50
-          list[i].Selected = true;
51
-        else
52
-          list[i].Selected = false;
48
+      if (this.data.IsEdit) {
49
+        var count = 0;
50
+        var list = this.data.AnswerList;
51
+        for (var i = 0; i < list.length; i++) {
52
+          if (id == list[i].AnswerID) {
53
+            list[i].Selected = !list[i].Selected;
54
+          }
55
+          if (list[i].Selected)
56
+            count++;
57
+        }
58
+        this.setData({
59
+          AnswerList: list,
60
+          SelectedCount: count,
61
+        });
62
+      }
63
+      else {
64
+        wx.navigateTo({
65
+          url: '../main/item?id=' + id,
66
+        });
67
+      }
68
+    }
69
+  },
70
+  deleteItem: function () {
71
+    var list = this.data.AnswerList;
72
+    for (var i = list.length - 1; i >= 0; i--) {
73
+      if (list[i].Selected) {
74
+        list.splice(i, 1);
53
       }
75
       }
54
-      this.setData({
55
-        AnswerList: list,
56
-      });
57
     }
76
     }
77
+    list.sort(function (a, b) {
78
+      if (a.CreateTime == b.CreateTime) {
79
+        return b.AnswerID - b.AnswerID;
80
+      } else {
81
+        return b.CreateTime > a.CreateTime;
82
+      }
83
+    });
84
+    this.setData({
85
+      AnswerList: list,
86
+      SelectedCount: 0,
87
+    });
88
+    wx.setStorageSync("AnswerList", list);
58
   },
89
   },
59
   btnEdit: function () {
90
   btnEdit: function () {
60
     var that = this;
91
     var that = this;
61
     that.data.IsEdit = !that.data.IsEdit;
92
     that.data.IsEdit = !that.data.IsEdit;
93
+    for (var i = 0; i < that.data.AnswerList.length; i++) {
94
+      that.data.AnswerList[i].Selected = false;
95
+    }
62
     that.setData({
96
     that.setData({
63
       IsEdit: that.data.IsEdit,
97
       IsEdit: that.data.IsEdit,
98
+      AnswerList: that.data.AnswerList,
64
     });
99
     });
65
   },
100
   },
66
   onShareAppMessage: function () {
101
   onShareAppMessage: function () {

+ 5 - 5
pages/main/answer.wxml

@@ -5,9 +5,9 @@
5
   <image class="answerroom_list_conveyer_headline_illus" src="../../images/answerroom_list_conveyer_headline_illus.png" />
5
   <image class="answerroom_list_conveyer_headline_illus" src="../../images/answerroom_list_conveyer_headline_illus.png" />
6
   <view class="panelTop FlexRow">
6
   <view class="panelTop FlexRow">
7
     <view class="panelTop0 FlexColumn">
7
     <view class="panelTop0 FlexColumn">
8
-      <view class="panelTop00 FlexRow" wx:if="{{IsEdit}}">
8
+      <view class="panelTop00 FlexRow" wx:if="{{IsEdit}}" bindtap="deleteItem">
9
         <image class="universalpic_select_on_white" src="../../images/universalpic_select_on_white.png" />
9
         <image class="universalpic_select_on_white" src="../../images/universalpic_select_on_white.png" />
10
-        <view class="text">删除选中 0个</view>
10
+        <view class="text">删除选中 {{SelectedCount}} 个</view>
11
       </view>
11
       </view>
12
       <view class="line" wx:if="{{IsEdit}}"></view>
12
       <view class="line" wx:if="{{IsEdit}}"></view>
13
     </view>
13
     </view>
@@ -20,7 +20,7 @@
20
   </view>
20
   </view>
21
 
21
 
22
   <view class="panel0 FlexColumn">
22
   <view class="panel0 FlexColumn">
23
-    <view class="panel00 FlexRow" style='height:{{ListHeight3}}rpx;'>
23
+    <view class="panel00 FlexRow" style='min-height:{{ListHeight2}}rpx;'>
24
 
24
 
25
     </view>
25
     </view>
26
     <image class="answerroom_list_conveyer_footer_illus" src="../../images/answerroom_list_conveyer_footer_illus.png" />
26
     <image class="answerroom_list_conveyer_footer_illus" src="../../images/answerroom_list_conveyer_footer_illus.png" />
@@ -47,7 +47,7 @@
47
     <view class="line21 line2"></view>
47
     <view class="line21 line2"></view>
48
 
48
 
49
     <!-- 列表 -->
49
     <!-- 列表 -->
50
-    <view class="panel0MainBG panel0Main" style='min-height:{{ListHeight}}rpx;'>
50
+     <view class="panel0MainBG panel0Main" style='min-height:{{ListHeight}}rpx;'>
51
       <view class="line2"></view>
51
       <view class="line2"></view>
52
       <view class="item FlexColumn" wx:for="{{AnswerList}}" wx:key="index" bindtap='selectItem' data-id='{{item.AnswerID}}'>
52
       <view class="item FlexColumn" wx:for="{{AnswerList}}" wx:key="index" bindtap='selectItem' data-id='{{item.AnswerID}}'>
53
         <view class="itemLine00 itemLine0"></view>
53
         <view class="itemLine00 itemLine0"></view>
@@ -76,6 +76,6 @@
76
 
76
 
77
         </view>
77
         </view>
78
       </view>
78
       </view>
79
-    </view>
79
+    </view> 
80
   </view>
80
   </view>
81
 </view>
81
 </view>

+ 3 - 3
pages/main/default.js

@@ -44,8 +44,7 @@ Page({
44
         code = res0.code;
44
         code = res0.code;
45
       }
45
       }
46
     });
46
     });
47
-
48
-
47
+    
49
     this.updateProgram();
48
     this.updateProgram();
50
   },
49
   },
51
   gotoList:function(e){
50
   gotoList:function(e){
@@ -77,7 +76,8 @@ Page({
77
       that.setData({
76
       that.setData({
78
         IsAccredit: false,
77
         IsAccredit: false,
79
       });
78
       });
80
-    } else {
79
+    } 
80
+    else {
81
       var userID = app.globalData.userInfo.UserID;
81
       var userID = app.globalData.userInfo.UserID;
82
       app.globalData.userInfo = res.userInfo;
82
       app.globalData.userInfo = res.userInfo;
83
       app.globalData.userInfo.UserID = userID;
83
       app.globalData.userInfo.UserID = userID;

+ 76 - 68
pages/main/detail.js

@@ -5,7 +5,7 @@ const app = getApp();
5
 var times = 1;
5
 var times = 1;
6
 var pageIndex = 0;
6
 var pageIndex = 0;
7
 var QuestionItem = [];
7
 var QuestionItem = [];
8
-var isAndroid=false;
8
+var isAndroid = false;
9
 const waitTime = ["", "10秒钟", "15秒钟", "20秒钟", "25秒钟", "半分钟", "35秒钟", "40秒钟", "45秒钟"];
9
 const waitTime = ["", "10秒钟", "15秒钟", "20秒钟", "25秒钟", "半分钟", "35秒钟", "40秒钟", "45秒钟"];
10
 
10
 
11
 Page({
11
 Page({
@@ -18,10 +18,10 @@ Page({
18
     PageNumber: 1,
18
     PageNumber: 1,
19
     PageCount: 60,
19
     PageCount: 60,
20
     IsFinished: false,
20
     IsFinished: false,
21
-    arrPage:[],
22
-    ShowLoading:false,
21
+    arrPage: [],
22
+    ShowLoading: false,
23
   },
23
   },
24
-  onLoad: function(options) {
24
+  onLoad: function (options) {
25
     var id = options.id;
25
     var id = options.id;
26
     this.setData({
26
     this.setData({
27
       Containnerheight: server.getWindowHeight(),
27
       Containnerheight: server.getWindowHeight(),
@@ -35,10 +35,10 @@ Page({
35
 
35
 
36
     isAndroid = false;
36
     isAndroid = false;
37
     if (app.globalData.systemInfo.system && app.globalData.systemInfo.system.indexOf("Android") >= 0)
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
     var item;
42
     var item;
43
     var data = wx.getStorageSync('QuestionTypeList');
43
     var data = wx.getStorageSync('QuestionTypeList');
44
     for (var i = 0; i < data.length; i++) {
44
     for (var i = 0; i < data.length; i++) {
@@ -55,66 +55,73 @@ Page({
55
       QuestionTypeItem: item,
55
       QuestionTypeItem: item,
56
     });
56
     });
57
   },
57
   },
58
-  gotoAnswer: function(e) {
58
+  gotoAnswer: function (e) {
59
     wx.navigateTo({
59
     wx.navigateTo({
60
       url: '../main/answer',
60
       url: '../main/answer',
61
     });
61
     });
62
   },
62
   },
63
-  getFinish: function() {
63
+  getFinish: function () {
64
     this.setData({
64
     this.setData({
65
       IsFinished: true,
65
       IsFinished: true,
66
     });
66
     });
67
     this.getList(this.data.ID);
67
     this.getList(this.data.ID);
68
   },
68
   },
69
 
69
 
70
-  getList: function(id) {
70
+  getList: function (id) {
71
     var that = this;
71
     var that = this;
72
     var pageNum = that.data.PageNumber;
72
     var pageNum = that.data.PageNumber;
73
     var QuestionTypeCategory = 3;
73
     var QuestionTypeCategory = 3;
74
     if (that.data.filter == "horizontal")
74
     if (that.data.filter == "horizontal")
75
       QuestionTypeCategory = 2;
75
       QuestionTypeCategory = 2;
76
     pageIndex = 0;
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
     if (list && list.length > 0) {
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
       for (var i = 0; i < list.length; i++) {
126
       for (var i = 0; i < list.length; i++) {
120
         if (list[i].AnswerID == id) {
127
         if (list[i].AnswerID == id) {
@@ -122,17 +129,18 @@ Page({
122
         }
129
         }
123
       }
130
       }
124
       data.AnswerID = id;
131
       data.AnswerID = id;
125
-      list.push(data);
132
+      list.unshift(data);
126
     }
133
     }
127
     else {
134
     else {
128
       data.AnswerID = 1;
135
       data.AnswerID = 1;
129
       list = [];
136
       list = [];
130
       list.push(data);
137
       list.push(data);
131
     }
138
     }
132
-    wx.setStorageSync("QuestionList", list);
139
+    
140
+    wx.setStorageSync("AnswerList", list);
133
     return data;
141
     return data;
134
   },
142
   },
135
-  saveImage: function() {
143
+  saveImage: function () {
136
     var that = this;
144
     var that = this;
137
     var item = QuestionItem;
145
     var item = QuestionItem;
138
     item = that.saveLocalData(item);
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
     ctx.setFontSize(24);
201
     ctx.setFontSize(24);
194
     for (var i = 0; i < 3; i++) {
202
     for (var i = 0; i < 3; i++) {
195
       for (var j = 0; j < item.PageCount / 3; j++) {
203
       for (var j = 0; j < item.PageCount / 3; j++) {
@@ -202,7 +210,7 @@ Page({
202
           if (item.QuestionList[index - 1].HiddenColumn == "A")
210
           if (item.QuestionList[index - 1].HiddenColumn == "A")
203
             A = "____";
211
             A = "____";
204
           var OperateAB = item.QuestionList[index - 1].OperateAB.toString();
212
           var OperateAB = item.QuestionList[index - 1].OperateAB.toString();
205
-          console.log(OperateAB);
213
+          //console.log(OperateAB);
206
           var B = item.QuestionList[index - 1].B.toString();
214
           var B = item.QuestionList[index - 1].B.toString();
207
           if (item.QuestionList[index - 1].HiddenColumn == "B")
215
           if (item.QuestionList[index - 1].HiddenColumn == "B")
208
             B = "____";
216
             B = "____";
@@ -307,7 +315,7 @@ Page({
307
     ctx.setTextBaseline('top');
315
     ctx.setTextBaseline('top');
308
     ctx.setFontSize(32);
316
     ctx.setFontSize(32);
309
     ctx.fillText(item.Name, 60, 45);
317
     ctx.fillText(item.Name, 60, 45);
310
-    
318
+
311
 
319
 
312
     ctx.setFontSize(12);
320
     ctx.setFontSize(12);
313
     ctx.fillText(item.CagegoryName, 60, 90);
321
     ctx.fillText(item.CagegoryName, 60, 90);
@@ -324,7 +332,7 @@ Page({
324
 
332
 
325
     ctx.drawImage("../../images/answer.png", 890, 54, 100, 100);
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
       var w = 1050,
336
       var w = 1050,
329
         h = 1485;
337
         h = 1485;
330
 
338
 
@@ -337,7 +345,7 @@ Page({
337
         //destWidth: w*times,
345
         //destWidth: w*times,
338
         //destHeight: h*times,
346
         //destHeight: h*times,
339
         canvasId: 'Canvas',
347
         canvasId: 'Canvas',
340
-        success: function(res2) {
348
+        success: function (res2) {
341
           console.log(res2.tempFilePath);
349
           console.log(res2.tempFilePath);
342
 
350
 
343
           wx.saveImageToPhotosAlbum({
351
           wx.saveImageToPhotosAlbum({
@@ -366,10 +374,10 @@ Page({
366
             },
374
             },
367
             fail(err3) {
375
             fail(err3) {
368
               console.log(err3);
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
     var id = Number(e.currentTarget.dataset.id);
407
     var id = Number(e.currentTarget.dataset.id);
400
     this.data.PageNumber += id;
408
     this.data.PageNumber += id;
401
     if (this.data.PageNumber < 1)
409
     if (this.data.PageNumber < 1)
@@ -407,22 +415,22 @@ Page({
407
       PageNumber: this.data.PageNumber,
415
       PageNumber: this.data.PageNumber,
408
     });
416
     });
409
   },
417
   },
410
-  showImage:function(e){
418
+  showImage: function (e) {
411
     var that = this;
419
     var that = this;
412
-    var id=e.currentTarget.dataset.id;
420
+    var id = e.currentTarget.dataset.id;
413
     wx.previewImage({
421
     wx.previewImage({
414
       current: that.data.arrPage[id], // 当前显示图片的http链接
422
       current: that.data.arrPage[id], // 当前显示图片的http链接
415
       urls: that.data.arrPage // 需要预览的图片http链接列表
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
     that.setData({
428
     that.setData({
421
       ShowLoading: false,
429
       ShowLoading: false,
422
-      IsFinished:false,
430
+      IsFinished: false,
423
     });
431
     });
424
   },
432
   },
425
-  menuClick: function(e) {
433
+  menuClick: function (e) {
426
     this.data.filter = e.currentTarget.dataset.id;
434
     this.data.filter = e.currentTarget.dataset.id;
427
     if (this.data.filter == "horizontal") {
435
     if (this.data.filter == "horizontal") {
428
       this.data.PageCount = this.data.QuestionTypeItem.QuestionNumber2;
436
       this.data.PageCount = this.data.QuestionTypeItem.QuestionNumber2;
@@ -436,25 +444,25 @@ Page({
436
       PageCount: this.data.PageCount,
444
       PageCount: this.data.PageCount,
437
     });
445
     });
438
   },
446
   },
439
-  closeMenu: function() {
447
+  closeMenu: function () {
440
     this.setData({
448
     this.setData({
441
       IsShowMenu: false,
449
       IsShowMenu: false,
442
     });
450
     });
443
   },
451
   },
444
-  openMenu: function() {
452
+  openMenu: function () {
445
     this.setData({
453
     this.setData({
446
       IsShowMenu: true,
454
       IsShowMenu: true,
447
     });
455
     });
448
   },
456
   },
449
-  onShareAppMessage: function() {
457
+  onShareAppMessage: function () {
450
     return {
458
     return {
451
       title: '',
459
       title: '',
452
       path: 'pages/index/index',
460
       path: 'pages/index/index',
453
-      success: function(res) {},
454
-      fail: function(err) {
461
+      success: function (res) { },
462
+      fail: function (err) {
455
         console.log(err);
463
         console.log(err);
456
       },
464
       },
457
-      complete: function(res) {
465
+      complete: function (res) {
458
         console.log(res);
466
         console.log(res);
459
       },
467
       },
460
     }
468
     }

+ 59 - 42
pages/main/item.js

@@ -7,57 +7,74 @@ Page({
7
     version: app.globalData.version,
7
     version: app.globalData.version,
8
     FileUrl: app.globalData.fileUrl,
8
     FileUrl: app.globalData.fileUrl,
9
   },
9
   },
10
-  onLoad: function() {
10
+  onLoad: function (options) {
11
     this.setData({
11
     this.setData({
12
       Containnerheight: server.getWindowHeight(),
12
       Containnerheight: server.getWindowHeight(),
13
-      TestDivEquation1: [{ Type: 'number', Array: ['', '', '', '1', '2', '3'] },
14
-      {
15
-        Type: 'number',
16
-        Array: ['×', '', '', '', '4', '5', '0', '0']
17
-      },
18
-      {
19
-        Type: 'line',
20
-        Array: ['1', '1', '1', '1', '1', '1', '1', '1']
21
-      },
22
-      { Type: 'number', Array: ['', '', '', '6', '1', '5'] },
23
-      { Type: 'number', Array: ['', '', '4', '9', '2'] },
24
-      {
25
-        Type: 'line',
26
-        Array: ['1', '1', '1', '1', '1', '1', '1', '1']
27
-      },
28
-      {
29
-        Type: 'number',
30
-        Array: ['', '', '5', '5', '3', '5', '0', '0']
31
-      }],
32
-      TestDivEquation2: [{
33
-        Type: 'number',
34
-        Array: ['', '', '', '', '0', '.', '6', '2', '5']
35
-      },
36
-      {
37
-        Type: 'line',
38
-        Array: ['', '', '0.5', '1', '1', '1', '1', '1', '1']
39
-      },
40
-      { Type: 'number', Array: ['5', '6', '√', '3', '5', '0'] },
41
-      { Type: 'number', Array: ['', '', '', '3', '3', '6'] },
42
-      { Type: 'line', Array: ['', '', '', '1', '1', '1'] },
43
-      { Type: 'number', Array: ['', '', '', '', '1', '4', '0'] },
44
-      { Type: 'number', Array: ['', '', '', '', '1', '1', '2'] },
45
-      { Type: 'line', Array: ['', '', '', '', '1', '1', '1'] },
46
-      { Type: 'number', Array: ['', '', '', '', '', '2', '8', '0'] },
47
-      { Type: 'number', Array: ['', '', '', '', '', '2', '8', '0'] },
48
-      { Type: 'line', Array: ['', '', '', '', '', '1', '1', '1'] },
49
-      { Type: 'number', Array: ['', '', '', '', '', '', '', '0'] }]
50
     });
13
     });
14
+
15
+    var id = options.id;
16
+    this.getItem(id);
17
+  },
18
+  scrollTop: function (e) {
19
+    var id = Number(e.currentTarget.dataset.id);
20
+    var top = 0;
21
+
22
+    var query = wx.createSelectorQuery();
23
+    query.select('#panelRowTop' + id).boundingClientRect();
24
+    query.selectViewport().scrollOffset();
25
+    query.exec(function (res) {
26
+      top = res[0].top       // #the-id节点的上边界坐标
27
+      //res[1].scrollTop // 显示区域的竖直滚动位置
28
+
29
+      wx.pageScrollTo({
30
+        scrollTop: top,
31
+        duration: 500
32
+      });
33
+    });
34
+
35
+  },
36
+  getItem: function (id) {
37
+    var that = this;
38
+    var list = wx.getStorageSync("AnswerList");
39
+    if (list && list.length > 0) {
40
+      var item;
41
+      for (var i = 0; i < list.length; i++) {
42
+        if (id == list[i].AnswerID) {
43
+          item = list[i];
44
+          break;
45
+        }
46
+      }
47
+      that.setData({
48
+        AnswerItem: item,
49
+      });
50
+    }
51
+  },
52
+  selectedItem: function (e) {
53
+    var id = e.currentTarget.dataset.id;
54
+    var list = this.data.AnswerItem.QuestionList;
55
+    for (var i = 0; i < list.length; i++) {
56
+      if (id == list[i].ID) {
57
+        list[i].IsShowVertical = !list[i].IsShowVertical;
58
+      }
59
+      else {
60
+        list[i].IsShowVertical = false;
61
+      }
62
+    }
63
+    this.data.AnswerItem.QuestionList=list;
64
+    this.setData({
65
+      AnswerItem: this.data.AnswerItem,
66
+    });
67
+
51
   },
68
   },
52
-  onShareAppMessage: function() {
69
+  onShareAppMessage: function () {
53
     return {
70
     return {
54
       title: '',
71
       title: '',
55
       path: 'pages/index/index',
72
       path: 'pages/index/index',
56
-      success: function(res) {},
57
-      fail: function(err) {
73
+      success: function (res) { },
74
+      fail: function (err) {
58
         console.log(err);
75
         console.log(err);
59
       },
76
       },
60
-      complete: function(res) {
77
+      complete: function (res) {
61
         console.log(res);
78
         console.log(res);
62
       },
79
       },
63
     }
80
     }

+ 78 - 10
pages/main/item.wxml

@@ -2,9 +2,9 @@
2
   <view class="panel0 FlexRow">
2
   <view class="panel0 FlexRow">
3
     <view class="panelLeft">快翻</view>
3
     <view class="panelLeft">快翻</view>
4
     <view class="panelRight FlexRow">
4
     <view class="panelRight FlexRow">
5
-      <view class="btn1 btn">1</view>
6
-      <view class="btn">4</view>
7
-      <view class="btn">7</view>
5
+      <view class="btn1 btn" bindtap="scrollTop" data-id="0">1</view>
6
+      <view class="btn" bindtap="scrollTop" data-id="1">{{AnswerItem.QuestionList.length/3+1}}</view>
7
+      <view class="btn" bindtap="scrollTop" data-id="2">{{AnswerItem.QuestionList.length*2/3+1}}</view>
8
     </view>
8
     </view>
9
   </view>
9
   </view>
10
   <view class="panel1 panel0 FlexRow">
10
   <view class="panel1 panel0 FlexRow">
@@ -29,12 +29,76 @@
29
     </view>
29
     </view>
30
   </view>
30
   </view>
31
 
31
 
32
-  <view class="panelRowTop panel0 FlexRow">
33
-    <view class="panelLeft1 panelLeft">第一列</view>
34
-    <view>
32
+
33
+  <block wx:for="{{AnswerItem.QuestionList}}" wx:key="index">
34
+    <block wx:if="{{(index % (AnswerItem.QuestionList.length/3))==0 }}">
35
+      <view id="panelRowTop{{index / (AnswerItem.QuestionList.length/3)}}" class="panelRowTop panel0 FlexRow">
36
+        <view class="panelLeft1 panelLeft">第
37
+          <block wx:if="{{index / (AnswerItem.QuestionList.length/3)==0}}">一</block>
38
+          <block wx:if="{{index / (AnswerItem.QuestionList.length/3)==1}}">二</block>
39
+          <block wx:if="{{index / (AnswerItem.QuestionList.length/3)==2}}">三</block>
40
+          列</view>
41
+        <view>
42
+        </view>
43
+      </view>
44
+    </block>
45
+    <view class="panelRowBody panel0 FlexRow">
46
+      <view class="panelLeft FlexRow">
47
+        <view class="number">{{index+1}}</view>
48
+        <view class="answer">{{item.Result}}</view>
49
+      </view>
50
+      <view class="panelRight FlexRow">
51
+        <view class="equation">
52
+          <block wx:if="{{item.HiddenColumn=='A'}}">___ </block>
53
+          <block wx:if="{{item.HiddenColumn!='A'}}">{{item.A}} </block>
54
+          {{item.OperateAB}}
55
+          <block wx:if="{{item.HiddenColumn=='B'}}">___ </block>
56
+          <block wx:if="{{item.HiddenColumn!='B'}}">{{item.B}} </block>
57
+          {{item.OperateBC}} {{item.C}} {{item.OperateCD}} {{item.D}} =
58
+          <block wx:if="{{item.HiddenColumn=='R'}}">___ </block>
59
+          <block wx:if="{{item.HiddenColumn!='R'}}">{{item.R}} </block>
60
+        </view>
61
+        <image class="formula_btn_show" src="../../images/formula_btn_show.png" wx:if="{{item.Vertical && !item.IsShowVertical}}" bindtap='selectedItem' data-id="{{item.ID}}" />
62
+        <image class="formula_btn_show" src="../../images/formula_btn_hide.png" wx:if="{{item.Vertical && item.IsShowVertical}}" bindtap='selectedItem' data-id="{{item.ID}}"/>
35
     </view>
63
     </view>
36
-  </view>
37
-  <view class="panelRowBody panel0 FlexRow">
64
+    </view>
65
+    <!-- 算式一 -->
66
+    <view class="panelRowBody panel0 FlexColumn" wx:if="{{item.Vertical && item.OperateAB!='÷' && item.IsShowVertical}}">
67
+      <view class="panelAnswer FlexColumn">
68
+        <view class="panelAnswerRow FlexRow" wx:for='{{item.Vertical}}' wx:key="index">
69
+          <view class="panelAnswerCol FlexRow" wx:for='{{item.Array}}' wx:key="i" wx:for-item="col" wx:for-index="i">
70
+            <view class="colNumber" wx:if="{{item.Type=='number' && col!='√' && col!='.'}}">{{col}}</view>
71
+            <view class="colDot" wx:if="{{item.Type=='number' && col=='.'}}">{{col}}</view>
72
+            <image wx:if="{{item.Type=='number' && col=='√'}}" class="formula_division_size01" src="../../images/formula_division_size01.png" />
73
+            <view class="colLine" wx:if="{{item.Type=='line' && col=='1'}}"></view>
74
+            <view class="colLineHalf" wx:if="{{item.Type=='line' && col=='0.5'}}"></view>
75
+            <view class="colLineNull" wx:if="{{item.Type=='line' && col==''}}"></view>
76
+          </view>
77
+        </view>
78
+      </view>
79
+    </view>
80
+    <!-- 算式二 -->
81
+    <view class="panelRowBody panel0 FlexColumn" wx:if="{{item.Vertical && item.OperateAB=='÷' && item.IsShowVertical}}">
82
+      <view class="panelAnswer FlexColumn">
83
+        <view class="panelAnswerRow FlexRow" wx:for='{{item.Vertical}}' wx:key="index">
84
+          <view class="panelAnswerCol FlexRow" wx:for='{{item.Array}}' wx:key="i" wx:for-item="col" wx:for-index="i">
85
+            <view class="colNumber" wx:if="{{item.Type=='number' && col!='√' && col!='.'}}">{{col}}</view>
86
+            <view class="colDot" wx:if="{{item.Type=='number' && col=='.'}}">{{col}}</view>
87
+            <image wx:if="{{item.Type=='number' && col=='√'}}" class="formula_division_size01" src="../../images/formula_division_size01.png" />
88
+            <view class="colLine" wx:if="{{item.Type=='line' && col=='1'}}"></view>
89
+            <view class="colLineHalf" wx:if="{{item.Type=='line' && col=='0.5'}}"></view>
90
+            <view class="colLineNull" wx:if="{{item.Type=='line' && col==''}}"></view>
91
+          </view>
92
+        </view>
93
+      </view>
94
+    </view>
95
+    <view class="line FlexRow">
96
+      <view class="line1"></view>
97
+    </view>
98
+
99
+  </block>
100
+
101
+  <!-- <view class="panelRowBody panel0 FlexRow">
38
     <view class="panelLeft FlexRow">
102
     <view class="panelLeft FlexRow">
39
       <view class="number">1</view>
103
       <view class="number">1</view>
40
       <view class="answer">7</view>
104
       <view class="answer">7</view>
@@ -97,8 +161,7 @@
97
       <view class="equation">35 ÷ 56 =</view>
161
       <view class="equation">35 ÷ 56 =</view>
98
       <image class="formula_btn_show" src="../../images/formula_btn_hide.png" />
162
       <image class="formula_btn_show" src="../../images/formula_btn_hide.png" />
99
     </view>
163
     </view>
100
-  </view>
101
-
164
+  </view> 
102
   <view class="panelRowBody panel0 FlexColumn">
165
   <view class="panelRowBody panel0 FlexColumn">
103
     <view class="panelAnswer FlexColumn">
166
     <view class="panelAnswer FlexColumn">
104
       <view class="panelAnswerRow FlexRow" wx:for='{{TestDivEquation2}}' wx:key="index">
167
       <view class="panelAnswerRow FlexRow" wx:for='{{TestDivEquation2}}' wx:key="index">
@@ -113,4 +176,9 @@
113
       </view>
176
       </view>
114
     </view>
177
     </view>
115
   </view>
178
   </view>
179
+  -->
180
+
181
+
182
+
183
+
116
 </view>
184
 </view>