Authored by 陈峰

commit

import * as Types from './types';
export default {
fetchProductFavStatus({commit}, {productId}) {
commit(Types.FETCH_PRODUCT_FAV_REQUEST, {productId});
fetchProductFavStatus({state, commit}, {productId}) {
if (!state.favBatchs.length) {
commit(Types.FETCH_PRODUCT_FAV_REQUEST, {productId, promise: () => {
return new Promise((resolve, reject) => {
setTimeout(async() => {
let fetchIds;
if (state.favBatchs.some(id => id === productId)) {
fetchIds = state.favBatchs.map(id => id);
} else {
fetchIds = [productId];
}
const result = await this.$api.get('/api/favorite/batchCheckIsFavorite', {
favIds: fetchIds,
});
if (result.code === 200) {
resolve(result.data);
} else {
resolve([]);
}
}, 50);
});
}});
} else {
commit(Types.FETCH_PRODUCT_FAV_REQUEST, {productId});
}
}
};
... ...