|
|
@@ -3,7 +3,7 @@ import { getPatients } from "../../../../pages/home/request";
|
|
|
import { toCertificationPage } from "../../../../pages/home/router";
|
|
|
import { Post } from "../../../../lib/request/method";
|
|
|
|
|
|
-let next: 'handleA' | 'handleB' | 'handleC';
|
|
|
+let next: "handleA" | "handleB" | "handleC";
|
|
|
|
|
|
Component({
|
|
|
lifetimes: {
|
|
|
@@ -23,9 +23,9 @@ Component({
|
|
|
// 获取评估剩余次数
|
|
|
this.setAnalysisCount().then(() => {
|
|
|
if (next) {
|
|
|
- const patientId = wx.getStorageSync('patientId');
|
|
|
+ const patientId = wx.getStorageSync("patientId");
|
|
|
if (patientId) this[next]();
|
|
|
- else wx.showToast({ title: '请先完善信息!', icon: 'none' });
|
|
|
+ else wx.showToast({ title: "请先完善信息!", icon: "none" });
|
|
|
next = undefined;
|
|
|
}
|
|
|
});
|
|
|
@@ -51,7 +51,8 @@ Component({
|
|
|
{},
|
|
|
{
|
|
|
transform({ data }: any) {
|
|
|
- if (data?.usedCou === 0 && data.residuedCou === 0) data.residuedCou = 3;
|
|
|
+ if (data?.usedCou === 0 && data.residuedCou === 0)
|
|
|
+ data.residuedCou = 3;
|
|
|
return data?.residuedCou;
|
|
|
},
|
|
|
}
|
|
|
@@ -65,35 +66,19 @@ Component({
|
|
|
const { patient } = await getPatients(/*this.data.patientId*/);
|
|
|
if (!patient) {
|
|
|
await toCertificationPage();
|
|
|
- next = 'handleA';
|
|
|
- }
|
|
|
- else {
|
|
|
+ next = "handleA";
|
|
|
+ } else {
|
|
|
if (this.data.active) {
|
|
|
- this.triggerEvent("next", {
|
|
|
- component: "questionnaire",
|
|
|
- scroll: true,
|
|
|
- });
|
|
|
+ // 设置 isAnalysis 为 3(健康分析/对话管家)
|
|
|
+ wx.setStorageSync("isAnalysis", 3);
|
|
|
+ // 先触发 nextType 更新 messageType,然后触发 next 切换组件
|
|
|
this.triggerEvent("nextType", { MessageType: 2 });
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- // 在线咨询
|
|
|
- async handleE() {
|
|
|
- const { patient } = await getPatients(/*this.data.patientId*/);
|
|
|
- if (!patient) await toCertificationPage();
|
|
|
- else {
|
|
|
- if (this.data.active) {
|
|
|
- // 清除之前的咨询结束状态,开始新咨询
|
|
|
- wx.setStorageSync("consultEnded", false);
|
|
|
- wx.setStorageSync("lastConsultTime", Date.now());
|
|
|
-
|
|
|
- wx.setStorageSync("isAnalysis", 5);
|
|
|
- this.triggerEvent("next", {
|
|
|
- component: "questionnaire",
|
|
|
- scroll: true,
|
|
|
- });
|
|
|
- this.triggerEvent("nextType", { MessageType: 3 });
|
|
|
-
|
|
|
+ setTimeout(() => {
|
|
|
+ this.triggerEvent("next", {
|
|
|
+ component: "questionnaire",
|
|
|
+ scroll: true,
|
|
|
+ });
|
|
|
+ }, 100);
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
@@ -101,9 +86,8 @@ Component({
|
|
|
const { patient } = await getPatients(/*this.data.patientId*/);
|
|
|
if (!patient) {
|
|
|
await toCertificationPage();
|
|
|
- next = 'handleB';
|
|
|
- }
|
|
|
- else {
|
|
|
+ next = "handleB";
|
|
|
+ } else {
|
|
|
if (this.data.active)
|
|
|
wx.navigateTo({
|
|
|
url: "/module/health/pages/status/status",
|
|
|
@@ -113,11 +97,10 @@ Component({
|
|
|
},
|
|
|
async handleC() {
|
|
|
const { patient } = await getPatients(/*this.data.patientId*/);
|
|
|
- if (!patient){
|
|
|
+ if (!patient) {
|
|
|
await toCertificationPage();
|
|
|
- next = 'handleC';
|
|
|
- }
|
|
|
- else {
|
|
|
+ next = "handleC";
|
|
|
+ } else {
|
|
|
if (this.data.active)
|
|
|
wx.navigateTo({
|
|
|
url: "/module/user/pages/user-edit/user-edit",
|
|
|
@@ -136,7 +119,29 @@ Component({
|
|
|
wx.redirectTo({ url: "/pages/home/home" });
|
|
|
}
|
|
|
},
|
|
|
+ // 在线咨询
|
|
|
+ async handleE() {
|
|
|
+ const { patient } = await getPatients(/*this.data.patientId*/);
|
|
|
+ if (!patient) await toCertificationPage();
|
|
|
+ else {
|
|
|
+ if (this.data.active) {
|
|
|
+ // 清除之前的咨询结束状态,开始新咨询
|
|
|
+ wx.setStorageSync("consultEnded", false);
|
|
|
+ wx.setStorageSync("lastConsultTime", Date.now());
|
|
|
|
|
|
+ wx.setStorageSync("isAnalysis", 5);
|
|
|
+ // 先触发 nextType 更新 messageType,然后立即触发 next 切换组件
|
|
|
+ // 由于 nextType 事件处理是同步的,所以可以立即触发 next
|
|
|
+ this.triggerEvent("nextType", { MessageType: 3 });
|
|
|
+ setTimeout(() => {
|
|
|
+ this.triggerEvent("next", {
|
|
|
+ component: "questionnaire",
|
|
|
+ scroll: true,
|
|
|
+ });
|
|
|
+ }, 100);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
_update(result: string[]) {
|
|
|
if (result.length) {
|
|
|
this.setData({ result });
|