guide.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // module/chats/components/guide/guide.ts
  2. import { getPatients } from "../../../../pages/home/request";
  3. import { toCertificationPage } from "../../../../pages/home/router";
  4. Component({
  5. lifetimes: {
  6. attached() {
  7. const showGuideActive = wx.getStorageSync("showGuideActive");
  8. // 从主页点击健康评估进来的
  9. if(showGuideActive){
  10. this.handleA();
  11. wx.removeStorageSync("showGuideActive");
  12. }
  13. },
  14. },
  15. observers: {
  16. active(newVal,oldVal) {
  17. console.log("active=>>>",newVal,oldVal);
  18. },
  19. },
  20. properties: {
  21. id: { type: String, value: "" },
  22. active: { type: Boolean, value: false },
  23. analysisCount: { type: Number, value: 0 },
  24. },
  25. data: {
  26. result: [] as string[],
  27. result2: false,
  28. patient: {} as any,
  29. },
  30. methods: {
  31. async handleA() {
  32. const { patient } = await getPatients(/*this.data.patientId*/);
  33. if (!patient) await toCertificationPage();
  34. else {
  35. console.log("patient",this.data.active);
  36. if (this.data.active) {
  37. this.triggerEvent("next", { component: "questionnaire", scroll: true });
  38. this.triggerEvent("nextType", { MessageType: 2 });
  39. }
  40. }
  41. },
  42. async handleB() {
  43. const { patient } = await getPatients(/*this.data.patientId*/);
  44. if (!patient) await toCertificationPage();
  45. else {
  46. if (this.data.active)
  47. wx.navigateTo({
  48. url: "/module/health/pages/status/status",
  49. events: { update: this._update.bind(this) },
  50. });
  51. }
  52. },
  53. async handleC() {
  54. const { patient } = await getPatients(/*this.data.patientId*/);
  55. if (!patient) await toCertificationPage();
  56. else {
  57. if (this.data.active)
  58. wx.navigateTo({
  59. url: "/module/user/pages/user-edit/user-edit",
  60. events: {
  61. update2: () => {
  62. this.setData({ result2: true });
  63. this.triggerEvent("next", { component: "guide", scroll: true });
  64. },
  65. },
  66. });
  67. }
  68. },
  69. handleD() {
  70. // if (this.data.active) wx.navigateBack();
  71. if (this.data.active) {
  72. console.log("tiaohzuan1");
  73. wx.redirectTo({ url: "/pages/home/home" });
  74. }
  75. },
  76. _update(result: string[]) {
  77. if (result.length) {
  78. this.setData({ result });
  79. this.triggerEvent("next", { component: "guide", scroll: true });
  80. } else {
  81. setTimeout(
  82. () => wx.showToast({ title: `没有更改项`, icon: "none" }),
  83. 300
  84. );
  85. }
  86. },
  87. },
  88. });