import { HTTP } from './request'

class API extends HTTP {
  getStaticHost(){
    return `${this.staticHost}`;
  }
  getIMappId(){
    return `${this.IMappId}`;
  }
  getIMsecretkey(){
    return `${this.IMsecretkey}`;
  }
  //获取oss签名数据
  getOssSign(params) {
    return this.request({
      url: `${this.baseUrl}/sign/oss`,
      method: 'GET',
      data: {
        ...params
      }
    })
  }
  //获取省份信息
  getAreaProvince(params) {
    return this.request({
      url: `${this.baseUrl}/area/province`,
      method: 'GET',
      data: {
        ...params
      }
    })
  }
  //获取城市信息
  getAreaCity(params) {
    return this.request({
      url: `${this.baseUrl}/area/city`,
      method: 'GET',
      data: {
        ...params
      }
    })
  }
  //获取区县信息
  getAreaCounty(params) {
    return this.request({
      url: `${this.baseUrl}/area/county`,
      method: 'GET',
      data: {
        ...params
      }
    })
  }
  //获取医院数据
  getBasicHospital(params) {
    return this.request({
      url: `${this.baseUrl}/basic/hospital`,
      method: 'GET',
      data: {
        ...params
      }
    })
  }
  //获取自定义科室数据
  getBasicDepartment(params) {
    return this.request({
      url: `${this.baseUrl}/basic/department`,
      method: 'GET',
      data: {
        ...params
      }
    })
  }
  //获取医生专长列表
  getDoctorExpertise(params) {
    return this.request({
      url: `${this.baseUrl}/doctor/info/expertise`,
      method: 'GET',
      data: {
        ...params
      }
    })
  }
  //使用微信手机号登陆
  wechatMobileLogin(params) {
    return this.request({
      url: `${this.baseUrl}/login/wechat_mobile_login`,
      method: 'POST',
      data: {
        ...params
      }
    })
  }
  //医师端首页
  yiShiIndex(params) {
    return this.request({
      url: `${this.baseUrl}/doctor/index`,
      method: 'GET',
      data: {
        ...params
      }
    })
  }
  //获取实名认证信息
  getDoctorAuthReal(params) {
    return this.request({
      url: `${this.baseUrl}/doctor/auth/real`,
      method: 'GET',
      data: {
        ...params
      }
    })
  }
  //新增实名认证信息
  postDoctorAuthReal(params) {
    return this.request({
      url: `${this.baseUrl}/doctor/auth/real`,
      method: 'POST',
      data: {
        ...params
      }
    })
  }
  //获取身份认证信息
  getDoctorAuthIden(params) {
    return this.request({
      url: `${this.baseUrl}/doctor/auth/iden`,
      method: 'GET',
      data: {
        ...params
      },
      showLoading: false
    })
  }
  //新增/修改身份认证信息
  postDoctorAuthIden(params) {
    return this.request({
      url: `${this.baseUrl}/doctor/auth/iden`,
      method: 'POST',
      data: {
        ...params
      },
      contentType: 'application/json'
    })
  }
  //获取多点执业认证信息
  getDoctorAuthMulti(params) {
    return this.request({
      url: `${this.baseUrl}/doctor/auth/multi`,
      method: 'GET',
      data: {
        ...params
      }
    })
  }
  //新增多点执业认证信息
  postDoctorAuthMulti(params) {
    return this.request({
      url: `${this.baseUrl}/doctor/auth/multi`,
      method: 'POST',
      data: {
        ...params
      }
    })
  }
 //手机号登陆
 mobileLogin(params) {
  return this.request({
    url: `${this.baseUrl}/login/mobile_login`,
    method: 'POST',
    data: {
      ...params
    }
  })
}
 //获取手机号验证码
 getCodePhone(params) {
  return this.request({
    url: `${this.baseUrl}/code/phone`,
    method: 'POST',
    data: {
      ...params
    }
  })
}
 //获取个人中心数据
 getDoctorCenter(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/center`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取银行卡列表
 getDoctorBank(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/bank`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //绑定医生银行卡
 postDoctorBank(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/bank`,
    method: 'POST',
    data: {
      ...params
    }
  })
}
 //更换医生银行卡
 putDoctorBank(params) {
   let bank_card_id = params.bank_card_id;
  return this.request({
    url: `${this.baseUrl}/doctor/bank/`+bank_card_id,
    method: 'PUT',
    data: {
      ...params
    }
  })
}
 //获取我的账户日账单明细数据
 getDoctorAccountInfo(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/account/info`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取提现数据
 postDoctorWithdrawalInfo(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/withdrawal/info`,
    method: 'POST',
    data: {
      ...params
    }
  })
}
 //发起提现
 postDoctorWithdrawal(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/withdrawal`,
    method: 'POST',
    data: {
      ...params
    }
  })
}
 //可提现问诊订单列表
 getDoctorWithdrawalOrder(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/withdrawal/order`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取医生提现记录列表
 getDoctorWithdrawalRecord(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/withdrawal/record`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取医生我的账户数据
 getDoctorCenterAccount(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/account`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取个人中心数据
 getDoctorCenter(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/center`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取银行列表
 getBasicBank(params) {
  return this.request({
    url: `${this.baseUrl}/basic/bank`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取医生信息
 getDoctorCenterInfo(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/center/info`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取医生证书信息
 getDoctorCret(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/info/cret`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取获取医生评价
 getDoctorEvaluation(params) {
  return this.request({
    url: `${this.baseUrl}/evaluation`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取医生问诊配置
 getDoctorInquiryConfig(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/inquiry/config`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //医生问诊开关
 putDoctorInquiryOpen(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/inquiry/open`,
    method: 'PUT',
    data: {
      ...params
    }
  })
}
 //修改医生问诊配置
 putDoctorInquiryConfig(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/inquiry/config`,
    method: 'PUT',
    data: {
      ...params
    }
  })
}
 //获取处方列表
 getDoctorPrescription(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/prescription`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取处方详情
 getDoctorPrescriptionInfo(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/prescription/info`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //修改处方
 putDoctorPrescription(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/prescription`,
    method: 'PUT',
    contentType: 'application/json',
    data: {
      ...params
    }
  })
}
 //新增处方
 postDoctorPrescription(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/prescription`,
    method: 'POST',
    contentType: 'application/json',
    data: {
      ...params
    }
  })
}
 //获取操作手册列表
 getBasicOperationManual(params) {
  return this.request({
    url: `${this.baseUrl}/basic/operation/manual`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取操作手册详情
 getBasicOperationManualID(params) {
  let manual_id = params.manual_id;
  params = {};
  return this.request({
    url: `${this.baseUrl}/basic/operation/manual/`+manual_id,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取常用语列表
 getDoctorWords(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/words`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //新增常用语列表
 postDoctorWords(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/words`,
    method: 'POST',
    data: {
      ...params
    }
  })
}
 //删除常用语列表
 delDoctorWords(params) {
   let doctor_words_id = params.doctor_words_id;
   params = {};
  return this.request({
    url: `${this.baseUrl}/doctor/words/`+doctor_words_id,
    method: 'DELETE',
    data: {
      ...params
    }
  })
}
 //搜索疾病分类-系统
 getBasicDiseaseSearch(params) {
  return this.request({
    url: `${this.baseUrl}/basic/disease/search`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //搜索疾病分类-平台
 getBasicIcdSearch(params) {
  return this.request({
    url: `${this.baseUrl}/basic/icd/search`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //搜索药品
 getBasicProductSearch(params) {
  return this.request({
    url: `${this.baseUrl}/basic/product/search`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取医生名片
 getDoctorInfoCard(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/info/card`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取医生问诊消息列表
 getDoctorInquiryMessage(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/inquiry/message`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取医生问诊消息用户属性
 getDoctorInquiryMessageAttr(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/inquiry/message/attr`,
    method: 'POST',
    data: {
      ...params
    },
    showLoading: false
  })
}
 //获取患者问诊病例
 getDoctorInquiryCase(params) {
  return this.request({
    url: `${this.baseUrl}/case`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取患者问诊病例
 getCase(params) {
  return this.request({
    url: `${this.baseUrl}/case`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取im签名数据
 getSignIM(params) {
  let usertype = wx.getStorageSync('usertype');
  let userID = wx.getStorageSync('user_id_'+usertype);
  let imsign = wx.getStorageSync(userID + '_imsign');
  console.log("缓存中的imsign:", imsign)

  if(imsign){
    const date = imsign.date;
    var minute = 1000 * 60;
    var hour = minute *60;
    var day = hour *24;
    if(new Date().getTime() - date < day){
      console.log("小于一天从缓存中获取imsign")
      return new Promise((resolve, reject) => {
        resolve({"data": imsign.sign,"from":"cache"})
      })
    }
  }

  return this.request({
    url: `${this.baseUrl}/sign/im`,
    method: 'GET',
    data: {
      ...params
    }
  })
}

 //药师基本资料
 getPharmacistInfo(params) {
  return this.request({
    url: `${this.baseUrl}/pharmacist/info`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //药师端-首页
 getPharmacistIndex(params) {
  return this.request({
    url: `${this.baseUrl}/pharmacist/index`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取药师审核处方列表
 getPharmacistPrescription(params) {
  return this.request({
    url: `${this.baseUrl}/pharmacist/prescription`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取处方详情
 getPharmacistPrescriptioninfo(params) {
  let order_prescription_id = params.order_prescription_id;
  params = {}
  return this.request({
    url: `${this.baseUrl}/pharmacist/prescription/info/`+order_prescription_id,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //设置上下线 药师端
 putPharmacistOnOff(params) {
  return this.request({
    url: `${this.baseUrl}/pharmacist/on-off`,
    method: 'PUT',
    data: {
      ...params
    }
  })
}
 //药师基本资料
 getPharmacistInfo(params) {
  return this.request({
    url: `${this.baseUrl}/pharmacist/info`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //审核处方
 putPharmacistPrescriptionVerify(params) {
  let order_prescription_id = params.order_prescription_id;
  delete params['order_prescription_id']; 
  return this.request({
    url: `${this.baseUrl}/pharmacist/prescription/verify/`+order_prescription_id,
    method: 'PUT',
    data: {
      ...params
    }
  })
}
 //医生接诊
 postDoctorInquiry(params) {
  let order_inquiry_id = params.order_inquiry_id;
  delete params['order_inquiry_id']; 
  return this.request({
    url: `${this.baseUrl}/doctor/inquiry/`+order_inquiry_id,
    method: 'POST',
    data: {
      ...params
    }
  })
}
 //结束问诊
 putDoctorInquiryFinish(params) {
  let order_inquiry_id = params.order_inquiry_id;
  params = {}
  return this.request({
    url: `${this.baseUrl}/inquiry/finish/`+order_inquiry_id,
    method: 'PUT',
    data: {
      ...params
    }
  })
}
 //获取问诊订单消息内页基础数据
 getInquiryMessageBasic(params) {
  let order_inquiry_id = params.order_inquiry_id;
  params = {}
  return this.request({
    url: `${this.baseUrl}/inquiry/message/basic/`+order_inquiry_id,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取医生消息页通知数据-医生
 getDoctorMessageNotice(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/message/notice`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取医生服务消息列表-分页
 getDoctorMessageService(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/message/service`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取医生系统公告列表-分页
 getDoctorMessageSystem(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/message/system`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取医生系统公告详情
 getDoctorMessageSystemDetail(params) {
  let notice_id = params.notice_id;
  params = {}
  return this.request({
    url: `${this.baseUrl}/doctor/message/system/`+notice_id,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //消息已读
 putMessageReadNotice(params) {
  let notice_id = params.notice_id;
  params = {}
  return this.request({
    url: `${this.baseUrl}/message/notice/read/`+notice_id,
    method: 'PUT',
    data: {
      ...params
    }
  })
}
 //一键消息已读
 putMessageReadNoticeAll(params) {
  return this.request({
    url: `${this.baseUrl}/message/notice/read`,
    method: 'PUT',
    data: {
      ...params
    }
  })
}
 //结束问诊会话列表
 getDoctorInquiryFinishMessage(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/inquiry/finish/message`,
    method: 'GET',
    data: {
      ...params
    },
    showLoading: false
  })
}
 //获取协议内容
 getBasicAgreement(params) {
  let agreement_id = params.agreement_id;
  params = {}
  return this.request({
    url: `${this.baseUrl}/basic/agreement/`+agreement_id,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取弹窗
 getPopup(params) {
  let agreement_id = params.agreement_id;
  params = {}
  return this.request({
    url: `${this.baseUrl}/popup`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //检测是否可以开具处方
 getDoctorPrescriptionCheck(params) {
  return this.request({
    url: `${this.baseUrl}/doctor/prescription/check`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
 //获取医生职称数据
 getBasicDoctorTitle(params) {
  return this.request({
    url: `${this.baseUrl}/basic/doctor/title`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
//药品清单
 getMedinceList(params) {
  return this.request({
    url: `${this.baseUrl}/basic/product`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
//获取患者最后一条问诊订单id
getLastInquiry(params) {
  return this.request({
    url: `${this.baseUrl}/inquiry/last`,
    method: 'GET',
    data: {
      ...params
    }
  })
}
//获取配置
getConfig() {
  return this.request({
    url: `${this.baseUrl}/user/system`,
    method: 'GET'
  })
}

//获取配置
editConfig(params) {
  return this.request({
    url: `${this.baseUrl}/user/system`,
    method: 'PUT',
    data: {
      ...params
    }
  })
}



}

export { API }
