actions.js
694 Bytes
export default {
async postProductFav(actions, {productId, favorite, productType}) {
let postUrl, params;
if (productType === 1) {
postUrl = favorite ? '/api/favorite/add' : '/api/favorite/cancel';
if (favorite) {
params = {
type: 'product',
id: productId
};
} else {
params = {
type: 'product',
fav_id: productId
};
}
} else if (productType === 2) { // ufo
postUrl = favorite ? '/api/ufo/user/favoriteAdd' : '/api/ufo/user/favoriteCancel';
params = {
productId
};
}
const result = await this.$api.post(postUrl, params);
return result;
}
};