// module/chats/components/guide/guide.ts
Component({
  lifetimes: {},
  properties: {
    id: { type: String, value: '' },
    active: { type: Boolean, value: false },
  },
  data: {
    result: [] as string[],
    result2: false,
  },
  methods: {
    handleA() {
      if (this.data.active) this.triggerEvent('next', { component: 'questionnaire', scroll: true });
    },
    handleB() {
      if (this.data.active) wx.navigateTo({
        url: '/module/health/pages/status/status',
        events: { update: this._update.bind(this) }
      });
    },
    handleC() {
      if (this.data.active) wx.navigateTo({
        url: '/module/user/pages/user-edit/user-edit',
        events: {
          update2: () => {
            this.setData({ result2: true });
            this.triggerEvent('next', { component: 'guide', scroll: true });
          }
        }
      });
    },
    handleD() {
      if (this.data.active) wx.navigateBack();
    },

    _update(result: string[]) {
      if (result.length) {
        this.setData({ result });
        this.triggerEvent('next', { component: 'guide', scroll: true });
      } else {
        setTimeout(() => wx.showToast({ title: `没有更改项`, icon: 'none' }), 300)
      }
    }
  }
})