/*
 * @Descripttion: zx
 * @Company: 思宏科技
 * @version: v1.0
 * @Author: zx
 * @Date: 2021-11-22 15:16:17
 * @LastEditors: zx
 * @LastEditTime: 2021-11-24 16:11:32
 */
import {
  fhSaveFamilyMembers,
  fhGetFamilyMembersDetail,
  fhEditFamilyMembers,
} from "../../../api/remote/index";
const app = getApp();
const pageOptions = {
  // 页面数据
  data: {
    isFirstOnShow: true, // 是否为首次执行onShow
    certificateType: [
      "中国居民身份证",
      "护照",
      "港澳居民来往内地通行证",
      "台湾居民来往内地通行证",
    ],
    bloodArray: ["A", "B", "O", "其它"],
    form: {
      sex: 1,
    },
  },
  // 输入
  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,
    });
    console.log(this.data.form);
  },
   //保存患者认证
   async fhSavePatientInfo() {
    const { form } = this.data;
    const memberId = app.globalData.baseInfo.memberId;
    const emp = {
      0: "ID_Card",
      1: "Passport",
      2: "HongKong_Macau_Pass",
      3: "Taiwan_Pass",
    };
    form.certificateType = emp[form.certificateType];
   const sickroomId= app.globalData.hospitalInfo.sickroomId;
   const   hospitalId = app.globalData.hospitalInfo.hospitalId;
    console.log(form, "🐱‍🏍🐱‍🏍🐱‍🏍111");
    try {
      const { results } = await fhSavePatientInfo(form, memberId);
      console.log(results, "🐱‍🏍🐱‍🏍🐱‍🏍🐱‍🏍");
      // this.setData({
      //   remoteVisitsList: results.results[0],
      // });
    } catch (e) {
      console.log("debug axios", e);
    }
    wx.navigateTo({
      url: "/remote/patient/hospitalInformation/index",
    });
  },
  // 页面载入时
  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)
