import { $get, $post } from '@/utils'

export const GTE_BANNER = () => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/content/slide', { position: "home" });
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const RATE_LIST = () => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/third/rate/list');
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})


export const OTHER_CONFIG = (act = '') => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/other/config', { act });
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const CONTENT_WINNOTICE = () => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/content/winnotice');
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const CONTENT_TUTORIAL = () => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/content/tutorial');
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const CONTENT_HELP = () => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/content/help');
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const OTHER_ABOUT = (type = '') => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/other/about', { type });
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const RONGIMCALL_OPEN = (params = {}) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/rongimcall/open', { ...params });
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const RONGIMCALL_CLOSE = (params = {}) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/rongimcall/close', { ...params });
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const RONGIMCALL_PAY_RETURN = (params = {}) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/rongimcall/pay/return', { ...params });
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const RONGIMCALL_HISTORY = (params) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/rongimcall/history', params, { isLoading: true });
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const RONGIMCALL_SEND = (params) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/rongimcall/send', params, { isLoading: true });
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const USERS_AUTH = (params) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/users/socket/auth', params, { isLoading: true });
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const SHOP_EXPRESS_CONFIG = (params) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/shop/express/config', params, { isLoading: true });
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const SHOP_POST_CALCULATE = (params) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/shop/post/calculate', params);
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})
