|
|
@@ -80,6 +80,8 @@ Page({
|
|
80
|
80
|
that.init();
|
|
81
|
81
|
else if (that.data.WordType == "review")
|
|
82
|
82
|
that.initReview();
|
|
|
83
|
+ else if (that.data.WordType == "search")
|
|
|
84
|
+ that.initSearch();
|
|
83
|
85
|
});
|
|
84
|
86
|
});
|
|
85
|
87
|
});
|
|
|
@@ -115,7 +117,6 @@ Page({
|
|
115
|
117
|
init: function () {
|
|
116
|
118
|
var arr = JSON.parse(wx.getStorageSync("HanziAll"));
|
|
117
|
119
|
var arrReview = wx.getStorageSync("ReviewList");
|
|
118
|
|
- var title = "";
|
|
119
|
120
|
var result;
|
|
120
|
121
|
for (var i = 0; i < arr.length; i++) {
|
|
121
|
122
|
if (arr[i].ID == this.data.BookID) {
|
|
|
@@ -129,9 +130,6 @@ Page({
|
|
129
|
130
|
item.Words[k].WordUrl = app.globalData.imageUrl + "/images/hanzi" + item.Words[k].Name + ".jpg";
|
|
130
|
131
|
|
|
131
|
132
|
item.Words[k].IsReview = false;
|
|
132
|
|
-
|
|
133
|
|
- title = arr[i].Name.replace("识字能力", "");
|
|
134
|
|
- title += " " + item.Name;
|
|
135
|
133
|
for (var l = 0; l < arrReview.length; l++) {
|
|
136
|
134
|
if (arrReview[l].Word == item.Words[k].Name) {
|
|
137
|
135
|
item.Words[k].IsReview = true;
|
|
|
@@ -163,35 +161,18 @@ Page({
|
|
163
|
161
|
});
|
|
164
|
162
|
|
|
165
|
163
|
this.restart(this.data.CurrentIndex);
|
|
166
|
|
-
|
|
167
|
164
|
wx.setNavigationBarTitle({
|
|
168
|
|
- title: title
|
|
|
165
|
+ title: "练习"
|
|
169
|
166
|
});
|
|
170
|
167
|
},
|
|
171
|
168
|
initReview: function () {
|
|
172
|
|
- var arr = JSON.parse(wx.getStorageSync("HanziAll"));
|
|
173
|
169
|
var arrReview = wx.getStorageSync("ReviewList");
|
|
174
|
|
- var title = "";
|
|
175
|
|
- var result = [];
|
|
176
|
170
|
for (var l = 0; l < arrReview.length; l++) {
|
|
177
|
|
- for (var i = 0; i < arr.length; i++) {
|
|
178
|
|
- for (var j = 0; j < arr[i].Units.length; j++) {
|
|
179
|
|
- var item = arr[i].Units[j];
|
|
180
|
|
- for (var k = 0; k < item.Words.length; k++) {
|
|
181
|
|
- if (arrReview[l].Word == item.Words[k].Name && arrReview[l].WordID == item.Words[k].ID) {
|
|
182
|
|
- if (item.Words[k].Pinyin.indexOf(",") > 0)
|
|
183
|
|
- item.Words[k].Pinyin = item.Words[k].Pinyin.substr(0, item.Words[k].Pinyin.indexOf(","));
|
|
184
|
|
-
|
|
185
|
|
- item.Words[k].WordUrl = app.globalData.imageUrl + "/images/hanzi" + item.Words[k].Name + ".jpg";
|
|
186
|
|
- item.Words[k].IsReview = false;
|
|
187
|
|
- item.Words[k].IsReview = true;
|
|
188
|
|
- result.push(item.Words[k]);
|
|
189
|
|
- break;
|
|
190
|
|
- }
|
|
191
|
|
- }
|
|
192
|
|
- }
|
|
193
|
|
- }
|
|
|
171
|
+ var item = arrReview[l];
|
|
|
172
|
+ item.WordUrl = app.globalData.imageUrl + "/images/hanzi" + item.Name + ".jpg";
|
|
|
173
|
+ item.IsReview = true;
|
|
194
|
174
|
}
|
|
|
175
|
+ var result = arrReview;
|
|
195
|
176
|
|
|
196
|
177
|
if (this.data.selectedRandom) {
|
|
197
|
178
|
result = common.randomArray(result);
|
|
|
@@ -211,8 +192,51 @@ Page({
|
|
211
|
192
|
this.restart(this.data.CurrentIndex);
|
|
212
|
193
|
|
|
213
|
194
|
wx.setNavigationBarTitle({
|
|
214
|
|
- title: "复习"
|
|
|
195
|
+ title: "练习"
|
|
|
196
|
+ });
|
|
|
197
|
+ },
|
|
|
198
|
+ initSearch: function () {
|
|
|
199
|
+ var arr = JSON.parse(wx.getStorageSync("HanziAll"));
|
|
|
200
|
+ var result = wx.getStorageSync("CurrentSearchWord");
|
|
|
201
|
+ result.WordUrl += "?" + new Date().getTime();
|
|
|
202
|
+ var arrReview = wx.getStorageSync("ReviewList");
|
|
|
203
|
+ var title = "汉字";
|
|
|
204
|
+ for (var i = 0; i < arr.length; i++) {
|
|
|
205
|
+ for (var j = 0; j < arr[i].Units.length; j++) {
|
|
|
206
|
+ var item = arr[i].Units[j];
|
|
|
207
|
+ for (var k = 0; k < item.Words.length; k++) {
|
|
|
208
|
+
|
|
|
209
|
+ if (result.ID == item.Words[k].ID) {
|
|
|
210
|
+ title = arr[i].Name.replace("识字能力", "");
|
|
|
211
|
+ title += " " + item.Name;
|
|
|
212
|
+ }
|
|
|
213
|
+ result.IsReview = false;
|
|
|
214
|
+
|
|
|
215
|
+ for (var l = 0; l < arrReview.length; l++) {
|
|
|
216
|
+ if (arrReview[l].Word == result.Name) {
|
|
|
217
|
+ result.IsReview = true;
|
|
|
218
|
+ break;
|
|
|
219
|
+ }
|
|
|
220
|
+ }
|
|
|
221
|
+ }
|
|
|
222
|
+ }
|
|
|
223
|
+ }
|
|
|
224
|
+
|
|
|
225
|
+ var resultArr = [];
|
|
|
226
|
+ resultArr.push(result);
|
|
|
227
|
+ var obj = {
|
|
|
228
|
+ IsEnd: true,
|
|
|
229
|
+ }
|
|
|
230
|
+ resultArr.push(obj);
|
|
|
231
|
+ this.setData({
|
|
|
232
|
+ List: resultArr,
|
|
|
233
|
+ });
|
|
|
234
|
+
|
|
|
235
|
+ wx.setNavigationBarTitle({
|
|
|
236
|
+ title: title
|
|
215
|
237
|
});
|
|
|
238
|
+
|
|
|
239
|
+ this.restart(this.data.CurrentIndex);
|
|
216
|
240
|
},
|
|
217
|
241
|
playAudio: function (e) {
|
|
218
|
242
|
//console.log("playAudio");
|
|
|
@@ -242,8 +266,7 @@ Page({
|
|
242
|
266
|
|
|
243
|
267
|
var Name = this.data.List[this.data.CurrentIndex].Name;
|
|
244
|
268
|
var CombineWords = this.data.List[this.data.CurrentIndex].CombineWords;
|
|
245
|
|
-
|
|
246
|
|
-
|
|
|
269
|
+ CombineWords = CombineWords.replace(Name, Name + "(" + pinyinItem + ")");
|
|
247
|
270
|
if ((e && e.currentTarget.dataset.pinyin) || !this.data.IsAudioLengthChecked) {
|
|
248
|
271
|
url = url.replace("[word]", Name + "(" + pinyinItem + ")");
|
|
249
|
272
|
url = url.replace("spd=3", "spd=1");
|
|
|
@@ -251,7 +274,6 @@ Page({
|
|
251
|
274
|
else {
|
|
252
|
275
|
url = url.replace("[word]", Name + "(" + pinyinItem + ")," + CombineWords + "的" + Name + "(" + pinyinItem + ")");
|
|
253
|
276
|
}
|
|
254
|
|
-
|
|
255
|
277
|
}
|
|
256
|
278
|
}
|
|
257
|
279
|
this.audioCtx.setSrc(url);
|
|
|
@@ -316,17 +338,6 @@ Page({
|
|
316
|
338
|
if (index == 0)
|
|
317
|
339
|
isShowPrev = false;
|
|
318
|
340
|
|
|
319
|
|
-
|
|
320
|
|
- if (that.data.wordType == "review") {
|
|
321
|
|
- for (var i = 0; i < that.data.List.length - 1; i++) {
|
|
322
|
|
- if (!that.data.List[i].IsReview)
|
|
323
|
|
- that.data.List.splice(i, 1);
|
|
324
|
|
- }
|
|
325
|
|
- that.setData({
|
|
326
|
|
- List: that.data.List,
|
|
327
|
|
- });
|
|
328
|
|
- }
|
|
329
|
|
-
|
|
330
|
341
|
this.setCurrentWord(index, isShowPrev, true);
|
|
331
|
342
|
|
|
332
|
343
|
this.playAudio();
|
|
|
@@ -359,7 +370,9 @@ Page({
|
|
359
|
370
|
});
|
|
360
|
371
|
},
|
|
361
|
372
|
getImageDownload: function () {
|
|
|
373
|
+ this.data.List[this.data.CurrentIndex].WordUrl += common.random(0, 9);
|
|
362
|
374
|
this.setData({
|
|
|
375
|
+ List: this.data.List,
|
|
363
|
376
|
IsImageError: false,
|
|
364
|
377
|
});
|
|
365
|
378
|
},
|
|
|
@@ -372,18 +385,41 @@ Page({
|
|
372
|
385
|
});
|
|
373
|
386
|
|
|
374
|
387
|
if (this.data.IsShowWordDetail) {
|
|
375
|
|
- var id = e.currentTarget.dataset.id;
|
|
376
|
|
- server.getData('GetHanziDetail?ID=' + id, function (data) {
|
|
377
|
|
- if (data) {
|
|
378
|
|
- //var data = common.Decrypt(data);
|
|
379
|
|
- //data=JSON.parse(data);
|
|
380
|
|
- data.Antonym = data.Antonym.join(" ");
|
|
381
|
|
- data.Synonym = data.Synonym.join(" ");
|
|
382
|
|
- that.setData({
|
|
383
|
|
- Detail: data,
|
|
384
|
|
- });
|
|
|
388
|
+ if (this.data.WordType == "search") {
|
|
|
389
|
+ var result = wx.getStorageSync("CurrentSearchWord");
|
|
|
390
|
+ result = JSON.parse(result.Details);
|
|
|
391
|
+ for (var i = 0; i < result.PinYin.length; i++) {
|
|
|
392
|
+ var item = result.PinYin[i].explain;
|
|
|
393
|
+ item = common.ReplaceAllString(item, "<p>", "");
|
|
|
394
|
+ item = common.ReplaceAllString(item, "<span>", "");
|
|
|
395
|
+ item = common.ReplaceAllString(item, "</span>", "");
|
|
|
396
|
+ item = common.ReplaceAllString(item, "\r", "");
|
|
|
397
|
+ item = common.ReplaceAllString(item, "\n", "");
|
|
|
398
|
+
|
|
|
399
|
+ var arr = item.split("</p>");
|
|
|
400
|
+ arr.pop();
|
|
|
401
|
+ result.PinYin[i].explain = arr;
|
|
385
|
402
|
}
|
|
386
|
|
- });
|
|
|
403
|
+ result.Antonym = result.Antonym.join(" ");
|
|
|
404
|
+ result.Synonym = result.Synonym.join(" ");
|
|
|
405
|
+ that.setData({
|
|
|
406
|
+ Detail: result,
|
|
|
407
|
+ });
|
|
|
408
|
+ }
|
|
|
409
|
+ else {
|
|
|
410
|
+ var id = e.currentTarget.dataset.id;
|
|
|
411
|
+ server.getData('GetHanziDetail?ID=' + id, function (data) {
|
|
|
412
|
+ if (data) {
|
|
|
413
|
+ //var data = common.Decrypt(data);
|
|
|
414
|
+ //data=JSON.parse(data);
|
|
|
415
|
+ data.Antonym = data.Antonym.join(" ");
|
|
|
416
|
+ data.Synonym = data.Synonym.join(" ");
|
|
|
417
|
+ that.setData({
|
|
|
418
|
+ Detail: data,
|
|
|
419
|
+ });
|
|
|
420
|
+ }
|
|
|
421
|
+ });
|
|
|
422
|
+ }
|
|
387
|
423
|
}
|
|
388
|
424
|
}
|
|
389
|
425
|
},
|