chengjie 7 年之前
父节点
当前提交
986c9dc05e
共有 15 个文件被更改,包括 1931 次插入85 次删除
  1. 28 4
      app.js
  2. 1 0
      app.json
  3. 36 0
      app.wxss
  4. 二进制
      images/05014.png
  5. 13 1
      pages/index/index.js
  6. 176 0
      pages/main/detail.js
  7. 7 0
      pages/main/detail.json
  8. 31 0
      pages/main/detail.wxml
  9. 79 0
      pages/main/detail.wxss
  10. 6 22
      pages/main/index.js
  11. 4 4
      pages/main/index.wxml
  12. 35 0
      pages/main/list.js
  13. 10 52
      pages/main/list.wxml
  14. 8 2
      project.config.json
  15. 1497 0
      utils/pinyin.js

+ 28 - 4
app.js

@@ -1,10 +1,34 @@
1 1
 //app.js
2 2
 App({
3
-  onLaunch: function () {
4
-
3
+  onLaunch: function (options) {
4
+    this.getSystemInfo();
5
+    if (options && options.scene) {
6
+      //console.log("scene:" + options.scene);
7
+      this.globalData.userSource = options.scene;
8
+    }
9
+  },
10
+  getSystemInfo: function () {
11
+    this.globalData.systemInfo = wx.getSystemInfoSync();
5 12
   },
6 13
   globalData: {
7
-    Version: "0.1.0",
8
-    userInfo: null
14
+    Version: "1.0.0",
15
+    IsProduction: true,
16
+    userInfo: null,
17
+    fileUrl: "https://www.kylx365.com/",
18
+    serverUrl: "https://www.kylx365.com/apiData/",
19
+    serverUrlServer: "https://www.kylx365.com/apiData/",
20
+    serverUrlLocalhost: "http://localhost:3020/apiData/",
21
+    imageUrl: "https://hanzi-1253256735.file.myqcloud.com",
22
+    audioUrl: "https://pinyin.kylx365.com",
23
+    Key: "kylx365_chengjie",
24
+    IV: "kylx365hongliren",
25
+    systemInfo: null,
26
+    userInfo: null,
27
+    SourceID: 0,//来源ID
28
+    IsRefreshFinished: true,
29
+    DayNumber: 0,//使用天数
30
+    PayMoney: 9.8,//产品销售价
31
+    TestScoreMax: 0,//测试最高分
32
+    IsShow: 0,
9 33
   }
10 34
 })

+ 1 - 0
app.json

@@ -2,6 +2,7 @@
2 2
   "pages": [
3 3
     "pages/index/index",
4 4
     "pages/main/list",
5
+    "pages/main/detail",
5 6
     "pages/main/index"
6 7
   ],
7 8
   "window": {

文件差异内容过多而无法显示
+ 36 - 0
app.wxss


二进制
images/05014.png


+ 13 - 1
pages/index/index.js

@@ -22,8 +22,20 @@ Page({
22 22
         url: '../main/index'
23 23
       })
24 24
     },2000);
25
+
26
+    this.getHanzi();
27
+  },
28
+  getHanzi: function () {
29
+    var that = this;
30
+    var time = wx.getStorageSync("HanziUpdateTime");
31
+    server.getData('GetHanziAll?UpdateTime=' + time, function (data) {
32
+      if (data) {
33
+        var arr = common.Decrypt(data.List);
34
+        wx.setStorageSync("HanziAll", arr);
35
+        wx.setStorageSync("HanziUpdateTime", data.UpdateTime);
36
+      }
37
+    });
25 38
   },
