/* eslint-disable import/prefer-default-export */
import HTTPREQUEST from "./http"
import Taro from "@tarojs/taro";

//登录
export const login = (res) => {
  return new Promise(async (resolve, reject) => {
    Taro.showLoading({
      title: '登录中...',
    })
    try {
      let msg = await HTTPREQUEST.post('/managesignin', {
        mobile: res.username,
        password: res.password,
        remeber: false
      });
      if (msg.error.length === 0) {
        Taro.setStorageSync('token', msg.token);
        Taro.setStorageSync('userInfor', msg.data);
        Taro.hideLoading();
        Taro.showToast({ title: '登录成功', icon: 'success' })
        resolve(msg);
      } else {
        Taro.hideLoading();
        Taro.showToast({ title: msg.error[0].message, icon: 'none' })
        reject();
      }
    } catch (err) {
      Taro.showToast({ title: '系统错误,请稍后重试', icon: 'none' });
      Taro.hideLoading();
      reject();
    }
  })
}
// 查询客户订单
export const getOrderByUid = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/release/selectOrderByUid', postData)
}
export const getUserByName = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/customer/getUserByNames', postData)
}

export const getadminByName = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/customer/listAdminByName', postData)
}

export const addPublicRelease = (postData = {}) => {
  return HTTPREQUEST.post('/api/admin/release/addPublicRelease', postData)
}

export const setOpenId = (postData = {}) => {
  return HTTPREQUEST.post('/api/admin/setOpenId', postData)
}
//获取最近打卡信息
export const getPunchClockInfo = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/release/getMyNewPublic', postData)
}

export const getPublicReleaseList = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/release/listPublicRelease', postData)
}

export const publicReleaseClockIn = (postData = {}) => {
  return HTTPREQUEST.post('/api/admin/release/publicReleaseClockIn', postData)
}

// 公出审批
export const examinePublicRelease = (isSuperior = 1, postData = {}) => {
  return HTTPREQUEST.post(isSuperior == 1
    ? '/api/admin/release/examinePublicRelease' : isSuperior == 2
      ? '/api/admin/release/marketersExamine' : isSuperior == 3
        ? '/api/admin/release/techExamine' : isSuperior == 4 && '/api/admin/release/assistExamine', postData)
}

//获取外出公出详情
export const getReleasetDails = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/release/dtails', postData)
}

//获取公出日志
export const getListPublicReleaseLog = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/release/listPublicReleaseLog', postData)
}

//修改公出申请
export const updatePublicRelease = (postData = {}) => {
  return HTTPREQUEST.post('/api/admin/release/updatePublicRelease', postData)
}

//外出未读
export const getPublicReleaseUnread = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/notice/publicReleaseUnread', postData)
}

//获取知道部门作息时间
export const getWorkingHours = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/department/workingHours/get', postData)
}

//获取部门作息列表
export const getWorkingHoursList = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/department/workingHours/list', postData)
}

//获取微信参数
export const getWxConfig = (postData = {}) => {
  return HTTPREQUEST.get('/open/getWxConfig', postData)
}

//测试
export const test = (postData = {}) => {
  return HTTPREQUEST.get('/open/getVCode', postData)
}

//技术协单驳回
export const techReject = (postData = {}) => {
  return HTTPREQUEST.post('/api/admin/release/techReject', postData)
}

//新增协单助力
export const addAssistant = (postData = {}) => {
  return HTTPREQUEST.post('/api/admin/release/addAssistant', postData)
}

//删除协单助力
export const deleteAssistant = (postData = {}) => {
  return HTTPREQUEST.post('/api/admin/release/deleteAssistant', postData)
}

//修改公出地址
export const updateLocation = (postData = {}) => {
  return HTTPREQUEST.post('/api/admin/release/updateLocation', postData)
}

// 技术公出发起情况
export const checkOrderNoDuration = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/release/checkOrderNoDuration', postData)
}

// 限定项目客户情况
export const getRestrictProjectUser = (postData = {}) => {
  return HTTPREQUEST.get('/api/restrict/Project/getRestrictProjectUser', postData)
}

// 未审核查询
export const getAssistUnaudited = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/release/unaudited', postData)
}

// 新增意见协单
export const publicAssistAdvice = (postData = {}) => {
  return HTTPREQUEST.post('/api/admin/publicAssistAdvice/add', postData)
}

// 查看协单公出意见
export const publicAssistAdviceList = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/publicAssistAdvice/list', postData)
}

// 获取我的客户列表
export const selectMyUser = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/customer/selectMyUser', postData)
}

// 客户信息详情
export const selectMyUserDetails = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/customer/selectMyUserDetails', postData)
}

// 客户档案详情
export const queryByUidAll = (notRequired = false, postData = {}) => {
  return HTTPREQUEST.get(notRequired ? '/api/admin/userArchives/superQueryByUidAll' : '/api/admin/userArchives/queryByUidAll', postData)
}

// 企业公出情况
export const getPublicList = (notRequired = false, postData = {}) => {
  return HTTPREQUEST.get(notRequired ? '/api/admin/customer/selectPublicReleaseList' : '/api/admin/customer/getPublicReleaseList', postData)
}

// 修改客户信息
export const updateUserDate = (type = 0, postData = {}) => {
  return HTTPREQUEST.post((type == 0 || type == 5) ? '/api/admin/customer/updateUserDate' : '/api/admin/userArchives/update', postData)
}

// 修改客户信息
export const updateUser = (postData = {}) => {
    return HTTPREQUEST.post('/api/admin/interview/updateUser', postData);
  }

// 新增联系人
export const addOneContact = (postData = {}) => {
  return HTTPREQUEST.post('/api/admin/customer/addOneContact', postData)
}

// 联系人列表
export const findCustomerContacts = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/customer/findCustomerContacts', postData)
}

// 主联系人设置
export const updateMainContact = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/customer/updateMainContact', postData)
}

// 分享限时查询
export const limitUser = (postData = {}) => {
  return HTTPREQUEST.post('/api/admin/release/limitUser', postData)
}

// 项目列表
export const getBusinessProjectByName = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/order/getBusinessProjectByName', postData)
}

// 公出补充
export const addSupplement = (postData = {}) => {
  return HTTPREQUEST.post('/api/admin/release/addSupplement', postData)
}

// 上级评价详情
export const getUserSuperEvaluate = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/userSuperEvaluate/list', postData)
}

// 上级填写评价
export const addUserSuperEvaluate = (postData = {}) => {
  return HTTPREQUEST.post('/api/admin/userSuperEvaluate/add', postData)
}

// 是否完成客户档案
export const checkUserArchives = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/release/checkUserArchives', postData)
}

// 公司名称验证
export const checkUserName = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/customer/checkUserName', postData)
}

// 新增客户
export const addCustomer = (postData = {}) => {
  return HTTPREQUEST.post('/api/admin/customer/addCustomer', postData)
}

// 新增渠道
export const addChannel = (postData = {}) => {
  return HTTPREQUEST.post('/api/admin/customer/addChannel', postData)
}

// 是否最大客户数判断
export const queryUserMax = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/customer/queryUserMax', postData)
}

// 新增客户面谈项目
export const addProject = (postData = {}) => {
  return HTTPREQUEST.post('/api/admin/userInterviewProject/add', postData)
}
// 查询面谈客户项目
export const queryProjectList = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/userInterviewProject/list', postData)
}
// 删除客户面谈项目
export const delProject = (id, postData = {}) => {
  return HTTPREQUEST.get('/api/admin/userInterviewProject/delete?id='+id, postData)
}

// 根据公出编号获取面谈记录
export const getInterviewByPrdid = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/interview/selectByPrdid', postData)
}

// 公出记录分页
export const getInterviewListByPage = (postData = {}) => {
  return HTTPREQUEST.get('/api/admin/interview/list', postData)
}

