Explorar o código

对话管家上传图片,显示分析中文案

cc12458 hai 1 ano
pai
achega
c4b68c79b6

+ 1 - 0
miniprogram/module/chats/components/message-text/message-text.json

@@ -5,6 +5,7 @@
   "usingComponents": {
     "t-cell": "tdesign-miniprogram/cell/cell",
     "t-icon": "tdesign-miniprogram/icon/icon",
+    "t-loading": "tdesign-miniprogram/loading/loading",
     "user-avatar": "../../../../components/user-avatar/user-avatar"
   }
 }

+ 9 - 1
miniprogram/module/chats/components/message-text/message-text.scss

@@ -1,4 +1,12 @@
 @import '../../../../themes/t.cell.scss';
 @import '../../common.scss';
 
-/* module/chats/components/message-text/message-text.wxss */
+/* module/chats/components/message-text/message-text.wxss */
+
+.container {
+  display: flex;
+  flex-direction: row;
+  align-items: center;
+  --td-loading-color: #fff;
+  --td-loading-text-font-size: 24px;
+}

+ 1 - 1
miniprogram/module/chats/components/message-text/message-text.ts

@@ -5,7 +5,7 @@ Component({
    * 组件的属性列表
    */
   properties: {
-    payload: { type: Object, value: { title: '' } }
+    payload: { type: Object, value: { title: '', loading: false } }
   },
 
   /**

+ 6 - 1
miniprogram/module/chats/components/message-text/message-text.wxml

@@ -4,6 +4,11 @@
     <image src="../../assets/robot.png" mode="aspectFill" />
   </view>
   <view class="chat-card__content">
-    <t-cell t-class="cell-border-gradient" title="{{payload.title}}"></t-cell>
+    <t-cell t-class="cell-border-gradient">
+      <view class="container" slot="title">
+        <text>{{payload.title}}</text>
+        <t-loading wx:if="{{payload.loading}}" theme="dots" style="margin-left: 4px;" />
+      </view>
+    </t-cell>
   </view>
 </view>

+ 48 - 20
miniprogram/module/chats/components/questionnaire/questionnaire.ts

@@ -70,32 +70,52 @@ Component({
       })
       this.triggerEvent('next', { component: 'guide', scroll: true });
     },
+    _pre() { },
     async _next() {
       try {
+        this._pre();
         const { data } = await Post(`/dialogueManage/dialog`, this.data._next);
         data.nextQuestions?.forEach((question: any, index: number) => {
-          if (question.css === 'tongue') {
-            this._createMessage({
-              id: `${question.classify}.${question.id}.${index}`, type: 'analysis',
-              payload: { title: question.title }
-            });
-          } else if (question.css === 'text') {
-            this._createMessage({
+          if (question.classify === 'tongue_result') {
+            this._updateMessage({
               id: `${question.classify}.${question.id}.${index}`, type: 'text',
               payload: { title: question.content }
-            });
-          } else if (['select', 'checkbox'].includes(question.css)) {
-            this._createMessage({
-              id: `${question.classify}.${question.id}.${index}`, type: 'select',
-              payload: {
-                title: question.title,
-                options: question.options,
-                multiple: question.css === 'checkbox',
-                required: question.required
-              }
             })
-          } else if (question.over) {
-            return this._end();
+          } else {
+            if (question.classify === 'tongue') {
+              this._pre = () => {
+                this._createMessage({
+                  id: `${question.classify}.${question.id}.loading`, type: 'text',
+                  payload: { title: '分析中', loading: true }
+                });
+                this.triggerEvent('to');
+              }
+            } else {
+              this._pre = () => { }
+            }
+            if (question.css === 'tongue') {
+              this._createMessage({
+                id: `${question.classify}.${question.id}.${index}`, type: 'analysis',
+                payload: { title: question.title }
+              });
+            } else if (question.css === 'text') {
+              this._createMessage({
+                id: `${question.classify}.${question.id}.${index}`, type: 'text',
+                payload: { title: question.content }
+              });
+            } else if (['select', 'checkbox'].includes(question.css)) {
+              this._createMessage({
+                id: `${question.classify}.${question.id}.${index}`, type: 'select',
+                payload: {
+                  title: question.title,
+                  options: question.options,
+                  multiple: question.css === 'checkbox',
+                  required: question.required
+                }
+              })
+            } else if (question.over) {
+              return this._end();
+            }
           }
         });
         if (data.classify === 'report') {
@@ -136,6 +156,14 @@ Component({
 
       console.log(this.data.messages);
 
-    }
+    },
+
+    _updateMessage(body: Message) {
+      const messages = this.data.messages;
+      const index = Object.keys(messages).length;
+      this.setData({
+        [`messages.${index - 1}`]: body,
+      })
+    },
   }
 })