Commit 8d439199 by hank

fix listPage bug

parent 40b09ef1
import api from '@/api/index'
import { setTempList, setDeviceList, setFilmData, setShopData } from './counter'
/** 获取 模板市场 数据列表 */
export function getTempList(page: number) {
return async dsipatch => {
return async (dispatch, state) => {
const oldState = state().counter
try {
const { list, count } = await api.common.getTempList(page)
dsipatch(setTempList(list, count))
let { list, count } = await api.common.getTempList(page)
if (page !== 1 && oldState.tempData) {
list = [...oldState.tempData.list, ...list]
}
dispatch(setTempList(list, count))
} catch (error) {
console.error(error)
}
......@@ -15,9 +18,13 @@ export function getTempList(page: number) {
/** 获取我的视片列表 */
export function getDeviceList(page: number) {
return async dispatch => {
return async (dispatch, state) => {
const oldState = state().counter
try {
const { list, count } = await api.common.getMyFilmsList(page)
let { list, count } = await api.common.getMyFilmsList(page)
if (page !== 1 && oldState.deviceData) {
list = [...oldState.deviceData.list, ...list]
}
dispatch(setDeviceList(list, count))
} catch (error) {
console.error(error)
......@@ -27,9 +34,13 @@ export function getDeviceList(page: number) {
/** 获取我的设备数据 */
export function getFilmList(page: number) {
return async dispatch => {
return async (dispatch, state) => {
const oldState = state().counter
try {
const { list, count } = await api.common.getMyDeviceList(page)
let { list, count } = await api.common.getMyDeviceList(page)
if (page !== 1 && oldState.filmData) {
list = [...oldState.filmData.list, ...list]
}
dispatch(setFilmData(list, count))
} catch (error) {
console.error(error)
......@@ -38,9 +49,13 @@ export function getFilmList(page: number) {
}
/** 获取商城设备数据 */
export function getShopDeviceList(page: number) {
return async dispatch => {
return async (dispatch, state) => {
const oldState = state().counter
try {
const { list, count } = await api.common.getShopDeviceList(page)
let { list, count } = await api.common.getShopDeviceList(page)
if (page !== 1 && oldState.shopData) {
list = [...oldState.shopData.list, ...list]
}
dispatch(setShopData(list, count))
} catch (error) {
console.error(error)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment