chengjie 4 meses atrás
pai
commit
694e3af854

+ 4 - 3
app.js

@@ -1,8 +1,8 @@
1
 // app.js
1
 // app.js
2
 App({
2
 App({
3
   globalData: {
3
   globalData: {
4
-    Version: "1.0.4",
5
-    //IsProduction: true,
4
+    Version: "1.0.5",
5
+    IsProduction: true,
6
     ShareTitle: "阅读理解+答题",
6
     ShareTitle: "阅读理解+答题",
7
     SharePath: "pages/index/index",
7
     SharePath: "pages/index/index",
8
     ShareImage: '../images/pic_07.png',
8
     ShareImage: '../images/pic_07.png',
@@ -31,7 +31,8 @@ App({
31
     TempStr:"",
31
     TempStr:"",
32
     OCRWords:[],//OCR的单词
32
     OCRWords:[],//OCR的单词
33
     SelectedWords:[],//选中的单词
33
     SelectedWords:[],//选中的单词
34
-    ocrReady: false
34
+    ocrReady: false,//
35
+    Generating:false,//生成文章中
35
   },
36
   },
36
   onLaunch: function (options) {
37
   onLaunch: function (options) {
37
     let that=this;
38
     let that=this;

+ 4 - 0
pages/main/article.js

@@ -77,6 +77,8 @@ Page({
77
     //   IsBuilding:true,
77
     //   IsBuilding:true,
78
     // });
78
     // });
79
     // that.getChoicenessArticle();
79
     // that.getChoicenessArticle();
80
+
81
+    main.checkGenerating();
80
   },
82
   },
81
   getArticleByID:function(id){
83
   getArticleByID:function(id){
82
     let that=this;
84
     let that=this;
@@ -116,6 +118,7 @@ Page({
116
     that.setData({
118
     that.setData({
117
       IsBuilding:true
119
       IsBuilding:true
118
     });
120
     });
121
+    app.globalData.Generating=true;
119
     let words=app.globalData.SelectedWords.join(",");
122
     let words=app.globalData.SelectedWords.join(",");
120
     main.postData('GenerateArticle?UserID='+app.globalData.userInfo.UserID, {
123
     main.postData('GenerateArticle?UserID='+app.globalData.userInfo.UserID, {
121
       Words:words,
124
       Words:words,
@@ -123,6 +126,7 @@ Page({
123
       ArticleStyle:that.data.ArticleStyle,
126
       ArticleStyle:that.data.ArticleStyle,
124
       AIVersion:that.data.AIVersion
127
       AIVersion:that.data.AIVersion
125
     }, function (data) {
128
     }, function (data) {
129
+      app.globalData.Generating=false;
126
       if (data){
130
       if (data){
127
         if (data=="-1"){
131
         if (data=="-1"){
128
           that.setData({
132
           that.setData({

+ 2 - 2
pages/main/article.wxss

@@ -630,7 +630,7 @@
630
 .pic_08{
630
 .pic_08{
631
   width: 100%;
631
   width: 100%;
632
   position: fixed;
632
   position: fixed;
633
-  top:200rpx;
633
+  top:0rpx;
634
   z-index: 50;
634
   z-index: 50;
635
 }
635
 }
636
 
636
 
@@ -697,7 +697,7 @@
697
 }
697
 }
698
 
698
 
699
 .text10{
699
 .text10{
700
-  margin-left: 30rpx;
700
+  margin-left: 50rpx;
701
   font-size: 24rpx;
701
   font-size: 24rpx;
702
   text-align: center;
702
   text-align: center;
703
 }
703
 }

+ 1 - 0
pages/main/feedbackinfo.js

@@ -23,6 +23,7 @@ Page({
23
       IsShow:app.globalData.userInfo.IsShow,
23
       IsShow:app.globalData.userInfo.IsShow,
24
       Feedback:that.data.Feedback,
24
       Feedback:that.data.Feedback,
25
     });
25
     });
26
+    main.checkGenerating();
26
   },
27
   },
27
   bindKeyInput:function(e){
28
   bindKeyInput:function(e){
28
     var that=this;
29
     var that=this;

+ 1 - 0
pages/main/help.js

@@ -11,6 +11,7 @@ Page({
11
     that.setData({
11
     that.setData({
12
       Containnerheight: main.getWindowHeight(),
12
       Containnerheight: main.getWindowHeight(),
13
     });
13
     });
14
+    main.checkGenerating();
14
   },
15
   },
15
   onShareAppMessage: function () {
16
   onShareAppMessage: function () {
16
     return {
17
     return {

+ 1 - 0
pages/main/index.js

@@ -19,6 +19,7 @@ Page({
19
   onShow:function(){
19
   onShow:function(){
20
     app.globalData.OCRWords=[];
20
     app.globalData.OCRWords=[];
21
     this.getData();
21
     this.getData();
22
+    main.checkGenerating();
22
   },
23
   },
23
   goto: function (e) {
24
   goto: function (e) {
24
     let that=this;
25
     let that=this;

+ 2 - 0
pages/main/myarticles.js

@@ -14,6 +14,8 @@ Page({
14
       Containnerheight: main.getWindowHeight(),
14
       Containnerheight: main.getWindowHeight(),
15
     });
15
     });
16
     that.getData(app.globalData.userInfo.UserID);
16
     that.getData(app.globalData.userInfo.UserID);
17
+
18
+    main.checkGenerating();
17
   },
19
   },
18
   getData:function(userID){
20
   getData:function(userID){
19
     wx.showLoading({
21
     wx.showLoading({

+ 1 - 0
pages/main/ocr.js

@@ -10,6 +10,7 @@ Page({
10
   },
10
   },
11
   onLoad: function (options) {
11
   onLoad: function (options) {
12
     app.globalData.OCRWords=[];
12
     app.globalData.OCRWords=[];
13
+    main.checkGenerating();
13
   },
14
   },
14
   onShow:function(){
15
   onShow:function(){
15
     let that = this;
16
     let that = this;

+ 1 - 0
pages/main/paste.js

@@ -21,6 +21,7 @@ Page({
21
       Containnerheight: main.getWindowHeight(),
21
       Containnerheight: main.getWindowHeight(),
22
       Words:words, 
22
       Words:words, 
23
     });
23
     });
24
+    main.checkGenerating();
24
   },
25
   },
25
   handlePaste: function(e) {
26
   handlePaste: function(e) {
26
     let that = this;
27
     let that = this;

+ 1 - 0
pages/main/selectword.js

@@ -17,6 +17,7 @@ Page({
17
     that.setData({
17
     that.setData({
18
       Containnerheight: main.getWindowHeight(),
18
       Containnerheight: main.getWindowHeight(),
19
     });
19
     });
20
+    main.checkGenerating();
20
   },
21
   },
21
 
22
 
22
   onShow:function(e){
23
   onShow:function(e){

+ 54 - 25
pages/main/wordsinput.js

@@ -16,27 +16,17 @@ Page({
16
   },
16
   },
17
   onLoad: function (options) {
17
   onLoad: function (options) {
18
     let that = this;
18
     let that = this;
19
-    let grade=wx.getStorageSync('Grade');
20
-    if (!grade)
21
-      grade=[{Name:"小学",CSS:"Selected"},{Name:"初中",CSS:""},{Name:"高中",CSS:""},{Name:"大学",CSS:""}];
22
-    let ArticleStyle=wx.getStorageSync('ArticleStyle');
23
-    if (!ArticleStyle)
24
-      ArticleStyle=[{Name:"随机",CSS:"Selected"},{Name:"童话",CSS:""},{Name:"奇幻",CSS:""},{Name:"动物",CSS:""},{Name:"校园生活",CSS:""},{Name:"家庭亲子",CSS:""},{Name:"成长",CSS:""},{Name:"科幻",CSS:""},{Name:"环保",CSS:""},{Name:"旅行",CSS:""},{Name:"科普",CSS:""},{Name:"节日文化",CSS:""},{Name:"人生励志",CSS:""}];
25
-    let AIVersion=wx.getStorageSync('AIVersion');
26
-    if (!AIVersion)
27
-      AIVersion=[{Version:"1.0",Content:"基础词汇,结构简明\n平均30秒生成",CSS:"Selected"},{Version:"1.5",Content:"词句丰富,深度表达\n平均60秒生成",CSS:""}];
28
-  
19
+    
29
     const hiddenhelp=wx.getStorageSync('HiddenWordInputFirstOpen');
20
     const hiddenhelp=wx.getStorageSync('HiddenWordInputFirstOpen');
30
 
21
 
31
     that.setData({
22
     that.setData({
32
       Containnerheight: main.getWindowHeight(),
23
       Containnerheight: main.getWindowHeight(),
33
-      Grade:grade,
34
-      ArticleStyle:ArticleStyle,
35
-      AIVersion:AIVersion,
36
       IsShowFirstOpen:!hiddenhelp,
24
       IsShowFirstOpen:!hiddenhelp,
37
       KeyboardBtnName:"next",
25
       KeyboardBtnName:"next",
38
     });
26
     });
27
+    that.initMenu();
39
 
28
 
29
+    main.checkGenerating();
40
   },
30
   },
41
   onShow:function(e){
31
   onShow:function(e){
42
     let that = this;
32
     let that = this;
@@ -70,6 +60,45 @@ Page({
70
   onHide:function(e){
60
   onHide:function(e){
71
     this.getInputData();
61
     this.getInputData();
72
   },
62
   },
63
+  initMenu:function(){
64
+    let that = this;
65
+    let GradeArr=[{Name:"小学",CSS:"Selected"},{Name:"初中",CSS:""},{Name:"高中",CSS:""},{Name:"大学",CSS:""}];
66
+    let grade=wx.getStorageSync('Grade');
67
+    if (grade && grade>=0 && grade<=3){
68
+      for(let i=0;i<GradeArr.length;i++){
69
+        GradeArr[i].CSS="";
70
+        if (grade==i)
71
+          GradeArr[i].CSS="Selected";
72
+      }
73
+    }
74
+
75
+    let ArticleStyleArr=[{Name:"童话",CSS:"Selected"},{Name:"奇幻",CSS:""},{Name:"动物",CSS:""},{Name:"校园生活",CSS:""},{Name:"家庭亲子",CSS:""},{Name:"成长",CSS:""},{Name:"科幻",CSS:""},{Name:"旅行",CSS:""},{Name:"大自然",CSS:""},{Name:"科普",CSS:""},{Name:"节日文化",CSS:""},{Name:"人生励志",CSS:""}];
76
+    let ArticleStyle=wx.getStorageSync('ArticleStyle');
77
+    if (ArticleStyle && ArticleStyle>=0 && ArticleStyle<=12){
78
+      for(let i=0;i<ArticleStyleArr.length;i++){
79
+        ArticleStyleArr[i].CSS="";
80
+        if (ArticleStyle==i)
81
+          ArticleStyleArr[i].CSS="Selected";
82
+      }
83
+    }
84
+
85
+    let AIVersionArr=[{Version:"1.0",Content:"词句丰富,结构简明\n平均30秒生成",CSS:"Selected"},{Version:"1.5",Content:"深度表达,更多要素\n平均60秒生成",CSS:""}];
86
+    let AIVersion=wx.getStorageSync('AIVersion');
87
+    if (AIVersion && AIVersion>=0 && AIVersion<=2){
88
+      for(let i=0;i<AIVersionArr.length;i++){
89
+        AIVersionArr[i].CSS="";
90
+        if (AIVersion==i)
91
+          AIVersionArr[i].CSS="Selected";
92
+      }
93
+    }
94
+
95
+    
96
+    that.setData({
97
+      GradeArr:GradeArr,
98
+      ArticleStyleArr:ArticleStyleArr,
99
+      AIVersionArr:AIVersionArr,
100
+    });
101
+  },
73
   bindKeyInput: function (e) {
102
   bindKeyInput: function (e) {
74
     let that=this;
103
     let that=this;
75
     let id=e.currentTarget.dataset.id;
104
     let id=e.currentTarget.dataset.id;
@@ -200,11 +229,11 @@ Page({
200
     const index=e.currentTarget.dataset.index;
229
     const index=e.currentTarget.dataset.index;
201
     const id=e.currentTarget.dataset.id;
230
     const id=e.currentTarget.dataset.id;
202
     
231
     
203
-    let arr=this.data.Grade;
232
+    let arr=this.data.GradeArr;
204
     if (id==1)
233
     if (id==1)
205
-      arr=this.data.ArticleStyle;
234
+      arr=this.data.ArticleStyleArr;
206
     else if (id==2)
235
     else if (id==2)
207
-      arr=this.data.AIVersion;
236
+      arr=this.data.AIVersionArr;
208
       
237
       
209
     for(let i=0;i<arr.length;i++){
238
     for(let i=0;i<arr.length;i++){
210
       arr[i].CSS="";
239
       arr[i].CSS="";
@@ -213,21 +242,21 @@ Page({
213
     }
242
     }
214
     if (id==1){
243
     if (id==1){
215
       this.setData({
244
       this.setData({
216
-        ArticleStyle:arr,
245
+        ArticleStyleArr:arr,
217
       });
246
       });
218
-      wx.setStorageSync('ArticleStyle', arr);
247
+      wx.setStorageSync('ArticleStyle', index);
219
     }
248
     }
220
     else if (id==2){
249
     else if (id==2){
221
       this.setData({
250
       this.setData({
222
-        AIVersion:arr,
251
+        AIVersionArr:arr,
223
       });
252
       });
224
-      wx.setStorageSync('AIVersion', arr);
253
+      wx.setStorageSync('AIVersion', index);
225
     }
254
     }
226
     else{
255
     else{
227
       this.setData({
256
       this.setData({
228
-        Grade:arr,
257
+        GradeArr:arr,
229
       });
258
       });
230
-      wx.setStorageSync('Grade', arr);
259
+      wx.setStorageSync('Grade', index);
231
     }
260
     }
232
     
261
     
233
   },
262
   },
@@ -243,21 +272,21 @@ Page({
243
     that.getInputData();
272
     that.getInputData();
244
 
273
 
245
     if (url=="article"){
274
     if (url=="article"){
246
-      let arr=this.data.Grade;
275
+      let arr=this.data.GradeArr;
247
       for(let i=0;i<arr.length;i++){
276
       for(let i=0;i<arr.length;i++){
248
         if (arr[i].CSS=="Selected"){
277
         if (arr[i].CSS=="Selected"){
249
           url+="?Level="+i;
278
           url+="?Level="+i;
250
           break;
279
           break;
251
         }
280
         }
252
       }
281
       }
253
-      arr=this.data.ArticleStyle;
282
+      arr=this.data.ArticleStyleArr;
254
       for(let i=0;i<arr.length;i++){
283
       for(let i=0;i<arr.length;i++){
255
         if (arr[i].CSS=="Selected"){
284
         if (arr[i].CSS=="Selected"){
256
           url+="&ArticleStyle="+arr[i].Name;
285
           url+="&ArticleStyle="+arr[i].Name;
257
           break;
286
           break;
258
         }
287
         }
259
       }
288
       }
260
-      arr=this.data.AIVersion;
289
+      arr=this.data.AIVersionArr;
261
       for(let i=0;i<arr.length;i++){
290
       for(let i=0;i<arr.length;i++){
262
         if (arr[i].CSS=="Selected"){
291
         if (arr[i].CSS=="Selected"){
263
           url+="&AIVersion="+arr[i].Version;
292
           url+="&AIVersion="+arr[i].Version;

+ 3 - 3
pages/main/wordsinput.wxml

@@ -65,21 +65,21 @@
65
     <view class="panelMenu11 FlexColumn">
65
     <view class="panelMenu11 FlexColumn">
66
       <view class="text04 text05">单词水平</view>
66
       <view class="text04 text05">单词水平</view>
67
       <view class="panelMenu111 FlexRow">
67
       <view class="panelMenu111 FlexRow">
68
-        <view class="btn btn{{item.CSS}} FlexRow" wx:for="{{Grade}}" wx:key="index" capture-bind:tap="selectBtn" data-id="0" data-index="{{index}}">{{item.Name}}</view>
68
+        <view class="btn btn{{item.CSS}} FlexRow" wx:for="{{GradeArr}}" wx:key="index" capture-bind:tap="selectBtn" data-id="0" data-index="{{index}}">{{item.Name}}</view>
69
       </view>
69
       </view>
70
     </view>
70
     </view>
71
     <view class="panelMenu11 FlexColumn">
71
     <view class="panelMenu11 FlexColumn">
72
       <view class="text04 text06">主题</view>
72
       <view class="text04 text06">主题</view>
73
       <scroll-view scroll-x="true" class="panelMenu1110">
73
       <scroll-view scroll-x="true" class="panelMenu1110">
74
         <view class="panelMenu1111 FlexRow">
74
         <view class="panelMenu1111 FlexRow">
75
-          <view class="btn btn{{item.CSS}} FlexRow" wx:for="{{ArticleStyle}}" wx:key="index" capture-bind:tap="selectBtn" data-id="1" data-index="{{index}}">{{item.Name}}</view>
75
+          <view class="btn btn{{item.CSS}} FlexRow" wx:for="{{ArticleStyleArr}}" wx:key="index" capture-bind:tap="selectBtn" data-id="1" data-index="{{index}}">{{item.Name}}</view>
76
         </view>
76
         </view>
77
       </scroll-view>
77
       </scroll-view>
78
     </view>
78
     </view>
79
     <view class="panelMenu11 FlexColumn">
79
     <view class="panelMenu11 FlexColumn">
80
       <view class="text04 text05">模型</view>
80
       <view class="text04 text05">模型</view>
81
       <view class="panelMenu111 FlexRow">
81
       <view class="panelMenu111 FlexRow">
82
-        <view class="btn btn4 btn{{item.CSS}} FlexRow" wx:for="{{AIVersion}}" wx:key="index" capture-bind:tap="selectBtn" data-id="2" data-index="{{index}}">
82
+        <view class="btn btn4 btn{{item.CSS}} FlexRow" wx:for="{{AIVersionArr}}" wx:key="index" capture-bind:tap="selectBtn" data-id="2" data-index="{{index}}">
83
           <view class="btn41">{{item.Version}}</view>
83
           <view class="btn41">{{item.Version}}</view>
84
           <text>{{item.Content}}</text>
84
           <text>{{item.Content}}</text>
85
         </view>
85
         </view>

+ 4 - 4
pages/main/wordsinput.wxss

@@ -247,17 +247,17 @@
247
 }
247
 }
248
 .panelMenu111{
248
 .panelMenu111{
249
   width:100%;
249
   width:100%;
250
-  margin: 30rpx 0 0 30rpx;
250
+  margin: 30rpx 0 0 60rpx;
251
   justify-content: flex-start;
251
   justify-content: flex-start;
252
   align-items: flex-start;
252
   align-items: flex-start;
253
 }
253
 }
254
 .panelMenu1110{
254
 .panelMenu1110{
255
   width:100%;
255
   width:100%;
256
-  margin: 30rpx 0 -20rpx 0;
256
+  margin: 30rpx 0 -20rpx 20rpx;
257
   white-space: nowrap;
257
   white-space: nowrap;
258
 }
258
 }
259
 .panelMenu1111{
259
 .panelMenu1111{
260
-  width:1108rpx;
260
+  width:1008rpx;
261
   height:260rpx;
261
   height:260rpx;
262
   margin-left: 20rpx;
262
   margin-left: 20rpx;
263
   flex-wrap: wrap;
263
   flex-wrap: wrap;
@@ -287,7 +287,7 @@
287
 }
287
 }
288
 .btn4{
288
 .btn4{
289
   height:126rpx;
289
   height:126rpx;
290
-  margin: 0 10rpx;
290
+  margin: 0 20rpx 0 0;
291
   font-size: 24rpx;
291
   font-size: 24rpx;
292
 }
292
 }
293
 
293
 

+ 31 - 0
utils/main.js

@@ -135,10 +135,41 @@ function onSelect(obj,event,callback){
135
   callback(obj,event,result);
135
   callback(obj,event,result);
136
 }
136
 }
137
 
137
 
138
+function checkGenerating(){
139
+  if (app.globalData.Generating){
140
+    let intervalGenerate=setInterval(function(){
141
+      console.log(new Date().getTime());
142
+      if (!app.globalData.Generating){
143
+        clearInterval(intervalGenerate);
144
+        wx.showModal({
145
+          title: '通知',
146
+          content: '文章生成好了。',
147
+          cancelText:"不去",
148
+          confirmText:"去看",
149
+          complete: (res) => {
150
+            if (res.confirm) {
151
+              let next='article?ID=MAX';
152
+              wx.reLaunch({
153
+                url: 'index',
154
+                complete:function(){
155
+                  wx.navigateTo({
156
+                    url: next,
157
+                  })
158
+                }
159
+              })
160
+            }
161
+          }
162
+        })
163
+      }
164
+    },1000);
165
+  }
166
+}
167
+
138
 module.exports = {
168
 module.exports = {
139
   getData: getData,
169
   getData: getData,
140
   postData: postData,
170
   postData: postData,
141
   getLocalHost: getLocalHost,
171
   getLocalHost: getLocalHost,
142
   getWindowHeight: getWindowHeight,
172
   getWindowHeight: getWindowHeight,
143
   onSelect:onSelect,
173
   onSelect:onSelect,
174
+  checkGenerating:checkGenerating,
144
 }
175
 }