import http from '@/utils/request'
export function getSystemConfigList () {
  return http.post('/admin/system-config/list', {
    data: {
      pageNum: 1,
      pageSize: 1000
    }
  })
}

export function deleteSystemConfig (params) {
  return http.post('/admin/system-config/delete', { data: params })
}

export function updateSystemConfig (params) {
  return http.post('/admin/system-config/update', { data: params })
}
export function getPayChannel () {
  return http.post('/admin/system-config/list', {
    pageNum: 1,
    pageSize: 1000
  }).then(res => {
    let item = res.list.find(item => item.config_key === 'payChannel')
    return item.config_value.split(',')
  })
}

export function getCustomerType () {
  return http.post('/admin/system-config/list', {
    pageNum: 1,
    pageSize: 1000
  }).then(res => {
    let item = res.list.find(item => item.config_key === 'customer_type')
    return item.config_value.split(',')
  })
}

export function getTravelAgencyType () {
  return http.post('/admin/system-config/list', {
    pageNum: 1,
    pageSize: 1000
  }).then(res => {
    let item = res.list.find(item => item.config_key === 'travel_agency_type')
    return item.config_value.split(',')
  })
}

export function getManualTicketCheckScenic () {
  /* 获取系统配置里的是否开启人工检票里选景点的功能 */
  return http.post('/admin/system-config/list', {
    pageNum: 1,
    pageSize: 1000
  }).then(res => {
    let item = res.list.find(item => item.config_key === 'manual_ticket_check_scenic')
    console.log('系统配置里的人工检票是否开启景点选择：', JSON.stringify(item), 'Y/N:', item.config_value)
    /* item.config_value.split(',') 为 [1] 这种数组, item.config_value为1或9 */
    return item.config_value /* 1 or 0 */
  })
}
