import request from './request';

// 微信授权登录
export const wxlogin = params => {
  return request({
    url: 'auth/wxlogin',
    data: params,
    method: 'post'
  },true)
};
// 获取openid
export const code2Session = params => {
  return request({
    url: 'auth/getOpenId',
    data: params,
    method: 'get'
  })
};
// 手机登录
export const login = params => {
  return request({
    url: `auth/loginVerify`,
    data: params,
    method: 'post',
  })
};
// 验证是否登录过
export const checkLogin = () => {
  let token = uni.getStorageSync('token')
  if (token&&token!='') {
    return request({
      url: `auth/checkLogin`,
      method: 'get'
    })
  } else {
    return new Promise(resolve => {
      resolve({
        status: '9001',
        message: '系统未登录'
      });
    });
  }
};
// 退出登录
export const logout = params => {
  return request({
    url: `auth/logout`,
    data: params,
    method: 'get'
  })
};
// 获取图片验证码
export const getCaptcha = randomCode => {
  return request({
    url: `auth/captchaCreate/${randomCode}`,
    method: 'get',
    responseType: 'text',
  },true)
}
// 验证手机
export const sendLoginVerifyCode = params => {
  return request({
    url: `auth/sendVerifyCode`,
    method: 'post',
	data:params,
  },true)
};

