chengjie 7 years ago
parent
commit
a9b9758e1e
7 changed files with 131 additions and 41 deletions
  1. 1 1
      app.js
  2. 3 8
      pages/main/detail.js
  3. 12 15
      pages/main/index.js
  4. 71 11
      pages/main/test.js
  5. 10 2
      pages/main/test.wxml
  6. 31 1
      pages/main/test.wxss
  7. 3 3
      utils/pinyin.js

+ 1 - 1
app.js

@@ -11,7 +11,7 @@ App({
11
     this.globalData.systemInfo = wx.getSystemInfoSync();
11
     this.globalData.systemInfo = wx.getSystemInfoSync();
12
   },
12
   },
13
   globalData: {
13
   globalData: {
14
-    Version: "1.1.9",
14
+    Version: "1.1.10",
15
     IsProduction: true,
15
     IsProduction: true,
16
     ProgramID: 106,
16
     ProgramID: 106,
17
     AppID: "wx313a8f2c0741efe1",
17
     AppID: "wx313a8f2c0741efe1",

+ 3 - 8
pages/main/detail.js

@@ -130,14 +130,9 @@ Page({
130
       wx.setStorageSync('IsHelpPosition1', 2);
130
       wx.setStorageSync('IsHelpPosition1', 2);
131
     }
131
     }
132
 
132
 
133
-    wx.getSetting({
134
-      success(res) {
135
-        if (!res.authSetting['scope.userInfo']) {
136
-          wx.setStorageSync('IsRemindAccredit', 1);
137
-        }
138
-      }
139
-    })
140
-
133
+    var IsRemindTest = wx.getStorageSync("IsRemindTest");
134
+    if (!IsRemindTest)
135
+      wx.setStorageSync('IsRemindTest', 1);
141
   },
136
   },
142
   submitData: function (content) {
137
   submitData: function (content) {
143
     if (app.globalData.userInfo && app.globalData.userInfo.UserID) {
138
     if (app.globalData.userInfo && app.globalData.userInfo.UserID) {

+ 12 - 15
pages/main/index.js

@@ -42,12 +42,9 @@ Page({
42
           });
42
           });
43
         }
43
         }
44
         else {
44
         else {
45
-          //付费用户请去授权
46
-          if (app.globalData.userInfo.IsMember == 1) {
47
-            wx.navigateTo({
48
-              url: '../about/payfinished?type=accredit',
49
-            });
50
-          }
45
+          wx.navigateTo({
46
+            url: '../about/payfinished?type=accredit',
47
+          });
51
         }
48
         }
52
       }
49
       }
53
     })
50
     })
