|
|
@@ -5,9 +5,14 @@ import pinyin from '../../utils/pinyin';
|
|
5
|
5
|
const app = getApp();
|
|
6
|
6
|
var currentIndex = 0;
|
|
7
|
7
|
var isRight = false;
|
|
|
8
|
+var arrTrue = [];
|
|
8
|
9
|
|
|
9
|
10
|
Page({
|
|
10
|
11
|
data: {
|
|
|
12
|
+ CurrentIndex: 1,
|
|
|
13
|
+ AnswerTrue: 0,
|
|
|
14
|
+ AnswerError: 0,
|
|
|
15
|
+ AnswerErrorMax: 3,
|
|
11
|
16
|
},
|
|
12
|
17
|
onLoad: function (options) {
|
|
13
|
18
|
this.setData({
|
|
|
@@ -30,13 +35,13 @@ Page({
|
|
30
|
35
|
for (var j = 0; j < pinyinList.length; j++) {
|
|
31
|
36
|
if (list[i].PinyinTest[k].options == pinyinList[j][1]) {
|
|
32
|
37
|
list[i].PinyinTest[k].name = pinyinList[j][2][0];
|
|
33
|
|
-
|
|
|
38
|
+
|
|
34
|
39
|
break;
|
|
35
|
40
|
}
|
|
36
|
41
|
}
|
|
37
|
42
|
}
|
|
38
|
43
|
}
|
|
39
|
|
-
|
|
|
44
|
+ arrTrue = [];
|
|
40
|
45
|
that.setData({
|
|
41
|
46
|
List: data,
|
|
42
|
47
|
CurrentItem: item,
|
|
|
@@ -61,10 +66,10 @@ Page({
|
|
61
|
66
|
});
|
|
62
|
67
|
},
|
|
63
|
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
|
73
|
var url = app.globalData.audioUrlBaidu;
|
|
69
|
74
|
url = url.replace("[token]", app.globalData.BaiduToken);
|
|
70
|
75
|
url = url.replace("[word]", name + "(" + pinyin + ")");
|
|
|
@@ -82,6 +87,17 @@ Page({
|
|
82
|
87
|
if (isRight) {
|
|
83
|
88
|
title = "正确";
|
|
84
|
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
|
103
|
wx.showToast({
|
|
|
@@ -89,17 +105,61 @@ Page({
|
|
89
|
105
|
icon: icon,
|
|
90
|
106
|
duration: 1000,
|
|
91
|
107
|
complete: function () {
|
|
92
|
|
- isRight=false;
|
|
|
108
|
+ isRight = false;
|
|
93
|
109
|
currentIndex++;
|
|
94
|
|
- if (currentIndex >= that.data.List.length)
|
|
|
110
|
+ if (currentIndex >= that.data.List.length) {
|
|
95
|
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
|
163
|
onShareAppMessage: function () {
|
|
104
|
164
|
return {
|
|
105
|
165
|
title: app.globalData.ShareTitle,
|