config.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import store from '@/store'
  2. import CONSTANT from '@/constant'
  3. import UTIL from '@/utils/util'
  4. import { getList as getLevelList } from '@/api/level'
  5. import { getAll, usageListB as getUsageList } from '@/api/item-class'
  6. import { getFestList } from '@/api/common'
  7. import { orderRelate as getOrderRelate } from '@/api/order'
  8. /**
  9. * 获取等级列表
  10. * @parmas update为true时会重新触发请求,重置vuex的数据
  11. */
  12. export async function getLevel(update) {
  13. let data = store.getters.getLevel
  14. if (!UTIL.isEmpty(data) && !update) {
  15. return data
  16. }
  17. await getLevelList().then(res => {
  18. data = res.data
  19. store.dispatch('setLevel', data)
  20. }).catch(() => {
  21. return false
  22. })
  23. return data
  24. }
  25. /**
  26. * 获取花材分类列表
  27. * @parmas update为true时会重新触发请求,重置vuex的数据
  28. */
  29. export async function getCategory(update) {
  30. let data = store.getters.getCategory
  31. if (!UTIL.isEmpty(data) && !update) {
  32. return data
  33. }
  34. await getAll().then(res => {
  35. data = res.data
  36. store.dispatch('setCategory', data)
  37. }).catch(() => {
  38. return false
  39. })
  40. return data
  41. }
  42. /**
  43. * 获取分类列表
  44. * @parmas update为true时会重新触发请求,重置vuex的数据
  45. */
  46. export async function getUsage(update) {
  47. let data = store.getters.getUsage
  48. if (!UTIL.isEmpty(data) && !update) {
  49. return data
  50. }
  51. await getUsageList().then(res => {
  52. data = res.data
  53. store.dispatch('setUsage', data)
  54. }).catch(() => {
  55. return false
  56. })
  57. return data
  58. }
  59. /**
  60. * 获取节日列表
  61. * @parmas update为true时会重新触发请求,重置vuex的数据
  62. */
  63. export async function getFest(update) {
  64. let data = store.getters.getFest
  65. if (!UTIL.isEmpty(data) && !update) {
  66. return data
  67. }
  68. await getFestList().then(res => {
  69. data = res.data
  70. store.dispatch('setFest', data)
  71. }).catch(() => {
  72. return false
  73. })
  74. return data
  75. }
  76. /**
  77. * 获取商城下单-相关信息 m
  78. * @parmas update为true时会重新触发请求,重置vuex的数据
  79. */
  80. export async function getOrderShop(update) {
  81. let data = store.getters.getOrderShop
  82. if (!UTIL.isEmpty(data) && !update) {
  83. return data
  84. }
  85. await getOrderRelate().then(res => {
  86. data = res.data
  87. store.dispatch('setOrderShop', data)
  88. }).catch(() => {
  89. return false
  90. })
  91. return data
  92. }