index.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import { address, store, goods, express } from "@/api/main";
  2. // 省市区
  3. export function useAddress() {
  4. const addressOptions = ref([]);
  5. const getAddress = () => {
  6. address().then((res) => {
  7. if (res.code === 0) {
  8. addressOptions.value = res.data;
  9. }
  10. });
  11. };
  12. return { addressOptions, getAddress };
  13. }
  14. // 店铺
  15. export function useStore() {
  16. const storeOptions = ref([]);
  17. const getStore = () => {
  18. store().then((res) => {
  19. if (res.code === 0) {
  20. storeOptions.value = res.data.records;
  21. }
  22. });
  23. };
  24. return { storeOptions, getStore };
  25. }
  26. // 产品型号
  27. export function useGoods() {
  28. const goodsForm = ref({
  29. pageNum: 1,
  30. pageSize: 10,
  31. });
  32. const goodsOptions = ref([]);
  33. const getGoods = () => {
  34. goods(goodsForm.value).then((res) => {
  35. if (res.code === 0) {
  36. goodsOptions.value = res.data.records;
  37. }
  38. });
  39. };
  40. return { goodsForm, goodsOptions, getGoods };
  41. }
  42. // 物流公司
  43. export function useExpress() {
  44. const expressOptions = ref({});
  45. const getExpress = (e) => {
  46. express({ name: e }).then((res) => {
  47. expressOptions.value = res
  48. });
  49. };
  50. return { expressOptions, getExpress };
  51. }
  52. // 非接口共用
  53. export function useCommon() {
  54. // 推送状态
  55. const pushStatusOptions = ref([
  56. { value: 0, label: "待推送" },
  57. { value: 1, label: "成功" },
  58. { value: 2, label: "失败" },
  59. ]);
  60. // 售后类型
  61. const applyTypeOptions = ref([
  62. { value: 1, label: "补发" },
  63. { value: 2, label: "换新" },
  64. { value: 3, label: "维修" },
  65. ]);
  66. // 维修审核
  67. const repairStatusOptions = ref([
  68. { value: 1, label: "审核通过" },
  69. { value: 2, label: "审核失败" },
  70. { value: 3, label: "待审核" },
  71. ]);
  72. // 维修类型
  73. const repairTypeOptions = ref([
  74. { value: 1, label: "保内维修" },
  75. { value: 2, label: "保外维修" },
  76. ]);
  77. return {
  78. pushStatusOptions,
  79. applyTypeOptions,
  80. repairStatusOptions,
  81. repairTypeOptions,
  82. };
  83. }