|
|
@@ -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,
|
|
|
+ })
|
|
|
+ },
|
|
|
}
|
|
|
})
|