import { address, store, goods } from "@/api/main";

// 省市区
export function useAddress() {
  const addressOptions = ref([]);
  const getAddress = () => {
    address().then((res) => {
      if (res.code === 0) {
        addressOptions.value = res.data;
      }
    });
  };

  return { addressOptions, getAddress };
}

// 店铺
export function useStore() {
  const storeOptions = ref([]);
  const getStore = () => {
    store().then((res) => {
      if (res.code === 0) {
        storeOptions.value = res.data.records;
      }
    });
  };
  return { storeOptions, getStore };
}

// 产品型号
export function useGoods() {
  const goodsForm = ref({
    pageNum: 1,
    pageSize: 10,
  });
  const goodsOptions = ref([]);
  const getGoods = () => {
    goods(goodsForm.value).then((res) => {
      if (res.code === 0) {
        goodsOptions.value = res.data.records;
      }
    });
  };
  return { goodsForm, goodsOptions, getGoods };
}

// 非接口共用
export function useCommon() {
  // 推送状态
  const pushStatusOptions = ref([
    { value: 0, label: "待推送" },
    { value: 1, label: "成功" },
    { value: 2, label: "失败" },
  ]);
  // 售后类型
  const applyTypeOptions = ref([
    { value: 1, label: "补发" },
    { value: 2, label: "换新" },
    { value: 3, label: "维修" },
  ]);
  // 维修审核
  const stepStatusOptions = ref([
    { value: 1, label: "审核通过" },
    { value: 2, label: "审核失败" },
    { value: 3, label: "待审核" }
  ]);
  return { pushStatusOptions, applyTypeOptions, stepStatusOptions };
}
