import axios from '@/libs/axios.js'

//  axios.request()  第二个参数若为true则表示不传token

// 登录
export const login = (params) => {
  return axios.request({
    url: 'auth/login',
    data: params,
    method: 'post'
  }, true)
}
//  校验手机号是否注册
export const validateUser = params => {
  return axios.request({
    url: `org/apply/validateUser/${params.phone}`,
    method: 'get'
  }, true)
}
// 获取图片验证码
export const getCaptcha = randomCode => {
  return axios.request({
    url: `org/apply/getCaptcha/${randomCode}`,
    method: 'get',
    responseType: 'blob',
  }, true)
}
// 发送短信验证码
export const sendVerifyCode = params => {
  return axios.request({
    url: 'org/apply/sendVerifyCode',
    method: 'post',
    data: params
  }, true)
}
// 申请试用
export const apply = params => {
  return axios.request({
    url: 'org/apply/apply',
    method: 'post',
    data: params
  }, true)
}
// 获取门店名称
export const getStore = (token) => {
  return axios.request({
    url: 'getStore',
    method: 'get'
  })
}
// 登出
export const logout = () => {
  return axios.request({
    url: 'auth/logout',
    method: 'get'
  })
}
// 修改密码
export const changePwd = params => {
  return axios.request({
    url: 'dduser/changePWD',
    method: 'post',
    data: {
      oldPassword: params.oldPassword,
      password: params.password
    }
  }).then(res => res)
} 
//  忘记密码 校验手机号是否注册过
export const memberGetByMobile = params => {
  return axios.request({
    url: 'member/getByMobile',
    method: 'post',
    data: params
  }, true)
}
//  忘记密码 获取图片验证码
export const memberCaptcha = randomCode => {
  return axios.request({
    url: `member/captcha/create/${randomCode}`,
    method: 'get',
    responseType: 'blob'
  }, true)
}
//  忘记密码 发送短信验证码
export const memberVerifyCode = params => {
  return axios.request({
    url: 'member/sendVerifyCode',
    method: 'post',
    data: params
  }, true)
}
//  忘记密码 修改密码
export const memberChangePwd = params => {
  return axios.request({
    url: 'member/changePwd',
    method: 'post',
    data: params
  }, true)
}
//  忘记密码 校验短信验证码是否正确
export const memberValidateVerifyCode = params => {
  return axios.request({
    url: 'member/validateVerifyCode',
    method: 'post',
    data: params
  }, true)
}
// 获取通知消息未读数
export const getUnreadCount = params => {
  return axios.request({
    url: 'noticeUser/queryNotReadCount',
    method: 'post'
  })
}
// 设置已读消息
export const hasRead = params => {
  return axios.request({
    url: `noticeUser/setRead/${params.msg_id}`,
    method: 'get'
  })
}
// 查询所有消息
export const getMessage = params => {
  let url = `noticeUser/queryLike/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios.request({
    url: url,
    data: params,
    method: 'post'
  })
}
// 获取当前登录用户信息
export const findUserInfo = params => {
  return axios.request({
    url: `dduser/findUserInfo`,
    method: 'get'
  })
}
// 获取用户列表
export const findUserList = params => {
  return axios.request({
    url: `dduser/query`,
	data: params,
	method: 'post'
  })
}