chengjie 6 년 전
부모
커밋
3b87eae004
10개의 변경된 파일513개의 추가작업 그리고 183개의 파일을 삭제
  1. 6 3
      app.js
  2. 24 35
      pages/main/searchWeb.js
  3. 16 10
      pages/main/searchWeb.wxml
  4. 34 19
      pages/main/searchWeb.wxss
  5. 149 39
      pages/main/searchWeb1.js
  6. 52 8
      pages/main/searchWeb1.wxml
  7. 59 4
      pages/main/searchWeb1.wxss
  8. 122 65
      pages/main/searchWeb2.js
  9. 47 0
      pages/main/searchWeb2.wxml
  10. 4 0
      utils/main.js

+ 6 - 3
app.js

@@ -25,8 +25,8 @@ App({
25 25
     }
26 26
   },
27 27
   globalData: {
28
-    Version: "1.0.0.20",
29
-    IsProduction: true,
28
+    Version: "1.0.0.22",
29
+    IsProduction: false,
30 30
     ShareTitle: "可以用来记忆一切的工具",
31 31
     SharePath: "pages/index/index",
32 32
     ShareImage: '',
@@ -54,6 +54,9 @@ App({
54 54
 
55 55
     CardList:[],//卡列表变量
56 56
     TaskToday:[],//今天任务列表
57
-    TempMiaoguoCardID:0,//临时题卡ID,用于资料选取时用
57
+    SearchResultList: [],//搜索获得要选择的字词或古诗词列表
58
+    TempMiaoguoCardID: 0,//临时题卡ID,用于资料选取时用
59
+    SearchNull: 0,//资料搜索为空时标记,用于资料搜索时用
60
+    SearchItem: {},//资料搜索项信息,用于资料搜索时用
58 61
   }
59 62
 })

+ 24 - 35
pages/main/searchWeb.js

