htc 6 часов назад
Родитель
Сommit
a4cb0140b5
2 измененных файлов с 16 добавлено и 4 удалено
  1. 8 3
      pages/dialog.vue
  2. 8 1
      pages/reportAsk.vue

+ 8 - 3
pages/dialog.vue

@@ -160,7 +160,7 @@
 					requestTask = uni.request({
 						url: `${BaseApi}/core/chat/sendChatMessageStream`,
 						method: 'POST',
-						timeout: 30000,
+						timeout: 20000,
 						data:{ 
 							query: this.question,
 							identity:'被教练者',
@@ -181,7 +181,7 @@
 							}
 						},
 						fail: (err) => {
-							if(err.errMsg.indexOf('time out')>-1||err.errMsg.indexOf('timeout')>-1) this.$showToast('请求超时,请稍后再试')
+							// if(err.errMsg.indexOf('time out')>-1||err.errMsg.indexOf('timeout')>-1) this.$showToast('请求超时,请稍后再试')
 							this._handleError(err.errMsg, resolve, reject);
 						},
 						complete: (com) => {
@@ -193,7 +193,12 @@
 						const uint8Array = new Uint8Array(res.data);
 						const decoder = new TextEncoding.TextDecoder("utf-8");
 						const decodedString = decoder.decode(uint8Array);
-						console.log(decodedString,'decodedString',typeof decodedString);
+						if(decodedString.indexOf('"code":500')>-1){
+							const dsJson = JSON.parse(decodedString);
+							if(dsJson){
+								return this.$showModal(dsJson.msg||'')
+							}
+						}
 						try {
 							let newtext = decodedString.replaceAll('data:','').replaceAll(':keepAlive','');
 							let ntArr = newtext.split('\n\n');

+ 8 - 1
pages/reportAsk.vue

@@ -126,7 +126,7 @@
 					requestTask = uni.request({
 						url: `${BaseApi}/core/chat/sendChatMessageStream`,
 						method: 'POST',
-						timeout: 10000,
+						timeout: 20000,
 						data:{ 
 							query: this.question,
 							identity:'被教练者',
@@ -148,6 +148,7 @@
 							}
 						},
 						fail: (err) => {
+							// if(err.errMsg.indexOf('time out')>-1||err.errMsg.indexOf('timeout')>-1) this.$showToast('请求超时,请稍后再试')
 							this._handleError(err.errMsg, resolve, reject);
 						},
 						complete: (com) => {
@@ -159,6 +160,12 @@
 						const uint8Array = new Uint8Array(res.data);
 						const decoder = new TextEncoding.TextDecoder("utf-8");
 						const decodedString = decoder.decode(uint8Array);
+						if(decodedString.indexOf('"code":500')>-1){
+							const dsJson = JSON.parse(decodedString);
+							if(dsJson){
+								return this.$showModal(dsJson.msg||'')
+							}
+						}
 						try {
 							let newtext = decodedString.replaceAll('data:','').replaceAll(':keepAlive','');
 							let ntArr = newtext.split('\n\n');