26
-  
27 39
   onShareAppMessage: function () {
28 40
     return {
29 41
       title: '',

+ 176 - 0
pages/main/detail.js

@@ -0,0 +1,176 @@
1
+import common from '../../utils/util';
2
+import server from '../../utils/main';
3
+import pinyin from '../../utils/pinyin';
4
+
5
+const app = getApp();
6
+var wordNumber = 0;
7
+
8
+Page({
9
+  data: {
10
+    IsAutoPlay: true,//是否自动播放
11
+    IsAutoPage: false,//是否自动翻页
12
+    SortTitle: "课文顺序",//排序
13
+    PlayChecked: "checked",
14
+    PageChecked: "",
15
+    IsFinished: false,//是否练会了
16
+    arrIntervalSecond: [3, 4, 5, 6, 7, 8, 9, 10],//播放间隔秒数组
17
+    IntervalSecondIndex: 2,//播放间隔秒数索引
18
+    IsImageError: false,
19
+  },
20
+  onLoad: function (options) {
21
+    var bookID = options.bookid;
22
+    var unitID = options.id;
23
+    this.audioCtx = wx.createAudioContext('myAudio');
24
+
25
+    this.setData({
26
+      Height: common.getSystemHeight(),
27
+      IsShowPrev: false,
28
+      IsShowNext: true,
29
+      CurrentIndex: 0,
30
+      IsFinished: false,
31
+      IsHelpPosition1: 0,
32
+      IsHelpPosition2: 0,
33
+      IsReview: false,
34
+      UnitID: unitID,
35
+      BookID: bookID,
36
+    });
37
+
38
+    this.init();
39
+  },
40
+  init: function () {
41
+    var arr = JSON.parse(wx.getStorageSync("HanziAll"));
42
+
43
+    var result;
44
+    for (var i = 0; i < arr.length; i++) {
45
+      if (arr[i].ID == this.data.BookID) {
46
+        result = arr[i];
47
+        for (var j = 0; j < result.Units.length; j++) {
48
+          var item = result.Units[j];
49
+          if (item.ID == this.data.UnitID){
50
+            for(var k=0;k<item.Words.length;k++){
51
+              if (item.Words[k].Pinyin.indexOf(",") > 0)
52
+                item.Words[k].Pinyin = item.Words[k].Pinyin.substr(0, item.Words[k].Pinyin.indexOf(","));
53
+
54
+              item.Words[k].WordUrl = app.globalData.imageUrl+"/images/hanzi"+item.Words[k].Name+".jpg";
55
+            }
56
+            result=item;
57
+            break;
58
+          }
59
+        }
60
+        break;
61
+      }
62
+    }
63
+    this.setData({
64
+      List: result.Words,
65
+    });
66
+
67
+    this.restart();
68
+  },
69
+  playAudio: function (e) {
70
+    //console.log("playAudio");
71
+    var click = false;
72
+    if (e)
73
+      click = e.currentTarget.dataset.click;
74
+
75
+
76
+    if ((click || this.data.IsAutoPlay) && !(click && this.data.IsAutoPage)) {
77
+      var pinyinItem = this.data.List[this.data.CurrentIndex].Pinyin;
78
+      if (pinyinItem) {
79
+        pinyinItem = pinyin.getPinyinName(pinyinItem);
80
+        this.audioCtx.setSrc(app.globalData.audioUrl + "/sounds/" + pinyinItem + ".m4a");
81
+        this.audioCtx.play();
82
+      }
83
+    }
84
+  },
85
+  prevHandler: function () {
86
+    if (this.data.IsShowPrev && !this.data.IsAutoPage) {
87
+      var index = this.data.CurrentIndex;
88
+      var isShowPrev = true;
89
+      var isShowNext = true;
90
+
91
+      index--;
92
+      if (index <= 0) {
93
+        index = 0;
94
+        isShowPrev = false;
95
+      }
96
+
97
+      this.setCurrentWord(index, isShowPrev, isShowNext);
98
+
99
+      this.playAudio();
100
+
101
+      wordNumber++;
102
+    }
103
+  },
104
+  nextHandler: function (e) {
105
+    if (e && e.currentTarget.dataset.status == "click" && this.data.IsAutoPage) {
106
+
107
+    }
108
+    else if (this.data.IsShowNext) {
109
+      var index = this.data.CurrentIndex;
110
+      var isShowPrev = true;
111
+      var isShowNext = true;
112
+
113
+      index++;
114
+      if (index >= this.data.List.length - 1) {
115
+        index = this.data.List.length - 1;
116
+        isShowNext = false;
117
+      }
118
+      this.setCurrentWord(index, isShowPrev, isShowNext);
119
+
120
+      if (isShowNext)
121
+        this.playAudio();
122
+
123
+      wordNumber++;
124
+    }
125
+  },
126
+  restart: function () {
127
+    var that = this;
128
+    var index = 0;
129
+
130
+    if (that.data.wordType == "review") {
131
+      for (var i = 0; i < that.data.List.length - 1; i++) {
132
+        if (!that.data.List[i].IsReview)
133
+          that.data.List.splice(i, 1);
134
+      }
135
+      that.setData({
136
+        List: that.data.List,
137
+      });
138
+    }
139
+
140
+    this.setCurrentWord(index, false, true);
141
+
142
+    this.playAudio();
143
+    wordNumber++;
144
+
145
+    if (this.data.IsAutoPage) {
146
+      this.startAutoPage();
147
+    }
148
+  },
149
+  startAutoPage: function () {
150
+    var that = this;
151
+    clearInterval(intervalAutoPage);
152
+    var second = this.data.arrIntervalSecond[this.data.IntervalSecondIndex] * 1000;
153
+    //console.log("second:" + second);
154
+    intervalAutoPage = setInterval(function () {
155
+      that.nextHandler();
156
+    }, second);
157
+  },
158
+  setCurrentWord: function (index, isShowPrev, isShowNext) {
159
+    
160
+    this.setData({
161
+      CurrentIndex: index,
162
+      IsShowPrev: isShowPrev,
163
+      IsShowNext: isShowNext,
164
+    });
165
+  },
166
+  getImageError:function(){
167
+    this.setData({
168
+      IsImageError:true,
169
+    });
170
+  },
171
+  getImageDownload: function () {
172
+    this.setData({
173
+      IsImageError: false,
174
+    });
175
+  },
176
+})

+ 7 - 0
pages/main/detail.json

@@ -0,0 +1,7 @@
1
+{
2
+  "navigationBarBackgroundColor": "#F0F0F0",
3
+  "navigationBarTitleText": "练习",
4
+  "enablePullDownRefresh": false,
5
+  "backgroundColor":"#F0F0F0",
6
+  "disableScroll":false
7
+}

+ 31 - 0
pages/main/detail.wxml

@@ -0,0 +1,31 @@
1
+<view class="container FlexColumn" style='height:{{Height}}rpx;'>
2
+  <view class="main FlexColumn" bindtap='playAudio' data-click="true" >
3
+    <view class="pinyin">{{List[CurrentIndex].Pinyin}}</view>
4
+    <image binderror='getImageError' wx:if="{{!IsImageError}}" src='{{List[CurrentIndex].WordUrl}}' class="wordImage" />
5
+    <image catchtap='getImageDownload' wx:if="{{IsImageError}}" src='../../images/05014.png' class="wordImage" />
6
+  </view>
7
+  <view class="bottom FlexColumn">
8
+    <view class="bottom1 FlexRow">
9
+      <view class="btn FlexColumn" bindtap='prevHandler'>
10
+        <image src='../../images/05001.png' class="btnImage05001" wx:if="{{IsShowPrev && !IsAutoPage }}" />
11
+      </view>
12
+      <view class="btn FlexColumn" bindtap='reviewHandler'>
13
+        <image wx:if="{{!List[CurrentIndex].IsReview && IsShowNext && !IsAutoPage}}" src='../../images/05002.png' class="btnImage05002" />
14
+        <image wx:if="{{List[CurrentIndex].IsReview && IsShowNext && !IsAutoPage}}" src='../../images/05003.png' class="btnImage05002" />
15
+        <image wx:if="{{!IsShowNext}}" src='../../images/05009.png' class="btnImage022" />
16
+      </view>
17
+      <view class="btn FlexColumn" bindtap='openSetting'>
18
+        <image src='../../images/05004.png' class="btnImage05004" />
19
+      </view>
20
+      <view class="btn FlexColumn" bindtap='showWordHandler'>
21
+        <image src='../../images/05005.png' wx:if="{{IsShowWordCurrent && IsShowNext && !IsAutoPage}}" class="btnImage05005" />
22
+        <image src='../../images/05006.png' wx:if="{{!IsShowWordCurrent && IsShowNext && !IsAutoPage}}" class="btnImage05006" />
23
+      </view>
24
+      <view class="btn FlexColumn" bindtap='nextHandler' data-status="click">
25
+        <image src='../../images/05007.png' class="btnImage05001" wx:if="{{IsShowNext && !IsAutoPage}}" />
26
+      </view>
27
+    </view>
28
+  </view>
29
+</view>
30
+
31
+<audio hidden='true' src="{{AudioSrc}}" id="myAudio"></audio>

+ 79 - 0
pages/main/detail.wxss

@@ -0,0 +1,79 @@
1
+.container {
2
+  background-color: #F0F0F0;
3
+  justify-content: flex-start;
4
+  font-weight: 500;
5
+}
6
+
7
+.bottom{
8
+  width:100%;
9
+  height:160rpx;
10
+  position: fixed;
11
+  bottom:0;
12
+  background-color: #CDB797;
13
+  justify-content: flex-end;
14
+}
15
+.bottom1{
16
+  width:100%;
17
+  height:140rpx;
18
+  background-color: #1B1B1B;
19
+  text-align: center;
20
+  line-height: 140rpx;
21
+  font-size: 48rpx;
22
+  color: #f0f0f0;
23
+}
24
+
25
+.bottom1 .btn{
26
+  width:20%;
27
+  height:120rpx;
28
+}
29
+
30
+.bottom1 .btnImage05004{
31
+  width:36rpx;
32
+  height:36rpx;
33
+}
34
+
35
+.bottom1 .btnImage05005{
36
+  width:45rpx;
37
+  height:44rpx;
38
+}
39
+
40
+.bottom1 .btnImage05002{
41
+  width:32rpx;
42
+  height:34rpx;
43
+}
44
+
45
+.bottom1 .btnImage05006{
46
+  width:42rpx;
47
+  height:44rpx;
48
+}
49
+
50
+.bottom1 .btnImage022{
51
+  width:40rpx;
52
+  height:40rpx;
53
+}
54
+
55
+.bottom1 .btnImage05001{
56
+  width:33rpx;
57
+  height:40rpx;
58
+}
59
+
60
+.main{
61
+  width:100%;
62
+  justify-content: flex-start;
63
+  position: fixed;
64
+  top:0;
65
+  left:0;
66
+}
67
+
68
+.main .pinyin{
69
+  font-size:88rpx;
70
+  margin-top: 212rpx;
71
+  font-family: 'GB Pinyinok-C';
72
+  font-weight: normal;
73
+  font-style: normal;
74
+}
75
+.main .wordImage{
76
+  margin-top: 40rpx;
77
+  width:366rpx;
78
+  height:370rpx;
79
+}

+ 6 - 22
pages/main/index.js

@@ -6,28 +6,6 @@ const app = getApp();
6 6
 Page({
7 7
   data: {
8 8
     Version: app.globalData.Version,
9
-    List: [
10
-      {
11
-        ImageUrl: "109.png",
12
-        Url: "./basicMain?type=a_z",
13
-      },
14
-      {
15
-        ImageUrl: "101.png",
16
-        Url: "./basicMain?type=basic",
17
-      },
18
-      {
19
-        ImageUrl: "102.png",
20
-        Url: "./basicMain?type=intermediate",
21
-      },
22
-      {
23
-        ImageUrl: "103.png",
24
-        Url: "./basicMain?type=all",
25
-      },
26
-      {
27
-        ImageUrl: "107.png",
28
-        Url: "./basicMain?type=read",
29
-      },
30
-    ],
31 9
     ListProgram: [
32 10
       {
33 11
         ImageUrl: "03001.png",
@@ -92,4 +70,10 @@ Page({
92 70
 
93 71
     }
94 72
   },
73
+  goto: function (e) {
74
+    var id = e.currentTarget.dataset.id;
75
+    wx.navigateTo({
76
+      url: "./list?id="+id,
77
+    });
78
+  },
95 79
 })

+ 4 - 4
pages/main/index.wxml

@@ -12,7 +12,7 @@
12 12
   <block wx:if="{{NavClass2=='nav2'}}">
13 13
     <view class="index2 FlexRow">
14 14
       <view class="index2_1 FlexRow">
15
-        <view class="btn" bindtap="">
15
+        <view class="btn" bindtap="goto" data-id="1">
16 16
           <view class="btn1">
17 17
             <view class="panel1 FlexRow">
18 18
               <image src='../../images/02005.png' class="img" />
@@ -22,7 +22,7 @@
22 22
             </view>
23 23
           </view>
24 24
         </view>
25
-        <view class="btn" bindtap="">
25
+        <view class="btn" bindtap="goto" data-id="2">
26 26
           <view class="btn1">
27 27
             <view class="panel1 FlexRow">
28 28
               <image src='../../images/02006.png' class="img" />
@@ -32,7 +32,7 @@
32 32
             </view>
33 33
           </view>
34 34
         </view>
35
-        <view class="btn" bindtap="">
35
+        <view class="btn" bindtap="goto" data-id="3">
36 36
           <view class="btn1">
37 37
             <view class="panel1 FlexRow">
38 38
               <image src='../../images/02007.png' class="img" />
@@ -42,7 +42,7 @@
42 42
             </view>
43 43
           </view>
44 44
         </view>
45
-        <view class="btn" bindtap="">
45
+        <view class="btn" bindtap="goto" data-id="4">
46 46
           <view class="btn1">
47 47
             <view class="panel1 FlexRow">
48 48
               <image src='../../images/02008.png' class="img" />

+ 35 - 0
pages/main/list.js

@@ -8,11 +8,39 @@ Page({
8 8
   
9 9
   },
10 10
   onLoad: function (options) {
11
+    var bookID=options.id;
11 12
     this.setData({
12 13
       Height: common.getSystemHeight(),
13 14
       NavClass1: "nav1",
14 15
       NavClass2: "nav2",
15 16
       IsShowNav1:true,
17
+      BookID:bookID,
18
+    });
19
+    this.init();
20
+  },
21
+  init:function(){
22
+    var arr=JSON.parse(wx.getStorageSync("HanziAll"));
23
+
24
+    var result;
25
+    for (var i = 0; i < arr.length; i++) {
26
+      if (arr[i].ID == this.data.BookID) {
27
+        result=arr[i];
28
+        for(var j=0;j<result.Units.length;j++){
29
+          var item = result.Units[j];
30
+          var rnd=common.random(2,5);
31
+          item.Example ="";
32
+          for(var k=0;k<rnd;k++)
33
+            item.Example += item.Words[k].Name;
34
+        }
35
+        break;
36
+      }
37
+    }
38
+    this.setData({
39
+      List:result.Units,
40
+      topImage: "../../images/0400" + this.data.BookID+".png"
41
+    });
42
+    wx.setNavigationBarTitle({
43
+      title: result.Name,
16 44
     });
17 45
   },
18 46
   selectNav: function (e) {
@@ -33,4 +61,11 @@ Page({
33 61
       })
34 62
     }
35 63
   },
64
+  goto: function (e) {
65
+    var bookid = e.currentTarget.dataset.bookid;
66
+    var id = e.currentTarget.dataset.id;
67
+    wx.navigateTo({
68
+      url: "./detail?bookid="+bookid+"&id=" + id,
69
+    });
70
+  },
36 71
 })

+ 10 - 52
pages/main/list.wxml

@@ -1,7 +1,7 @@
1 1
 <view class="container FlexColumn" style='min-height:{{Height}}rpx;'>
2 2
   <view class="line"></view>
3 3
   <view class="line1 line"></view>
4
-  <image src='../../images/04001.png' class="topImage" />
4
+  <image src='{{topImage}}' class="topImage" />
5 5
 
6 6
   <view class="line"></view>
7 7
 
@@ -18,82 +18,40 @@
18 18
     <view class="line2 line">
19 19
     </view>
20 20
     <view class="list2 FlexColumn">
21
-      <view class="btn" bindtap="">
21
+      <view class="btn" bindtap="goto" data-bookid='{{BookID}}' data-id='{{item.ID}}' wx:for="{{List}}" wx:key="index">
22 22
         <view class="btn1 FlexRow">
23 23
           <view class="left FlexRow">
24 24
             <image src='../../images/04007.png' class="img04007" />
25
-            <view class="title">天地人</view>
25
+            <view class="title">{{item.Example}}</view>
26 26
           </view>
27 27
           <view class="right FlexColumn">
28 28
             <view class="right1 FlexRow">
29 29
               <view class="line"></view>
30
-              <view class="title2">识字 1-5</view>
30
+              <view class="title2">{{item.Name}}</view>
31 31
             </view>
32 32
             <view class="right2 FlexRow">
33 33
               <image src='../../images/04008.png' class="img04008" />
34
-              <view class="title3">38个</view>
35
-            </view>
36
-          </view>
37
-        </view>
38
-      </view>
39
-      <view class="btn" bindtap="">
40
-        <view class="btn1 FlexRow">
41
-          <view class="left FlexRow">
42
-            <image src='../../images/04005.png' class="img04005" />
43
-            <view class="title">爸妈</view>
44
-          </view>
45
-          <view class="right FlexColumn">
46
-            <view class="right1 FlexRow">
47
-              <view class="line"></view>
48
-              <view class="title2">汉语拼音 1-8</view>
49
-            </view>
50
-            <view class="right2 FlexRow">
51
-              <image src='../../images/04008.png' class="img04008" />
52
-              <view class="title3">38个</view>
53
-            </view>
54
-          </view>
55
-        </view>
56
-      </view>
57
-      <view class="btn" bindtap="">
58
-        <view class="btn1 FlexRow">
59
-          <view class="left FlexRow">
60
-            <image src='../../images/04006.png' class="img04007" />
61
-            <view class="title">秋叶飞</view>
62
-          </view>
63
-          <view class="right FlexColumn">
64
-            <view class="right1 FlexRow">
65
-              <view class="line"></view>
66
-              <view class="title2">汉语拼音 9-10</view>
67
-            </view>
68
-            <view class="right2 FlexRow">
69
-              <image src='../../images/04008.png' class="img04008" />
70
-              <view class="title3">38个</view>
34
+              <view class="title3">{{item.Words.length}}个</view>
71 35
             </view>
72 36
           </view>
73 37
         </view>
74 38
       </view>
39
+      
75 40
     </view>
76 41
     <view class="line3 line">
77 42
   </view>
78 43
   </block>
79 44
 
80 45
   <block wx:if="{{!IsShowNav1}}">
81
-    <view class="group FlexColumn">
82
-      <view class="title FlexRow">
83
-        <view class="title1">识字1-5</view>
84
-      </view>
85
-      <view class="table FlexRow">
86
-      <view class="boxSelect box" wx:for="{{['中','中','中','中','中','中','中','中','中']}}">{{item}}</view>
87
-      </view>
88
-    </view>
89
-    <view class="group FlexColumn">
46
+    <view class="group FlexColumn" wx:for="{{List}}" wx:key="index">
90 47
       <view class="title FlexRow">
91
-        <view class="title1">识字1-5</view>
48
+        <view class="title1">{{item.Name}}</view>
92 49
       </view>
93 50
       <view class="table FlexRow">
94
-      <view class="box" wx:for="{{['中','中','中','中','中','中','中','中','中']}}">{{item}}</view>
51
+      <view class="box" wx:for="{{item.Words}}" wx:for-item="itemChild">{{itemChild.Name}}</view>
95 52
       </view>
96 53
     </view>
54
+    
97 55
     <view class="line4 line">
98 56
   </view>
99 57
   </block>

+ 8 - 2
project.config.json

@@ -1,7 +1,7 @@
1 1
 {
2 2
 	"description": "项目配置文件。",
3 3
 	"setting": {
4
-		"urlCheck": true,
4
+		"urlCheck": false,
5 5
 		"es6": true,
6 6
 		"postcss": true,
7 7
 		"minified": true,
@@ -30,7 +30,7 @@
30 30
 			"list": []
31 31
 		},
32 32
 		"miniprogram": {
33
-			"current": 1,
33
+			"current": -1,
34 34
 			"list": [
35 35
 				{
36 36
 					"id": -1,
@@ -43,6 +43,12 @@
43 43
 					"name": "列表",
44 44
 					"pathName": "pages/main/list",
45 45
 					"query": ""
46
+				},
47
+				{
48
+					"id": 2,
49
+					"name": "详情页",
50
+					"pathName": "pages/main/detail",
51
+					"query": "bookid=1&id=1"
46 52
 				}
47 53
 			]
48 54
 		}

文件差异内容过多而无法显示
+ 1497 - 0
utils/pinyin.js