import request from './fetcher/request'

export default {
  // 用户详情
  fetchUserInfo (user_id) {
    return request.get('user/detail', { user_id })
  },
  // 登录
  /*
  ** wx_code String
  ** phone_num String
  ** iv String
  */
  loginByPhoneCode (data) {
    let str = '?'
    Object.keys(data).forEach(item => {
      str += `${item}=${data[item]}&`
    })
    
    return request.post(`user/login${str}`, data)
  },
  loginByUserInfo (data) {
    return request.post(`agency/login`, data)
  },
  loginByPhoneCodeAgency (data) {
    let str = '?'
    Object.keys(data).forEach(item => {
      str += `${item}=${data[item]}&`
    })
    
    // return request.post(`agency/login${str}`, data)
    return request.post(`agency/getPhoneNum${str}`, data)
  },
  // 分享历史
  fetchSharedHistory (data) {
    return request.get('user/house/share/list', data)
  },
  // 浏览历史
  fetchReadHistory (data) {
    return request.post('user/house/read/history', data)
  },
  // 关注列表
  fetchFocusHouses (data) {
    data = Object.assign({
      page_num: 1,
      page_size: 50
    }, data)
    return request.get('user/focus/house', data)
  },
  delegation (data) {
    return request.post('user/delegation', data)
  }
}