/*
 * @Descripttion:
 * @Company: 思宏科技
 * @version: v1.0
 * @Author: HJ
 * @Date: 2021-11-26 09:44:09
 * @LastEditors: zx
 * @LastEditTime: 2021-11-29 18:21:44
 */
const app = getApp();
import { fhSavePatientInfo } from "../../../api/remote/index";
const pageOptions = {
  // 页面数据
  data: {
    isFirstOnShow: true, // 是否为首次执行onShow
    steps: [
      {
        desc: "填写基础信息",
      },
      {
        desc: "确认住院信息",
      },
    ],
    stepIndex: 2,
    // hospitalInfo:[],//医院信息
    form:{
      bedNumber: app.globalData.hospitalInfo.bedNumber,
      sickroomId: app.globalData.hospitalInfo.sickroomId,
      hospitalId: app.globalData.hospitalInfo.hospitalId,
    }
  },
  //保存患者认证
  async savePatientInfo() {
    const { form } = app.globalData.Form;
    const memberId = app.globalData.baseInfo.memberId;
    form.sickroomId = app.globalData.hospitalInfo.sickroomId;
    form.hospitalId =  app.globalData.hospitalInfo.hospitalId;
    try {
      const { results } = await fhSavePatientInfo(form, memberId);
      this.setData({
        stepIndex:2
      })
    } catch (e) {
      console.log("debug axios", e);
    }
  },
  //输入事件
  onInputChange({ currentTarget: { dataset }, detail }) {
    const { key, formKey = "form" } = dataset;
    let { value } = detail;
    if (key === "sex") value = +value;
    this.setData({
      [`${formKey}.${key}`]: typeof detail === "string" ? detail : value,
    });
  },
  // 页面载入时
  onLoad(e) {
    this.init(e);
  },
  // 页面初始化
  init(e) {},
  // 页面准备好时
  onReady() {},
  // 页面显示时
  onShow() {
    const { isFirstOnShow } = this.data;

    if (isFirstOnShow) {
      // 首次执行时
      this.setData({
        isFirstOnShow: false,
      });
      return;
    }
  },
  // 页面隐藏时
  onHide() {},
  // 页面卸载时
  onUnload() {},
  // 下拉页面时
  onPullDownRefresh() {},
  // 到达页面底部时
  onReachBottom() {},
  // 页面滚动时
  onPageScroll() {},
  // 分享时，注：onShareAppMessage不能为async异步函数，会导致不能及时取得返回值，使得分享设置无效
  onShareAppMessage() {
    /* const title = ''
    const path = ''
    const imageUrl = ``

    return {
      title,
      path,
      imageUrl,
    } */
  },

};

Page(pageOptions);
