chengjie 7 years ago
parent
commit
87b7f31c95
6 changed files with 129 additions and 88 deletions
  1. 47 4
      pages/main/answer.js
  2. 36 67
      pages/main/answer.wxml
  3. 3 0
      pages/main/answer.wxss
  4. 33 7
      pages/main/detail.js
  5. 9 9
      pages/main/list.js
  6. 1 1
      project.config.json

+ 47 - 4
pages/main/answer.js

@@ -6,16 +6,59 @@ Page({
6 6
   data: {
7 7
     version: app.globalData.version,
8 8
     FileUrl: app.globalData.fileUrl,
9
-    IsEdit:false,
9
+    IsEdit: false,
10
+    ListHeight: 1320,
10 11
   },
11 12
   onLoad: function () {
12 13
     this.setData({
13 14
       Containnerheight: server.getWindowHeight(),
14 15
     });
16
+    this.getList();
15 17
   },
16
-  btnEdit:function(){
17
-    var that=this;
18
-    that.data.IsEdit=!that.data.IsEdit;
18
+  getList: function () {
19
+    var that = this;
20
+    var list = wx.getStorageSync("QuestionList");
21
+    if (list && list.length > 0) {
22
+      var arr = [];
23
+      for (var i = list.length - 1; i >= 0; i--) {
24
+        list[i].Selected = false;
25
+        arr.push(list[i]);
26
+      }
27
+
28
+      var ListHeight = 1320;
29
+      var ListHeight2 = 1490;
30
+      var ListHeight3 = arr.length * 130+20;
31
+      if (arr.length > 10) {
32
+        ListHeight = 1320 + (arr.length - 10) * 130;
33
+        ListHeight2 = 1490 + (arr.length - 10) * 130;
34
+      }
35
+
36
+      that.setData({
37
+        AnswerList: arr,
38
+        ListHeight: ListHeight,
39
+        ListHeight2: ListHeight2,
40
+        ListHeight3: ListHeight3,
41
+      });
42
+    }
43
+  },
44
+  selectItem: function (e) {
45
+    if (e.currentTarget.dataset.id) {
46
+      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;
53
+      }
54
+      this.setData({
55
+        AnswerList: list,
56
+      });
57
+    }
58
+  },
59
+  btnEdit: function () {
60
+    var that = this;
61
+    that.data.IsEdit = !that.data.IsEdit;
19 62
     that.setData({
20 63
       IsEdit: that.data.IsEdit,
21 64
     });

+ 36 - 67
pages/main/answer.wxml

@@ -20,67 +20,8 @@
20 20
   </view>
21 21
 
22 22
   <view class="panel0 FlexColumn">
23
-    <view class="panel00 FlexRow">
24
-      <view class="panel0MainBG panel0Main" bindtap='selectItem'>
25
-        <view class="line2"></view>
26
-        <view class="item FlexColumn">
27
-          <view class="itemLine0"></view>
28
-          <view class="itemChild FlexRow">
29
-            <view class="FlexRow">
30
-              <image wx:if="{{IsEdit}}" class="universalpic_select_on_gray" src="../../images/universalpic_select_on_gray.png" />
31
-              <image wx:if="{{!IsEdit}}" class="questioncard_icon" src="{{FileUrl}}questioncard_icon_grade0602_size01.png" />
32
-              <view class="title FlexColumn">
33
-                <view class="title1">
34
-                  2018年12月23日 23:14
35
-                </view>
36
-                <view class="title2 FlexRow">
37
-                  四则运算a+b+c
38
-                </view>
39
-              </view>
40
-            </view>
41
-            <view class="title3 FlexRow">
42
-              <view class="title30">#</view>
43
-              <view class="title31">48</view>
44
-              <image class="universalpic_new_red_size01" src="../../images/universalpic_new_red_size01.png" />
45
-            </view>
46
-          </view>
47
-          <view class="itemLine1"></view>
48
-          <view class="itemLineSelected" wx:if="{{true}}">
49
-            <image class="universalpic_select_on_orange" src="../../images/universalpic_select_on_orange.png" />
50
-              
51
-          </view>
52
-        </view>
53
-
54
-        <view class="item FlexColumn">
55
-          <view class="itemLine00 itemLine0"></view>
56
-          <view class="itemChild0 itemChild FlexRow">
57
-            <view class="FlexRow">
58
-              <image wx:if="{{IsEdit}}" class="universalpic_select_on_gray" src="../../images/universalpic_select_on_gray.png" />
59
-              <image wx:if="{{!IsEdit}}" class="questioncard_icon" src="{{FileUrl}}questioncard_icon_grade0602_size01.png" />
60
-              <view class="title FlexColumn">
61
-                <view class="title1">
62
-                  2018年12月23日 23:14
63
-                </view>
64
-                <view class="title2 FlexRow">
65
-                  四则运算a+b+c
66
-                </view>
67
-              </view>
68
-            </view>
69
-            <view class="title3 FlexRow">
70
-              <view class="title30">#</view>
71
-              <view class="title31">13</view>
23
+    <view class="panel00 FlexRow" style='height:{{ListHeight3}}rpx;'>
72 24
 
73
-            </view>
74
-          </view>
75
-          <view class="itemLine1"></view>
76
-        </view>
77
-
78
-        <view class="item FlexColumn">
79
-          <view class="itemLine0"></view>
80
-          <view class="itemChild"></view>
81
-          <view class="itemLine1"></view>
82
-        </view>
83
-      </view>
84 25
     </view>
85 26
     <image class="answerroom_list_conveyer_footer_illus" src="../../images/answerroom_list_conveyer_footer_illus.png" />
86 27
 
@@ -89,24 +30,52 @@
89 30
       <view class="textFooter1">删除小程序时,答案也会被删除。</view>
90 31
     </view>
91 32
 
92
-    <view class="panel01 panel00 FlexRow">
33
+    <view class="panel01 panel00 FlexRow" bindtap='selectItem'>
93 34
 
94
-      <view class="panel000 FlexColumn">
35
+      <view class="panel000 FlexColumn" style='min-height:{{ListHeight2}}rpx;'>
95 36
         <image class="answerroom_list_conveyer_part_left" src="../../images/answerroom_list_conveyer_part_left.png" />
96 37
         <image class="answerroom_list_conveyer_part_left" src="../../images/answerroom_list_conveyer_part_left.png" />
97 38
       </view>
98
-      <view class="panel001"></view>
39
+      <view class="panel001" style='min-height:{{ListHeight2}}rpx;'></view>
99 40
       <view class="line2"></view>
100
-      <view class="panel001"></view>
101
-      <view class="panel000 FlexColumn">
41
+      <view class="panel001" style='min-height:{{ListHeight2}}rpx;'></view>
42
+      <view class="panel000 FlexColumn" style='min-height:{{ListHeight2}}rpx;'>
102 43
         <image class="answerroom_list_conveyer_part_right" src="../../images/answerroom_list_conveyer_part_right.png" />
103 44
         <image class="answerroom_list_conveyer_part_right" src="../../images/answerroom_list_conveyer_part_right.png" />
104 45
       </view>
105 46
     </view>
106
-
107 47
     <view class="line21 line2"></view>
108
-  </view>
109 48
 
49
+    <!-- 列表 -->
50
+    <view class="panel0MainBG panel0Main" style='min-height:{{ListHeight}}rpx;'>
51
+      <view class="line2"></view>
52
+      <view class="item FlexColumn" wx:for="{{AnswerList}}" wx:key="index" bindtap='selectItem' data-id='{{item.AnswerID}}'>
53
+        <view class="itemLine00 itemLine0"></view>
54
+        <view class="itemChild0 itemChild FlexRow">
55
+          <view class="FlexRow">
56
+            <image wx:if="{{IsEdit}}" class="universalpic_select_on_gray" src="../../images/universalpic_select_on_gray.png" />
57
+            <image wx:if="{{!IsEdit}}" class="questioncard_icon" src="{{FileUrl}}questioncard_icon_grade0602_size01.png" />
58
+            <view class="title FlexColumn">
59
+              <view class="title1">
60
+                {{item.CreateTime}}
61
+              </view>
62
+              <view class="title2 FlexRow">
63
+                {{item.Name}}
64
+              </view>
65
+            </view>
66
+          </view>
67
+          <view class="title3 FlexRow">
68
+            <view class="title30">#</view>
69
+            <view class="title31">{{item.AnswerID}}</view>
110 70
 
71
+          </view>
72
+        </view>
73
+        <view class="itemLine1"></view>
74
+        <view class="itemLineSelected" wx:if="{{item.Selected}}">
75
+          <image class="universalpic_select_on_orange" src="../../images/universalpic_select_on_orange.png" />
111 76
 
77
+        </view>
78
+      </view>
79
+    </view>
80
+  </view>
112 81
 </view>

+ 3 - 0
pages/main/answer.wxss

@@ -141,6 +141,9 @@
141 141
 
142 142
 .panel0 .panel0MainBG {
143 143
   background-color: #6a6d6f;
144
+  position: absolute;
145
+  z-index: 200;
146
+  top:0rpx;
144 147
 }
145 148
 
146 149
 .panel0 .item {

+ 33 - 7
pages/main/detail.js

@@ -4,7 +4,7 @@ import server from '../../utils/main';
4 4
 const app = getApp();
5 5
 var times = 1;
6 6
 var pageIndex = 0;
7
-var QuestionList = [];
7
+var QuestionItem = [];
8 8
 var isAndroid=false;
9 9
 const waitTime = ["", "10秒钟", "15秒钟", "20秒钟", "25秒钟", "半分钟", "35秒钟", "40秒钟", "45秒钟"];
10 10
 
@@ -83,8 +83,8 @@ Page({
83 83
             arrPage: [],
84 84
             WaitTime: waitTime[that.data.PageNumber],
85 85
           });
86
-          QuestionList = data;
87
-          
86
+
87
+          QuestionItem = data;
88 88
 
89 89
           if (isAndroid) {
90 90
             var ctx = wx.createCanvasContext("Canvas", that);
@@ -109,10 +109,34 @@ Page({
109 109
       });
110 110
     });
111 111
   },
112
+  saveLocalData:function(data){
113
+    var list = wx.getStorageSync("QuestionList");
114
+    if (list && list.length > 0) {
115
+      var id = list[list.length - 1].AnswerID + 1;
116
+      if (id >= 100) {
117
+        id = 1;
118
+      }
119
+      for (var i = 0; i < list.length; i++) {
120
+        if (list[i].AnswerID == id) {
121
+          list.splice(i, 1);
122
+        }
123
+      }
124
+      data.AnswerID = id;
125
+      list.push(data);
126
+    }
127
+    else {
128
+      data.AnswerID = 1;
129
+      list = [];
130
+      list.push(data);
131
+    }
132
+    wx.setStorageSync("QuestionList", list);
133
+    return data;
134
+  },
112 135
   saveImage: function() {
113
-    var item = QuestionList;
114
-
115 136
     var that = this;
137
+    var item = QuestionItem;
138
+    item = that.saveLocalData(item);
139
+
116 140
     var ctx = wx.createCanvasContext("Canvas", that);
117 141
     ctx.setFillStyle('white');
118 142
     ctx.fillRect(0, 0, 2100, 2970);
@@ -283,8 +307,7 @@ Page({
283 307
     ctx.setTextBaseline('top');
284 308
     ctx.setFontSize(32);
285 309
     ctx.fillText(item.Name, 60, 45);
286
-    ctx.fillText("99", 835, 50);
287
-
310
+    
288 311
 
289 312
     ctx.setFontSize(12);
290 313
     ctx.fillText(item.CagegoryName, 60, 90);
@@ -296,6 +319,9 @@ Page({
296 319
     ctx.fillText("出题时间 " + item.CreateTime, 875, 94);
297 320
     ctx.fillText("微信扫一扫 计时看答案", 875, 111);
298 321
     ctx.fillText("《数学计算题》选题 打印 扫码 批改", 875, 137);
322
+    ctx.setFontSize(32);
323
+    ctx.fillText(item.AnswerID, 872, 50);
324
+
299 325
     ctx.drawImage("../../images/answer.png", 890, 54, 100, 100);
300 326
 
301 327
     ctx.draw(true, function(n) {

+ 9 - 9
pages/main/list.js

@@ -101,15 +101,15 @@ Page({
101 101
       query.select('.line4').boundingClientRect();
102 102
       query.exec(function (res) {
103 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;
104
+        var LineLongHeight = Number(res[0].top) * 2-200;
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 113
         console.log("LineLongHeight:" + LineLongHeight);
114 114
         that.setData({
115 115
           LineLongHeight: LineLongHeight,

+ 1 - 1
project.config.json

@@ -30,7 +30,7 @@
30 30
 			"list": []
31 31
 		},
32 32
 		"miniprogram": {
33
-			"current": 2,
33
+			"current": -1,
34 34
 			"list": [
35 35
 				{
36 36
 					"id": 0,