12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- import { getCategoryList, setCategoryList, addCategoryList } from '@/api/categoryList'
- const state = {
- getCategoryData: [],
- getCategoryDataLength: 0
- }
- const mutations = {
- GET_CATEGORY: (state, data) => {
- state.getCategoryData = data
- },
- CATEGORY_LENGTH: (state, length) => {
- state.getCategoryDataLength = length
- }
- }
- const actions = {
- // 获取课程表专区
- getBlockList({ commit, state }, obj) {
- const blockType = obj.blockType
- const page = (obj.page - 1) * 10
- return new Promise((resolve, reject) => {
- getCategoryList(blockType).then((res) => {
- const list = res.data
- commit('CATEGORY_LENGTH', list.length)
- commit('GET_CATEGORY', list.splice(page, 10))
- resolve()
- }).catch(error => {
- reject(error)
- })
- })
- },
- // 修改课程表专区
- setBlockList({ commit, state }, obj) {
- return new Promise((resolve, reject) => {
- setCategoryList(obj).then((res) => {
- resolve()
- }).catch(error => {
- reject(error)
- })
- })
- },
- // 添加课程表专区
- addBlockList({ commit, state }, obj) {
- return new Promise((resolve, reject) => {
- addCategoryList(obj).then((res) => {
- resolve()
- }).catch(error => {
- reject(error)
- })
- })
- }
- }
- export default {
- namespaced: true,
- state,
- mutations,
- actions
- }
|