chengjie vor 4 Monaten
Ursprung
Commit
694e3af854

+ 4 - 3
app.js

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

+ 4 - 0
pages/main/article.js

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

+ 2 - 2
pages/main/article.wxss

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

+ 1 - 0
pages/main/feedbackinfo.js

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

+ 1 - 0
pages/main/help.js

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

+ 1 - 0
pages/main/index.js

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

+ 2 - 0
pages/main/myarticles.js

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

+ 1 - 0
pages/main/ocr.js

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

+ 1 - 0
pages/main/paste.js

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

+ 1 - 0
pages/main/selectword.js

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

+ 54 - 25
pages/main/wordsinput.js

@@ -16,27 +16,17 @@ Page({
16 16
   },
17 17
   onLoad: function (options) {
18 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 20
     const hiddenhelp=wx.getStorageSync('HiddenWordInputFirstOpen');
30 21
 
31 22
     that.setData({
32 23
       Containnerheight: main.getWindowHeight(),
33
-      Grade:grade,
34
-      ArticleStyle:ArticleStyle,
35
-      AIVersion:AIVersion,
36 24
       IsShowFirstOpen:!hiddenhelp,
37 25
       KeyboardBtnName:"next",
38 26
     });
27
+    that.initMenu();
39 28
 
29
+    main.checkGenerating();
40 30
   },
41 31
   onShow:function(e){
42 32
     let that = this;
@@ -70,6 +60,45 @@ Page({
70 60
   onHide:function(e){
71 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 102
   bindKeyInput: function (e) {
74 103
     let that=this;
75 104
     let id=e.currentTarget.dataset.id;
@@ -200,11 +229,11 @@ Page({
200 229
     const index=e.currentTarget.dataset.index;
201 230
     const id=e.currentTarget.dataset.id;
202 231
     
203
-    let arr=this.data.Grade;
232
+    let arr=this.data.GradeArr;
204 233
     if (id==1)
205
-      arr=this.data.ArticleStyle;
234
+      arr=this.data.ArticleStyleArr;
206 235
     else if (id==2)
207
-      arr=this.data.AIVersion;
236
+      arr=this.data.AIVersionArr;
208 237
       
209 238
     for(let i=0;i<arr.length;i++){
210 239
       arr[i].CSS="";
@@ -213,21 +242,21 @@ Page({
213 242
     }
214 243
     if (id==1){
215 244
       this.setData({
216
-        ArticleStyle:arr,
245
+        ArticleStyleArr:arr,
217 246
       });
218
-      wx.setStorageSync('ArticleStyle', arr);
247
+      wx.setStorageSync('ArticleStyle', index);
219 248
     }
220 249
     else if (id==2){
221 250
       this.setData({
222
-        AIVersion:arr,
251
+        AIVersionArr:arr,
223 252
       });
224
-      wx.setStorageSync('AIVersion', arr);
253
+      wx.setStorageSync('AIVersion', index);
225 254
     }
226 255
     else{
227 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 272
     that.getInputData();
244 273
 
245 274
     if (url=="article"){
246
-      let arr=this.data.Grade;
275
+      let arr=this.data.GradeArr;
247 276
       for(let i=0;i<arr.length;i++){
248 277
         if (arr[i].CSS=="Selected"){
249 278
           url+="?Level="+i;
250 279
           break;
251 280
         }
252 281
       }
253
-      arr=this.data.ArticleStyle;
282
+      arr=this.data.ArticleStyleArr;
254 283
       for(let i=0;i<arr.length;i++){
255 284
         if (arr[i].CSS=="Selected"){
256 285
           url+="&ArticleStyle="+arr[i].Name;
257 286
           break;
258 287
         }
259 288
       }
260
-      arr=this.data.AIVersion;
289
+      arr=this.data.AIVersionArr;
261 290
       for(let i=0;i<arr.length;i++){
262 291
         if (arr[i].CSS=="Selected"){
263 292
           url+="&AIVersion="+arr[i].Version;

+ 3 - 3
pages/main/wordsinput.wxml

@@ -65,21 +65,21 @@
65 65
     <view class="panelMenu11 FlexColumn">
66 66
       <view class="text04 text05">单词水平</view>
67 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 69
       </view>
70 70
     </view>
71 71
     <view class="panelMenu11 FlexColumn">
72 72
       <view class="text04 text06">主题</view>
73 73
       <scroll-view scroll-x="true" class="panelMenu1110">
74 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 76
         </view>
77 77
       </scroll-view>
78 78
     </view>
79 79
     <view class="panelMenu11 FlexColumn">
80 80
       <view class="text04 text05">模型</view>
81 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 83
           <view class="btn41">{{item.Version}}</view>
84 84
           <text>{{item.Content}}</text>
85 85
         </view>

+ 4 - 4
pages/main/wordsinput.wxss

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

+ 31 - 0
utils/main.js

@@ -135,10 +135,41 @@ function onSelect(obj,event,callback){
135 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 168
 module.exports = {
139 169
   getData: getData,
140 170
   postData: postData,
141 171
   getLocalHost: getLocalHost,
142 172
   getWindowHeight: getWindowHeight,
143 173
   onSelect:onSelect,
174
+  checkGenerating:checkGenerating,
144 175
 }