import request from '@/utils/request'

// 查询用户列表
export function listMember(query) {
  return request({
    url: '/system/member/listRet',
    method: 'get',
    params: query
  })
}

// 获取全部的仪器列表
export function getAllInstrument() {
  return request({
    url: '/system/instrument/getAllInstrument',
    method: 'get',
  })
}

// 查询用户详细
export function getMember(id) {
  return request({
    url: '/system/member/' + id,
    method: 'get'
  })
}

// 新增用户
export function addMember(data) {
  return request({
    url: '/system/member',
    method: 'post',
    data: data
  })
}

// 修改用户
export function updateMember(data) {
  return request({
    url: '/system/member',
    method: 'put',
    data: data
  })
}

// 删除用户
export function delMember(id) {
  return request({
    url: '/system/member/' + id,
    method: 'delete'
  })
}

export function selectUserCount() {
  return request({
    url: '/system/member/selectUserCount',
    method: 'get',
  })
}


export function getMiniProgramTagsTree() {
  return request({
    url: '/system/tagInfo/tagTree',
    method: 'get',
    params:{
      type: 1
    }
  })
}

export function getMiniProgramTags() {
  return request({
    url: '/system/tagInfo/getMiniProgramTags',
    method: 'get',
  })
}

export function getWecomTags() {
  return request({
    url: '/system/tagInfo/getWecomTags',
    method: 'get',
  })
}

// 获取购买渠道
export function getPurchaseChannel() {
  return request({
    url: '/system/channelInfo/getPurchaseChannel',
    method: 'get',
  })
}

// 获取省市区
export function getRegionByPid(pid) {
  return request({
    url: '/system/region/getRegionByPid',
    method: 'get',
    params: {
      pid : pid
    }
  })
}

// 批量添加小程序标签
export function batchAddMiniProgramTag(tagIdList, userIdList) {
  return request({
    url: '/system/member/batchAddMiniProgramTag?tagIdList=' + tagIdList + '&userIdList=' + userIdList,
    method: 'post',
    // params: {
    //   "tagIdList": tagIdList,
    //   "userIdList": userIdList
    // },
    header: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'
    }
  })
}

// 全量添加小程序标签
export function allAddMiniProgramTag(tagIdList, data) {
  return request({
    url: '/system/member/allAddMiniProgramTag?tagIdList=' + tagIdList,
    method: 'post',
    // params: {
    //   tagIdList: tagIdList
    // },
    data: data
  })
}

// 批量删除小程序标签
export function batchDelMiniProgramTag(tagIdList, userIdList) {
  return request({
    url: '/system/member/batchDelMiniProgramTag?tagIdList=' + tagIdList + '&userIdList=' + userIdList,
    method: 'post',
    // params: {
    //   tagIdList: tagIdList,
    //   userIdList: userIdList
    // }
  })
}

// 全量删除小程序标签
export function allDelMiniProgramTag(tagIdList, data) {
  return request({
    url: '/system/member/allDelMiniProgramTag?tagIdList=' + tagIdList,
    method: 'post',
    // params: {
    //   tagIdList: tagIdList,
    // },
    data: data
  })
}

// 批量操作积分
export function batchChangIntegral(userIdList, data) {
  return request({
    url: '/system/member/batchChangIntegral?userIdList=' + userIdList,
    method: 'post',
    // params: {
    //   userIdList: userIdList
    // },
    data: data
  })
}

// 全量 操作积分
export function allChangIntegral(data, user) {
  return request({
    url: '/system/member/allChangIntegral',
    method: 'post',
    data: {
      wxUserIntegralVm: data,
      wxUserMemberVm: user
    },
  })
}

// 批量发送话术
export function batchSendScript(data) {
  return request({
    url: '/system/userScriptLog/batchSendScript',
    method: 'post',
    data: data
  })
}

// 全量发送话术
export function allSendScript(data, user) {
  return request({
    url: '/system/userScriptLog/allSendScript',
    method: 'post',
    data:  {
      wxUserScriptReq: data,
      wxUserMemberVm: user
    },
  })
}

// 批量添加备注
export function batchAddRemark(data) {
  return request({
    url: '/system/wxUserRemark/batchAddRemark',
    method: 'post',
    data: data
  })
}

// 全量添加备注
export function allAddRemark(content, user) {
  return request({
    url: '/system/wxUserRemark/allAddRemark?content=' + content,
    method: 'post',
    data: user
  })
}

export function scriptTreeSelect(query) {
  return request({
    url: '/system/scriptTemplate/scriptTree',
    method: 'get',
    params: query
  })
}


// 修改用户备注
export function editRemark(data) {
  return request({
    url: '/system/wxUserRemark',
    method: 'put',
    data: data
  })
}

// 删除用户备注
export function delRemark(id) {
  return request({
    url: '/system/wxUserRemark/' + id,
    method: 'delete',
  })
}

// 开关打卡
export function openOrCloseClock(id) {
  return request({
    url: '/system/member/openOrCloseClock/' + id,
    method: 'get'
  })
}

// 开关活动
export function openOrCloseActivity(id) {
  return request({
    url: '/system/member/openOrCloseActivity/' + id,
    method: 'get'
  })
}

// 分页获取消息列表
export function uObtainUserScriptLog(data) {
  return request({
    url: '/system/userScriptLog/list',
    method: 'get',
    params: data
  })
}

// 删除用户的消息列表
export function delUserScriptLog(data) {
  return request({
    url: '/system/userScriptLog',
    method: 'put',
    data: data
  })
}

// 获取用户积分列表
export function obtainUserIntegralLog(data) {
  return request({
    url: '/system/integralLog/list',
    method: 'get',
    params: data
  })
}

// 查询用户仪器绑定列表
export function listUserInstrument(query) {
  return request({
    url: '/system/userInstrument/list',
    method: 'get',
    params: query
  })
}
