import { createSubscribe } from 'applet-page-component';
import { getPatientList } from '../../service/common';
import history from '../../utils/history';
Component(createSubscribe({
  async onShow() {
    this.init();
  }

})({
  props: {},
  data: {
    loadMore: '',
    loadContent: ['马不停蹄加载更多数据中...', '-- 已经到底了，加不了咯 --'],
    patientList: []
  },

  didMount() {
    this.init();
  },

  methods: {
    init() {
      const that = this;
      my.showLoading({
        content: '加载中...'
      });
      getPatientList().then(data => {
        my.hideLoading({
          page: that
        });
        this.setData({
          patientList: data
        });
      });
    },

    onDetail(e) {
      history.push({
        query: {
          id: e.target.dataset.id
        },
        title: '就诊人详情',
        pageType: 'patient-detail'
      });
    },

    // 添加就诊人
    addPatient() {
      history.push({
        title: '添加就诊人',
        pageType: 'edit-patient'
      });
    }

  }
}));