chengjie 7 年 前
コミット
4bbb9ebe29
共有5 個のファイルを変更した52 個の追加45 個の削除を含む
  1. 36 36
      pages/main/detail.js
  2. 3 3
      pages/main/detail.wxml
  3. 1 1
      pages/main/index.wxml
  4. 1 1
      pages/main/list.js
  5. 11 4
      pages/main/search.js

+ 36 - 36
pages/main/detail.js

@@ -27,6 +27,7 @@ Page({
27 27
     var bookID = options.bookid || 0;
28 28
     var unitID = options.unitid || 0;
29 29
     var wordID = options.wordid || 0;
30
+
30 31
     this.audioCtx = wx.createAudioContext('myAudio');
31 32
     hanziNumber = 0;
32 33
     isClickFinished = true;
@@ -54,7 +55,7 @@ Page({
54 55
       ShowMenu: "sort",
55 56
       UnitID: unitID,
56 57
       BookID: bookID,
57
-      selectedRandom: false,
58
+      SelectedRandom: false,
58 59
       SpeakerTitle: this.data.SpeakerArray[0].name,
59 60
       SpeakerMan: 0,
60 61
       ShowPinyin: true,
@@ -65,14 +66,14 @@ Page({
65 66
     var that = this;
66 67
     common.getStorageValue(that, "IsAutoPlay", true, function () {
67 68
       common.getStorageValue(that, "IsAutoPage", false, function () {
68
-        common.getStorageValue(that, "selectedRandom", false, function () {
69
+        common.getStorageValue(that, "SelectedRandom", false, function () {
69 70
           common.getStorageValue(that, "ShowPinyin", true, function () {
70 71
             common.getStorageValue(that, "IntervalSecondIndex", 2, function () {
71 72
               common.getStorageValue(that, "IsAudioLengthChecked", true, function () {
72 73
                 common.getStorageValue(that, "SpeakerMan", 0, function () {
73 74
                   that.settingPlay(null, that.data.IsAutoPlay);
74 75
                   that.settingPage(null, that.data.IsAutoPage);
75
-                  that.settingSort(null, that.data.selectedRandom.toString());
76
+                  that.settingSort(null, that.data.SelectedRandom.toString());
76 77
                   that.settingShowPinyin(null, that.data.ShowPinyin);
77 78
                   that.settingAudioLength(null, that.data.IsAudioLengthChecked);
78 79
                   that.settingSpeaker(null, that.data.SpeakerMan);
@@ -127,7 +128,7 @@ Page({
127 128
               item.Words[k].PinyinAll = item.Words[k].Pinyin;
128 129
               if (item.Words[k].Pinyin.indexOf(",") > 0)
129 130
                 item.Words[k].Pinyin = item.Words[k].Pinyin.substr(0, item.Words[k].Pinyin.indexOf(","));
130
-              
131
+
131 132
               item.Words[k].WordUrl = app.globalData.imageUrl + "/images/hanzi" + item.Words[k].Name + ".jpg";
132 133
 
133 134
               item.Words[k].IsReview = false;
@@ -146,7 +147,7 @@ Page({
146 147
       }
147 148
     }
148 149
 
149
-    if (this.data.selectedRandom) {
150
+    if (this.data.SelectedRandom) {
150 151
       result.Words = common.randomArray(result.Words);
151 152
     }
152 153
 
@@ -171,7 +172,7 @@ Page({
171 172
     for (var l = 0; l < arrReview.length; l++) {
172 173
       var item = arrReview[l];
173 174
       item.PinyinAll = item.Pinyin;
174
-      if (item.Pinyin.indexOf(",")>0)
175
+      if (item.Pinyin.indexOf(",") > 0)
175 176
         item.Pinyin = item.Pinyin.substr(0, item.Pinyin.indexOf(","));
176 177
 
177 178
       item.WordUrl = app.globalData.imageUrl + "/images/hanzi" + item.Name + ".jpg";
@@ -179,7 +180,7 @@ Page({
179 180
     }
180 181
     var result = arrReview;
181 182
 
182
-    if (this.data.selectedRandom) {
183
+    if (this.data.SelectedRandom) {
183 184
       result = common.randomArray(result);
184 185
     }
185 186
 
@@ -206,7 +207,7 @@ Page({
206 207
     var result = wx.getStorageSync("CurrentSearchWord");
207 208
     result.WordUrl += "?" + new Date().getTime();
208 209
     result.PinyinAll = result.Pinyin;
209
-    if (result.Pinyin && result.Pinyin.indexOf(",")>0)
210
+    if (result.Pinyin && result.Pinyin.indexOf(",") > 0)
210 211
       result.Pinyin = result.Pinyin.substr(0, result.Pinyin.indexOf(","));
211 212
 
212 213
 
@@ -244,7 +245,7 @@ Page({
244 245
     wx.setNavigationBarTitle({
245 246
       title: title
246 247
     });
247
-    
248
+
248 249
     if (result.IsNew) {
249 250
       wx.showLoading({
250 251
         title: '加载中',
@@ -255,9 +256,9 @@ Page({
255 256
           List: resultArr,
256 257
         });
257 258
         that.restart(that.data.CurrentIndex);
258
-      }, 5000)
259
+      }, 1000);
259 260
     }
260
-    else{
261
+    else {
261 262
       that.setData({
262 263
         List: resultArr,
263 264
       });
@@ -286,15 +287,15 @@ Page({
286 287
       else {
287 288
 
288 289
         var pinyinItem = this.data.List[this.data.CurrentIndex].PinyinAll;
289
-        
290
+
290 291
         if (pinyinItem) {
291 292
           var pinyinStr = "";
292
-          if (pinyinItem.indexOf(",")>0){
293
-            pinyinItem=pinyinItem.substr(0,pinyinItem.indexOf(","));
293
+          if (pinyinItem.indexOf(",") > 0) {
294
+            pinyinItem = pinyinItem.substr(0, pinyinItem.indexOf(","));
294 295
             if (e && e.currentTarget.dataset.pinyin)
295 296
               pinyinItem = e.currentTarget.dataset.pinyin;
296
-              
297
-            pinyinStr = "(" + pinyin.getPinyinName(pinyinItem)+")";
297
+
298
+            pinyinStr = "(" + pinyin.getPinyinName(pinyinItem) + ")";
298 299
           }
299 300
 
300 301
           var Name = this.data.List[this.data.CurrentIndex].Name;
@@ -305,13 +306,13 @@ Page({
305 306
           else {
306 307
             var CombineWords = this.data.List[this.data.CurrentIndex].CombineWords;
307 308
             if (CombineWords)
308
-              CombineWords = ","+CombineWords.replace(Name, Name + pinyinStr)+"的"+Name;
309
+              CombineWords = "," + CombineWords.replace(Name, Name + pinyinStr) + "的" + Name;
309 310
 
310 311
             url = url.replace("[word]", Name + pinyinStr + CombineWords + pinyinStr);
311 312
           }
312 313
         }
313 314
       }
314
-      url=encodeURI(url);
315
+      url = encodeURI(url);
315 316
       this.audioCtx.setSrc(url);
316 317
       this.audioCtx.play();
317 318
     }
@@ -393,32 +394,31 @@ Page({
393 394
     }, second);
394 395
   },
395 396
   setCurrentWord: function (index, isShowPrev, isShowNext) {
396
-    var that=this;
397
+    var that = this;
397 398
     that.setData({
398 399
       CurrentIndex: index,
399 400
       IsShowPrev: isShowPrev,
400 401
       IsShowNext: isShowNext,
401 402
       IsShowWordDetail: false,
402 403
     });
403
-    
404
+
404 405
   },
405 406
   getImageError: function () {
406 407
     var that = this;
408
+    that.data.List[that.data.CurrentIndex].WordUrl = "";
409
+
407 410
     that.setData({
411
+      List: that.data.List,
408 412
       IsImageError: true,
409 413
     });
410
-    if (that.data.WordType == "normal")
411
-      that.init();
412
-    else if (that.data.WordType == "review")
413
-      that.initReview();
414
-    else if (that.data.WordType == "search")
415
-      that.initSearch();
414
+
416 415
   },
417 416
   getImageDownload: function () {
418
-    this.data.List[this.data.CurrentIndex].WordUrl += "?"+common.random(0, 9);
419
-    this.setData({
420
-      List: this.data.List,
421
-      IsImageError: false,
417
+    var that = this;
418
+    server.getData('SearchHanzi?Word=' + that.data.List[that.data.CurrentIndex].Name, function (data) {
419
+      wx.redirectTo({
420
+        url: "./detail?Type=" + that.data.WordType + "&bookid=" + that.data.BookID + "&unitid=" + that.data.UnitID + "&wordid=" + that.data.CurrentIndex + "&isfinished=" + that.data.IsFinished,
421
+      });
422 422
     });
423 423
   },
424 424
   showWordDetailHandler: function (e) {
@@ -428,7 +428,7 @@ Page({
428 428
       this.setData({
429 429
         IsShowWordDetail: this.data.IsShowWordDetail,
430 430
       });
431
-      if (!this.data.IsShowWordDetail){
431
+      if (!this.data.IsShowWordDetail) {
432 432
         this.setData({
433 433
           Detail: null,
434 434
         });
@@ -531,10 +531,10 @@ Page({
531 531
       result = e.currentTarget.dataset.id;
532 532
 
533 533
     var title = "";
534
-    var selectedRandom = true;
534
+    var SelectedRandom = true;
535 535
     if (result == "false") {
536 536
       title = "课本一致";
537
-      selectedRandom = false;
537
+      SelectedRandom = false;
538 538
     }
539 539
     else {
540 540
       title = "随机";
@@ -542,9 +542,9 @@ Page({
542 542
     this.setData({
543 543
       isShowSettingMenu: false,
544 544
       SortTitle: title,
545
-      selectedRandom: selectedRandom,
545
+      SelectedRandom: SelectedRandom,
546 546
     });
547
-    wx.setStorageSync('selectedRandom', selectedRandom);
547
+    wx.setStorageSync('SelectedRandom', SelectedRandom);
548 548
   },
549 549
   settingSpeaker: function (e, b) {
550 550
     isEditSetting.push("speaker");
@@ -685,7 +685,7 @@ Page({
685 685
 
686 686
     //this.animation = animation;
687 687
     animation.opacity(opacity).step();
688
-    if (obj =="animationData"){
688
+    if (obj == "animationData") {
689 689
       this.setData({
690 690
         animationData: animation.export(),
691 691
       });

+ 3 - 3
pages/main/detail.wxml

@@ -6,7 +6,7 @@
6 6
           {{List[CurrentIndex].Pinyin}}
7 7
         </block>
8 8
       </view>
9
-      <image binderror='getImageError' wx:if="{{!IsImageError}}" src='{{List[CurrentIndex].WordUrl}}' class="wordImage" animation="{{animationDataWord}}"/>
9
+      <image binderror='getImageError' wx:if="{{!IsImageError}}" src='{{List[CurrentIndex].WordUrl}}' class="wordImage" />
10 10
       <image catchtap='getImageDownload' wx:if="{{IsImageError}}" src='../../images/05014.png' class="wordImage" />
11 11
     </block>
12 12
     <block wx:if="{{CurrentIndex==List.length-1}}">
@@ -249,12 +249,12 @@
249 249
       </view>
250 250
       <view class="settingMenuBasic FlexColumn" bindtap='settingSort' data-id="false">
251 251
         <view class="word">课本一致</view>
252
-        <image class="SelectLogo" src="../../images/012.png" hidden="{{selectedRandom}}" />
252
+        <image class="SelectLogo" src="../../images/012.png" hidden="{{SelectedRandom}}" />
253 253
       </view>
254 254
       <view style='height:2rpx'></view>
255 255
       <view class="settingMenuBasic FlexColumn" bindtap='settingSort' data-id="true">
256 256
         <view class="word">随机</view>
257
-        <image class="SelectLogo" src="../../images/012.png" hidden="{{!selectedRandom}}" />
257
+        <image class="SelectLogo" src="../../images/012.png" hidden="{{!SelectedRandom}}" />
258 258
       </view>
259 259
     </block>
260 260
 

+ 1 - 1
pages/main/index.wxml

@@ -141,7 +141,7 @@
141 141
       </view>
142 142
     </view>
143 143
 
144
-    <view class="index9 FlexRow" wx:if="{{IsMember==1 && NewUserNumber>=NewUserNumberMax}}">
144
+    <view class="index9 FlexRow" wx:if="{{IsMember==0 || (IsMember==1 && NewUserNumber>=NewUserNumberMax)}}">
145 145
       <image src='../../images/02016.png' class="imgWave" />
146 146
     </view>
147 147
   </block>

+ 1 - 1
pages/main/list.js

@@ -103,7 +103,7 @@ Page({
103 103
       if (!wordid)
104 104
         wordid = 0
105 105
       else {
106
-        wx.setStorageSync('selectedRandom', false);
106
+        wx.setStorageSync('SelectedRandom', false);
107 107
       }
108 108
       wx.navigateTo({
109 109
         url: "./detail?bookid=" + bookid + "&unitid=" + unitid + "&wordid=" + wordid + "&isfinished=" + isfinished,

+ 11 - 4
pages/main/search.js

@@ -38,12 +38,19 @@ Page({
38 38
   },
39 39
   researchWord: function (e) {
40 40
     var that = this;
41
+    that.setData({
42
+      IsSearchResult: false,
43
+    });
41 44
     var result = false;
42 45
     var word = e.detail.value;
43 46
     if (common.IsChinese(word)) {
44 47
       server.getData('SearchHanzi?Word=' + word, function (data) {
45 48
         if (data) {
46 49
           wx.setStorageSync("CurrentSearchWord", data);
50
+
51
+          wx.setStorageSync('SelectedRandom', false);
52
+          wx.setStorageSync('IsAutoPage', false);
53
+
47 54
           wx.navigateTo({
48 55
             url: "./detail?Type=search",
49 56
           });
@@ -68,10 +75,10 @@ Page({
68 75
     var isfinished = e.currentTarget.dataset.isfinished;
69 76
     if (!wordid)
70 77
       wordid = 0
71
-    else {
72
-      wx.setStorageSync('selectedRandom', false);
73
-      wx.setStorageSync('IsAutoPage', false);
74
-    }
78
+   
79
+    wx.setStorageSync('SelectedRandom', false);
80
+    wx.setStorageSync('IsAutoPage', false);
81
+    
75 82
     wx.navigateTo({
76 83
       url: "./detail?Type=search&bookid=" + bookid + "&unitid=" + unitid + "&wordid=" + wordid + "&isfinished=" + isfinished,
77 84
     });