import Content from '@/sheep/layouts/content.vue';
import { request } from '@/sheep/request';
import { CRUD } from '@/sheep/request/crud';

const route = {
  path: 'user',
  name: 'shop.admin.user',
  component: Content,
  meta: {
    title: '用户',
  },
  children: [
    {
      path: 'list',
      name: 'shop.admin.user.list',
      component: () => import('./list/index.vue'),
      meta: {
        title: '用户列表',
      },
    },
    {
      path: 'level',
      name: 'shop.admin.user.level',
      component: () => import('./level/index.vue'),
      meta: {
        title: '会员等级',
      },
    },
    {
      path: 'tag',
      name: 'shop.admin.user.tag',
      component: () => import('./tag/index.vue'),
      meta: {
        title: '会员标签',
      },
    },
  ],
};

const api = {
  // 用户列表相关 API
  list: {
    ...CRUD('shop/admin/user/list'),
    export: (params) =>
      request({
        url: 'shop/admin/user/list/export',
        method: 'GET',
        params,
      }),
    statistics: () =>
      request({
        url: 'shop/admin/user/list/statistics',
        method: 'GET',
      }),
  },

  // 会员等级相关 API
  level: {
    ...CRUD('shop/admin/user/level'),
  },

  // 会员标签相关 API
  tag: {
    ...CRUD('shop/admin/user/tag'),
  },

  // 其他用户相关 API
  share: (id, params) =>
    request({
      url: `shop/admin/share/${id}`,
      method: 'GET',
      params,
    }),
  coupon: (id, params) =>
    request({
      url: `shop/admin/user/coupon/${id}`,
      method: 'GET',
      params,
    }),
  couponList: (id, params) =>
    request({
      url: `shop/admin/user/coupon/couponList/${id}`,
      method: 'GET',
      params,
    }),
};

export { route, api };