@@ -16,11 +16,29 @@ Page({
16 16
   },
17 17
   onShow:function(){
18 18
     var that = this;
19
-    var arr = wx.getStorageSync("SearchWord");
19
+    var arr = wx.getStorageSync("SearchWord2");
20 20
     if (!arr)
21 21
       arr = [];
22
+    
23
+    var list=[];
24
+    for(var i=0;i<10;i++){
25
+      if (!arr[i].Type)
26
+        arr[i].Type="zici";
27
+      switch(arr[i].Type){
28
+        case 'zici':
29
+          arr[i].TypeName = '字词';
30
+          break;
31
+        case 'shici':
32
+          arr[i].TypeName = '诗词';
33
+          break;
34
+        case 'eng':
35
+          arr[i].TypeName = '外语';
36
+          break;
37
+      }
38
+      list.push(arr[i]);
39
+    }
22 40
     that.setData({
23
-      SelectList: arr,
41
+      SelectList: list,
24 42
     });
25 43
   },
26 44
   onSearch: function (e) {
@@ -30,40 +48,11 @@ Page({
30 48
   },
31 49
   onSearchHistory: function (e) {
32 50
     var search = e.currentTarget.dataset.search;
33
-    var arr = wx.getStorageSync("SearchWord");
34
-    if (!arr)
35
-      arr = [];
36
-    var obj = {};
37
-    obj.Key = search;
38
-    for (var i = 0; i < arr.length; i++) {
39
-      if (arr[i].Key == search) {
40
-        obj.Key = arr[i].Key;
41
-        obj.Value = arr[i].Value;
42
-        arr.splice(i, 1);
43
-        break;
44
-      }
45
-    }
46
-    arr.unshift(obj);
47
-    wx.setStorageSync("SearchWord", arr);
51
+    var searchType = e.currentTarget.dataset.searchtype;
52
+    var author = e.currentTarget.dataset.author;
53
+
48 54
     wx.navigateTo({
49
-      url: './searchWeb2?back=2&search=' + search+'&type=1',
50
-    });
51
-  },
52
-  deleteItem:function(e){
53
-    var that=this;
54
-    wx.showModal({
55
-      title: '提醒',
56
-      content: '删除这条搜索记录?',
57
-      success(res) {
58
-        if (res.confirm) {
59
-          var index = e.currentTarget.dataset.id;
60
-          that.data.SelectList.splice(index, 1);
61
-          that.setData({
62
-            SelectList: that.data.SelectList,
63
-          });
64
-          wx.setStorageSync("SearchWord", that.data.SelectList);
65
-        }
66
-      }
55
+      url: './searchWeb2?back=2&search=' + search + '&searchType=' + searchType+'&author='+author,
67 56
     });
68 57
   },
69 58
   onShareAppMessage: function () {

+ 16 - 10
pages/main/searchWeb.wxml

@@ -2,26 +2,32 @@
2 2
   <view class="panelSearch FlexRow">
3 3
     <view class="panelSearch1 FlexRow" bindtap="onSearch">
4 4
       <image class="universalpic_search_gray_30x30" src='../images/universalpic_search_gray_30x30.png' />
5
-      <view>搜索字词、成语、单词,添加丰富资料</view>
5
+      <view>搜索字词、成语、诗词、单词,添加丰富资料</view>
6 6
     </view>
7 7
   </view>
8 8
   <view class='lineFooter'></view>
9
-  <view class="panelTitle FlexRow">
10
-    <view class="panelTitle1">搜索记录</view>
9
+  <view class="panelTitle FlexRow" wx:if="{{SelectList.length>0}}">
10
+    <view class="panelTitle1">看过的资料</view>
11 11
   </view>
12 12
 
13 13
   <block wx:for="{{SelectList}}" wx:key="index">
14 14
     <view class="lineWidthAll FlexRow" wx:if="{{index>0}}">
15 15
       <view class="lineWidth720"></view>
16 16
     </view>
17
-    <view class="panelItem FlexRow" >
18
-      <view class="panelItem1">
17
+    <view class="panelItemSearch FlexColumn">
18
+      <view class="panelItemSearch1 FlexRow">
19
+        <view class="panelItemSearch11" bindtap='onSearchHistory' data-search="{{item.Key}}" data-searchtype="{{item.Type}}" data-author="{{item.Author}}">
20
+          {{item.Key}}
21
+        </view>
22
+        <view class="panelItemSearch12 FlexRow">
23
+          {{item.TypeName}}
24
+        </view>
19 25
       </view>
20
-      <view class="panelItem2 FlexRow">
21
-        <text class="text1" bindtap='onSearchHistory' data-search="{{item.Key}}">{{item.Key}}</text>
22
-        <view class="panelItem21 FlexRow" bindtap='deleteItem' data-id="{{index}}">
23
-            <image src='../images/universalpic_del_gray_14x14.png' class="universalpic_del_gray_14x14" />
24
-         </view>
26
+      <view class="panelItemSearch2 FlexRow" wx:if="{{item.Type=='shici'}}">
27
+        {{item.Author}} {{item.Dynasty}}
28
+      </view>
29
+      <view class="panelItemSearch2 FlexRow" wx:if="{{item.Type=='shici'}}">
30
+        {{item.Content}}
25 31
       </view>
26 32
     </view>
27 33
   </block>

+ 34 - 19
pages/main/searchWeb.wxss

@@ -50,38 +50,53 @@
50 50
   margin-bottom: 32rpx;
51 51
 }
52 52
 
53
-.panelItem {
53
+.panelItemSearch {
54 54
   width: 100%;
55
-  justify-content: flex-start;
56
-  font-size: 28rpx;
57 55
   min-height: 100rpx;
58
-  height:auto;
59 56
   background-color: #fff;
57
+  justify-content: flex-start;
58
+  align-items: flex-start;
60 59
 }
61 60
 
62
-.panelItem1 {
63
-  margin-left: 30rpx;
64
-  font-weight: 400;
65
-}
66
-
67
-.panelItem2 {
61
+.panelItemSearch .panelItemSearch1{
68 62
   color: #1e1e1e;
69 63
   font-weight: 400;
70 64
   justify-content: space-between;
71
-  width:720rpx;
65
+  width:100%;
72 66
 }
73 67
 
74
-.text1{
68
+.panelItemSearch .panelItemSearch11{
75 69
   width:624rpx;
76
-  line-height: 100rpx;
70
+  font-size:28rpx;
71
+  font-weight: 400;
72
+  margin-left: 30rpx;
73
+  margin-top: 30rpx
77 74
 }
78 75
 
79
-.panelItem21{
80
-  width:96rpx;
81
-  height:100rpx;
76
+
77
+.panelItemSearch .panelItemSearch12{
78
+  border:2rpx solid #0071EF;
79
+  font-size:20rpx;
80
+  text-align: center;
81
+  line-height: 34rpx;
82
+  width:60rpx;
83
+  color:#0071EF;
84
+  margin-right: 30rpx;
85
+  margin-top: 34rpx
82 86
 }
83 87
 
84
-.universalpic_del_gray_14x14{
85
-  width:14rpx;
86
-  height:14rpx;
88
+.panelItemSearch .panelItemSearch2{
89
+  color: #1e1e1e;
90
+  font-weight: 400;
91
+  justify-content: flex-start;
92
+  margin-left: 30rpx;
93
+  font-size:24rpx;
94
+}
95
+.panelItemSearch .panelItemSearch3{
96
+  color: #787878;
97
+  font-weight: 400;
98
+  justify-content: flex-start;
99
+  margin-left: 30rpx;
100
+  font-size:24rpx;
101
+  margin-bottom: 30rpx;
87 102
 }

+ 149 - 39
pages/main/searchWeb1.js

@@ -5,6 +5,20 @@ const app = getApp();
5 5
 
6 6
 Page({
7 7
   data: {
8
+    ListOther: [{
9
+      Key: '愛', Type: 'zici'
10
+    }, {
11
+      Key: '饕餮', Type: 'zici'
12
+    }, {
13
+      Key: '鸿鹄之志', Type: 'zici'
14
+    }, {
15
+      Key: '天净沙·秋思', Type: 'shici'
16
+    }, {
17
+      Key: 'success', Type: 'zici'
18
+    }, {
19
+      Key: 'Study hard and make progress every day.', Type: 'eng'
20
+    }
21
+    ]
8 22
   },
9 23
   onLoad: function () {
10 24
     wx.hideShareMenu();
@@ -13,13 +27,24 @@ Page({
13 27
       Containnerheight: main.getWindowHeight(),
14 28
       IsShowNull: false,
15 29
     });
30
+    app.globalData.SearchResultList = [];
31
+    app.globalData.SearchNull = 0;
32
+    common.getStorageValue(that, "SearchTextList", [], function () {
33
+    });
16 34
   },
17
-  onShow:function(){
18
-    if (wx.getStorageSync("SearchNull")){
35
+  onShow: function () {
36
+    if (app.globalData.SearchNull == 1) {
37
+      var len = 26;
38
+      var list = app.globalData.SearchResultList;
39
+      for (var i = 0; i < list.length; i++) {
40
+        var item = list[i];
41
+        if (item.Content && item.Content.length > len)
42
+          item.Content = item.Content.substr(0, len) + "...";
43
+      }
19 44
       this.setData({
20
-        IsShowNull:true,
21
-      })
22
-      wx.removeStorageSync("SearchNull");
45
+        List: list,
46
+      });
47
+      app.globalData.SearchNull = 0;
23 48
     }
24 49
   },
25 50
   onKeyInput: function (e) {
@@ -30,63 +55,148 @@ Page({
30 55
     });
31 56
   },
32 57
   onSearch: function (e) {
33
-    if (this.data.SearchInfo && this.data.SearchInfo.length>0){
58
+    var that = this;
59
+    if (e.currentTarget.dataset.search)
60
+      this.data.SearchInfo = e.currentTarget.dataset.search;
61
+    if (this.data.SearchInfo && this.data.SearchInfo.length > 0) {
34 62
       var search = this.data.SearchInfo;
35
-      var arr=wx.getStorageSync("SearchWord");
36
-      if (!arr)
37
-        arr=[];
38
-      var obj = {};
39
-      obj.Key = search;
40
-      for(var i=0;i<arr.length;i++){
41
-        if (arr[i].Key == search){
42
-          obj.Key = arr[i].Key;
43
-          obj.Value = arr[i].Value;
44
-          arr.splice(i,1);
63
+      
64
+      that.searchResult(search);
65
+
66
+      var arr = that.data.SearchTextList;
67
+      for (var i = 0; i < arr.length; i++) {
68
+        if (arr[i] == search) {
69
+          arr.splice(i, 1);
45 70
           break;
46 71
         }
47 72
       }
48
-      arr.unshift(obj);
49
-      wx.setStorageSync("SearchWord", arr);
50
-      wx.navigateTo({
51
-        url: './searchWeb2?back=3&search=' + search+'&type=0',
52
-      })
73
+      arr.unshift(search);
74
+
75
+      wx.setStorageSync("SearchTextList", arr);
76
+      that.setData({
77
+        SearchTextList: arr,
78
+      });
53 79
     }
54
-    else{
80
+    else {
55 81
       wx.showToast({
56 82
         title: '请输搜索内容',
57 83
       })
58 84
     }
59 85
   },
60
-  onSearchHistory: function (e) {
86
+  onSearchSelect: function (e) {
61 87
     var search = e.currentTarget.dataset.search;
62
-    var arr = wx.getStorageSync("SearchWord");
88
+    var searchType = e.currentTarget.dataset.searchtype;
89
+    var author = e.currentTarget.dataset.author;
90
+    wx.navigateTo({
91
+      url: './searchWeb2?search=' + search + '&searchType=' + searchType + '&author=' + author,
92
+    });
93
+  },
94
+  close: function (e) {
95
+    wx.navigateBack({
96
+      delta: 1,
97
+    });
98
+  },
99
+
100
+  deleteItem: function (e) {
101
+    var that = this;
102
+    var index = e.currentTarget.dataset.id;
103
+    that.data.SearchTextList.splice(index, 1);
104
+    that.setData({
105
+      SearchTextList: that.data.SearchTextList,
106
+    });
107
+    wx.setStorageSync("SearchTextList", that.data.SearchTextList);
108
+
109
+  },
110
+  searchResult: function (search, searchType, author,dynasty,content) {
111
+
112
+    wx.showLoading({
113
+      title: '查询中',
114
+    });
115
+    var that = this;
116
+
117
+    var arr = wx.getStorageSync("SearchWord2");
63 118
     if (!arr)
64 119
       arr = [];
65 120
     var obj = {};
66 121
     obj.Key = search;
67
-    var b=false,type=0;
122
+    if (searchType)
123
+      obj.Type = searchType;
124
+    else
125
+      obj.Type = "zici";
126
+    if (author)
127
+      obj.Author = author;
128
+    if (dynasty)
129
+      obj.dynasty = dynasty;
130
+    if (content)
131
+      obj.Content = content;
132
+    var b = false;
68 133
     for (var i = 0; i < arr.length; i++) {
69
-      if (arr[i].Key == search) {
70
-        obj.Key = arr[i].Key;
134
+      if (arr[i].Key == search 
135
+      && arr[i].Type == searchType 
136
+      && arr[i].Author == author) {
71 137
         obj.Value = arr[i].Value;
72 138
         arr.splice(i, 1);
73
-        b=true;
74
-        type=1
139
+        b = true;
75 140
         break;
76 141
       }
77 142
     }
78
-    if (b){
143
+    if (b) {
79 144
       arr.unshift(obj);
80
-      wx.setStorageSync("SearchWord", arr);
145
+      wx.setStorageSync("SearchWord2", arr);
146
+      app.globalData.SearchItem=obj.Value;
147
+
148
+      wx.hideLoading();
149
+
150
+      wx.navigateTo({
151
+        url: './searchWeb2?back=3',
152
+      });
153
+    }
154
+    else {
155
+      var url = 'GetMiaoguoAISearch?UserID=' + app.globalData.userInfo.UserID;
156
+      url += "&Word=" + search;
157
+      if (searchType)
158
+        url += "&SearchType=" + searchType;
159
+      if (author)
160
+        url += "&Author=" + author;
161
+      main.getData(url, function (data) {
162
+        wx.hideLoading();
163
+        searchType = "";
164
+        author = "";
165
+        if (data) {
166
+          //console.log(data);
167
+
168
+          if (data.List) {
169
+            app.globalData.SearchResultList = data.List;
170
+            app.globalData.SearchNull = 1;
171
+            wx.navigateBack({
172
+              delta: 1,
173
+            });
174
+          }
175
+          else {
176
+            obj.Value = data;
177
+            if (data.CHN && data.CHN.Author)
178
+              obj.Author = data.CHN.Author;
179
+            if (data.CHN && data.CHN.PeomContent)
180
+              obj.Type = "shici";
181
+            arr.unshift(obj);
182
+
183
+            if (arr.length > 100) {
184
+              arr.pop();
185
+            }
186
+
187
+            wx.setStorageSync("SearchWord2", arr);
188
+            that.getListFinished(data);
189
+          }
190
+        }
191
+        else {
192
+          app.globalData.SearchNull = 1;
193
+          app.globalData.SearchResultList = [];
194
+          wx.navigateBack({
195
+            delta: 1,
196
+          });
197
+        }
198
+      });
81 199
     }
82
-    wx.navigateTo({
83
-      url: './searchWeb2?back=2&search=' + search + '&type='+type,
84
-    });
85
-  },
86
-  close: function (e) {
87
-    wx.navigateBack({
88
-      delta: 1,
89
-    });
90 200
   },
91 201
   onShareAppMessage: function () {
92 202
     return {

+ 52 - 8
pages/main/searchWeb1.wxml

@@ -12,25 +12,69 @@
12 12
     <view class='text2 text1' bindtap="onSearch" data-idsave="true">搜索</view>
13 13
   </view>
14 14
   <view class='lineFooter'></view>
15
-  <block wx:if="{{IsShowNull}}">
15
+
16
+  <block wx:if="{{SearchTextList.length>0}}">
17
+    <view class="panelTitle FlexRow">
18
+      <view class="panelTitle1">搜索记录</view>
19
+    </view>
20
+    <block wx:for="{{SearchTextList}}" wx:key="index">
21
+      <view class="lineWidthAll FlexRow" wx:if="{{index>0}}">
22
+        <view class="lineWidth720"></view>
23
+      </view>
24
+      <view class="panelItemSearch FlexRow">
25
+        <view class="panelItemSearch1">
26
+        </view>
27
+        <view class="panelItemSearch2 FlexRow">
28
+          <view class="panelItemSearchText1" bindtap='onSearch' data-search="{{item}}">
29
+            {{item}}
30
+          </view>
31
+          <view class="panelItemSearch21 FlexRow" bindtap='deleteItem' data-id="{{index}}">
32
+            <image src='../images/universalpic_del_gray_14x14.png' class="universalpic_del_gray_14x14" />
33
+          </view>
34
+        </view>
35
+      </view>
36
+
37
+    </block>
38
+    <view class='lineFooter'></view>
39
+  </block>
40
+
41
+  <block wx:if="{{List.length==0}}">
16 42
     <view class='panelNull FlexColumn'>
17 43
       <view class="text3">无资料匹配</view>
18
-      <view class="text4">通过搜索汉字、词语、成语、英语单词,添加相关资料</view>
44
+      <view class="text4">通过搜索汉字、词语、成语、诗词、英语单词,添加相关资料</view>
19 45
     </view>
20 46
     <view class="panelTitle FlexRow">
21 47
       <view class="panelTitle1">换个搜搜看</view>
22 48
     </view>
23
-
24
-    <block wx:for="{{['饕餮','鸿鹄之志','success','好好学习,天天向上','Study hard and make progress every day.']}}" wx:key="index">
49
+    <block wx:for="{{ListOther}}" wx:key="index">
25 50
       <view class="lineWidthAll FlexRow" wx:if="{{index>0}}">
26 51
         <view class="lineWidth720"></view>
27 52
       </view>
28
-      <view class="panelItem FlexRow" bindtap='onSearchHistory' data-search="{{item}}">
29
-        <view class="panelItem1">
53
+      <view class="panelItem0 panelItem FlexColumn" bindtap='onSearchSelect' data-search="{{item.Key}}" data-searchtype="{{item.Type}}">
54
+        <view class='Text1 FlexRow'>
55
+          <view>{{item.Key}}</view>
56
+          <view class='Text11'></view>
30 57
         </view>
31
-        <view class="panelItem2">
32
-          <text class="textNull">{{item}}</text>
58
+      </view>
59
+
60
+    </block>
61
+    <view class='lineFooter'></view>
62
+  </block>
63
+
64
+  <block wx:if="{{List.length>0}}">
65
+    <view class="panelTitle FlexRow">
66
+      <view class="panelTitle1">请选择</view>
67
+    </view>
68
+    <block wx:for="{{List}}" wx:key="index">
69
+      <view class="lineWidthAll FlexRow" wx:if="{{index>0}}">
70
+        <view class="lineWidth720"></view>
71
+      </view>
72
+      <view class="panelItem FlexColumn" bindtap='onSearchSelect' data-search="{{item.Title}}" data-searchtype="{{item.Type}}" data-author="{{item.Author}}">
73
+        <view class='Text1 FlexRow'>
74
+          <view>{{item.Title}}</view>
75
+          <view class='Text11'>{{item.Remark}}</view>
33 76
         </view>
77
+        <view class='Text2'>{{item.Content}}</view>
34 78
       </view>
35 79
     </block>
36 80
     <view class='lineFooter'></view>

+ 59 - 4
pages/main/searchWeb1.wxss

@@ -95,6 +95,37 @@
95 95
 }
96 96
 
97 97
 .panelItem {
98
+  width: 100%;
99
+  align-items: flex-start;
100
+  min-height: 136rpx;
101
+  background-color: #fff;
102
+}
103
+.panelItem0 {
104
+  min-height: 100rpx;
105
+}
106
+
107
+.Text1 {
108
+  margin-left: 30rpx;
109
+  color: #1e1e1e;
110
+  font-weight: 400;
111
+  font-size:30rpx;
112
+}
113
+.Text11 {
114
+  margin-left: 30rpx;
115
+  color: #787878;
116
+  font-weight: 400;
117
+  font-size:24rpx;
118
+}
119
+
120
+.Text2 {
121
+  margin-left: 30rpx;
122
+  color: #787878;
123
+  font-weight: 400;
124
+  font-size:24rpx;
125
+}
126
+
127
+
128
+.panelItemSearch {
98 129
   width: 100%;
99 130
   justify-content: flex-start;
100 131
   font-size: 28rpx;
@@ -103,13 +134,37 @@
103 134
   background-color: #fff;
104 135
 }
105 136
 
106
-.panelItem1 {
137
+.panelItemSearch .panelItemSearch1 {
107 138
   margin-left: 30rpx;
108 139
   font-weight: 400;
109 140
 }
110 141
 
111
-.panelItem2 {
112
-  margin-right: 30rpx;
142
+.panelItemSearch .panelItemSearch2 {
113 143
   color: #1e1e1e;
114 144
   font-weight: 400;
115
-}
145
+  justify-content: space-between;
146
+  width:720rpx;
147
+}
148
+
149
+.panelItemSearch .panelItemSearchText1{
150
+  width:624rpx;
151
+  font-size:28rpx;
152
+  justify-content: flex-start;
153
+}
154
+
155
+
156
+.panelItemSearch .panelItemSearchText11{
157
+  color:#787878;
158
+  font-size:24rpx;
159
+  margin-right: 10rpx;
160
+}
161
+
162
+.panelItemSearch .panelItemSearch21{
163
+  width:96rpx;
164
+  height:100rpx;
165
+}
166
+
167
+.universalpic_del_gray_14x14{
168
+  width:14rpx;
169
+  height:14rpx;
170
+}

+ 122 - 65
pages/main/searchWeb2.js

@@ -3,7 +3,8 @@ import main from '../../utils/main';
3 3
 
4 4
 const app = getApp();
5 5
 var back = 3;
6
-var hasStart={};
6
+var hasStart = {};
7
+var searchType="",author="";
7 8
 
8 9
 Page({
9 10
   data: {
@@ -16,9 +17,15 @@ Page({
16 17
     that.setData({
17 18
       Containnerheight: main.getWindowHeight(),
18 19
     });
19
-
20
+    searchType="";
21
+    if (options.searchType)
22
+      searchType = options.searchType;
23
+    
24
+    author = "";
25
+    if (options.author)
26
+      author = options.author;
20 27
     if (options.search) {
21
-      this.getList(options.search, options.type);
28
+      this.getList(options.search);
22 29
     }
23 30
     if (options.back)
24 31
       back = Number(options.back);
@@ -26,56 +33,84 @@ Page({
26 33
     hasStart = {};
27 34
 
28 35
   },
29
-  getList: function (word, type) {
36
+  getList: function (search) {
30 37
 
31 38
     wx.showLoading({
32 39
       title: '查询中',
33 40
     });
34 41
     var that = this;
35
-    if (type == 1) {
36
-      var data;
37
-      var arr = wx.getStorageSync("SearchWord");
38
-      if (!arr)
39
-        arr = [];
40
-      for (var i = 0; i < arr.length; i++) {
41
-        if (arr[i].Key == word) {
42
-          data = arr[i].Value;
43
-          break;
44
-        }
45
-      }
46
-      if (!data) {
47
-        wx.hideLoading();
48
-        that.getList(word, 0);
49
-      }
50
-      else {
51
-        wx.hideLoading();
52
-        that.getListFinished(data);
42
+    
43
+    var arr = wx.getStorageSync("SearchWord2");
44
+    if (!arr)
45
+      arr = [];
46
+    var obj = {};
47
+    obj.Key = search;
48
+    if (searchType)
49
+      obj.Type = searchType;
50
+    else
51
+      obj.Type = "zici";
52
+    if (author)
53
+      obj.Author = author;
54
+    if (author)
55
+      obj.Author = author;
56
+    var b = false, type = 0;
57
+    back = 3;
58
+    for (var i = 0; i < arr.length; i++) {
59
+      if (arr[i].Key == search && arr[i].Type == searchType && arr[i].Author == author) {
60
+        obj.Value = arr[i].Value;
61
+        arr.splice(i, 1);
62
+        back = 2;
63
+        b = true;
64
+        type = 1
65
+        break;
53 66
       }
54 67
     }
55
-    else {
68
+    if (b) {
69
+      arr.unshift(obj);
70
+      wx.setStorageSync("SearchWord2", arr);
71
+      that.getListFinished(obj.Value);
72
+      wx.hideLoading();
73
+    }
74
+    else{
56 75
       var url = 'GetMiaoguoAISearch?UserID=' + app.globalData.userInfo.UserID;
57
-      url += "&Word=" + word;
76
+      url +="&Word=" + search;
77
+      if (searchType)
78
+        url += "&SearchType=" + searchType;
79
+      if (author)
80
+        url += "&Author=" + author;
58 81
       main.getData(url, function (data) {
59 82
         wx.hideLoading();
83
+        searchType="";
84
+        author="";
60 85
         if (data) {
61 86
           //console.log(data);
62 87
 
63
-          //保存搜索结果
64
-          var arr = wx.getStorageSync("SearchWord");
65
-          if (!arr)
66
-            arr = [];
67
-          for (var i = 0; i < arr.length; i++) {
68
-            if (arr[i].Key == word) {
69
-              arr[i].Value = data;
70
-              break;
71
-            }
88
+          if (data.List){
89
+            app.globalData.SearchResultList=data.List;
90
+            app.globalData.SearchNull=1;
91
+            wx.navigateBack({
92
+              delta: 1,
93
+            });
72 94
           }
73
-          wx.setStorageSync("SearchWord", arr);
95
+          else{
96
+            obj.Value=data;
97
+            if (data.CHN && data.CHN.Author)
98
+              obj.Author=data.CHN.Author;
99
+            if (data.CHN && data.CHN.PeomContent)
100
+              obj.Type="shici";
101
+            arr.unshift(obj);
74 102
 
75
-          that.getListFinished(data);
103
+            if (arr.length>100){
104
+              arr.pop();
105
+            }
106
+
107
+            wx.setStorageSync("SearchWord2", arr);
108
+            that.getListFinished(data);
109
+          }
76 110
         }
77 111
         else {
78
-          wx.setStorageSync("SearchNull", 1);
112
+          app.globalData.SearchNull = 1;
113
+          app.globalData.SearchResultList = [];
79 114
           wx.navigateBack({
80 115
             delta: 1,
81 116
           });
@@ -86,25 +121,37 @@ Page({
86 121
   getListFinished: function (data) {
87 122
     var that = this;
88 123
     if (data.CHN) {
89
-      for (var i = 0; i < data.CHN.PinYin.length; i++) {
90
-        var item = data.CHN.PinYin[i].explain;
91
-        item = common.ReplaceAllString(item, "<p>", "");
92
-        item = common.ReplaceAllString(item, "<span>", "");
93
-        item = common.ReplaceAllString(item, "</span>", "");
94
-        item = common.ReplaceAllString(item, "\r", "");
95
-        item = common.ReplaceAllString(item, "\n", "");
96
-
97
-        var arr = item.split("</p>");
98
-        arr.pop();
99
-        data.CHN.PinYin[i].explain = arr.join("\n");
124
+      if (data.CHN.PinYin) {
125
+        for (var i = 0; i < data.CHN.PinYin.length; i++) {
126
+          var item = data.CHN.PinYin[i].explain;
127
+          item = common.ReplaceAllString(item, "<p>", "");
128
+          item = common.ReplaceAllString(item, "<span>", "");
129
+          item = common.ReplaceAllString(item, "</span>", "");
130
+          item = common.ReplaceAllString(item, "\r", "");
131
+          item = common.ReplaceAllString(item, "\n", "");
132
+
133
+          var arr = item.split("</p>");
134
+          arr.pop();
135
+          data.CHN.PinYin[i].explain = arr.join("\n");
136
+        }
137
+      }
138
+
139
+      if (data.CHN.HanZi) {
140
+        if (data.CHN.HanZi.length >= 2 && data.CHN.HanZi.length <= 4 && data.CHN.PinYin && data.CHN.PinYin.length > 0) {
141
+          data.CHN.TianKong = [];
142
+          var arrPinyin = data.CHN.PinYin[0].pinyin.split(" ");
143
+          for (var i = 0; i < data.CHN.HanZi.length; i++) {
144
+            var str = data.CHN.HanZi.replace(data.CHN.HanZi[i], arrPinyin[i]);
145
+            data.CHN.TianKong.push(str);
146
+          }
147
+        }
100 148
       }
101 149
 
102
-      if (data.CHN.HanZi.length >= 2 && data.CHN.HanZi.length <= 4 && data.CHN.PinYin && data.CHN.PinYin.length > 0) {
103
-        data.CHN.TianKong = [];
104
-        var arrPinyin = data.CHN.PinYin[0].pinyin.split(" ");
105
-        for (var i = 0; i < data.CHN.HanZi.length; i++) {
106
-          var str = data.CHN.HanZi.replace(data.CHN.HanZi[i], arrPinyin[i]);
107
-          data.CHN.TianKong.push(str);
150
+      if (data.ENG && data.ENG.Paraphrase && common.checkIsArray(data.ENG.Paraphrase)) {
151
+
152
+        for (var i = 0; i < data.ENG.Paraphrase.length; i++) {
153
+          var item = data.ENG.Paraphrase[i];
154
+          item.PartOfSpeech = common.ReplaceAllString(item.PartOfSpeech, "释义", "");
108 155
         }
109 156
       }
110 157
     }
@@ -135,7 +182,7 @@ Page({
135 182
       this.data.CSS[css].Tag = tag;
136 183
       if (tag == "发音")
137 184
         this.data.CSS[css].SoundMark = soundmark;
138
-      
185
+
139 186
       if (tag == "读写") {
140 187
         var pinyin = e.currentTarget.dataset.pinyin;
141 188
         if (pinyin)
@@ -145,7 +192,7 @@ Page({
145 192
       this.data.CSS[css].Number = "1";
146 193
       if (wx.getStorageSync("TempFieldNumber") && !hasStart[css]) {
147 194
         this.data.CSS[css].Number = Number(wx.getStorageSync("TempFieldNumber"));
148
-        hasStart[css]=true;
195
+        hasStart[css] = true;
149 196
       }
150 197
     }
151 198
     else if (this.data.CSS[css].Number == "3") {
@@ -200,7 +247,7 @@ Page({
200 247
             else if (item.Type == "sound") {
201 248
               str = "[读]" + item.Content + "[/读]";
202 249
               if (item.Tag == "发音") {
203
-                str = "[读 src='" + item.SoundMark+"']" + item.Content + "[/读]";
250
+                str = "[读 src='" + item.SoundMark + "']" + item.Content + "[/读]";
204 251
               }
205 252
               else if (item.Tag == "拼音" || item.Tag == "读写") {
206 253
                 if (item.SoundMark)
@@ -210,18 +257,28 @@ Page({
210 257
               }
211 258
             }
212 259
             else {
213
-              str = item.Content;
260
+              if (item.Tag == "诗词原文") {
261
+                for (var j = 0; j < item.Content.length; j++) {
262
+                  if (item.Content.length == 1)
263
+                    item.Content[j] = item.Content[j].join("\n");
264
+                  else
265
+                    item.Content[j] = item.Content[j].join("");
266
+                }
267
+                str = item.Content.join("\n");
268
+              }
269
+              else
270
+                str = item.Content;
214 271
             }
215
-            
272
+
216 273
             if (list[i].Content[item.Number].Content)
217
-                str="\n"+str;
218
-            list[i].Content[item.Number].Content+=str;
219
-            
274
+              str = "\n" + str;
275
+            list[i].Content[item.Number].Content += str;
276
+
220 277
           }
221 278
           break;
222 279
         }
223 280
       }
224
-      app.globalData.CardList=list;
281
+      app.globalData.CardList = list;
225 282
 
226 283
       wx.navigateBack({
227 284
         delta: back,
@@ -238,11 +295,11 @@ Page({
238 295
       IsShowHelp: 0,
239 296
     });
240 297
   },
241
-  close:function(){
298
+  close: function () {
242 299
     this.setData({
243
-      IsShowHelp:1,
300
+      IsShowHelp: 1,
244 301
     });
245
-    wx.setStorageSync("IsShowHelp",1);
302
+    wx.setStorageSync("IsShowHelp", 1);
246 303
   },
247 304
   onShareAppMessage: function () {
248 305
     return {

+ 47 - 0
pages/main/searchWeb2.wxml

@@ -121,6 +121,53 @@
121 121
     <view class='lineFooter'></view>
122 122
   </block>
123 123
 
124
+  <!-- 作者与朝代 -->
125
+  <block wx:if="{{Result.CHN.Author && Result.CHN.Author.length>0}}">
126
+    <view class="panelTitle FlexRow">
127
+      <view class="panelTitle1">诗词作者</view>
128
+    </view>
129
+    <view class="panelItem FlexRow">
130
+      <view class="{{CSS.CHN_Author.Css1}} panelItemFrame FlexRow" bindtap='getInputData' data-type="normal" data-content="{{Result.CHN.Dynasty}} {{Result.CHN.Author}}" data-css="CHN_Author"  data-tag="诗词作者">
131
+        <view class="{{CSS.CHN_Author.Css2}} panelSelect0">{{CSS.CHN_Author.Number}}</view>
132
+        <view class="text1">{{Result.CHN.Dynasty}} {{Result.CHN.Author}}</view>
133
+      </view>
134
+    </view>
135
+    <view class='lineFooter'></view>
136
+  </block>
137
+
138
+  <!-- 诗词原文 -->
139
+  <block wx:if="{{Result.CHN.PeomContent && Result.CHN.PeomContent.length>0}}">
140
+    <view class="panelTitle FlexRow">
141
+      <view class="panelTitle1">诗词原文</view>
142
+    </view>
143
+    <view class="panelItem FlexRow">
144
+      <view class="{{CSS.CHN_PeomContent.Css1}} panelItemFrame FlexRow" bindtap='getInputData' data-type="normal" data-content="{{Result.CHN.PeomContent}}" data-css="CHN_PeomContent" data-tag="诗词原文">
145
+        <view class="{{CSS.CHN_PeomContent.Css2}} panelSelect0">{{CSS.CHN_PeomContent.Number}}</view>
146
+        <view class="text1">
147
+          <block wx:for="{{Result.CHN.PeomContent}}" wx:key="index" wx:for-item="item1">
148
+            <block wx:for="{{item1}}" wx:key="indexChild" wx:for-item="item2">{{item2}}</block>\n
149
+          </block>
150
+        </view>
151
+      </view>
152
+    </view>
153
+    <view class='lineFooter'></view>
154
+  </block>
155
+
156
+  <!-- 诗词译文 -->
157
+  <block wx:if="{{Result.CHN.Translation && Result.CHN.Translation.length>0}}">
158
+    <view class="panelTitle FlexRow">
159
+      <view class="panelTitle1">诗词译文</view>
160
+    </view>
161
+    <view class="panelItem FlexRow">
162
+      <view class="{{CSS.CHN_Translation.Css1}} panelItemFrame FlexRow" bindtap='getInputData' data-type="normal" data-content="{{Result.CHN.Translation}}" data-css="CHN_Translation" data-tag="诗词译文">
163
+        <view class="{{CSS.CHN_Translation.Css2}} panelSelect0">{{CSS.CHN_Translation.Number}}</view>
164
+        <view class="text1">{{Result.CHN.Translation}}</view>
165
+      </view>
166
+    </view>
167
+    <view class='lineFooter'></view>
168
+  </block>
169
+
170
+
124 171
   <!-- 英文原文 -->
125 172
   <block wx:if="{{Result.ENG.Word && Result.ENG.Word.length>0 && !Result.CHN.HanZi}}">
126 173
     <view class="panelTitle FlexRow">

+ 4 - 0
utils/main.js

@@ -644,6 +644,10 @@ function saveTempImage(serverUrl, tempUrl) {
644 644
   if (!b) {
645 645
     list.push({ "ServerUrl": serverUrl, "TempUrl": tempUrl });
646 646
   }
647
+
648
+  if (list>200){
649
+    list.pop();
650
+  }
647 651
   wx.setStorageSync("TempImageList", list);
648 652
 }
649 653