import request from '@/utils/request'
import org from '../../router/modules/org'

export function verifyToken(token) {
  return request({
    url: '/api/token/verify',
    method: 'post',
    params: {
      'token': token
    }
  })
}

export function modifyAdminInfo(params) {
  return request({
    url: '/api/admin/edit_info',
    method: 'post',
    params: params
  })
}

export function getModifyPwdCode(phone) {
  console.log('phone', phone)
  return request({
    url: '/api/password/code?phone=' + phone,
    method: 'post'
  })
}

export function modifyPassword(new_pwd, code) {
  var params = {
    password: new_pwd,
    code: code
  }
  return request({
    url: '/api/password/modify',
    method: 'post',
    params: params
  })
}

export function submitModifyPwdAction(phone, password, code) {
  const params = {
    phone: phone,
    password: password,
    code: code
  }
  return request({
    url: '/api/save/register',
    method: 'Post',
    params: params
  })
}

export function getAllProvince(params) {
  console.log('params', params)
  return request({
    url: '/api/login/getallprovince',
    method: 'Get',
    params: params
  })
}

export function NoPassToLogin(phone, code) {
  const params = {
    phone: phone,
    code: code
  }
  console.log('code', code)
  return request({
    url: '/api/login/nopasslogin',
    method: 'Get',
    params: params
  })
}

export function getCode(phone) {
  const params = {
    phone: phone
  }
  return request({
    url: '/api/login/getcode',
    method: 'Post',
    params: params
  })
}

export function NextStep(phone, code) {
  const params = {
    phone: phone,
    code: code
  }
  return request({
    url: '/api/login/nextstep',
    method: 'Get',
    params: params
  })
}

export function Accomplish(phone, newpassword, confirmpassword) {
  const params = {
    // eslint-disable-next-line no-dupe-keys
    phone,
    phone,
    newpassword: newpassword,
    confirmpassword: confirmpassword
  }
  return request({
    url: '/api/login/accomplish',
    method: 'Post',
    params: params
  })
}

export function getAllOrgName(id) {
  const params = {
    id: id
  }
  return request({
    url: '/api/login/getallorgname',
    method: 'Get',
    params: params
  })
}

export function getCityByid(id, params) {
  return request({
    url: '/api/login/getcitybyid?id=' + id,
    method: 'Get',
    params: params
  })
}

export function getAllOrgType(params) {
  return request({
    url: '/api/login/getallorgtype',
    method: 'Get',
    params: params
  })
}

export function SaveOrgInformation(data, id) {
  console.log('data是什么', data)
  return request({
    url: '/api/login/saveorginformation?id=' + id,
    method: 'Post',
    data: data
  })
}

export function getBloodDialysisPatient(page, limit, id) {
  const params = {
    page: page,
    limit: limit,
    id: id
  }
  return request({
    url: '/api/login/getblooddialysispatient',
    method: 'Get',
    params: params
  })
}

export function GetDoctroAdvice(patientid, orgid, starttime, endtime, searchval) {
  console.log('patientid', patientid)
  console.log('starttime', starttime)
  console.log('orgid', orgid)
  console.log('endtime', endtime)

  const params = {
    patientid: patientid,
    starttime: starttime,
    orgid: orgid,
    endtime: endtime,
    searchval: searchval
  }

  return request({
    url: '/api/site/getdoctoradvice',
    method: 'Get',
    params: params
  })
}

export function SaveSearch(searchval) {
  const params = {
    searchval: searchval
  }
  return request({
    url: '/api/site/savesearch',
    method: 'Get',
    params: params
  })
}

export function toSeacherDoctorAdvice(patientid, orgid, searchval) {
  const params = {
    patientid: patientid,
    orgid: orgid,
    searchval: searchval
  }
  return request({
    url: '/api/site/toseacherdoctoradvice',
    method: 'Get',
    params: params
  })
}

export function deleteDoctorAdvice(id, params) {
  return request({
    url: '/api/site/deleteDoctorAdvice?id=' + id,
    method: 'Get',
    params: params
  })
}