@@ -60,15 +57,6 @@ Page({
60
   onShow: function () {
57
   onShow: function () {
61
     this.getData();
58
     this.getData();
62
 
59
 
63
-    //进入详情出来后,让用户授权
64
-    if (!this.data.IsAccredit) {
65
-      var IsRemindAccredit = wx.getStorageSync("IsRemindAccredit");
66
-      if (IsRemindAccredit == 1) {
67
-        this.getAccredit();
68
-        wx.removeStorageSync('IsRemindAccredit');
69
-      }
70
-    }
71
-
72
     if (wx.getStorageSync("indexNav")) {
60
     if (wx.getStorageSync("indexNav")) {
73
       var obj = {
61
       var obj = {
74
         currentTarget: {
62
         currentTarget: {
@@ -87,6 +75,15 @@ Page({
87
         url: '../about/paylist',
75
         url: '../about/paylist',
88
       });
76
       });
89
     }
77
     }
78
+    else{
79
+      var IsRemindTest = wx.getStorageSync("IsRemindTest");
80
+      if (IsRemindTest == 1) {
81
+        wx.setStorageSync('IsRemindTest', 2);
82
+        wx.navigateTo({
83
+          url: '../main/test',
84
+        });
85
+      }
86
+    }
90
   },
87
   },
91
   getAccredit: function () {
88
   getAccredit: function () {
92
     if (!this.data.IsAccredit) {
89
     if (!this.data.IsAccredit) {

+ 71 - 11
pages/main/test.js

@@ -5,9 +5,14 @@ import pinyin from '../../utils/pinyin';
5
 const app = getApp();
5
 const app = getApp();
6
 var currentIndex = 0;
6
 var currentIndex = 0;
7
 var isRight = false;
7
 var isRight = false;
8
+var arrTrue = [];
8
 
9
 
9
 Page({
10
 Page({
10
   data: {
11
   data: {
12
+    CurrentIndex: 1,
13
+    AnswerTrue: 0,
14
+    AnswerError: 0,
15
+    AnswerErrorMax: 3,
11
   },
16
   },
12
   onLoad: function (options) {
17
   onLoad: function (options) {
13
     this.setData({
18
     this.setData({
@@ -30,13 +35,13 @@ Page({
30
             for (var j = 0; j < pinyinList.length; j++) {
35
             for (var j = 0; j < pinyinList.length; j++) {
31
               if (list[i].PinyinTest[k].options == pinyinList[j][1]) {
36
               if (list[i].PinyinTest[k].options == pinyinList[j][1]) {
32
                 list[i].PinyinTest[k].name = pinyinList[j][2][0];
37
                 list[i].PinyinTest[k].name = pinyinList[j][2][0];
33
-                
38
+
34
                 break;
39
                 break;
35
               }
40
               }
36
             }
41
             }
37
           }
42
           }
38
         }
43
         }
39
-
44
+        arrTrue = [];
40
         that.setData({
45
         that.setData({
41
           List: data,
46
           List: data,
42
           CurrentItem: item,
47
           CurrentItem: item,
@@ -61,10 +66,10 @@ Page({
61
     });
66
     });
62
   },
67
   },
63
   playAudio: function (pinyin, name) {
68
   playAudio: function (pinyin, name) {
64
-    if (name != undefined){
65
-      if (pinyin==undefined)
66
-        pinyin="";
67
-      
69
+    if (name != undefined) {
70
+      if (pinyin == undefined)
71
+        pinyin = "";
72
+
68
       var url = app.globalData.audioUrlBaidu;
73
       var url = app.globalData.audioUrlBaidu;
69
       url = url.replace("[token]", app.globalData.BaiduToken);
74
       url = url.replace("[token]", app.globalData.BaiduToken);
70
       url = url.replace("[word]", name + "(" + pinyin + ")");
75
       url = url.replace("[word]", name + "(" + pinyin + ")");
@@ -82,6 +87,17 @@ Page({
82
     if (isRight) {
87
     if (isRight) {
83
       title = "正确";
88
       title = "正确";
84
       icon = "success";
89
       icon = "success";
90
+      that.data.AnswerTrue++;
91
+      for (var i = 0; i < arrTrue.length; i++) {
92
+        if (arrTrue[i] == that.data.CurrentItem.HanziUnitID) {
93
+          arrTrue.splice(i, 1);
94
+          break;
95
+        }
96
+      }
97
+      arrTrue.push(that.data.CurrentItem.HanziUnitID);
98
+    }
99
+    else {
100
+      that.data.AnswerError++;
85
     }
101
     }
86
 
102
 
87
     wx.showToast({
103
     wx.showToast({
@@ -89,17 +105,61 @@ Page({
89
       icon: icon,
105
       icon: icon,
90
       duration: 1000,
106
       duration: 1000,
91
       complete: function () {
107
       complete: function () {
92
-        isRight=false;
108
+        isRight = false;
93
         currentIndex++;
109
         currentIndex++;
94
-        if (currentIndex >= that.data.List.length)
110
+        if (currentIndex >= that.data.List.length) {
95
           currentIndex = 0;
111
           currentIndex = 0;
96
-        that.setData({
97
-          CurrentItem: that.data.List[currentIndex],
98
-        });
112
+          that.getResult(1);
113
+        } 
114
+        else if (that.data.AnswerError > 3) {
115
+          currentIndex = 0;
116
+          that.getResult(0);
117
+        }
118
+        else {
119
+          that.setData({
120
+            CurrentItem: that.data.List[currentIndex],
121
+            CurrentIndex: currentIndex + 1,
122
+            AnswerTrue: that.data.AnswerTrue,
123
+            AnswerError: that.data.AnswerError,
124
+          });
125
+        }
99
       }
126
       }
100
     })
127
     })
101
 
128
 
102
   },
129
   },
130
+  getResult: function (isFinished) {
131
+    var content = "";
132
+    var arr = JSON.parse(wx.getStorageSync("HanziAll"));
133
+    var count = 0;
134
+    var book = arr[0].Name;
135
+    for (var i = 0; i < arr.length; i++) {
136
+      for (var j = 0; j < arr[i].Units.length; j++) {
137
+        for (var k = 0; k < arrTrue.length; k++) {
138
+          if (arrTrue[k] == arr[i].Units[j].ID) {
139
+            count += arr[i].Units[j].Words.length;
140
+            book=arr[i].Name;
141
+          }
142
+        }
143
+      }
144
+    }
145
+    content = '您孩子的识字数大约是' + count + '个,建议从《' + book+'》学习起。';
146
+    if (count == 0) {
147
+      content = '您孩子的识字数未知,建议从《' + book +'》学习起。';
148
+    }
149
+    if (isFinished == 1) {
150
+      content = '您孩子的识字数大约是' + count + '个,实在太优秀了!建议自行搜索文字学习。';
151
+    }
152
+    wx.showModal({
153
+      title: '测试结果',
154
+      content: content,
155
+      showCancel: false,
156
+      success: function () {
157
+        wx.navigateBack({
158
+          delta: 1
159
+        })
160
+      },
161
+    });
162
+  },
103
   onShareAppMessage: function () {
163
   onShareAppMessage: function () {
104
     return {
164
     return {
105
       title: app.globalData.ShareTitle,
165
       title: app.globalData.ShareTitle,

+ 10 - 2
pages/main/test.wxml

@@ -1,6 +1,11 @@
1
 <view class="container FlexColumn" style='min-height:{{Height}}rpx;'>
1
 <view class="container FlexColumn" style='min-height:{{Height}}rpx;'>
2
   <image src='https://hanzi-1253256735.file.myqcloud.com/images/hanzi{{CurrentItem.Name}}.jpg' class="wordImage" />
2
   <image src='https://hanzi-1253256735.file.myqcloud.com/images/hanzi{{CurrentItem.Name}}.jpg' class="wordImage" />
3
 
3
 
4
+  <view class="panelTop0 FlexRow">
5
+    <view class='left'>得分:{{AnswerTrue}} / {{List.length}}</view>
6
+    <view class='right'>错误:{{AnswerError}} / {{AnswerErrorMax}}</view>
7
+  </view>
8
+
4
   <view class="panelTop FlexRow">
9
   <view class="panelTop FlexRow">
5
     <view class="title">选择正确的汉字发音</view>
10
     <view class="title">选择正确的汉字发音</view>
6
   </view>
11
   </view>
@@ -8,10 +13,13 @@
8
     <view wx:if="{{!item.IsSelected}}" class="universalpic_select_on_black"></view>
13
     <view wx:if="{{!item.IsSelected}}" class="universalpic_select_on_black"></view>
9
     <image src='../../images/SelectYes.png' wx:if="{{item.IsSelected}}" class="universalpic_select_on_black" />
14
     <image src='../../images/SelectYes.png' wx:if="{{item.IsSelected}}" class="universalpic_select_on_black" />
10
     <view class="Number">{{index+1}}.</view>
15
     <view class="Number">{{index+1}}.</view>
11
-    
16
+
12
     <view class="Name">{{item.options}}</view>
17
     <view class="Name">{{item.options}}</view>
13
   </view>
18
   </view>
14
-  <view class="bottom" bindtap='gotoOK' data-id="0">确认</view>
19
+  <view class="bottom FlexRow" >
20
+    <text class="bottom1" bindtap='getResult'>退出\n测试</text>
21
+    <view class="bottom2" bindtap='gotoOK' data-id="0">确认</view>
22
+  </view>
15
 
23
 
16
 </view>
24
 </view>
17
 <audio hidden='true' id="myAudio"></audio>
25
 <audio hidden='true' id="myAudio"></audio>

+ 31 - 1
pages/main/test.wxss

@@ -11,12 +11,30 @@
11
 }
11
 }
12
 
12
 
13
 
13
 
14
+.panelTop0{
15
+  width:100%;
16
+  justify-content:space-between;
17
+  height:100rpx;
18
+  position: absolute;
19
+  top:-10rpx;
20
+  font-size: 24rpx;
21
+}
22
+
23
+.panelTop0 .left{
24
+  margin-left: 30rpx;
25
+}
26
+
27
+.panelTop0 .right{
28
+  margin-right: 30rpx;
29
+}
30
+
14
 .panelTop{
31
 .panelTop{
15
   width:100%;
32
   width:100%;
16
   justify-content: flex-start;
33
   justify-content: flex-start;
17
   height:100rpx;
34
   height:100rpx;
18
 }
35
 }
19
 
36
 
37
+
20
 .title{
38
 .title{
21
   margin: 50rpx 0 30rpx 30rpx;
39
   margin: 50rpx 0 30rpx 30rpx;
22
   font-size:24rpx;
40
   font-size:24rpx;
@@ -51,10 +69,22 @@
51
 .bottom{
69
 .bottom{
52
   position: fixed;
70
   position: fixed;
53
   bottom:0;
71
   bottom:0;
72
+  width: 100%;
73
+  background-color: #4A4A4A;
74
+}
75
+
76
+.bottom1{
77
+  font-size:28rpx;
78
+  color:#fff;
79
+  text-align: center;
80
+  width: 20%;
81
+}
82
+
83
+.bottom2{
54
   font-size:48rpx;
84
   font-size:48rpx;
55
   color:#fff;
85
   color:#fff;
56
   background-color: #FF7245;
86
   background-color: #FF7245;
57
   text-align: center;
87
   text-align: center;
58
   line-height: 120rpx;
88
   line-height: 120rpx;
59
-  width: 100%;
89
+  width: 80%;
60
 }
90
 }

+ 3 - 3
utils/pinyin.js

@@ -24,7 +24,7 @@ const getPinyinArray = function () {
24
     ['ba2', 'bá', ['拔']],
24
     ['ba2', 'bá', ['拔']],
25
     ['ba3', 'bǎ', ['把']],
25
     ['ba3', 'bǎ', ['把']],
26
     ['ba4', 'bà', ['爸']],
26
     ['ba4', 'bà', ['爸']],
27
-    ['ba5', 'ba', ['']],
27
+    ['ba5', 'ba', ['']],
28
     ['bai1', 'bāi', ['掰']],
28
     ['bai1', 'bāi', ['掰']],
29
     ['bai2', 'bái', ['白']],
29
     ['bai2', 'bái', ['白']],
30
     ['bai3', 'bǎi', ['百']],
30
     ['bai3', 'bǎi', ['百']],
@@ -718,7 +718,7 @@ const getPinyinArray = function () {
718
     ['men2', 'mén', ['门', '们']],
718
     ['men2', 'mén', ['门', '们']],
719
     ['men3', 'měn', ['']],
719
     ['men3', 'měn', ['']],
720
     ['men4', 'mèn', ['闷']],
720
     ['men4', 'mèn', ['闷']],
721
-    ['men5', 'men', ['']],
721
+    ['men5', 'men', ['']],
722
     ['meng1', 'mēng', ['蒙']],
722
     ['meng1', 'mēng', ['蒙']],
723
     ['meng2', 'méng', ['蒙', '盟', '萌']],
723
     ['meng2', 'méng', ['蒙', '盟', '萌']],
724
     ['meng3', 'měng', ['猛', '']],
724
     ['meng3', 'měng', ['猛', '']],
@@ -1404,7 +1404,7 @@ const getPinyinArray = function () {
1404
     ['zhe2', 'zhé', ['折']],
1404
     ['zhe2', 'zhé', ['折']],
1405
     ['zhe3', 'zhě', ['者']],
1405
     ['zhe3', 'zhě', ['者']],
1406
     ['zhe4', 'zhè', ['这']],
1406
     ['zhe4', 'zhè', ['这']],
1407
-    ['zhe5', 'zhe', ['']],
1407
+    ['zhe5', 'zhe', ['']],
1408
     ['zhei4', 'zhèi', ['这']],
1408
     ['zhei4', 'zhèi', ['这']],
1409
     ['zhen1', 'zhēn', ['真', '针', '珍']],
1409
     ['zhen1', 'zhēn', ['真', '针', '珍']],
1410
     ['zhen3', 'zhěn', ['枕', '诊', '疹']],
1410
     ['zhen3', 'zhěn', ['枕', '诊', '疹']],