| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- import store from '@/store'
- import CONSTANT from '@/constant'
- import UTIL from '@/utils/util'
- import { getList as getLevelList } from '@/api/level'
- import { getAll, usageListB as getUsageList } from '@/api/item-class'
- import { getFestList } from '@/api/common'
- import { orderRelate as getOrderRelate } from '@/api/order'
- /**
- * 获取等级列表
- * @parmas update为true时会重新触发请求,重置vuex的数据
- */
- export async function getLevel(update) {
- let data = store.getters.getLevel
- if (!UTIL.isEmpty(data) && !update) {
- return data
- }
- await getLevelList().then(res => {
- data = res.data
- store.dispatch('setLevel', data)
- }).catch(() => {
- return false
- })
- return data
- }
- /**
- * 获取花材分类列表
- * @parmas update为true时会重新触发请求,重置vuex的数据
- */
- export async function getCategory(update) {
- let data = store.getters.getCategory
- if (!UTIL.isEmpty(data) && !update) {
- return data
- }
- await getAll().then(res => {
- data = res.data
- store.dispatch('setCategory', data)
- }).catch(() => {
- return false
- })
- return data
- }
- /**
- * 获取分类列表
- * @parmas update为true时会重新触发请求,重置vuex的数据
- */
- export async function getUsage(update) {
- let data = store.getters.getUsage
- if (!UTIL.isEmpty(data) && !update) {
- return data
- }
- await getUsageList().then(res => {
- data = res.data
- store.dispatch('setUsage', data)
- }).catch(() => {
- return false
- })
- return data
- }
- /**
- * 获取节日列表
- * @parmas update为true时会重新触发请求,重置vuex的数据
- */
- export async function getFest(update) {
- let data = store.getters.getFest
- if (!UTIL.isEmpty(data) && !update) {
- return data
- }
- await getFestList().then(res => {
- data = res.data
- store.dispatch('setFest', data)
- }).catch(() => {
- return false
- })
- return data
- }
- /**
- * 获取商城下单-相关信息 m
- * @parmas update为true时会重新触发请求,重置vuex的数据
- */
- export async function getOrderShop(update) {
- let data = store.getters.getOrderShop
- if (!UTIL.isEmpty(data) && !update) {
- return data
- }
- await getOrderRelate().then(res => {
- data = res.data
- store.dispatch('setOrderShop', data)
- }).catch(() => {
- return false
- })
- return data
- }
|